/* ============================================================
   Coso's Typing Game 2.0 — Modernized Redesign Stylesheet
   ============================================================ */

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

:root {
    --bg-dark: #eaf0f8;
    --bg-card: #ffffff;
    --bg-card-elevated: rgba(255, 255, 255, 0.92);
    --bg-surface: #f1f5f9;
    --bg-glass: rgba(255, 255, 255, 0.78);
    --accent-green: #00c853;
    --accent-green-dark: #009624;
    --accent-yellow: #f59e0b;
    --accent-yellow-bright: #ffd600;
    --accent-red: #ff1744;
    --accent-blue: #2563eb;
    --accent-cyan: #00b0ff;
    --accent-magenta: #d500f9;
    --accent-purple: #7c3aed;
    --text-primary: #1e293b;
    --text-bright: #0f172a;
    --text-dim: #64748b;
    --prompt-bg: #ffffff;
    --input-bg: #f8fafc;
    --border-subtle: rgba(15, 23, 42, 0.1);
    --border-strong: #cbd5e1;
    --notebook-line: #e2e8f0;
    --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.07), 0 2px 8px rgba(15, 23, 42, 0.04);
    --shadow-glow: 0 0 30px rgba(0, 200, 83, 0.22);
    --radius-lg: 22px;
    --radius: 16px;
    --radius-sm: 10px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* Finger zone colors */
    --zone-lp: #f43f5e;
    --zone-lr: #f97316;
    --zone-lm: #eab308;
    --zone-li: #22c55e;
    --zone-thumb: #64748b;
    --zone-ri: #06b6d4;
    --zone-rm: #3b82f6;
    --zone-rr: #8b5cf6;
    --zone-rp: #ec4899;
}

body.dark-theme {
    --bg-dark: #0b1120;
    --bg-card: #1e293b;
    --bg-card-elevated: rgba(30, 41, 59, 0.92);
    --bg-surface: #0f172a;
    --bg-glass: rgba(15, 23, 42, 0.8);
    --text-primary: #e2e8f0;
    --text-bright: #f8fafc;
    --text-dim: #94a3b8;
    --prompt-bg: #1e293b;
    --input-bg: #0f172a;
    --border-subtle: rgba(255, 255, 255, 0.1);
    --border-strong: #334155;
    --notebook-line: #334155;
    --shadow-soft: 0 12px 34px rgba(0, 0, 0, 0.45);
}

body {
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Subtle ambient desk background */
body::before {
    content: '';
    position: fixed;
    top: -40%;
    left: -40%;
    width: 180%;
    height: 180%;
    background:
        radial-gradient(ellipse at 20% 45%, rgba(0, 200, 83, 0.08) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 20%, rgba(37, 99, 235, 0.08) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 85%, rgba(124, 58, 237, 0.06) 0%, transparent 55%);
    animation: bgShift 18s ease-in-out infinite alternate;
    z-index: 0;
    pointer-events: none;
}
@keyframes bgShift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(4%, 3%) scale(1.04); }
}

.screen {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 1;
}
.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ============ TOP BAR / PROFILE & THEME CONTROLS ============ */
.top-nav-bar {
    position: fixed;
    top: 14px;
    left: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
}
.top-nav-left, .top-nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}
.brand-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--bg-card-elevated);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-soft);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-bright);
    backdrop-filter: blur(10px);
}
.brand-pill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

.profile-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card-elevated);
    border: 1px solid var(--border-strong);
    padding: 5px 12px;
    border-radius: 999px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
}
.access-badge {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}
.player-select {
    background: transparent;
    border: none;
    color: var(--text-bright);
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    padding-right: 4px;
}
.player-select option {
    background: var(--bg-card);
    color: var(--text-bright);
}
.icon-pill-btn {
    background: var(--bg-card-elevated);
    border: 1px solid var(--border-strong);
    color: var(--text-bright);
    padding: 6px 12px;
    border-radius: 999px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-soft);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.icon-pill-btn:hover {
    border-color: var(--accent-blue);
    transform: translateY(-1px);
}

/* ============ MENU SCREEN ============ */
#menu-screen {
    justify-content: center;
    gap: 24px;
    padding: 68px 32px 28px;
    background:
        linear-gradient(135deg, rgba(234, 240, 248, 0.92) 0%, rgba(226, 232, 240, 0.94) 100%),
        repeating-linear-gradient(45deg, rgba(37, 99, 235, 0.025) 0 14px, transparent 14px 28px);
    overflow-y: auto;
}
body.dark-theme #menu-screen {
    background:
        linear-gradient(135deg, rgba(11, 17, 32, 0.93) 0%, rgba(15, 23, 42, 0.95) 100%),
        repeating-linear-gradient(45deg, rgba(37, 99, 235, 0.025) 0 14px, transparent 14px 28px);
}

.menu-hero {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
#menu-screen .title {
    font-size: clamp(2.2rem, 4.5vw, 3.4rem);
    font-weight: 800;
    background: linear-gradient(135deg, #00a846, #0284c7, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
    letter-spacing: -0.5px;
}
body.dark-theme #menu-screen .title {
    background: linear-gradient(135deg, #4ade80, #38bdf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
#menu-screen .subtitle {
    font-size: 1.08rem;
    color: var(--text-dim);
    text-align: center;
    font-weight: 500;
}

/* Session Target / Melody Quick Bar */
.menu-quick-options {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
    background: var(--bg-card-elevated);
    border: 1px solid var(--border-strong);
    padding: 8px 18px;
    border-radius: 999px;
    box-shadow: var(--shadow-soft);
}
.quick-opt-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dim);
}
.quick-opt-group select {
    background: var(--bg-surface);
    color: var(--text-bright);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    padding: 4px 12px;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    outline: none;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    max-width: 1120px;
    width: 100%;
}

.menu-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 100%;
    padding: 18px 20px;
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    border: 2px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-bright);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: visible;
    min-height: 98px;
}
.menu-btn .btn-Row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.menu-btn .btn-sub {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-dim);
}
.menu-btn .emoji {
    font-size: 1.7rem;
}
.menu-btn:hover {
    border-color: var(--accent-green);
    transform: translateY(-3px);
    box-shadow: 0 10px 26px rgba(0, 200, 83, 0.2);
}
.menu-btn.accent-cyan:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 10px 26px rgba(0, 176, 255, 0.22);
}
.menu-btn.accent-purple:hover {
    border-color: var(--accent-purple);
    box-shadow: 0 10px 26px rgba(124, 58, 237, 0.22);
}
.menu-btn.accent-yellow:hover {
    border-color: var(--accent-yellow);
    box-shadow: 0 10px 26px rgba(245, 158, 11, 0.22);
}
.menu-btn:active {
    transform: translateY(-1px);
}

/* Dropdown for words */
.dropdown-container {
    position: relative;
    height: 100%;
}
.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 260px;
    max-height: 360px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-sm);
    z-index: 300;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
    animation: dropIn 0.18s ease-out;
}
.dropdown-menu.open {
    display: block;
}
@keyframes dropIn {
    0% { opacity: 0; transform: translateY(-8px); }
    100% { opacity: 1; transform: translateY(0); }
}
.dropdown-item {
    padding: 12px 18px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text-bright);
    transition: var(--transition);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.dropdown-item:last-child {
    border-bottom: none;
}
.dropdown-item:hover {
    background: rgba(0, 200, 83, 0.12);
    color: var(--accent-green);
}
.dropdown-count {
    font-size: 0.78rem;
    color: var(--text-dim);
    background: var(--bg-surface);
    padding: 2px 8px;
    border-radius: 999px;
}

.menu-bottom {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    background: var(--bg-card-elevated);
    padding: 12px 22px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-soft);
}
.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    font-weight: 600;
}
.toggle-label input[type="checkbox"] {
    appearance: none;
    width: 42px;
    height: 23px;
    border-radius: 12px;
    background: #cbd5e1;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid #94a3b8;
}
body.dark-theme .toggle-label input[type="checkbox"] {
    background: #334155;
    border-color: #475569;
}
.toggle-label input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #ffffff;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.toggle-label input[type="checkbox"]:checked {
    background: var(--accent-green);
    border-color: var(--accent-green);
}
.toggle-label input[type="checkbox"]:checked::after {
    transform: translateX(19px);
    background: white;
}

/* ============ GAME SCREEN ============ */
#game-screen {
    padding: 58px 28px 12px;
    gap: 10px;
    height: 100vh;
    justify-content: space-between;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: min(96vw, 1320px);
    gap: 16px;
    flex-shrink: 0;
}
.progress-bar-container {
    flex: 1;
    display: flex;
    gap: 6px;
}
.progress-segment {
    flex: 1;
    height: 24px;
    border-radius: 7px;
    background: rgba(0, 200, 83, 0.12);
    border: 1px solid rgba(0, 200, 83, 0.28);
    transition: var(--transition);
}
.progress-segment.filled {
    background: linear-gradient(135deg, #00e676, #00c853);
    border-color: var(--accent-green);
    box-shadow: 0 0 12px rgba(0, 200, 83, 0.35);
}
.progress-segment.flash {
    animation: flashSeg 0.3s ease-in-out infinite;
}
@keyframes flashSeg {
    0%, 100% { background: var(--accent-green); }
    50% { background: var(--accent-yellow-bright); }
}

.hud-stats-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.hud-pill {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-bright);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: var(--shadow-soft);
}
.hud-pill .label {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.8rem;
}
.remaining-badge {
    font-size: 1rem;
    font-weight: 800;
    color: #d97706;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    padding: 5px 14px;
    border-radius: 999px;
    white-space: nowrap;
}

.game-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: min(96vw, 1320px);
    gap: 8px;
    min-height: 0;
}

/* Visual Stage (Clipart + Modernized Fallback Flashcard) */
.clipart-container {
    flex: 1;
    width: 100%;
    max-height: clamp(160px, 34vh, 420px);
    min-height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: var(--radius);
    position: relative;
    background: var(--bg-card-elevated);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-soft);
    padding: 12px 20px;
}
.stage-top-controls {
    position: absolute;
    top: 10px;
    left: 14px;
    right: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
    pointer-events: none;
}
.stage-badge {
    pointer-events: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stage-speak-btn {
    pointer-events: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    color: var(--text-bright);
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 5px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.stage-speak-btn:hover {
    border-color: var(--accent-blue);
    background: rgba(37, 99, 235, 0.1);
}

.clipart-container img {
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: clamp(140px, 30vh, 380px);
    object-fit: contain;
    border-radius: 12px;
    filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.18));
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.clipart-container img.hidden {
    display: none;
}

/* Rich Illustrated Fallback Card when clipart is absent */
.visual-flashcard {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 16px 32px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(0, 200, 83, 0.08), rgba(2, 132, 199, 0.08));
    border: 2px dashed var(--border-strong);
    min-width: 280px;
}
.visual-flashcard.active {
    display: flex;
}
.visual-flashcard-emoji {
    font-size: clamp(3rem, 6vw, 4.8rem);
    line-height: 1.1;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.12));
    animation: floatEmoji 3s ease-in-out infinite alternate;
}
@keyframes floatEmoji {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(-6px) scale(1.05); }
}
.visual-flashcard-caption {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-dim);
}

.prompt-pointer-icon {
    font-size: clamp(2rem, 3.5vw, 3.2rem);
    line-height: 1;
    user-select: none;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 8px rgba(255, 214, 0, 0.4));
    animation: pointerPulse 2s ease-in-out infinite;
}
@keyframes pointerPulse {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(5px); }
}

.prompt-box, .input-box {
    width: 100%;
    min-height: 62px;
    padding: 10px 22px;
    border-radius: var(--radius);
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.6rem, 3.1vw, 2.8rem);
    font-weight: 600;
    line-height: 1.3;
    white-space: pre-wrap;
    word-break: keep-all;
    overflow-wrap: break-word;
    position: relative;
}
.prompt-box {
    background: var(--prompt-bg);
    border: 2px solid var(--border-strong);
    color: var(--text-dim);
}
.prompt-box.correct-border {
    border-color: var(--accent-green);
    box-shadow: 0 0 20px rgba(0, 200, 83, 0.3);
}
.prompt-box .char {
    position: relative;
    display: inline;
}
.prompt-box .char.typed-correct {
    color: var(--accent-green-dark);
}
body.dark-theme .prompt-box .char.typed-correct {
    color: #4ade80;
}
.prompt-box .char.highlight {
    background: var(--accent-yellow-bright);
    color: #000;
    border-radius: 5px;
    padding: 0 2px;
    box-shadow: 0 0 10px rgba(255, 214, 0, 0.6);
}
.prompt-box .char.error-highlight {
    background: var(--accent-red);
    color: #fff;
    border-radius: 5px;
    padding: 0 2px;
}

.input-box {
    background: var(--input-bg);
    border: 2px solid var(--border-strong);
    color: var(--text-bright);
    min-height: 64px;
}
.input-box .char-correct {
    color: var(--text-bright);
}
.input-box .char-error {
    background: var(--accent-red);
    color: white;
    border-radius: 5px;
    padding: 0 2px;
}
.cursor-blink {
    display: inline-block;
    width: 3px;
    height: 1.05em;
    background: var(--accent-blue);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 1s step-end infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Notebook Sheet Card */
.notebook-sheet-card {
    position: relative;
    width: 100%;
    background: var(--bg-card);
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 33px,
        var(--notebook-line) 34px
    );
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    padding: 12px 18px 12px 34px;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    overflow: visible;
}
.notebook-paperclip {
    position: absolute;
    top: -12px;
    left: 20px;
    width: 16px;
    height: 42px;
    border: 3.5px solid #00bcd4;
    border-radius: 10px 10px 8px 8px;
    background: transparent;
    transform: rotate(-10deg);
    z-index: 10;
    box-shadow: 2px 4px 8px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}
.notebook-paperclip::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 1.5px;
    width: 6px;
    height: 24px;
    border: 2.5px solid #00bcd4;
    border-top: none;
    border-radius: 0 0 5px 5px;
}
.notebook-red-margin {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 48px;
    width: 2px;
    background: #fca5a5;
    pointer-events: none;
}
.notebook-content-row {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 14px;
    z-index: 2;
    padding-left: 14px;
    min-width: 0;
}

/* Tactile Letter Tiles */
.letter-tiles-container {
    display: flex;
    gap: clamp(6px, 0.9vw, 10px);
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    width: auto;
    flex-shrink: 0;
    padding: 4px 0;
}
.letter-tile {
    width: clamp(42px, 5.4vw, 72px);
    height: clamp(52px, 7vw, 84px);
    flex-shrink: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 2px solid var(--border-strong);
    border-radius: 14px;
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.7rem, 3.4vw, 3.1rem);
    font-weight: 700;
    color: var(--text-bright);
    box-shadow: 0 4px 0 var(--border-strong), 0 4px 10px rgba(0, 0, 0, 0.07);
    position: relative;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}
.letter-tile.tile-active {
    background: #e0f7fa;
    border: 3px solid var(--accent-cyan);
    color: #0077b6;
    transform: translateY(-4px) scale(1.06);
    box-shadow: 0 6px 0 #00b0ff, 0 0 22px rgba(0, 176, 255, 0.45);
}
.letter-tile.tile-active::before {
    content: '▼';
    position: absolute;
    top: -21px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--accent-cyan);
    font-size: 0.85rem;
    animation: bounce-tile 0.75s infinite alternate;
}
@keyframes bounce-tile {
    0% { transform: translateX(-50%) translateY(0); }
    100% { transform: translateX(-50%) translateY(-5px); }
}
.letter-tile.tile-correct {
    background: linear-gradient(135deg, #00c853, #009624);
    border-color: #00e676;
    color: #ffffff;
    box-shadow: 0 3px 0 #00701a, 0 0 16px rgba(0, 200, 83, 0.4);
}
.letter-tile.tile-error {
    background: linear-gradient(135deg, #ff1744, #d50000);
    border-color: #ff5252;
    color: #ffffff;
    animation: tile-shake 0.35s ease-in-out;
    box-shadow: 0 3px 0 #9b0000, 0 0 20px rgba(255, 23, 68, 0.5);
}

/* Side Letter Boxes (Next Word Preview) */
.side-letterboxes-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 18px;
    border-left: 2px dashed var(--border-strong);
    overflow: hidden;
    user-select: none;
    min-width: 0;
}
.side-letterboxes-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.side-word-tag {
    font-size: 0.76rem;
    font-weight: 700;
    color: #0284c7;
    background: #e0f2fe;
    padding: 3px 8px;
    border-radius: 12px;
    white-space: nowrap;
}
.side-tiles-row {
    display: flex;
    gap: 7px;
    align-items: center;
    flex-wrap: nowrap;
    overflow: hidden;
}
.side-tile {
    width: clamp(34px, 3.8vw, 48px);
    height: clamp(44px, 5vw, 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 2px dashed #94a3b8;
    border-radius: 8px;
    font-size: clamp(1.2rem, 2.1vw, 1.8rem);
    font-weight: 700;
    color: var(--text-dim);
    flex-shrink: 0;
}
.side-tile.empty-slot {
    border-color: var(--border-strong);
    opacity: 0.45;
    color: transparent;
}
@keyframes tile-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* Dual-Key Shift Guide */
.shift-key-guide {
    display: none;
    align-items: center;
    gap: 10px;
    background: rgba(37, 99, 235, 0.14);
    border: 1px solid rgba(37, 99, 235, 0.45);
    padding: 6px 16px;
    border-radius: 999px;
    color: var(--text-bright);
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 0 16px rgba(37, 99, 235, 0.2);
    animation: pulse-shift 1.2s infinite alternate;
    align-self: center;
}
@keyframes pulse-shift {
    0% { box-shadow: 0 0 8px rgba(37, 99, 235, 0.18); }
    100% { box-shadow: 0 0 20px rgba(37, 99, 235, 0.45); }
}
.shift-key-badge {
    background: var(--accent-blue);
    color: #ffffff;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
}
.shift-letter-badge {
    background: var(--accent-yellow-bright);
    color: #0f172a;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 800;
}

/* ============ KEYBOARD & HAND GUIDANCE ============ */
.keyboard-guide-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    flex-shrink: 0;
    user-select: none;
    position: relative;
}
.v-keyboard-chassis {
    position: relative;
    background: #1e2231;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 18px;
    padding: 8px 14px 11px;
    width: 800px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.v-keyboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px 6px;
    font-size: 0.82rem;
    color: #94a3b8;
}
.v-kb-title {
    font-weight: 700;
    letter-spacing: 0.4px;
    color: #f8fafc;
}
.v-kb-controls {
    display: flex;
    align-items: center;
    gap: 14px;
}
.v-kb-toggle-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #cbd5e1;
    font-weight: 600;
}
.v-keyboard {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
}
.v-keyboard-row {
    display: flex;
    gap: 5px;
    width: 100%;
}
.v-key {
    flex: 1;
    height: 40px;
    background: #ffffff;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Outfit', sans-serif;
    font-size: 0.92rem;
    font-weight: 700;
    color: #1e293b;
    box-shadow: 0 3px 0 #94a3b8;
    transition: all 0.1s cubic-bezier(0.2, 0, 0, 1);
    position: relative;
    cursor: default;
}
.v-key .key-sub {
    font-size: 0.65rem;
    line-height: 1;
    opacity: 0.65;
}
.v-key .key-main {
    font-size: 0.9rem;
    line-height: 1.1;
}
.v-key.key-special {
    background: #e2e8f0;
    font-size: 0.78rem;
    color: #475569;
    box-shadow: 0 3px 0 #94a3b8;
}

/* Color-coded Finger Zones when enabled */
.v-keyboard.zones-enabled .v-key[data-finger="lp"] { border-bottom: 3px solid var(--zone-lp); background: #fff1f2; }
.v-keyboard.zones-enabled .v-key[data-finger="lr"] { border-bottom: 3px solid var(--zone-lr); background: #fff7ed; }
.v-keyboard.zones-enabled .v-key[data-finger="lm"] { border-bottom: 3px solid var(--zone-lm); background: #fefce8; }
.v-keyboard.zones-enabled .v-key[data-finger="li"] { border-bottom: 3px solid var(--zone-li); background: #f0fdf4; }
.v-keyboard.zones-enabled .v-key[data-finger="rt"],
.v-keyboard.zones-enabled .v-key[data-finger="lt"] { border-bottom: 3px solid var(--zone-thumb); background: #f8fafc; }
.v-keyboard.zones-enabled .v-key[data-finger="ri"] { border-bottom: 3px solid var(--zone-ri); background: #ecfeff; }
.v-keyboard.zones-enabled .v-key[data-finger="rm"] { border-bottom: 3px solid var(--zone-rm); background: #eff6ff; }
.v-keyboard.zones-enabled .v-key[data-finger="rr"] { border-bottom: 3px solid var(--zone-rr); background: #f5f3ff; }
.v-keyboard.zones-enabled .v-key[data-finger="rp"] { border-bottom: 3px solid var(--zone-rp); background: #fdf2f8; }

/* Home Row Bump Indicators on F and J */
#key-f::after, #key-j::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 12px;
    height: 2px;
    border-radius: 2px;
    background: rgba(15, 23, 42, 0.35);
}

.v-key.key-active {
    background: #0284c7 !important;
    color: #ffffff !important;
    box-shadow: 0 0 22px rgba(56, 189, 248, 0.9), 0 2px 0 #0369a1 !important;
    transform: translateY(2px);
}
.v-key.shift-active {
    background: #2563eb !important;
    color: #ffffff !important;
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.85), 0 2px 0 #1d4ed8 !important;
    transform: translateY(2px);
}
.v-key.key-correct {
    background: #00c853 !important;
    color: #ffffff !important;
    box-shadow: 0 0 20px rgba(0, 200, 83, 0.8), 0 2px 0 #009624 !important;
    transform: translateY(2px);
}
.v-key.key-error {
    background: #ff1744 !important;
    color: #ffffff !important;
    box-shadow: 0 0 20px rgba(255, 23, 68, 0.8), 0 2px 0 #b71c1c !important;
    transform: translateY(2px);
    animation: tile-shake 0.3s ease-in-out;
}

/* Finger Hint Bar (which finger presses the highlighted key) */
.finger-hint-bar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 8px;
    padding: 0 4px;
}
.hand-group {
    display: flex;
    gap: 5px;
}
.finger-dot {
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 3px solid var(--fc, #64748b);
    transition: all 0.15s ease;
}
.finger-dot[data-finger="lp"] { --fc: var(--zone-lp); }
.finger-dot[data-finger="lr"] { --fc: var(--zone-lr); }
.finger-dot[data-finger="lm"] { --fc: var(--zone-lm); }
.finger-dot[data-finger="li"] { --fc: var(--zone-li); }
.finger-dot[data-finger="lt"],
.finger-dot[data-finger="rt"] { --fc: var(--zone-thumb); }
.finger-dot[data-finger="ri"] { --fc: var(--zone-ri); }
.finger-dot[data-finger="rm"] { --fc: var(--zone-rm); }
.finger-dot[data-finger="rr"] { --fc: var(--zone-rr); }
.finger-dot[data-finger="rp"] { --fc: var(--zone-rp); }
.finger-dot.active {
    background: var(--fc);
    color: #ffffff;
    border-color: var(--fc);
    box-shadow: 0 0 14px var(--fc);
    transform: translateY(-2px) scale(1.08);
}

.hint-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.game-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    max-width: min(96vw, 1320px);
    flex-shrink: 0;
    padding-top: 2px;
}

/* Buttons */
.btn {
    padding: 12px 26px;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-back {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}
.btn-more {
    background: linear-gradient(135deg, var(--accent-green-dark), var(--accent-green));
    color: white;
}
.btn-blue {
    background: linear-gradient(135deg, #2563eb, #0284c7);
    color: white;
}
.btn-orange {
    background: linear-gradient(135deg, #ea580c, #f59e0b);
    color: white;
}
.btn-danger {
    background: linear-gradient(135deg, #b91c1c, #dc2626);
    color: white;
}
.btn-reset-single {
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    background: rgba(255, 23, 68, 0.14);
    color: var(--accent-red);
    border: 1px solid rgba(255, 23, 68, 0.3);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}
.btn-reset-single:hover {
    background: rgba(255, 23, 68, 0.25);
}

/* ============ GAME OVER OVERLAY ============ */
#gameover-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(8px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px;
}
#gameover-overlay.active {
    display: flex;
}
.dance-container {
    width: min(75vw, 420px);
    height: min(42vh, 290px);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
}
/* Original "Keybo" celebration mascot (pure CSS) */
.mascot {
    position: relative;
    width: 180px;
    height: 200px;
    animation: mascotDance 0.55s ease-in-out infinite alternate;
}
@keyframes mascotDance {
    0% { transform: translateY(0) rotate(-6deg); }
    100% { transform: translateY(-18px) rotate(6deg); }
}
.mascot-body {
    position: absolute;
    left: 20px;
    top: 30px;
    width: 140px;
    height: 150px;
    border-radius: 26px;
    background: linear-gradient(160deg, #22c55e, #2563eb);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35), inset 0 -6px 0 rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 16px;
    gap: 12px;
}
.mascot-screen {
    position: relative;
    width: 104px;
    height: 64px;
    border-radius: 14px;
    background: #0f172a;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 26px;
    padding-top: 16px;
}
.mascot-eye {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 10px #4ade80;
    animation: mascotBlink 2.4s infinite;
}
@keyframes mascotBlink {
    0%, 92%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(0.1); }
}
.mascot-mouth {
    position: absolute;
    bottom: 10px;
    left: 50%;
    width: 30px;
    height: 14px;
    transform: translateX(-50%);
    border: 4px solid #4ade80;
    border-top: none;
    border-radius: 0 0 20px 20px;
}
.mascot-keys {
    display: flex;
    gap: 5px;
}
.mascot-keys i {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    background: #ffffff;
    box-shadow: 0 3px 0 #94a3b8;
    animation: mascotKey 0.6s infinite alternate;
}
.mascot-keys i:nth-child(2) { animation-delay: 0.1s; }
.mascot-keys i:nth-child(3) { animation-delay: 0.2s; }
.mascot-keys i:nth-child(4) { animation-delay: 0.3s; }
.mascot-keys i:nth-child(5) { animation-delay: 0.4s; }
@keyframes mascotKey {
    0% { transform: translateY(0); background: #ffffff; }
    100% { transform: translateY(3px); background: #fde047; }
}
.mascot-arm {
    position: absolute;
    top: 80px;
    width: 18px;
    height: 70px;
    border-radius: 10px;
    background: #2563eb;
    transform-origin: top center;
}
.mascot-arm.left { left: 8px; animation: armWaveL 0.55s ease-in-out infinite alternate; }
.mascot-arm.right { right: 8px; animation: armWaveR 0.55s ease-in-out infinite alternate; }
@keyframes armWaveL { 0% { transform: rotate(20deg); } 100% { transform: rotate(150deg); } }
@keyframes armWaveR { 0% { transform: rotate(-20deg); } 100% { transform: rotate(-150deg); } }
.mascot-notes span {
    position: absolute;
    top: 0;
    font-size: 1.6rem;
    color: #fde047;
    animation: noteFloat 1.6s linear infinite;
    opacity: 0;
}
.mascot-notes span:nth-child(1) { left: 0; }
.mascot-notes span:nth-child(2) { left: 80px; animation-delay: 0.5s; }
.mascot-notes span:nth-child(3) { right: 0; animation-delay: 1s; }
@keyframes noteFloat {
    0% { transform: translateY(20px); opacity: 0; }
    20% { opacity: 1; }
    100% { transform: translateY(-50px); opacity: 0; }
}
.celebration-border {
    position: absolute;
    inset: -6px;
    border: 5px solid;
    border-radius: 22px;
    animation: borderCycle 1.2s linear infinite;
    pointer-events: none;
}
@keyframes borderCycle {
    0% { border-color: var(--accent-red); }
    25% { border-color: var(--accent-green); }
    50% { border-color: var(--accent-yellow-bright); }
    75% { border-color: var(--accent-cyan); }
    100% { border-color: var(--accent-red); }
}

.stars-row {
    display: flex;
    gap: 14px;
    justify-content: center;
    align-items: center;
}
.star-icon {
    font-size: 3rem;
    filter: grayscale(100%) opacity(0.3);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: scale(0.85);
    user-select: none;
}
.star-icon.earned {
    filter: grayscale(0%) opacity(1) drop-shadow(0 0 16px rgba(255, 214, 0, 0.8));
    transform: scale(1.18);
}

.gameover-stats-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}
.gameover-stat-box {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 18px;
    border-radius: 14px;
    color: #ffffff;
    text-align: center;
}
.gameover-stat-box .val {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--accent-yellow-bright);
}
.gameover-stat-box .lbl {
    font-size: 0.78rem;
    color: #cbd5e1;
    text-transform: uppercase;
}
.gameover-msg {
    font-size: 1.4rem;
    font-weight: 800;
    background: var(--accent-yellow-bright);
    color: #0f172a;
    padding: 10px 28px;
    border-radius: var(--radius-sm);
}
.gameover-buttons {
    display: flex;
    gap: 14px;
}

/* ============ CUSTOMIZATION, BACKUPS & STATS SCREENS ============ */
#customize-screen, #backups-screen, #stats-screen {
    padding: 64px 32px 24px;
    overflow-y: auto;
}
.subscreen-panel {
    width: 100%;
    max-width: 960px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding-bottom: 40px;
}
.subscreen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 960px;
    margin-bottom: 12px;
}

/* Keyboard Accuracy Heatmap on Stats Screen */
.heatmap-card {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 18px 22px;
    box-shadow: var(--shadow-soft);
}
.heatmap-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    margin-top: 12px;
}
.heatmap-row {
    display: flex;
    gap: 6px;
}
.heatmap-key {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
}
.heatmap-key .hm-pct {
    font-size: 0.62rem;
    font-weight: 600;
    opacity: 0.85;
}
.heatmap-key.hm-good {
    background: #dcfce7;
    border-color: #22c55e;
    color: #14532d;
}
.heatmap-key.hm-warn {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #78350f;
}
.heatmap-key.hm-bad {
    background: #fee2e2;
    border-color: #ef4444;
    color: #7f1d1d;
}

/* Confetti & Toasts */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -10px;
    z-index: 250;
    animation: confettiFall 3s linear forwards;
}
@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

.toast-notification {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    color: var(--text-bright);
    padding: 12px 26px;
    border-radius: 999px;
    border: 2px solid var(--accent-green);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    font-size: 0.98rem;
    font-weight: 700;
    z-index: 9999;
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
    pointer-events: none;
}
.toast-notification.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.caps-warning-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #f59e0b;
    color: #0f172a;
    padding: 10px 22px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.95rem;
    display: none;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    z-index: 2000;
}

@media (max-height: 860px) {
    .keyboard-guide-container {
        transform: scale(0.86);
        transform-origin: bottom center;
        margin-top: -10px;
        margin-bottom: -12px;
    }
    .clipart-container {
        max-height: clamp(120px, 26vh, 260px);
    }
}

@media (max-width: 920px) {
    .menu-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .v-keyboard-chassis {
        width: 100%;
        overflow-x: auto;
    }
}
@media (max-width: 540px) {
    .menu-grid {
        grid-template-columns: 1fr;
    }
}
