/* ============================================================
   Affleck's Dunkin' Run - Dracut Nor'easter Edition
   Complete Stylesheet
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --dunkin-orange: #ff6b35;
    --dunkin-pink: #dd1367;
    --ice-blue: #00bfff;
    --boston-red: #bd3039;
    --jlo-pink: #ff69b4;
    --bg-dark: #1a1a2e;
    --bg-darker: #2d3436;
    --text-light: #ffffff;
    --text-muted: #aaaaaa;
    --overlay-bg: rgba(0, 0, 0, 0.92);
    --btn-radius: 8px;
    --transition-speed: 0.3s;
}

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

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

body {
    background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-darker) 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Courier New', Courier, monospace;
    color: var(--text-light);
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* --- Game Container --- */
#game-container {
    position: relative;
    border: 4px solid var(--dunkin-orange);
    border-radius: 8px;
    box-shadow:
        0 0 30px rgba(255, 107, 53, 0.5),
        0 0 60px rgba(255, 107, 53, 0.2);
    animation: containerGlow 4s ease-in-out infinite;
    overflow: hidden;
    max-width: 100vw;
}

#gameCanvas {
    display: block;
    background: #87ceeb;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* --- HUD Overlay --- */
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    pointer-events: none;
    z-index: 5;
}

.stat-box {
    background: rgba(0, 0, 0, 0.6);
    color: var(--dunkin-orange);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: bold;
    border: 1px solid rgba(255, 107, 53, 0.4);
    white-space: nowrap;
}

#score-box {
    position: absolute;
    top: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: var(--dunkin-orange);
    padding: 3px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    border: 1px solid rgba(255, 107, 53, 0.3);
    pointer-events: none;
    z-index: 5;
    white-space: nowrap;
}

#combo-display {
    position: absolute;
    top: 55px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    font-weight: bold;
    color: var(--ice-blue);
    text-shadow: 0 0 8px rgba(0, 191, 255, 0.8);
    pointer-events: none;
    z-index: 5;
    white-space: nowrap;
    transition: opacity 0.3s ease;
}

/* --- Screen Overlays (shared) --- */
#title-screen,
#level-screen,
#level2-intro,
#win-screen,
#lose-screen,
#pause-screen,
#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8px 20px;
    z-index: 100;
    overflow: hidden;
    transition: opacity 0.4s ease, transform 0.4s ease, visibility 0s;
}

#title-screen.hidden,
#level-screen.hidden,
#level2-intro.hidden,
#win-screen.hidden,
#lose-screen.hidden,
#pause-screen.hidden,
#loading-screen.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.4s ease, transform 0.4s ease, visibility 0s 0.4s;
}

/* --- Title Screen --- */
#title-screen h1 {
    color: var(--dunkin-orange);
    font-size: 38px;
    letter-spacing: 3px;
    text-shadow:
        0 0 10px var(--dunkin-orange),
        0 0 20px var(--dunkin-orange),
        0 0 40px var(--dunkin-pink);
    animation: titlePulse 3s ease-in-out infinite;
    margin-bottom: 6px;
}

#title-screen h2 {
    color: var(--dunkin-pink);
    font-size: 18px;
    font-weight: normal;
    letter-spacing: 2px;
    margin-bottom: 4px;
}

#title-screen .subtitle {
    color: var(--text-muted);
    max-width: 700px;
    line-height: 1.3;
    font-size: 13px;
    margin-bottom: 10px;
}

/* highlight classes */
.dunkin-logo {
    color: var(--dunkin-orange);
    font-weight: bold;
}

.coffee-order {
    color: var(--dunkin-pink);
    font-weight: bold;
}

.ice-gun {
    color: var(--ice-blue);
    font-weight: bold;
}

.jlo-pink {
    color: var(--jlo-pink);
    font-weight: bold;
}

/* controls info box */
.controls-info {
    background: rgba(255, 107, 53, 0.15);
    border: 1px solid rgba(255, 107, 53, 0.3);
    border-radius: 8px;
    padding: 6px 14px;
    margin-bottom: 10px;
    max-width: 650px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-muted);
}

.controls-info strong {
    color: var(--dunkin-orange);
    font-size: 15px;
}

/* difficulty selector */
.difficulty-select {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.diff-btn {
    background: rgba(255, 107, 53, 0.15);
    color: var(--dunkin-orange);
    border: 2px solid var(--dunkin-orange);
    border-radius: var(--btn-radius);
    padding: 7px 16px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.diff-btn:hover {
    background: rgba(255, 107, 53, 0.4);
    transform: scale(1.05);
}

.diff-btn:active {
    transform: scale(0.97);
}

.diff-btn.selected {
    background: var(--dunkin-orange);
    color: var(--text-light);
    box-shadow: 0 0 15px rgba(255, 107, 53, 0.5);
}

.diff-btn:focus-visible {
    outline: 2px solid var(--ice-blue);
    outline-offset: 2px;
}

/* section divider between difficulty and kehd toggle */
.section-divider {
    border: none;
    height: 1px;
    width: 50%;
    max-width: 240px;
    margin: 4px auto 6px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(0, 191, 255, 0.25) 30%,
        rgba(255, 107, 53, 0.25) 70%,
        transparent 100%
    );
}

/* kehd mode toggle - "secret mode" container */
.kehd-toggle {
    margin-bottom: 8px;
    text-align: center;
    border: 1px dashed rgba(0, 191, 255, 0.25);
    border-radius: 10px;
    padding: 6px 14px;
    background:
        linear-gradient(135deg, rgba(0, 191, 255, 0.03) 0%, transparent 50%, rgba(0, 191, 255, 0.02) 100%);
    transition: all 0.4s ease;
    position: relative;
}

.kehd-toggle.active {
    border-color: rgba(255, 102, 0, 0.45);
    background:
        linear-gradient(135deg, rgba(255, 102, 0, 0.05) 0%, transparent 50%, rgba(255, 102, 0, 0.03) 100%);
    box-shadow: 0 0 20px rgba(255, 102, 0, 0.06);
}

.kehd-btn {
    background: rgba(255, 102, 0, 0.12);
    color: #FF6600;
    border: 2px solid #FF6600;
    border-radius: var(--btn-radius);
    padding: 7px 18px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.kehd-btn:hover {
    background: rgba(255, 102, 0, 0.3);
    transform: scale(1.05);
}

.kehd-btn:active {
    transform: scale(0.97);
}

.kehd-btn.active {
    background: linear-gradient(135deg, #FF6600 0%, #e85d00 60%, #ff7b1a 100%);
    color: var(--text-light);
    border-color: #ff8533;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow:
        0 0 12px rgba(255, 102, 0, 0.5),
        0 0 28px rgba(255, 102, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    animation: kehdGlow 2s ease-in-out infinite;
}

.kehd-btn:focus-visible {
    outline: 2px solid var(--ice-blue);
    outline-offset: 2px;
}

/* baby emoji icon in kehd button */
.kehd-icon {
    display: inline-block;
    font-style: normal;
    transition: transform 0.3s ease;
}

.kehd-btn:hover .kehd-icon {
    transform: scale(1.15);
}

.kehd-btn.active .kehd-icon {
    animation: kehdBounce 1.2s ease-in-out infinite;
}

.kehd-desc {
    color: #ffffff;
    font-size: 11px;
    font-style: italic;
    font-weight: bold;
    margin-top: 4px;
    opacity: 1.0;
    transition: opacity 0.4s ease, color 0.4s ease, text-shadow 0.4s ease;
}

.kehd-desc.active {
    opacity: 1.0;
    color: var(--ice-blue);
    text-shadow: 0 0 8px rgba(0, 191, 255, 0.25);
}

@keyframes kehdGlow {
    0%, 100% {
        box-shadow:
            0 0 12px rgba(255, 102, 0, 0.5),
            0 0 28px rgba(255, 102, 0, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.15);
    }
    50% {
        box-shadow:
            0 0 18px rgba(255, 102, 0, 0.7),
            0 0 40px rgba(255, 102, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.15);
    }
}

@keyframes kehdBounce {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-2px) rotate(-4deg); }
    50% { transform: translateY(-3px) rotate(0deg); }
    75% { transform: translateY(-2px) rotate(4deg); }
}

/* CRT scanline overlay on title screen */
#title-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 1px,
            rgba(0, 0, 0, 0.2) 1px,
            rgba(0, 0, 0, 0.2) 3px
        );
    opacity: 0.035;
    z-index: 101;
}

/* dedication */
.dedication {
    color: var(--text-muted);
    font-size: 15px;
    font-style: italic;
    margin-top: 4px;
    margin-bottom: 10px;
    opacity: 0.7;
    letter-spacing: 0.5px;
}

/* start / action buttons */
.start-btn {
    background: var(--dunkin-orange);
    color: var(--text-light);
    border: none;
    border-radius: var(--btn-radius);
    padding: 10px 24px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
    margin-top: 6px;
}

.start-btn:hover {
    background: var(--dunkin-pink);
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(221, 19, 103, 0.5);
}

.start-btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.start-btn:focus-visible {
    outline: 2px solid var(--ice-blue);
    outline-offset: 2px;
}

/* "press any key" blink text — used in JS if needed */
.press-start {
    animation: pressStart 1.5s ease-in-out infinite;
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 12px;
}

/* --- Loading Screen --- */
#loading-screen {
    gap: 16px;
}

.loading-cup {
    width: 60px;
    height: 80px;
    border: 4px solid var(--dunkin-orange);
    border-top: none;
    border-radius: 0 0 12px 12px;
    position: relative;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
}

.loading-cup::after {
    content: '';
    position: absolute;
    right: -18px;
    top: 14px;
    width: 14px;
    height: 24px;
    border: 3px solid var(--dunkin-orange);
    border-left: none;
    border-radius: 0 8px 8px 0;
}

.loading-liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, #8B4513, #5C2E0E);
    animation: fillCup 3s ease-in-out infinite;
}

.loading-text {
    color: var(--dunkin-orange);
    font-size: 14px;
    animation: pressStart 1.5s ease-in-out infinite;
}

.loading-progress {
    width: 200px;
    height: 6px;
    background: rgba(255, 107, 53, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    background: var(--dunkin-orange);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

/* --- Level Complete Screen --- */
#level-screen h1 {
    color: var(--dunkin-orange);
    font-size: 26px;
    letter-spacing: 2px;
    text-shadow: 0 0 15px rgba(255, 107, 53, 0.6);
    margin-bottom: 10px;
    animation: titlePulse 2s ease-in-out 1;
}

.level-emoji {
    font-size: 48px;
    margin: 8px 0;
    animation: floatUp 2s ease-in-out infinite alternate;
}

.level-message {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 8px;
}

.quote {
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
    max-width: 380px;
    line-height: 1.5;
    margin-bottom: 14px;
}

.final-stats {
    background: rgba(255, 107, 53, 0.15);
    border: 1px solid rgba(255, 107, 53, 0.3);
    border-radius: 6px;
    padding: 10px 20px;
    color: var(--dunkin-orange);
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 16px;
    letter-spacing: 0.5px;
}

/* --- Level 2 Intro --- */
#level2-intro h1 {
    color: var(--jlo-pink);
    font-size: 24px;
    letter-spacing: 2px;
    text-shadow:
        0 0 10px var(--jlo-pink),
        0 0 25px var(--dunkin-pink);
    margin-bottom: 6px;
}

#level2-intro h2 {
    color: var(--dunkin-pink);
    font-size: 16px;
    font-weight: normal;
    margin-bottom: 14px;
}

#level2-intro .subtitle {
    color: var(--text-muted);
    max-width: 420px;
    line-height: 1.6;
    font-size: 13px;
    margin-bottom: 14px;
}

/* --- Win Screen --- */
#win-screen h1 {
    color: var(--jlo-pink);
    font-size: 28px;
    letter-spacing: 3px;
    text-shadow:
        0 0 10px var(--jlo-pink),
        0 0 25px var(--dunkin-pink),
        0 0 50px rgba(255, 105, 180, 0.3);
    animation: rainbowText 6s linear infinite;
    margin-bottom: 8px;
}

.coffee-emoji {
    font-size: 48px;
    margin: 6px 0;
}

.win-message {
    color: var(--text-light);
    font-size: 15px;
    margin-bottom: 8px;
}

.rank-display {
    font-size: 20px;
    font-weight: bold;
    color: var(--dunkin-orange);
    text-shadow: 0 0 10px rgba(255, 107, 53, 0.5);
    margin-bottom: 12px;
}

/* floating hearts background for win */
#win-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image:
        radial-gradient(circle, var(--jlo-pink) 1px, transparent 1px),
        radial-gradient(circle, var(--dunkin-pink) 1px, transparent 1px);
    background-size: 60px 60px, 80px 80px;
    background-position: 0 0, 30px 30px;
    opacity: 0.06;
    z-index: -1;
}

/* --- Lose Screen --- */
#lose-screen h1 {
    color: var(--dunkin-pink);
    font-size: 28px;
    letter-spacing: 3px;
    text-shadow: 0 0 15px rgba(221, 19, 103, 0.6);
    margin-bottom: 8px;
    animation: shakeIt 0.5s ease-in-out 1;
}

.sad-emoji {
    font-size: 48px;
    margin: 8px 0;
}

.lose-reason {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 8px;
    max-width: 380px;
    line-height: 1.5;
}

#lose-screen .start-btn {
    background: var(--dunkin-pink);
}

#lose-screen .start-btn:hover {
    background: var(--dunkin-orange);
}

/* --- Pause Screen --- */
#pause-screen {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

#pause-screen h1 {
    color: var(--text-light);
    font-size: 36px;
    letter-spacing: 6px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    margin-bottom: 12px;
}

#pause-screen .subtitle {
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
    max-width: 360px;
    line-height: 1.5;
    margin-bottom: 20px;
}

#pause-screen .start-btn {
    margin-bottom: 8px;
}

/* --- Mobile Controls --- */
#mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 12px 16px;
    pointer-events: none;
    z-index: 1000;
}

#mobile-controls.hidden {
    display: none;
}

/* D-pad */
.dpad {
    display: grid;
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 50px);
    gap: 4px;
    pointer-events: auto;
}

.dpad-empty {
    /* empty cells in the grid */
}

.mobile-btn {
    background: rgba(255, 107, 53, 0.5);
    color: var(--text-light);
    border: 2px solid rgba(255, 107, 53, 0.7);
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    font-family: 'Courier New', Courier, monospace;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    transition: background 0.1s ease, transform 0.1s ease;
    pointer-events: auto;
}

.mobile-btn:active {
    background: var(--dunkin-pink);
    transform: scale(0.93);
}

/* Action buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: auto;
}

.fire-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(0, 191, 255, 0.5);
    border-color: rgba(0, 191, 255, 0.7);
    font-size: 16px;
    letter-spacing: 1px;
    text-shadow: 0 0 6px rgba(0, 191, 255, 0.8);
    box-shadow: 0 0 15px rgba(0, 191, 255, 0.3);
}

.fire-btn:active {
    background: rgba(0, 191, 255, 0.8);
    box-shadow: 0 0 25px rgba(0, 191, 255, 0.6);
    transform: scale(0.93);
}

.sprint-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255, 107, 53, 0.5);
    border-color: rgba(255, 107, 53, 0.7);
    font-size: 11px;
    letter-spacing: 1px;
    box-shadow: 0 0 10px rgba(255, 107, 53, 0.3);
}

.sprint-btn:active {
    background: rgba(255, 107, 53, 0.8);
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.5);
    transform: scale(0.93);
}

/* ============================================================
   Keyframe Animations
   ============================================================ */

@keyframes containerGlow {
    0%, 100% {
        box-shadow:
            0 0 30px rgba(255, 107, 53, 0.5),
            0 0 60px rgba(255, 107, 53, 0.2);
    }
    50% {
        box-shadow:
            0 0 50px rgba(255, 107, 53, 0.8),
            0 0 80px rgba(221, 19, 103, 0.3);
    }
}

@keyframes titlePulse {
    0%, 100% {
        transform: scale(1);
        text-shadow:
            0 0 10px var(--dunkin-orange),
            0 0 20px var(--dunkin-orange);
    }
    50% {
        transform: scale(1.02);
        text-shadow:
            0 0 20px var(--dunkin-orange),
            0 0 40px var(--dunkin-pink);
    }
}

@keyframes pressStart {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

@keyframes fillCup {
    0% { height: 0%; }
    80% { height: 100%; }
    100% { height: 100%; }
}

@keyframes floatUp {
    from { transform: translateY(0); }
    to { transform: translateY(-8px); }
}

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

@keyframes rainbowText {
    0%   { color: #ff6b35; }
    17%  { color: #ff69b4; }
    33%  { color: #dd1367; }
    50%  { color: #ff69b4; }
    67%  { color: #ff6b35; }
    83%  { color: #dd1367; }
    100% { color: #ff6b35; }
}

@keyframes heartFloat {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) scale(0.5);
        opacity: 0;
    }
}

/* ============================================================
   Responsive Design
   ============================================================ */

/* Desktop: hide mobile controls */
@media (min-width: 851px) {
    #mobile-controls {
        display: none !important;
    }
}

/* Tablet & Mobile */
@media (max-width: 850px) {
    body {
        justify-content: flex-start;
    }

    #game-container {
        border: none;
        border-radius: 0;
        box-shadow: none;
        animation: none;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
    }

    #gameCanvas {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        object-fit: contain;
    }

    /* Overlays fill the full viewport on mobile */
    #title-screen,
    #level-screen,
    #level2-intro,
    #win-screen,
    #lose-screen,
    #pause-screen {
        padding: 8px 16px;
    }

    /* Scale overlay text */
    #title-screen h1 {
        font-size: 22px;
        letter-spacing: 2px;
    }

    #title-screen h2 {
        font-size: 13px;
        margin-bottom: 2px;
    }

    #title-screen .subtitle {
        font-size: 11px;
        max-width: 90vw;
        margin-bottom: 6px;
        line-height: 1.3;
    }

    .controls-info {
        font-size: 10px;
        padding: 4px 10px;
        max-width: 90vw;
        line-height: 1.4;
        margin-bottom: 4px;
    }

    .difficulty-select {
        margin-bottom: 4px;
    }

    .diff-btn {
        padding: 6px 12px;
        font-size: 11px;
    }

    .kehd-toggle {
        padding: 4px 10px;
        margin-bottom: 4px;
    }

    .kehd-btn {
        padding: 6px 14px;
        font-size: 11px;
    }

    .kehd-desc {
        margin-top: 2px;
        font-size: 10px;
    }

    .section-divider {
        margin: 2px auto 4px;
    }

    .dedication {
        font-size: 10px;
        margin-top: 0;
        margin-bottom: 4px;
    }

    .start-btn {
        padding: 10px 20px;
        font-size: 13px;
        margin-top: 2px;
    }

    .final-stats {
        font-size: 12px;
        padding: 8px 14px;
    }

    .quote {
        font-size: 12px;
        max-width: 85vw;
    }

    #level-screen h1,
    #level2-intro h1,
    #win-screen h1,
    #lose-screen h1 {
        font-size: 22px;
    }

    #pause-screen h1 {
        font-size: 28px;
    }

    .level-emoji,
    .coffee-emoji,
    .sad-emoji {
        font-size: 36px;
    }

    .stat-box {
        font-size: 11px;
        padding: 3px 6px;
    }

    #score-box {
        font-size: 10px;
        top: 26px;
    }

    #combo-display {
        font-size: 14px;
        top: 44px;
    }

    /* Mobile controls overlay on top of canvas */
    #mobile-controls {
        position: fixed;
        bottom: 10px;
    }
}

/* Extra small screens */
@media (max-width: 450px) {
    #title-screen h1 {
        font-size: 18px;
        letter-spacing: 1px;
    }

    #title-screen h2 {
        font-size: 11px;
    }

    #title-screen .subtitle {
        font-size: 10px;
    }

    .difficulty-select {
        gap: 6px;
    }

    .diff-btn {
        padding: 5px 10px;
        font-size: 10px;
    }

    .kehd-toggle {
        padding: 4px 8px;
    }

    .kehd-btn {
        padding: 5px 10px;
        font-size: 10px;
    }

    .start-btn {
        padding: 8px 16px;
        font-size: 11px;
        letter-spacing: 1px;
    }

    .dpad {
        grid-template-columns: repeat(3, 42px);
        grid-template-rows: repeat(3, 42px);
        gap: 3px;
    }

    .fire-btn {
        width: 68px;
        height: 68px;
        font-size: 14px;
    }

    .sprint-btn {
        width: 58px;
        height: 58px;
        font-size: 10px;
    }

    #level-screen h1,
    #level2-intro h1,
    #win-screen h1,
    #lose-screen h1 {
        font-size: 18px;
    }

    #pause-screen h1 {
        font-size: 24px;
    }

    .level-emoji,
    .coffee-emoji,
    .sad-emoji {
        font-size: 30px;
    }
}

/* Landscape mobile - extra compact */
@media (max-width: 850px) and (max-height: 500px) {
    #title-screen h1 {
        font-size: 18px;
        margin-bottom: 1px;
    }

    #title-screen h2 {
        font-size: 11px;
        margin-bottom: 1px;
    }

    #title-screen .subtitle {
        font-size: 9px;
        margin-bottom: 3px;
        line-height: 1.2;
    }

    .controls-info {
        font-size: 9px;
        padding: 2px 8px;
        margin-bottom: 2px;
    }

    .difficulty-select {
        margin-bottom: 2px;
    }

    .diff-btn {
        padding: 4px 10px;
        font-size: 10px;
    }

    .kehd-toggle {
        padding: 3px 8px;
        margin-bottom: 2px;
    }

    .kehd-btn {
        padding: 4px 10px;
        font-size: 10px;
    }

    .kehd-desc {
        font-size: 9px;
    }

    .start-btn {
        padding: 6px 14px;
        font-size: 11px;
    }

    .dedication {
        font-size: 9px;
    }
}

/* ============================================================
   Accessibility
   ============================================================ */

/* Focus indicators */
:focus-visible {
    outline: 2px solid var(--ice-blue);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Ensure minimum touch target size */
button {
    min-width: 44px;
    min-height: 44px;
}

/* ============================================================
   Utility Classes
   ============================================================ */

.hidden {
    display: none !important;
}

/* Screen overlay transitions (JS can toggle these) */
.screen-fade-in {
    animation: screenIn 0.4s ease forwards;
}

@keyframes screenIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
