/* ===================================
   KAIWA NO TABI - Conversation Game Styles
   L'Atelier des Kanji
   =================================== */

/* CSS Variables */
:root {
    /* Colors */
    --orange-primary: #E67E5A;
    --orange-light: #F5A882;
    --orange-dark: #C75D3A;
    --green-primary: #7DB59A;
    --green-light: #A8D5BA;
    --green-dark: #5A9A7A;
    --beige-light: #FBF8F4;
    --beige-medium: #EDE5DA;
    --beige-dark: #D4C9BC;
    --accent-gold: #D4A84B;
    --accent-blue: #8AB4F8;

    /* Text */
    --text-primary: #2D2A26;
    --text-secondary: #5C5650;
    --text-muted: #8A847C;
    --text-inverse: #FFFFFF;

    /* Backgrounds */
    --bg-body: #FBF8F4;
    --bg-white: #FFFFFF;

    /* Typography */
    --font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-extrabold: 800;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-8: 3rem;

    /* Borders */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(45, 42, 38, 0.08);
    --shadow-md: 0 4px 12px rgba(45, 42, 38, 0.1);
    --shadow-lg: 0 8px 24px rgba(45, 42, 38, 0.12);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Base */
body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Game Header */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    background: var(--bg-white);
    border-bottom: 2px solid var(--beige-medium);
    z-index: 100;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--beige-light);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: var(--font-weight-semibold);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.back-btn:hover {
    background: var(--beige-medium);
    color: var(--text-primary);
}

.game-title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.game-icon {
    font-size: 1.5rem;
}

.game-title h1 {
    font-size: 1.5rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

.mode-switch {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--beige-light);
    border: 2px solid var(--beige-medium);
    border-radius: var(--radius-full);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mode-switch:hover {
    border-color: var(--orange-light);
}

.mode-indicator {
    width: 8px;
    height: 8px;
    background: var(--green-primary);
    border-radius: var(--radius-full);
}

/* Main */
.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Screens */
.screen {
    flex: 1;
    padding: var(--space-6);
}

#selectionScreen {
    max-width: 800px;
    margin: 0 auto;
}

#dialogueScreen {
    display: flex;
    flex-direction: column;
    padding: 0;
}

#resultsScreen {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Selection Header */
.selection-header {
    text-align: center;
    margin-bottom: var(--space-6);
}

.selection-header h2 {
    font-size: 2rem;
    font-weight: var(--font-weight-extrabold);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.selection-header .subtitle {
    font-size: 1.1rem;
    color: var(--orange-primary);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-3);
}

.selection-header .description {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Episodes Grid */
.episodes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.episode-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-5);
    background: var(--bg-white);
    border: 2px solid var(--beige-medium);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.episode-card:hover {
    border-color: var(--orange-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.episode-illustration {
    font-size: 3rem;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--beige-light);
    border-radius: var(--radius-lg);
}

.episode-info {
    flex: 1;
}

.episode-info h3 {
    font-size: 1.1rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.episode-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.episode-meta {
    display: flex;
    gap: var(--space-3);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.episode-status {
    width: 24px;
    height: 24px;
}

/* Mode Selection */
.mode-selection {
    background: var(--bg-white);
    border: 2px solid var(--beige-medium);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    text-align: center;
}

.mode-selection h3 {
    font-size: 0.9rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

.mode-buttons {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-4) var(--space-6);
    background: var(--bg-white);
    border: 2px solid var(--beige-medium);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mode-btn:hover {
    border-color: var(--orange-light);
}

.mode-btn.active {
    border-color: var(--orange-primary);
    background: var(--orange-light);
}

.mode-btn .mode-icon {
    font-size: 1.5rem;
}

.mode-btn .mode-name {
    font-size: 1rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

.mode-btn .mode-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Dialogue Screen */
.dialogue-progress {
    height: 4px;
    background: var(--beige-medium);
}

.dialogue-progress .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--orange-primary), var(--accent-gold));
    transition: width var(--transition-normal);
}

/* Fluency Bar */
.fluency-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-6);
    background: var(--bg-white);
    border-bottom: 1px solid var(--beige-medium);
}

.fluency-label {
    font-size: 0.8rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
}

.fluency-track {
    flex: 1;
    height: 8px;
    background: var(--beige-medium);
    border-radius: var(--radius-full);
    overflow: hidden;
    max-width: 200px;
}

.fluency-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green-primary), var(--green-light));
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}

.fluency-value {
    font-size: 0.85rem;
    font-weight: var(--font-weight-bold);
    color: var(--green-dark);
    min-width: 40px;
}

/* Scene */
.scene {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: var(--space-6);
    position: relative;
    background: linear-gradient(180deg, var(--beige-light) 0%, var(--beige-medium) 100%);
    min-height: 350px;
}

.scene-background {
    position: absolute;
    top: var(--space-6);
    font-size: 6rem;
    opacity: 0.3;
}

/* Character */
.character {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: var(--space-4);
    position: relative;
    z-index: 1;
}

.character-avatar {
    font-size: 4rem;
    background: var(--bg-white);
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    border: 3px solid var(--beige-medium);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.character.speaking .character-avatar {
    border-color: var(--orange-primary);
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.character-name {
    margin-top: var(--space-2);
    font-size: 0.9rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    background: var(--bg-white);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
}

/* Dialogue Box */
.dialogue-box {
    width: 100%;
    max-width: 600px;
    background: var(--bg-white);
    border: 2px solid var(--beige-medium);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.speaker-indicator {
    position: absolute;
    top: -12px;
    left: var(--space-5);
    padding: var(--space-1) var(--space-3);
    background: var(--orange-primary);
    color: var(--text-inverse);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: var(--font-weight-bold);
}

.dialogue-content {
    text-align: center;
}

.dialogue-japanese {
    font-size: 1.75rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    line-height: 1.4;
}

.dialogue-romaji {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.dialogue-translation {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Immersion Mode */
.immersion-mode .dialogue-romaji,
.immersion-mode .response-romaji {
    display: none;
}

.immersion-mode .dialogue-translation,
.immersion-mode .response-translation {
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.immersion-mode .dialogue-box:hover .dialogue-translation,
.immersion-mode .response-btn:hover .response-translation {
    opacity: 1;
}

/* Mobile/Touch: Show translations by default (no hover on touch devices) */
@media (max-width: 1100px), (hover: none) {
    .immersion-mode .dialogue-translation,
    .immersion-mode .response-translation {
        opacity: 1;
    }
}

/* Response Area */
.response-area {
    padding: var(--space-5) var(--space-6);
    background: var(--bg-white);
    border-top: 2px solid var(--beige-medium);
}

.response-prompt {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

.response-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 600px;
    margin: 0 auto;
}

.response-btn {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-4);
    background: var(--bg-white);
    border: 2px solid var(--beige-medium);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.response-btn:hover:not(:disabled) {
    border-color: var(--orange-light);
    background: var(--beige-light);
}

.response-btn.selected {
    border-color: var(--orange-primary);
    background: var(--orange-light);
}

.response-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.response-japanese {
    font-size: 1.1rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

.response-romaji {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.response-translation {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Continue Button */
.continue-btn {
    margin: var(--space-4) auto;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-lg);
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 2px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--orange-primary) 0%, var(--orange-dark) 100%);
    color: var(--text-inverse);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(230, 126, 90, 0.3);
}

.btn-outline {
    background: var(--bg-white);
    border-color: var(--beige-medium);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--orange-light);
    color: var(--orange-primary);
}

/* Results Card */
.results-card {
    background: var(--bg-white);
    border: 2px solid var(--beige-medium);
    border-radius: var(--radius-2xl);
    padding: var(--space-6);
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.results-header {
    margin-bottom: var(--space-5);
}

.results-icon {
    font-size: 4rem;
    margin-bottom: var(--space-2);
}

.results-card h2 {
    font-size: 1.5rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

#resultsEpisodeName {
    font-size: 1rem;
    color: var(--text-muted);
}

/* Fluency Result */
.fluency-result {
    margin-bottom: var(--space-5);
}

.fluency-circle {
    width: 120px;
    height: 120px;
    margin: 0 auto var(--space-3);
    background: linear-gradient(135deg, var(--green-light) 0%, var(--green-primary) 100%);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

.fluency-score {
    font-size: 2.5rem;
    font-weight: var(--font-weight-extrabold);
    color: var(--text-inverse);
}

.fluency-percent {
    font-size: 1rem;
    color: var(--text-inverse);
}

.fluency-message {
    font-size: 1rem;
    font-weight: var(--font-weight-semibold);
    color: var(--green-dark);
}

/* XP Earned */
.xp-earned {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background: linear-gradient(135deg, var(--accent-gold) 0%, #C4943D 100%);
    color: var(--text-inverse);
    border-radius: var(--radius-full);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-5);
}

.xp-icon {
    font-size: 1.25rem;
}

/* Phrases Review */
.phrases-review {
    text-align: left;
    margin-bottom: var(--space-5);
}

.phrases-review h3,
.vocab-section h3 {
    font-size: 0.9rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
    text-align: center;
}

.phrases-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.phrase-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--beige-light);
    border-radius: var(--radius-md);
}

.phrase-item.perfect .phrase-quality {
    color: var(--green-primary);
}

.phrase-item.ok .phrase-quality {
    color: var(--accent-gold);
}

.phrase-item.confused .phrase-quality {
    color: var(--orange-primary);
}

.phrase-quality {
    font-weight: var(--font-weight-bold);
}

.phrase-content {
    flex: 1;
}

.phrase-jp {
    display: block;
    font-size: 0.9rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.phrase-fr {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Vocabulary */
.vocab-section {
    margin-bottom: var(--space-5);
}

.vocab-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
}

.vocab-item {
    display: flex;
    flex-direction: column;
    padding: var(--space-3);
    background: var(--beige-light);
    border-radius: var(--radius-md);
    text-align: center;
}

.vocab-jp {
    font-size: 1.1rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

.vocab-romaji {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.vocab-fr {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Results Actions */
.results-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-3);
}

/* Responsive */
@media (max-width: 768px) {
    .game-header {
        padding: var(--space-3) var(--space-4);
        flex-wrap: wrap;
        gap: var(--space-2);
    }

    .game-title h1 {
        font-size: 1.2rem;
    }

    .mode-switch {
        padding: var(--space-1) var(--space-3);
        font-size: 0.8rem;
    }

    /* Episodes grid */
    .episodes-grid {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }

    .episode-card {
        padding: var(--space-4);
        flex-direction: row;
        gap: var(--space-4);
    }

    .episode-illustration {
        font-size: 2.5rem;
        width: 60px;
        height: 60px;
        flex-shrink: 0;
    }

    .episode-info {
        text-align: left;
    }

    .mode-buttons {
        flex-direction: column;
        gap: var(--space-2);
    }

    .mode-btn {
        padding: var(--space-3) var(--space-4);
        min-height: 48px;
    }

    /* Scene adjustments */
    .scene {
        min-height: 250px;
        padding: var(--space-4);
    }

    .scene-background {
        font-size: 4rem;
    }

    .character-avatar {
        font-size: 3rem;
        width: 70px;
        height: 70px;
    }

    .character-name {
        font-size: 0.8rem;
    }

    /* Dialogue box - messaging style */
    .dialogue-box {
        padding: var(--space-4);
        max-width: 100%;
        border-radius: var(--radius-lg);
    }

    .dialogue-japanese {
        font-size: 1.3rem;
    }

    .dialogue-translation {
        font-size: 0.9rem;
    }

    /* Response area - fixed at bottom */
    .response-area {
        padding: var(--space-3);
        position: sticky;
        bottom: 0;
        z-index: 10;
    }

    .response-prompt {
        font-size: 0.8rem;
        margin-bottom: var(--space-3);
    }

    .response-options {
        gap: var(--space-2);
    }

    .response-btn {
        padding: var(--space-3);
        min-height: 56px;
    }

    .response-japanese {
        font-size: 1rem;
    }

    .response-romaji,
    .response-translation {
        font-size: 0.75rem;
    }

    /* Results card */
    .results-card {
        padding: var(--space-4);
        margin: var(--space-4);
    }

    .results-card h2 {
        font-size: 1.25rem;
    }

    .fluency-circle {
        width: 100px;
        height: 100px;
    }

    .fluency-percent {
        font-size: 2rem;
    }

    .vocab-grid {
        grid-template-columns: 1fr;
    }

    .results-actions {
        flex-direction: column;
    }

    .results-actions .btn {
        width: 100%;
        min-height: 48px;
    }

    /* Touch targets */
    .btn {
        min-height: 48px;
    }

    .continue-btn {
        width: 100%;
        max-width: 300px;
    }
}

/* =====================================================
   IMMERSION MODE STYLES
   ===================================================== */

#immersionScreen {
    display: flex;
    flex-direction: column;
    padding: 0;
    height: calc(100vh - 70px);
    height: calc(100svh - 70px);
    height: calc(100dvh - 70px);
    overflow: hidden;
}

/* Immersion Header */
.immersion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-5);
    background: var(--bg-white);
    border-bottom: 2px solid var(--beige-medium);
    gap: var(--space-3);
    flex-wrap: wrap;
}

/* Objectives header button - hidden by default on desktop */
.objectives-header-btn {
    display: none;
    align-items: center;
    gap: var(--space-2);
    background: var(--beige-light);
    border: 1px solid var(--beige-medium);
    border-radius: var(--radius-lg);
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.objectives-header-btn:hover {
    background: var(--beige-medium);
    border-color: var(--beige-dark);
}

.objectives-btn-icon {
    font-size: 1rem;
}

.objectives-btn-text {
    font-weight: var(--font-weight-semibold);
}

.objectives-btn-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: var(--space-1);
}

.scene-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.scene-icon {
    font-size: 1.5rem;
}

.scene-name {
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

.stage-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--beige-light);
    border-radius: var(--radius-full);
}

.stage-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stage-name {
    font-size: 0.85rem;
    font-weight: var(--font-weight-semibold);
    color: var(--orange-primary);
}

.btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: 0.8rem;
}

/* Conversation + Keyboard Wrapper (Desktop: side-by-side) */
.conversation-keyboard-wrapper {
    display: flex;
    flex-direction: row;
    flex: 1;
    overflow: hidden;
}

/* Conversation Area */
.conversation-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    background: linear-gradient(180deg, var(--beige-light) 0%, var(--beige-medium) 100%);
}

.conversation-messages {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 600px;
    margin: 0 auto;
}

.message {
    display: flex;
    gap: var(--space-3);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.npc {
    justify-content: flex-start;
}

.message.player {
    justify-content: flex-end;
}

.message-avatar {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-white);
    border-radius: var(--radius-full);
    border: 2px solid var(--beige-medium);
    flex-shrink: 0;
}

.message.player .message-avatar {
    order: 2;
    background: var(--orange-light);
    border-color: var(--orange-primary);
}

.message-bubble {
    max-width: 75%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-xl);
    background: var(--bg-white);
    border: 2px solid var(--beige-medium);
    /* WebKit/iOS fixes */
    display: block;
    overflow: visible;
    -webkit-overflow-scrolling: touch;
}

.message.player .message-bubble {
    background: var(--orange-light);
    border-color: var(--orange-primary);
}

.message-text {
    font-size: 1.1rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    line-height: 1.5;
}

.message-translation {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: var(--space-1);
    line-height: 1.4;
    /* WebKit/iOS fixes */
    display: block;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
}

.message.player .message-translation {
    color: var(--orange-dark);
    opacity: 0.8;
}

/* Translation toggle wrapper - Block layout for iOS compatibility */
.message-translation-wrapper {
    display: block;
    margin-top: var(--space-1);
    position: relative;
}

.message-translation-wrapper .message-translation {
    display: block !important;
    width: 100%;
    margin-top: 0;
    margin-bottom: var(--space-1);
}

/* Actions row below translation */
.message-translation-wrapper .message-actions {
    display: inline-flex;
    margin-top: var(--space-1);
}

/* Translation toggle button */
.translation-toggle {
    background: none;
    border: none;
    font-size: 0.85rem;
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    opacity: 0.7;
    flex-shrink: 0;
}

.translation-toggle:hover {
    opacity: 1;
    background: var(--beige-light);
    transform: scale(1.1);
}

.message.player .translation-toggle:hover {
    background: var(--orange-dark);
    opacity: 0.9;
}

/* Message actions container */
.message-actions {
    display: flex;
    gap: var(--space-1);
    align-items: center;
}

.message-actions.standalone {
    margin-top: var(--space-1);
}

/* Replay audio button */
.replay-audio-btn {
    background: none;
    border: none;
    font-size: 0.85rem;
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    opacity: 0.6;
}

.replay-audio-btn:hover {
    opacity: 1;
    background: var(--beige-light);
    transform: scale(1.15);
}

.replay-audio-btn:active {
    transform: scale(0.95);
}

/* Immersion Character */
.immersion-character {
    display: none;
    padding: var(--space-3) var(--space-5);
    background: var(--bg-white);
    border-top: 1px solid var(--beige-medium);
}

.character-bubble {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    max-width: 600px;
    margin: 0 auto;
}

.character-avatar-small {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--beige-light);
    border-radius: var(--radius-full);
    border: 2px solid var(--beige-medium);
}

.bubble-content {
    flex: 1;
}

.bubble-name {
    display: block;
    font-size: 0.75rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.bubble-text {
    font-size: 1.25rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

/* Keyboard Container */
.keyboard-container {
    width: 380px;
    flex-shrink: 0;
    padding: var(--space-4);
    background: var(--beige-medium);
    border-left: 2px solid var(--beige-dark);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Keyboard Input */
.keyboard-input {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.kana-input {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    font-size: 1.25rem;
    font-family: var(--font-family);
    border: 2px solid var(--beige-dark);
    border-radius: var(--radius-lg);
    background: var(--bg-white);
    color: var(--text-primary);
}

.kana-input::placeholder {
    color: var(--text-muted);
}

.clear-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-white);
    border: 2px solid var(--beige-dark);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.clear-btn:hover {
    border-color: var(--orange-primary);
    color: var(--orange-primary);
}

/* Keyboard Modes */
.keyboard-modes {
    display: flex;
    justify-content: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.keyboard-modes .mode-btn {
    padding: var(--space-2) var(--space-4);
    font-size: 1.1rem;
    background: var(--bg-white);
    border: 2px solid var(--beige-dark);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.keyboard-modes .mode-btn.active {
    background: var(--orange-light);
    border-color: var(--orange-primary);
}

/* Keyboard Grid */
.keyboard-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    max-width: 400px;
    margin: 0 auto var(--space-2);
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: var(--space-1);
}

.key {
    min-width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-family: var(--font-family);
    background: var(--bg-white);
    border: 2px solid var(--beige-dark);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.key:hover:not(.empty-key) {
    background: var(--orange-light);
    border-color: var(--orange-primary);
}

.key:active:not(.empty-key) {
    transform: scale(0.95);
}

.empty-key {
    visibility: hidden;
}

/* Special Keys */
.keyboard-special {
    display: flex;
    justify-content: center;
    gap: var(--space-4);
    margin-bottom: var(--space-2);
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.small-kana,
.punctuation {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    justify-content: center;
}

.small-key,
.punct-key {
    min-width: 36px;
    height: 36px;
    font-size: 1rem;
}

/* Keyboard Actions */
.keyboard-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    max-width: 400px;
    margin: 0 auto;
}

.backspace-key {
    flex: 1;
    max-width: 100px;
    background: var(--beige-light);
}

.send-btn {
    flex: 2;
    max-width: 200px;
    padding: var(--space-3) var(--space-5);
    font-size: 1rem;
    font-weight: var(--font-weight-bold);
    background: linear-gradient(135deg, var(--orange-primary), var(--orange-dark));
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(230, 126, 90, 0.3);
}

/* API Modal */
.api-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.api-modal-content {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.api-modal-content h3 {
    font-size: 1.25rem;
    margin-bottom: var(--space-3);
}

.api-modal-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

.api-input {
    width: 100%;
    padding: var(--space-3);
    font-size: 1rem;
    border: 2px solid var(--beige-medium);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
}

.api-note {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.api-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
    margin-top: var(--space-4);
}

/* Responsive Immersion */
@media (max-width: 768px) {
    .keyboard-grid {
        max-width: 100%;
    }

    .key {
        min-width: 32px;
        height: 40px;
        font-size: 1rem;
    }

    .small-key,
    .punct-key {
        min-width: 28px;
        height: 32px;
        font-size: 0.85rem;
    }

    .kana-input {
        font-size: 1rem;
    }

    .bubble-text {
        font-size: 1.1rem;
    }

    .message-text {
        font-size: 1rem;
    }
}

/* =====================================================
   EVALUATION PANEL STYLES
   ===================================================== */

.evaluation-panel {
    background: var(--bg-white);
    border-top: 2px solid var(--beige-medium);
    padding: var(--space-3) var(--space-5);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.eval-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.eval-title {
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.eval-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--beige-light);
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.eval-close:hover {
    background: var(--beige-medium);
    color: var(--text-primary);
}

.eval-content {
    display: flex;
    gap: var(--space-5);
    align-items: flex-start;
    max-width: 600px;
    margin: 0 auto;
}

.eval-score {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-shrink: 0;
}

.eval-note {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: var(--font-weight-extrabold);
    color: var(--text-inverse);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--green-primary), var(--green-dark));
}

.eval-note.grade-a {
    background: linear-gradient(135deg, #4CAF50, #388E3C);
}

.eval-note.grade-b {
    background: linear-gradient(135deg, var(--green-primary), var(--green-dark));
}

.eval-note.grade-c {
    background: linear-gradient(135deg, var(--accent-gold), #C4943D);
}

.eval-note.grade-d {
    background: linear-gradient(135deg, var(--orange-primary), var(--orange-dark));
}

.eval-note.grade-f {
    background: linear-gradient(135deg, #E57373, #D32F2F);
}

.eval-coherence {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.coherence-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.coherence-bar {
    width: 80px;
    height: 6px;
    background: var(--beige-medium);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.coherence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green-light), var(--green-primary));
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

.coherence-value {
    font-size: 0.8rem;
    font-weight: var(--font-weight-bold);
    color: var(--green-dark);
}

.eval-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.eval-translation,
.eval-advice {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: var(--font-weight-semibold);
}

.detail-value {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.eval-advice .detail-value {
    color: var(--orange-primary);
    font-style: italic;
}

/* Responsive Evaluation */
@media (max-width: 600px) {
    .eval-content {
        flex-direction: column;
        gap: var(--space-3);
    }

    .eval-score {
        align-self: flex-start;
    }
}

/* =====================================================
   OBJECTIVES PANEL STYLES
   ===================================================== */

.immersion-content {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Objectives Panel */
.objectives-panel {
    width: 280px;
    flex-shrink: 0;
    background: var(--bg-white);
    border-right: 2px solid var(--beige-medium);
    padding: var(--space-4);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.objectives-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--beige-medium);
}

.objectives-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.objectives-icon {
    font-size: 1.25rem;
}

.objectives-header h3 {
    font-size: 0.95rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin: 0;
}

/* Toggle button - hidden by default on desktop */
.objectives-toggle {
    display: none;
    background: var(--beige-medium);
    border: none;
    border-radius: var(--radius-sm);
    padding: var(--space-2);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.objectives-toggle:hover {
    background: var(--beige-dark);
}

.toggle-icon {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.objectives-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-3);
    background: var(--beige-light);
    border-radius: var(--radius-lg);
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.meta-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-value {
    font-size: 0.85rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

/* Objectives List */
.objectives-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.objective-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--beige-light);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--beige-dark);
    transition: all var(--transition-normal);
}

.objective-item.current {
    background: var(--orange-light);
    border-left-color: var(--orange-primary);
}

.objective-item.completed {
    background: var(--green-light);
    border-left-color: var(--green-primary);
}

.objective-check {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-white);
    border: 2px solid var(--beige-dark);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: all var(--transition-normal);
}

.objective-item.current .objective-check {
    border-color: var(--orange-primary);
    background: var(--orange-primary);
    color: var(--text-inverse);
}

.objective-item.current .objective-check::after {
    content: '▶';
    font-size: 0.6rem;
}

.objective-item.completed .objective-check {
    border-color: var(--green-primary);
    background: var(--green-primary);
    color: var(--text-inverse);
}

.objective-item.completed .objective-check::after {
    content: '✔';
    font-size: 0.75rem;
}

.objective-content {
    flex: 1;
    min-width: 0;
}

.objective-titre {
    font-size: 0.85rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.objective-but {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.objective-item.completed .objective-titre,
.objective-item.completed .objective-but {
    text-decoration: line-through;
    opacity: 0.7;
}

/* Updated Conversation Area for side-by-side layout */
.immersion-content .conversation-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    background: linear-gradient(180deg, var(--beige-light) 0%, var(--beige-medium) 100%);
}

/* Responsive Objectives */
/* Includes iPad Pro (1024px portrait) */
@media (max-width: 1100px) {

    /* Show header button on tablet */
    .objectives-header-btn {
        display: flex;
    }

    /* Panel behavior on tablet */
    .objectives-panel {
        width: 250px;
        transition: width 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    }

    /* When collapsed: hide panel completely */
    .objectives-panel.collapsed {
        width: 0;
        padding: 0;
        overflow: hidden;
        border: none;
        opacity: 0;
    }

    .objectives-panel.collapsed .objectives-header,
    .objectives-panel.collapsed .objectives-body {
        display: none;
    }

    /* Show toggle button inside panel */
    .objectives-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .objectives-header {
        cursor: pointer;
    }
}

@media (max-width: 768px) {
    .immersion-content {
        flex-direction: column;
    }

    .objectives-panel {
        width: 100%;
        max-height: none;
        border-right: none;
        border-bottom: 2px solid var(--beige-medium);
        transition: all 0.3s ease;
    }

    /* Collapsed state on mobile */
    .objectives-panel.collapsed {
        padding-bottom: var(--space-2);
    }

    .objectives-panel.collapsed .objectives-header {
        margin-bottom: 0;
        border-bottom: none;
    }

    .objectives-body {
        transition: all 0.3s ease;
        overflow: hidden;
    }

    .objectives-panel.collapsed .objectives-body {
        max-height: 0;
        padding: 0;
        margin: 0;
    }

    .objectives-list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--space-2);
    }

    .objective-item {
        flex: 1 1 calc(50% - var(--space-2));
        min-width: 140px;
    }

    /* Toggle icon styling */
    .toggle-icon {
        font-size: 0.7rem;
    }
}

/* =====================================================
   QUEST SUMMARY SCREEN STYLES
   ===================================================== */

#questSummaryScreen {
    padding: var(--space-5);
    overflow-y: auto;
}

.summary-container {
    max-width: 900px;
    margin: 0 auto;
}

.summary-header {
    text-align: center;
    margin-bottom: var(--space-5);
}

.summary-header h2 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.quest-info {
    display: flex;
    justify-content: center;
    gap: var(--space-4);
    color: var(--text-muted);
}

.quest-name {
    font-weight: var(--font-weight-semibold);
}

.quest-time {
    color: var(--orange-primary);
}

/* Global Result */
.summary-result {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-5);
    padding: var(--space-5);
    background: linear-gradient(135deg, var(--green-light) 0%, rgba(166, 215, 106, 0.3) 100%);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-5);
    border: 2px solid var(--green-primary);
}

.summary-result.failed {
    background: linear-gradient(135deg, var(--orange-light) 0%, rgba(242, 160, 75, 0.3) 100%);
    border-color: var(--orange-primary);
}

.result-grade {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: var(--font-weight-extrabold);
    color: var(--text-inverse);
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--green-primary), var(--green-dark));
}

.result-grade.grade-a {
    background: linear-gradient(135deg, #4CAF50, #388E3C);
}

.result-grade.grade-b {
    background: linear-gradient(135deg, var(--green-primary), var(--green-dark));
}

.result-grade.grade-c {
    background: linear-gradient(135deg, var(--accent-gold), #C4943D);
}

.result-grade.grade-d {
    background: linear-gradient(135deg, var(--orange-primary), var(--orange-dark));
}

.result-grade.grade-e {
    background: linear-gradient(135deg, #E57373, #D32F2F);
}

.result-info {
    text-align: left;
}

.result-status {
    font-size: 1.25rem;
    font-weight: var(--font-weight-bold);
    color: var(--green-dark);
    margin-bottom: var(--space-1);
}

.summary-result.failed .result-status {
    color: var(--orange-dark);
}

.result-message {
    color: var(--text-muted);
}

/* Mastery Bar */
.mastery-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-5);
    border: 1px solid var(--beige-medium);
}

.mastery-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.mastery-track {
    flex: 1;
    height: 12px;
    background: var(--beige-medium);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.mastery-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green-light), var(--green-primary));
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

.mastery-percent {
    font-size: 1rem;
    font-weight: var(--font-weight-bold);
    color: var(--green-dark);
    min-width: 50px;
    text-align: right;
}

/* Badges */
.summary-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: center;
    margin-bottom: var(--space-5);
}

.summary-badge {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: linear-gradient(135deg, var(--accent-gold), #D4A856);
    color: var(--text-inverse);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: var(--font-weight-semibold);
    animation: badgePop 0.3s ease;
}

@keyframes badgePop {
    0% {
        transform: scale(0);
    }

    70% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

.summary-badge.keigo {
    background: linear-gradient(135deg, #9C27B0, #7B1FA2);
}

.summary-badge.grammar {
    background: linear-gradient(135deg, #2196F3, #1976D2);
}

.summary-badge.coherence {
    background: linear-gradient(135deg, #4CAF50, #388E3C);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    text-align: center;
    border: 1px solid var(--beige-medium);
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: var(--space-2);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: var(--font-weight-extrabold);
    color: var(--green-dark);
    margin-bottom: var(--space-1);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Phrases Table */
.phrases-section {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    border: 1px solid var(--beige-medium);
}

.phrases-section h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

.phrases-table-wrapper {
    overflow-x: auto;
}

.phrases-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.phrases-table th,
.phrases-table td {
    padding: var(--space-3);
    text-align: left;
    border-bottom: 1px solid var(--beige-medium);
}

.phrases-table th {
    background: var(--beige-light);
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.phrases-table tbody tr:hover {
    background: var(--beige-light);
}

.phrase-original {
    font-family: var(--font-family);
    color: var(--text-primary);
}

.phrase-improved {
    font-family: var(--font-family);
    color: var(--green-dark);
}

.phrase-grade {
    display: inline-block;
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    border-radius: var(--radius-full);
    font-weight: var(--font-weight-bold);
    color: var(--text-inverse);
    font-size: 0.85rem;
}

.phrase-grade.grade-a {
    background: #4CAF50;
}

.phrase-grade.grade-b {
    background: var(--green-primary);
}

.phrase-grade.grade-c {
    background: var(--accent-gold);
}

.phrase-grade.grade-d {
    background: var(--orange-primary);
}

.phrase-grade.grade-e {
    background: #E57373;
}

.phrase-error {
    font-size: 0.75rem;
    padding: var(--space-1) var(--space-2);
    background: var(--beige-light);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}

.phrase-error.error-aucune {
    color: var(--green-dark);
    background: var(--green-light);
}

.phrase-error.error-grammaire {
    color: #D32F2F;
    background: #FFEBEE;
}

.phrase-error.error-politesse {
    color: #7B1FA2;
    background: #F3E5F5;
}

.politeness-cell {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.politeness-alert {
    color: var(--orange-primary);
    font-size: 1rem;
}

/* Vocab Section */
.vocab-section {
    background: var(--beige-light);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-5);
}

.vocab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
}

#vocabCount {
    color: var(--green-dark);
    font-size: 1.25rem;
}

/* Summary Actions */
.summary-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
}

/* Responsive Summary */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .summary-result {
        flex-direction: column;
        text-align: center;
    }

    .result-info {
        text-align: center;
    }

    .phrases-table {
        font-size: 0.75rem;
    }

    /* Mobile: Stack keyboard below conversation */
    .conversation-keyboard-wrapper {
        flex-direction: column;
    }

    .keyboard-container {
        width: 100%;
        border-left: none;
        border-top: 2px solid var(--beige-dark);
        max-height: 50vh;
    }

    .conversation-area {
        flex: 1;
        min-height: 30vh;
    }

    .phrases-table th,
    .phrases-table td {
        padding: var(--space-2);
    }
}