/* ============================================
   Kimi Spelling Teacher - Frontend Styles
   ============================================ */

.kst-spelling-game {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

/* Browser Notice */
.kst-browser-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

/* Setup Screen */
.kst-setup-screen {
    text-align: center;
    padding: 20px 0;
}

.kst-setup-screen h2 {
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 8px;
}

.kst-subtitle {
    color: #666;
    margin-bottom: 30px;
}

.kst-form-group {
    margin-bottom: 20px;
    text-align: left;
}

.kst-form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #444;
}

.kst-form-group input,
.kst-form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.kst-form-group input:focus,
.kst-form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.kst-options {
    text-align: left;
    margin-bottom: 24px;
}

.kst-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    color: #555;
}

.kst-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #667eea;
}

.kst-difficulty-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    text-align: left;
}

.kst-difficulty-checkbox {
    flex: 1 1 calc(50% - 10px);
    min-width: 160px;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    margin-bottom: 0;
    transition: border-color 0.2s, background 0.2s;
}

.kst-difficulty-checkbox:has(input:checked),
.kst-difficulty-checkbox.is-checked {
    border-color: #667eea;
    background: #f4f5ff;
}

.kst-field-error {
    color: #d63638;
    font-size: 0.85rem;
    margin-top: 8px;
    margin-bottom: 0;
}

/* Buttons */
.kst-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.kst-btn:hover {
    transform: translateY(-2px);
}

.kst-btn:active {
    transform: translateY(0);
}

.kst-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102,126,234,0.3);
}

.kst-btn-primary:hover {
    box-shadow: 0 6px 20px rgba(102,126,234,0.4);
}

.kst-btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.kst-btn-secondary:hover {
    background: #e0e0e0;
}

.kst-btn-mic {
    background: #ff6b6b;
    color: white;
    font-size: 1.3rem;
    min-width: 56px;
    min-height: 56px;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(255,107,107,0.3);
}

.kst-btn-mic:hover {
    background: #ff5252;
    box-shadow: 0 6px 20px rgba(255,107,107,0.4);
}

.kst-btn-mic.listening {
    background: #ff4757;
    animation: kst-pulse 1.2s infinite;
}

.kst-btn-large {
    padding: 16px 40px;
    font-size: 1.1rem;
    border-radius: 14px;
}

.kst-btn-check {
    flex: 2;
}

@keyframes kst-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 4px 15px rgba(255,107,107,0.3); }
    50% { transform: scale(1.08); box-shadow: 0 6px 25px rgba(255,107,107,0.5); }
}

/* Game Screen */
.kst-game-screen {
    padding: 10px 0;
}

/* Progress Bar */
.kst-progress-bar {
    position: relative;
    height: 8px;
    background: #e8e8e8;
    border-radius: 4px;
    margin-bottom: 20px;
    overflow: hidden;
}

.kst-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

.kst-progress-text {
    position: absolute;
    top: 14px;
    right: 0;
    font-size: 0.8rem;
    color: #888;
    font-weight: 600;
}

/* Score Board */
.kst-score-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}

.kst-score-item {
    text-align: center;
    padding: 12px 8px;
    background: #f8f9fa;
    border-radius: 12px;
}

.kst-score-value {
    display: block;
    font-size: 1.6rem;
    font-weight: bold;
    color: #667eea;
    line-height: 1.2;
}

.kst-score-label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Word Card */
.kst-word-card {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    margin-bottom: 20px;
    color: white;
    position: relative;
    overflow: hidden;
}

.kst-word-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
}

.kst-word-number {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.kst-audio-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    margin: -8px 0 16px;
    background: #fff8e6;
    border: 1px solid #f0d896;
    border-radius: 10px;
    color: #8a6d1f;
    font-size: 0.85rem;
    animation: kst-fade-in 0.15s ease-in;
}

.kst-audio-status-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #e5c977;
    border-top-color: #8a6d1f;
    border-radius: 50%;
    display: inline-block;
    animation: kst-spin 0.7s linear infinite;
}

@keyframes kst-spin {
    to { transform: rotate(360deg); }
}

@keyframes kst-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.kst-word-hint {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 12px;
    min-height: 1.5em;
}

.kst-word-blanks {
    font-size: 2.2rem;
    letter-spacing: 10px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.kst-sentence {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.2);
    font-size: 0.95rem;
    font-style: italic;
    opacity: 0.9;
}

/* Controls */
.kst-controls-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.kst-controls-row .kst-btn {
    flex: 1;
}

/* Input Area */
.kst-input-area {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.kst-spelling-input {
    flex: 1;
    padding: 16px 20px;
    font-size: 1.3rem;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    text-align: center;
    letter-spacing: 4px;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    transition: all 0.2s;
    background: #fafafa;
}

.kst-spelling-input:focus {
    outline: none;
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(102,126,234,0.1);
}

.kst-spelling-input.correct {
    border-color: #28a745;
    background: #d4edda;
    animation: kst-success-bounce 0.5s ease;
}

.kst-spelling-input.incorrect {
    border-color: #dc3545;
    background: #f8d7da;
    animation: kst-shake 0.5s ease;
}

@keyframes kst-success-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes kst-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* Feedback - Enhanced for motivation */
.kst-feedback {
    text-align: center;
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 1.05rem;
    line-height: 1.5;
    display: none;
    animation: kst-fade-in-up 0.4s ease;
    position: relative;
    overflow: hidden;
}

.kst-feedback::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.kst-feedback.correct {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    display: block;
    border: 1px solid #b1dfbb;
}

.kst-feedback.correct::before {
    background: linear-gradient(90deg, #28a745, #34ce57);
}

.kst-feedback.incorrect {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe0e0 100%);
    color: #721c24;
    display: block;
    border: 1px solid #f5c6cb;
}

.kst-feedback.incorrect::before {
    background: linear-gradient(90deg, #dc3545, #ff6b6b);
}

.kst-feedback.hint {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    color: #856404;
    display: block;
    border: 1px solid #ffeeba;
}

.kst-feedback.hint::before {
    background: linear-gradient(90deg, #ffc107, #ffdb4d);
}

/* Motivational emoji in feedback */
.kst-feedback .kst-emoji {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 8px;
}

@keyframes kst-fade-in-up {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Shortcuts */
.kst-shortcuts {
    text-align: center;
    color: #999;
    font-size: 0.8rem;
}

.kst-shortcuts kbd {
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 0.75rem;
}

/* Results Screen */
.kst-results-screen {
    text-align: center;
    padding: 20px 0;
}

.kst-results-screen h2 {
    font-size: 1.8rem;
    margin-bottom: 24px;
    color: #333;
}

.kst-results-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 30px;
    color: white;
    margin-bottom: 24px;
    animation: kst-fade-in-up 0.5s ease;
}

.kst-results-score {
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 8px;
}

.kst-results-score span {
    display: block;
}

.kst-results-stars {
    font-size: 2rem;
    margin: 12px 0;
    animation: kst-pop-in 0.6s ease 0.3s both;
}

@keyframes kst-pop-in {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.kst-results-message {
    font-size: 1.15rem;
    opacity: 0.95;
    line-height: 1.5;
    font-weight: 500;
    animation: kst-fade-in-up 0.5s ease 0.5s both;
}

.kst-results-details {
    margin-bottom: 24px;
    text-align: left;
}

.kst-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    margin-bottom: 8px;
    border-radius: 10px;
    background: #f8f9fa;
    transition: transform 0.2s;
}

.kst-result-item:hover {
    transform: translateX(4px);
}

.kst-result-item.correct {
    border-left: 4px solid #28a745;
}

.kst-result-item.incorrect {
    border-left: 4px solid #dc3545;
}

.kst-result-word {
    font-weight: 600;
}

.kst-result-attempt {
    font-family: monospace;
    color: #666;
}

.kst-results-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.kst-stat {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    transition: transform 0.2s;
}

.kst-stat:hover {
    transform: translateY(-2px);
}

.kst-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

.kst-stat-label {
    font-size: 0.8rem;
    color: #888;
}

.kst-results-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Loading */
.kst-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    z-index: 100;
}

.kst-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: kst-spin 1s linear infinite;
}

@keyframes kst-spin {
    to { transform: rotate(360deg); }
}

/* Leaderboard */
.kst-leaderboard {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
}

.kst-leaderboard h3 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.kst-leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.kst-leaderboard-table th,
.kst-leaderboard-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.kst-leaderboard-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
}

.kst-leaderboard-table tr:last-child td {
    border-bottom: none;
}

/* Responsive */
@media (max-width: 480px) {
    .kst-spelling-game {
        padding: 12px;
        border-radius: 16px;
    }

    .kst-score-board {
        grid-template-columns: repeat(2, 1fr);
    }

    .kst-word-blanks {
        font-size: 1.6rem;
        letter-spacing: 6px;
    }

    .kst-controls-row {
        flex-wrap: wrap;
    }

    .kst-controls-row .kst-btn {
        flex: 1 1 calc(50% - 5px);
    }

    .kst-results-stats {
        grid-template-columns: 1fr;
    }

    .kst-feedback {
        font-size: 0.95rem;
        padding: 16px;
    }
}

/* Admin Styles */
.kst-admin {
    max-width: 1200px;
}

.kst-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin: 20px 0;
}

.kst-stat-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #e0e0e0;
    transition: transform 0.2s;
}

.kst-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.kst-stat-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.kst-stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

.kst-stat-label {
    color: #888;
    font-size: 0.9rem;
}

.kst-admin-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.kst-admin-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #e0e0e0;
}

.kst-admin-section h2 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1.2rem;
    color: #333;
}

.kst-shortcode-help {
    margin-top: 20px;
}

.kst-shortcode-help code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.kst-admin-section ol,
.kst-admin-section ul {
    padding-left: 20px;
    line-height: 1.8;
}

.kst-admin-section li {
    margin-bottom: 4px;
}

@media (max-width: 768px) {
    .kst-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .kst-admin-sections {
        grid-template-columns: 1fr;
    }
}
