* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #010204;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
}

/* Menu Screens */
.menu-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, rgba(10,15,25,0.97) 0%, rgba(2,3,8,0.99) 100%);
    z-index: 100;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
}

.menu-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.menu-screen h1 {
    color: rgba(255,120,80,0.95);
    font-size: 2.5rem;
    font-weight: 200;
    letter-spacing: 8px;
    text-transform: uppercase;
    margin-bottom: 10px;
    text-shadow: 0 0 60px rgba(255,80,50,0.6), 0 0 120px rgba(255,60,40,0.3);
}

.menu-screen h2 {
    color: rgba(255,140,100,0.9);
    font-size: 1.8rem;
    font-weight: 200;
    letter-spacing: 5px;
    text-transform: uppercase;
    margin-bottom: 30px;
    text-shadow: 0 0 40px rgba(255,80,50,0.4);
}

.subtitle {
    color: rgba(255,180,150,0.4);
    font-size: 0.85rem;
    font-weight: 300;
    letter-spacing: 3px;
    margin-bottom: 50px;
}

/* Menu Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.menu-btn {
    background: radial-gradient(circle, rgba(255,80,50,0.25) 0%, rgba(255,50,80,0.1) 100%);
    border: 1px solid rgba(255,100,70,0.35);
    color: rgba(255,200,180,0.9);
    padding: 14px 45px;
    font-size: 0.85rem;
    font-weight: 300;
    letter-spacing: 3px;
    text-transform: uppercase;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(255,80,50,0.15);
    min-width: 200px;
}

.menu-btn:hover, .menu-btn:active {
    background: radial-gradient(circle, rgba(255,100,60,0.5) 0%, rgba(255,60,90,0.3) 100%);
    border-color: rgba(255,150,100,0.6);
    transform: scale(1.03);
    box-shadow: 0 0 40px rgba(255,80,50,0.4);
}

.menu-btn.primary {
    background: radial-gradient(circle, rgba(255,100,60,0.5) 0%, rgba(255,60,90,0.25) 100%);
    border-color: rgba(255,120,80,0.6);
    box-shadow: 0 0 35px rgba(255,80,50,0.3);
}

.menu-btn.primary:hover, .menu-btn.primary:active {
    background: radial-gradient(circle, rgba(255,120,70,0.7) 0%, rgba(255,80,100,0.4) 100%);
    box-shadow: 0 0 50px rgba(255,80,50,0.6);
}

.back-btn {
    margin-top: 30px;
    padding: 10px 30px;
    font-size: 0.75rem;
    min-width: 120px;
}

/* Game UI */
#game-ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 20px;
    padding-top: calc(15px + env(safe-area-inset-top, 0px));
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 10;
}

#game-ui.hidden {
    display: none;
}

#size-indicator {
    background: radial-gradient(circle, rgba(255,120,100,0.3) 0%, rgba(255,80,80,0.1) 100%);
    border: 1px solid rgba(255,150,130,0.3);
    border-radius: 50px;
    padding: 8px 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#size-value {
    color: rgba(255,200,180,0.9);
    font-size: 14px;
    font-weight: 300;
    letter-spacing: 2px;
}

#level-info {
    text-align: center;
    flex: 1;
    padding: 0 20px;
}

#level-name {
    display: block;
    color: rgba(255,180,150,0.7);
    font-size: 12px;
    font-weight: 300;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

#level-objective {
    display: block;
    color: rgba(255,150,120,0.5);
    font-size: 11px;
    font-weight: 300;
    letter-spacing: 1px;
}

#pause-btn {
    background: rgba(255,100,70,0.2);
    border: 1px solid rgba(255,120,90,0.3);
    color: rgba(255,200,180,0.8);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#pause-btn:hover, #pause-btn:active {
    background: rgba(255,100,70,0.4);
    border-color: rgba(255,150,100,0.5);
}

/* Island Progress Bar - wraps around Dynamic Island on iPhone */
#island-progress {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 11;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#island-progress.active {
    opacity: 1;
}

/* The pill container that positions around Dynamic Island */
.island-pill {
    position: relative;
    width: 162px;  /* Wider than Dynamic Island */
    height: 54px;  /* Taller than Dynamic Island */
    margin-top: 5px; /* Position to frame the Dynamic Island */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* SVG-based progress ring that wraps around the pill shape */
.island-ring-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.island-ring-bg {
    fill: none;
    stroke: rgba(255, 120, 80, 0.15);
    stroke-width: 4;
}

.island-ring-progress {
    fill: none;
    stroke: rgba(255, 120, 80, 0.9);
    stroke-width: 4;
    stroke-linecap: round;
    /* Total perimeter of the rounded rectangle path */
    stroke-dasharray: 340;
    stroke-dashoffset: 340;
    transition: stroke-dashoffset 0.3s ease;
    filter: drop-shadow(0 0 6px rgba(255, 100, 60, 0.6));
}

.island-ring-progress.glow {
    stroke: rgba(255, 140, 100, 1);
    filter: drop-shadow(0 0 10px rgba(255, 100, 60, 0.8))
            drop-shadow(0 0 20px rgba(255, 80, 50, 0.5));
}

/* Progress percentage text below the pill */
.island-text {
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 180, 150, 0.9);
    font-size: 11px;
    font-weight: 300;
    letter-spacing: 1px;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Hide island progress on non-notched devices */
@supports not (padding-top: env(safe-area-inset-top)) {
    #island-progress {
        display: none !important;
    }
}

/* iPhone 14 Pro / 15 Pro / 15 Pro Max (Dynamic Island devices) */
@media (min-width: 390px) and (max-width: 435px) {
    .island-pill {
        width: 162px;
        height: 54px;
        margin-top: 5px;
    }
}

/* Smaller notch devices (iPhone X, XS, 11 Pro, 12 mini, 13 mini) - hide island UI */
@media (max-width: 375px) {
    #island-progress {
        display: none !important;
    }
}

/* Light theme island progress */
body.light-theme .island-ring-bg {
    stroke: rgba(100, 80, 150, 0.15);
}

body.light-theme .island-ring-progress {
    stroke: rgba(100, 80, 150, 0.9);
    filter: drop-shadow(0 0 6px rgba(100, 80, 150, 0.6));
}

body.light-theme .island-ring-progress.glow {
    stroke: rgba(120, 100, 180, 1);
    filter: drop-shadow(0 0 10px rgba(100, 80, 150, 0.8))
            drop-shadow(0 0 20px rgba(80, 60, 130, 0.5));
}

body.light-theme .island-text {
    color: rgba(60, 50, 90, 0.9);
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.8);
}

/* Level Select Grid */
#level-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
    width: 100%;
    max-width: 500px;
}

.zone-header {
    color: rgba(255,150,120,0.6);
    font-size: 0.7rem;
    font-weight: 300;
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-top: 10px;
    padding-left: 5px;
}

.zone-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.level-btn {
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(255,100,70,0.2) 0%, rgba(255,60,90,0.08) 100%);
    border: 1px solid rgba(255,120,90,0.3);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    position: relative;
}

.level-btn:hover:not(.locked) {
    background: radial-gradient(circle, rgba(255,120,80,0.4) 0%, rgba(255,70,100,0.2) 100%);
    border-color: rgba(255,150,100,0.5);
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(255,80,50,0.3);
}

.level-btn.locked {
    background: rgba(30,30,40,0.5);
    border-color: rgba(80,80,100,0.2);
    cursor: not-allowed;
}

.level-btn.completed {
    border-color: rgba(100,255,150,0.4);
    background: radial-gradient(circle, rgba(100,200,150,0.15) 0%, rgba(50,150,100,0.05) 100%);
}

.level-num {
    color: rgba(255,200,180,0.9);
    font-size: 1.2rem;
    font-weight: 200;
}

.level-title {
    color: rgba(255,180,150,0.6);
    font-size: 0.55rem;
    letter-spacing: 1px;
    text-align: center;
    margin-top: 4px;
    text-transform: uppercase;
}

.lock-icon {
    font-size: 0.8rem;
    margin-top: 4px;
    opacity: 0.5;
}

.check-icon {
    position: absolute;
    top: 5px;
    right: 5px;
    color: rgba(100,255,150,0.8);
    font-size: 0.7rem;
}

/* How to Play */
.instructions {
    display: flex;
    flex-direction: column;
    gap: 25px;
    max-width: 350px;
    margin-bottom: 30px;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 15px;
}

.instruction-icon {
    font-size: 1.5rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,100,70,0.15);
    border-radius: 50%;
    flex-shrink: 0;
}

.instruction-item p {
    color: rgba(255,180,150,0.7);
    font-size: 0.85rem;
    font-weight: 300;
    line-height: 1.5;
}

/* Game Over */
.game-over-text {
    color: rgba(255,150,120,0.6);
    font-size: 0.9rem;
    font-weight: 300;
    margin-bottom: 40px;
    text-align: center;
}

#complete-stats {
    color: rgba(255,180,150,0.7);
    font-size: 1rem;
    font-weight: 300;
    line-height: 1.8;
    margin-bottom: 40px;
    text-align: center;
}

/* Scrollbar styling */
#level-grid::-webkit-scrollbar {
    width: 4px;
}

#level-grid::-webkit-scrollbar-track {
    background: rgba(255,100,70,0.1);
    border-radius: 2px;
}

#level-grid::-webkit-scrollbar-thumb {
    background: rgba(255,100,70,0.3);
    border-radius: 2px;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .menu-screen h1 {
        font-size: 1.8rem;
        letter-spacing: 5px;
    }

    .menu-screen h2 {
        font-size: 1.3rem;
        letter-spacing: 3px;
    }

    .subtitle {
        font-size: 0.75rem;
        padding: 0 20px;
        text-align: center;
    }

    .menu-btn {
        padding: 12px 35px;
        font-size: 0.75rem;
        min-width: 180px;
    }

    .level-btn {
        width: 65px;
        height: 65px;
    }

    .level-num {
        font-size: 1rem;
    }

    .level-title {
        font-size: 0.5rem;
    }

    .instructions {
        padding: 0 10px;
    }

    .instruction-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .instruction-item p {
        font-size: 0.8rem;
    }

    #level-name {
        font-size: 10px;
    }

    #level-objective {
        font-size: 9px;
    }
}

/* Light Theme */
body.light-theme {
    background: #f0f5fa;
}

body.light-theme .menu-screen {
    background: radial-gradient(ellipse at center, rgba(240,245,250,0.97) 0%, rgba(200,215,230,0.99) 100%);
}

body.light-theme .menu-screen h1 {
    color: rgba(80, 60, 120, 0.95);
    text-shadow: 0 0 60px rgba(100, 80, 150, 0.4), 0 0 120px rgba(80, 60, 130, 0.2);
}

body.light-theme .menu-screen h2 {
    color: rgba(80, 70, 120, 0.9);
    text-shadow: 0 0 40px rgba(100, 80, 150, 0.3);
}

body.light-theme .subtitle {
    color: rgba(60, 50, 90, 0.5);
}

body.light-theme .menu-btn {
    background: radial-gradient(circle, rgba(80, 60, 120, 0.2) 0%, rgba(100, 80, 150, 0.1) 100%);
    border: 1px solid rgba(80, 60, 120, 0.35);
    color: rgba(40, 50, 80, 0.9);
    box-shadow: 0 0 20px rgba(100, 80, 150, 0.15);
}

body.light-theme .menu-btn:hover,
body.light-theme .menu-btn:active {
    background: radial-gradient(circle, rgba(100, 80, 150, 0.4) 0%, rgba(80, 60, 120, 0.25) 100%);
    border-color: rgba(120, 100, 170, 0.5);
    box-shadow: 0 0 40px rgba(100, 80, 150, 0.3);
}

body.light-theme .menu-btn.primary {
    background: radial-gradient(circle, rgba(100, 80, 150, 0.35) 0%, rgba(80, 60, 120, 0.2) 100%);
    border-color: rgba(100, 80, 150, 0.5);
    box-shadow: 0 0 35px rgba(100, 80, 150, 0.25);
}

body.light-theme .menu-btn.primary:hover,
body.light-theme .menu-btn.primary:active {
    background: radial-gradient(circle, rgba(120, 100, 170, 0.5) 0%, rgba(100, 80, 150, 0.3) 100%);
    box-shadow: 0 0 50px rgba(100, 80, 150, 0.4);
}

body.light-theme #size-indicator {
    background: radial-gradient(circle, rgba(80, 60, 120, 0.2) 0%, rgba(100, 80, 150, 0.1) 100%);
    border: 1px solid rgba(80, 60, 120, 0.3);
}

body.light-theme #size-value {
    color: rgba(40, 50, 80, 0.9);
}

body.light-theme #level-name {
    color: rgba(60, 50, 90, 0.7);
}

body.light-theme #level-objective {
    color: rgba(80, 70, 110, 0.5);
}

body.light-theme #pause-btn {
    background: rgba(80, 60, 120, 0.2);
    border: 1px solid rgba(80, 60, 120, 0.3);
    color: rgba(40, 50, 80, 0.8);
}

body.light-theme #pause-btn:hover,
body.light-theme #pause-btn:active {
    background: rgba(80, 60, 120, 0.35);
    border-color: rgba(100, 80, 150, 0.4);
}

body.light-theme .zone-header {
    color: rgba(80, 70, 120, 0.6);
}

body.light-theme .level-btn {
    background: radial-gradient(circle, rgba(80, 60, 120, 0.15) 0%, rgba(100, 80, 150, 0.08) 100%);
    border: 1px solid rgba(80, 60, 120, 0.25);
}

body.light-theme .level-btn:hover:not(.locked) {
    background: radial-gradient(circle, rgba(100, 80, 150, 0.3) 0%, rgba(80, 60, 120, 0.15) 100%);
    border-color: rgba(120, 100, 170, 0.4);
    box-shadow: 0 0 25px rgba(100, 80, 150, 0.25);
}

body.light-theme .level-btn.locked {
    background: rgba(180, 185, 195, 0.4);
    border-color: rgba(150, 155, 170, 0.3);
}

body.light-theme .level-btn.completed {
    border-color: rgba(60, 150, 100, 0.5);
    background: radial-gradient(circle, rgba(60, 150, 100, 0.15) 0%, rgba(40, 130, 80, 0.08) 100%);
}

body.light-theme .level-num {
    color: rgba(40, 50, 80, 0.9);
}

body.light-theme .level-title {
    color: rgba(60, 50, 90, 0.6);
}

body.light-theme .check-icon {
    color: rgba(60, 150, 100, 0.9);
}

body.light-theme .instruction-icon {
    background: rgba(80, 60, 120, 0.15);
}

body.light-theme .instruction-item p {
    color: rgba(60, 50, 90, 0.7);
}

body.light-theme .game-over-text {
    color: rgba(80, 70, 120, 0.6);
}

body.light-theme #complete-stats {
    color: rgba(60, 50, 90, 0.7);
}

body.light-theme #level-grid::-webkit-scrollbar-track {
    background: rgba(80, 60, 120, 0.1);
}

body.light-theme #level-grid::-webkit-scrollbar-thumb {
    background: rgba(80, 60, 120, 0.3);
}

/* Install Banner */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(20, 15, 30, 0.98) 0%, rgba(10, 8, 18, 0.99) 100%);
    border-top: 1px solid rgba(255, 120, 80, 0.3);
    padding: 16px 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transform: translateY(100%);
    transition: transform 0.4s ease;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.install-banner.show {
    transform: translateY(0);
}

.install-banner.hidden {
    display: none;
}

.install-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.install-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(255, 100, 70, 0.3) 0%, rgba(255, 60, 90, 0.15) 100%);
    border-radius: 12px;
    flex-shrink: 0;
}

.install-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.install-text strong {
    color: rgba(255, 200, 180, 0.95);
    font-size: 1rem;
    font-weight: 500;
}

.install-text span {
    color: rgba(255, 180, 150, 0.6);
    font-size: 0.85rem;
    font-weight: 300;
}

.install-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.install-btn-action {
    flex: 1;
    padding: 12px 24px !important;
    min-width: auto !important;
}

.install-dismiss {
    background: transparent;
    border: none;
    color: rgba(255, 180, 150, 0.5);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 12px;
    transition: color 0.2s ease;
}

.install-dismiss:hover {
    color: rgba(255, 180, 150, 0.8);
}

/* Light theme install banner */
body.light-theme .install-banner {
    background: linear-gradient(180deg, rgba(240, 245, 250, 0.98) 0%, rgba(220, 230, 240, 0.99) 100%);
    border-top: 1px solid rgba(80, 60, 120, 0.3);
}

body.light-theme .install-icon {
    background: radial-gradient(circle, rgba(80, 60, 120, 0.2) 0%, rgba(100, 80, 150, 0.1) 100%);
}

body.light-theme .install-text strong {
    color: rgba(40, 50, 80, 0.95);
}

body.light-theme .install-text span {
    color: rgba(60, 50, 90, 0.6);
}

body.light-theme .install-dismiss {
    color: rgba(60, 50, 90, 0.5);
}

body.light-theme .install-dismiss:hover {
    color: rgba(60, 50, 90, 0.8);
}

/* Safe area padding for notched devices */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .install-banner {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* Level Intro Screen */
.level-intro {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, rgba(10,15,25,0.95) 0%, rgba(2,3,8,0.98) 100%);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.4s ease;
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
}

.level-intro.show {
    opacity: 1;
}

.intro-content {
    max-width: 420px;
    text-align: center;
    transform: translateY(30px);
    transition: transform 0.4s ease;
}

.level-intro.show .intro-content {
    transform: translateY(0);
}

.intro-title {
    color: rgba(255,140,100,0.95);
    font-size: 1.6rem;
    font-weight: 300;
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-bottom: 25px;
    text-shadow: 0 0 50px rgba(255,100,60,0.5);
}

.intro-body {
    color: rgba(255,200,180,0.85);
    font-size: 1rem;
    font-weight: 300;
    line-height: 1.7;
    margin-bottom: 20px;
    padding: 0 15px;
}

.intro-tip {
    color: rgba(255,180,150,0.6);
    font-size: 0.85rem;
    font-weight: 300;
    line-height: 1.6;
    margin-bottom: 30px;
    padding: 15px 20px;
    background: rgba(255,100,70,0.08);
    border: 1px solid rgba(255,120,80,0.2);
    border-radius: 12px;
}

.intro-tip strong {
    color: rgba(255,150,100,0.9);
}

.intro-objective {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 35px;
    padding: 20px;
    background: radial-gradient(circle, rgba(255,120,80,0.15) 0%, rgba(255,80,100,0.05) 100%);
    border: 1px solid rgba(255,140,100,0.25);
    border-radius: 15px;
}

.objective-label {
    color: rgba(255,150,120,0.6);
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.objective-text {
    color: rgba(255,200,180,0.95);
    font-size: 1.15rem;
    font-weight: 300;
    letter-spacing: 1px;
}

.intro-start-btn {
    background: radial-gradient(circle, rgba(255,100,60,0.5) 0%, rgba(255,60,90,0.3) 100%);
    border: 1px solid rgba(255,130,90,0.5);
    color: rgba(255,220,200,0.95);
    padding: 16px 60px;
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 4px;
    text-transform: uppercase;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 40px rgba(255,80,50,0.35);
}

.intro-start-btn:hover,
.intro-start-btn:active {
    background: radial-gradient(circle, rgba(255,120,70,0.7) 0%, rgba(255,80,100,0.45) 100%);
    border-color: rgba(255,160,110,0.7);
    transform: scale(1.05);
    box-shadow: 0 0 60px rgba(255,80,50,0.55);
}

/* Light theme level intro */
body.light-theme .level-intro {
    background: radial-gradient(ellipse at center, rgba(240,245,250,0.95) 0%, rgba(200,215,230,0.98) 100%);
}

body.light-theme .intro-title {
    color: rgba(80, 60, 120, 0.95);
    text-shadow: 0 0 50px rgba(100, 80, 150, 0.4);
}

body.light-theme .intro-body {
    color: rgba(40, 50, 80, 0.85);
}

body.light-theme .intro-tip {
    color: rgba(60, 50, 90, 0.6);
    background: rgba(80, 60, 120, 0.08);
    border-color: rgba(80, 60, 120, 0.2);
}

body.light-theme .intro-tip strong {
    color: rgba(80, 60, 120, 0.9);
}

body.light-theme .intro-objective {
    background: radial-gradient(circle, rgba(80, 60, 120, 0.12) 0%, rgba(100, 80, 150, 0.05) 100%);
    border-color: rgba(80, 60, 120, 0.2);
}

body.light-theme .objective-label {
    color: rgba(80, 70, 120, 0.6);
}

body.light-theme .objective-text {
    color: rgba(40, 50, 80, 0.95);
}

body.light-theme .intro-start-btn {
    background: radial-gradient(circle, rgba(100, 80, 150, 0.4) 0%, rgba(80, 60, 120, 0.25) 100%);
    border-color: rgba(100, 80, 150, 0.5);
    color: rgba(40, 50, 80, 0.95);
    box-shadow: 0 0 40px rgba(100, 80, 150, 0.3);
}

body.light-theme .intro-start-btn:hover,
body.light-theme .intro-start-btn:active {
    background: radial-gradient(circle, rgba(120, 100, 170, 0.55) 0%, rgba(100, 80, 150, 0.35) 100%);
    border-color: rgba(120, 100, 170, 0.6);
    box-shadow: 0 0 60px rgba(100, 80, 150, 0.45);
}

/* Mobile responsive level intro */
@media (max-width: 480px) {
    .intro-title {
        font-size: 1.3rem;
        letter-spacing: 3px;
    }

    .intro-body {
        font-size: 0.9rem;
    }

    .intro-tip {
        font-size: 0.8rem;
        padding: 12px 15px;
    }

    .intro-objective {
        padding: 15px;
    }

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

    .intro-start-btn {
        padding: 14px 45px;
        font-size: 0.85rem;
    }
}

/* Coke.Games edition: a specimen under glass, quiet controls, readable objectives. */
:root { --abyss-ink: #07151c; --abyss-pearl: #e4f1ed; --abyss-rose: #f7a1ac; --abyss-mist: #8cdbcc; }
button, a { touch-action: manipulation; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--abyss-mist); outline-offset: 5px; }
[hidden] { display: none !important; }
.menu-screen { overflow-y: auto; touch-action: pan-y; transition: opacity .18s, visibility .18s; }
.menu-screen h2 { color: var(--abyss-pearl); font-family: 'Iowan Old Style', 'Palatino Linotype', Georgia, serif; font-size: clamp(1.8rem,4vw,3rem); letter-spacing: -.02em; text-transform: none; font-weight: 400; text-align: center; text-shadow: none; }
.menu-btn { min-height: 48px; font-weight: 500; font-size: .78rem; letter-spacing: .08em; border-radius: 6px; background: rgba(15,32,41,.75); border: 1px solid #42565d; color: var(--abyss-pearl); box-shadow: none; padding: 14px 26px; backdrop-filter: none; }
.menu-btn.primary { background: var(--abyss-rose); color: #261b25; border-color: var(--abyss-rose); box-shadow: none; }
.menu-btn:hover { background: #24434d; border-color: var(--abyss-mist); transform: translateY(-1px); box-shadow: none; }
.menu-btn.primary:hover { background: #ffbdc5; color: #261b25; }
.menu-buttons { gap: 12px; }
#main-menu { align-items: flex-start; padding-left: 9%; background: linear-gradient(90deg,rgba(7,21,28,.92),rgba(7,21,28,.68) 42%,rgba(7,21,28,.04) 67%) !important; }
#main-menu h1 { color: var(--abyss-pearl); font: 400 clamp(4rem,8.2vw,8.4rem)/.93 'Iowan Old Style', 'Palatino Linotype', Georgia, serif; letter-spacing: -.06em; text-transform: none; text-shadow: none; margin: 24px 0; }
#main-menu h1 em { font-weight: 400; color: var(--abyss-rose); }
.eyebrow { color: var(--abyss-mist); font: 500 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; letter-spacing: .18em; }
#main-menu .subtitle { color: #b4c5c8; font: 400 16px/1.7 'Helvetica Neue',Arial,sans-serif; letter-spacing: .01em; margin: 0 0 28px; }
#main-menu .menu-buttons { display: grid; grid-template-columns: 1fr 1fr; max-width: 370px; width: 100%; }
#main-menu .menu-btn { min-width: 0; padding: 14px 12px; letter-spacing: .04em; }
#main-menu #play-btn { grid-column: 1 / -1; font-size: 13px; min-height: 54px; }
.arcade-link { position: absolute; top: max(26px,env(safe-area-inset-top)); left: 9%; color: #b4c5c8; text-decoration: none; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.menu-settings { display: flex; gap: 24px; margin-top: 20px; }
.quiet-btn, .intro-back-btn { color: #b4c5c8; background: none; border: 0; cursor: pointer; min-height: 44px; font: 12px 'Helvetica Neue',Arial,sans-serif; padding: 8px 2px; }
.quiet-btn:hover, .intro-back-btn:hover { color: white; }
.journey-progress { color: #7e959e; font: 10px ui-monospace,monospace; letter-spacing: .06em; margin-top: 12px; }
.specimen-caption { position: absolute; top: 77%; left: 65%; color: #7e959e; font: italic 15px Georgia,serif; }
.specimen-caption i { display:block; width:70px; border-top:1px solid #57737a; margin-top:15px; }
#game-ui { pointer-events: none; }
#game-ui button { pointer-events: auto; }
#size-indicator { color: var(--abyss-pearl); background: rgba(7,21,28,.84); border: 1px solid #45636b; border-radius: 8px; display: flex; align-items: center; gap: 9px; padding: 10px 13px; }
.hud-label { font-size: 10px; color: #a2b6ba; text-transform: uppercase; letter-spacing: .12em; }
#level-info { width: min(360px,calc(100% - 220px)); padding: 9px 16px 12px; border-radius: 8px; background: rgba(7,21,28,.88); }
#level-name { color: #e4f1ed; font-size: 12px; letter-spacing: .14em; }
#level-objective { color: #b6ccd0; margin-top: 5px; font-size: 12px; }
.objective-track { display: flex; align-items: center; gap: 12px; margin-top: 9px; }
#objective-progress { width: 100%; min-width: 20px; height: 4px; border: 0; border-radius: 8px; appearance: none; background: #29434a; }
#objective-progress::-webkit-progress-bar { background: #29434a; border-radius: 8px; }
#objective-progress::-webkit-progress-value { background: var(--abyss-mist); border-radius: 8px; }
#objective-progress::-moz-progress-bar { background: var(--abyss-mist); border-radius: 8px; }
#objective-count { white-space: nowrap; font: 10px ui-monospace,monospace; color: var(--abyss-mist); }
#pause-btn { border-radius: 8px; background: rgba(7,21,28,.86); border-color: #45636b; color: var(--abyss-pearl); width:44px; height:44px; font-size:18px; }
#run-time { position: absolute; left: 22px; top: calc(74px + env(safe-area-inset-top,0px)); color: #aac2c7; font: 11px ui-monospace,monospace; }
#control-hint { position:absolute; bottom:calc(25px + env(safe-area-inset-bottom,0px)); left:50%; transform:translateX(-50%); color:#ccdede; font-size:12px; text-align:center; line-height:1.6; width:max-content; max-width:80%; background:rgba(7,21,28,.8); padding:9px 16px; border-radius:6px; }
#ability-btn { position:absolute; right:20px; bottom:calc(25px + env(safe-area-inset-bottom,0px)); border:1px solid var(--abyss-rose); border-radius:8px; color:var(--abyss-pearl); background:#30232b; padding:14px 20px; min-height:48px; }
#ability-btn:disabled { opacity:.5; }
.pause-controls { font-size: 12px; color: #94afb6; text-align:center; line-height:1.8; }
.level-intro { background: rgba(4,13,19,.9); backdrop-filter: blur(5px); touch-action:pan-y; overflow-y:auto; }
.intro-content { max-width:470px; width:100%; padding:26px; margin:auto; }
.intro-title { color:var(--abyss-pearl); font:400 clamp(1.7rem,4vw,2.7rem)/1.15 'Iowan Old Style',Georgia,serif; text-transform:none; letter-spacing:-.025em; text-shadow:none; margin-top:16px; }
.intro-body { color:#c5d9dc; line-height:1.7; }
.intro-tip { color:#a7c8cc; border:0; background:none; padding:8px 0; font-size:13px; }
.intro-objective { background:rgba(36,67,77,.35); border:1px solid #36555e; border-radius:8px; }
.objective-label { color:var(--abyss-mist); }
.objective-text { color:var(--abyss-pearl); }
.intro-start-btn { background:var(--abyss-rose); color:#261b25; border:0; border-radius:6px; box-shadow:none; font-size:12px; letter-spacing:.1em; }
.intro-start-btn:hover { background:#ffbdc5; box-shadow:none; }
.intro-back-btn { display:block; margin:16px auto 0; }
#complete-stats { color:#b6ccd0; text-align:center; line-height:1.8; margin:0 0 28px; }
.result-label { display:block; text-transform:uppercase; color:var(--abyss-mist); font-size:10px; letter-spacing:.15em; }
.result-time { display:block; font:400 56px 'Iowan Old Style',Georgia,serif; color:var(--abyss-pearl); margin:10px 0; }
.game-over-text { color:#b6ccd0; max-width:320px; text-align:center; line-height:1.7; }
#level-select { justify-content:flex-start; padding-top:max(35px,env(safe-area-inset-top)); }
#level-select h2 { margin-bottom:18px; }
#level-grid { touch-action:pan-y; max-height:none; overflow:visible; width:min(700px,100%); flex:none; }
.zone-header { color:var(--abyss-mist); }
.zone-row { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.level-btn { min-width:0; width:100%; border-radius:6px; border-color:#3c5960; background:rgba(16,34,42,.85); color:var(--abyss-pearl); }
.level-btn.locked { opacity:.45; }
.level-btn.completed { border-color:var(--abyss-mist); }
.level-title { color:#c5d9dc; }
#how-to-play .instructions { max-width:460px; }
.instruction-item p { color:#c5d9dc; font-size:14px; }
@media (max-width:699px) {
    #main-menu { align-items:center; justify-content:flex-start; text-align:center; padding:0 24px 26px; background:linear-gradient(0deg,rgba(7,21,28,.92),rgba(7,21,28,.65) 52%,rgba(7,21,28,.05)) !important; }
    #main-menu .eyebrow { margin-top: min(37vh,270px); }
    #main-menu h1 { font-size:clamp(3.3rem,16vw,5rem); margin:14px 0; }
    #main-menu .subtitle { font-size:14px; line-height:1.55; margin-bottom:20px; }
    #main-menu .menu-buttons { max-width:330px; gap:9px; }
    .arcade-link { top:calc(20px + env(safe-area-inset-top,0px)); left:24px; }
    .menu-settings { margin-top:8px; }
    .journey-progress { margin-top:2px; }
    .specimen-caption { display:none; }
    #size-indicator { top:calc(16px + env(safe-area-inset-top,0px)); left:12px; padding:10px; gap:5px; }
    #size-value { font-size:15px; }
    .hud-label { font-size:8px; }
    #pause-btn { top:calc(16px + env(safe-area-inset-top,0px)); right:12px; }
    #level-info { top:calc(16px + env(safe-area-inset-top,0px)); width:calc(100% - 150px); padding:9px; }
    #level-name { font-size:10px; letter-spacing:.04em; }
    #level-objective { font-size:10px; }
    .objective-track { gap:7px; }
    #objective-count { font-size:9px; }
    #run-time { left:16px; top:calc(68px + env(safe-area-inset-top,0px)); }
    #control-hint { font-size:11px; bottom:calc(20px + env(safe-area-inset-bottom,0px)); }
    .menu-screen h2 { max-width:90%; }
    .zone-row { gap:7px; }
    .level-btn { padding:12px 5px; }
    .level-title { font-size:10px; }
}
@media (max-height:600px) and (min-width:700px) {
    #main-menu h1 { font-size:64px; margin:12px 0; }
    #main-menu .subtitle { margin-bottom:15px; font-size:14px; }
    .menu-settings { margin-top:6px; }
    #main-menu .eyebrow { margin-top:35px; }
    .intro-content { padding:20px; }
    .intro-title { margin:12px 0; }
    .intro-objective { margin:16px 0; padding:12px; }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none !important; transition:none !important; scroll-behavior:auto !important; } }
/* Anchor the HUD to the viewport, independent of its content height. */
#game-ui { height:100%; padding:0; display:block; }
#size-indicator { position:absolute; top:calc(16px + env(safe-area-inset-top,0px)); left:20px; }
#level-info { position:absolute; left:50%; transform:translateX(-50%); top:calc(16px + env(safe-area-inset-top,0px)); flex:none; }
#pause-btn { position:absolute; top:calc(16px + env(safe-area-inset-top,0px)); right:20px; }
body.light-theme .menu-screen:not(#main-menu) { background:rgba(232,241,237,.98); }
body.light-theme .menu-screen h2, body.light-theme .level-title, body.light-theme .instruction-item p, body.light-theme .game-over-text { color:#23434a; }
body.light-theme .zone-header, body.light-theme .pause-controls { color:#396e70; }
body.light-theme .level-btn { background:#eaf1ed; border-color:#aac5bf; color:#23434a; }
body.light-theme .intro-title, body.light-theme .intro-body, body.light-theme .objective-text { color:#23434a; }
body.light-theme .intro-tip, body.light-theme .objective-label, body.light-theme .intro-back-btn { color:#396e70; }
body.light-theme #complete-stats, body.light-theme .result-time { color:#23434a; }
body.light-theme .result-label { color:#396e70; }
body.light-theme #main-menu .menu-btn:not(.primary) { background:#183039; color:#e4f1ed; border-color:#52727a; }
@media (max-width:699px) { #size-indicator { left:12px; } #pause-btn { right:12px; } }
@media (max-width:699px) { #level-info { width:calc(100% - 190px); } #size-indicator { min-width:72px; } }
@media (max-height:450px) and (min-width:700px) {
    #main-menu { padding-top:55px; padding-bottom:20px; }
    #main-menu .eyebrow { margin-top:0; }
    #main-menu h1 { font-size:48px; margin:8px 0; }
    #main-menu .subtitle { font-size:12px; margin-bottom:10px; line-height:1.5; }
    #main-menu #play-btn { min-height:42px; }
    #main-menu .menu-btn { min-height:38px; padding:9px; }
    #main-menu .menu-buttons { gap:6px; }
    .menu-settings { margin-top:0; }
    .journey-progress { margin-top:0; }
}
/* Brightfield optics need equally legible instrument labels. */
body.light-theme #size-indicator, body.light-theme #pause-btn, body.light-theme #level-info { background:rgba(237,245,239,.94); border-color:#90aaa5; color:#24464c; }
body.light-theme #level-name, body.light-theme #size-value { color:#24464c; }
body.light-theme #level-objective, body.light-theme .hud-label, body.light-theme #run-time { color:#3e6669; }
body.light-theme #objective-count { color:#245f5b; }
body.light-theme #objective-progress::-webkit-progress-bar { background:#bfd0c9; }
body.light-theme #objective-progress::-webkit-progress-value { background:#397c72; }
