@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&family=Nunito:wght@400;600;800&display=swap');

:root {
    --ink: #062233;
    --panel: rgba(6, 30, 46, 0.82);
    --panel-light: rgba(255, 255, 255, 0.08);
    --accent: #ffd23f;
    --accent-2: #35d0ff;
    --danger: #ff5d6c;
    --radius: 18px;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: #041827;
    color: #eaf6ff;
    font-family: 'Nunito', system-ui, sans-serif;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    height: 100%;
    width: 100%;
}

h1, h2, h3, .heading {
    font-family: 'Baloo 2', 'Nunito', sans-serif;
    margin: 0;
}

#site-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 10px;
    gap: 8px;
}

#game-root {
    position: relative;
    width: 100%;
    max-width: 1100px;
    aspect-ratio: 9 / 16;
    max-height: 92vh;
    margin: 0 auto;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
    background: #051a2b;
}

@media (min-width: 900px) {
    #game-root { aspect-ratio: 16 / 9; max-height: 82vh; }
}

#game-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    gap: 14px;
    background: linear-gradient(180deg, rgba(4, 18, 32, 0.55), rgba(2, 10, 20, 0.85));
    backdrop-filter: blur(2px);
}

[hidden] { display: none !important; }

.logo-title {
    font-size: clamp(30px, 8vw, 54px);
    font-weight: 800;
    letter-spacing: 1px;
    color: #fff;
    text-shadow: 0 0 24px rgba(53, 208, 255, 0.55), 0 4px 0 rgba(0, 0, 0, 0.35);
    line-height: 1.02;
}
.logo-title span { color: var(--accent); }
.tagline { font-size: 15px; opacity: 0.85; max-width: 320px; }

.btn {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 700;
    font-size: 17px;
    color: #05202f;
    background: linear-gradient(180deg, #ffe27a, var(--accent));
    border: none;
    border-radius: 999px;
    padding: 14px 34px;
    cursor: pointer;
    box-shadow: 0 6px 0 #c99b12, 0 10px 20px rgba(0, 0, 0, 0.35);
    transition: transform 0.08s ease;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #c99b12; }
.btn--ghost {
    background: var(--panel-light);
    color: #eaf6ff;
    box-shadow: 0 4px 0 rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.18);
    font-size: 15px;
    padding: 11px 24px;
}
.btn--ghost:active { transform: translateY(3px); box-shadow: none; }
.btn--small { padding: 8px 16px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.icon-btn {
    width: 42px; height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--panel-light);
    color: #eaf6ff;
    font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
}
.icon-btn[aria-pressed="false"] { opacity: 0.45; }
.icon-btn svg { display: block; }

#hud {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 14px;
    pointer-events: none;
    font-family: 'Baloo 2', sans-serif;
    z-index: 5;
}
#hud * { pointer-events: auto; }
.hud-stat {
    background: var(--panel);
    border-radius: 12px;
    padding: 6px 12px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
    min-width: 84px;
}
.hud-stat .label { font-size: 10px; letter-spacing: 1px; opacity: 0.65; font-family: 'Nunito', sans-serif; }
.hud-stat .value { font-size: 20px; font-weight: 700; }
.hud-top-left, .hud-top-right { display: flex; flex-direction: column; gap: 6px; }
.hud-icons { display: flex; gap: 6px; }

#hud-bottom {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 5;
    pointer-events: none;
}
#hud-bottom * { pointer-events: auto; }

.oxygen-wrap {
    display: flex; align-items: center; gap: 8px;
    background: var(--panel);
    border-radius: 999px;
    padding: 6px 12px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}
.oxygen-bar {
    flex: 1;
    height: 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.12);
    overflow: hidden;
}
.oxygen-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #35d0ff, #7dffcf);
    border-radius: 999px;
    transition: width 0.15s linear, background-color 0.3s ease;
}
.oxygen-wrap.low .oxygen-fill { background: linear-gradient(90deg, #ff9d3d, var(--danger)); }
.oxygen-icon { display: flex; color: #7dffcf; }

.combo-badge {
    align-self: flex-start;
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 15px;
    background: var(--panel);
    border-radius: 999px;
    padding: 4px 14px;
    color: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
    opacity: 0;
    transform: translateY(6px) scale(0.9);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.combo-badge.show { opacity: 1; transform: translateY(0) scale(1); }

.bottom-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.boost-btn {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: 13px;
    color: #05202f;
    background: linear-gradient(180deg, #7dffcf, #35d0ff);
    border: none;
    border-radius: 999px;
    padding: 12px 20px;
    box-shadow: 0 5px 0 #1a7fa8;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.boost-btn:disabled { filter: grayscale(0.8); opacity: 0.55; cursor: default; }
.boost-cooldown {
    position: absolute; inset: 0;
    background: rgba(4, 24, 39, 0.65);
    transform-origin: left;
    transform: scaleX(0);
}

.banner {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    font-size: clamp(20px, 4.4vw, 34px);
    text-align: center;
    color: #fff;
    text-shadow: 0 0 18px rgba(255, 210, 63, 0.7), 0 3px 0 rgba(0,0,0,0.4);
    opacity: 0;
    z-index: 6;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.warning-vignette {
    position: absolute; inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 120px 20px rgba(255, 60, 60, 0);
    transition: box-shadow 0.4s ease;
    z-index: 4;
}
.warning-vignette.active {
    box-shadow: inset 0 0 120px 30px rgba(255, 60, 60, 0.55);
    animation: pulseVignette 1s ease-in-out infinite;
}
@keyframes pulseVignette {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.panel {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 22px 26px;
    max-width: 380px;
    width: 100%;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 20px 40px rgba(0,0,0,0.4);
}

.stat-line { display: flex; justify-content: space-between; font-size: 15px; padding: 5px 0; border-bottom: 1px dashed rgba(255,255,255,0.12); }
.stat-line:last-of-type { border-bottom: none; }
.stat-line .k { opacity: 0.75; }
.stat-line.total { font-size: 20px; font-weight: 800; color: var(--accent); border-top: 2px solid rgba(255,255,255,0.2); margin-top: 6px; padding-top: 10px; }

.newbest {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 800;
    color: var(--accent);
    font-size: 16px;
    animation: pop 0.5s ease;
}
@keyframes pop { 0% { transform: scale(0.5); opacity: 0; } 60% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }

.nick-form { display: flex; gap: 8px; margin-top: 8px; }
.nick-form input {
    flex: 1;
    border-radius: 10px;
    border: none;
    padding: 12px;
    font-size: 15px;
    font-family: 'Nunito', sans-serif;
    background: rgba(255,255,255,0.9);
    color: #05202f;
}
.hint { font-size: 12px; opacity: 0.6; margin-top: 4px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 16px; }

.lb-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.lb-tab {
    flex: 1;
    background: var(--panel-light);
    border: none;
    color: #eaf6ff;
    padding: 8px;
    border-radius: 10px;
    font-family: 'Baloo 2', sans-serif;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    opacity: 0.6;
}
.lb-tab.active { opacity: 1; background: linear-gradient(180deg, #ffe27a, var(--accent)); color: #05202f; }

#leaderboard-list {
    list-style: none;
    margin: 0; padding: 0;
    max-height: 46vh;
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 4px;
}
.lb-row, .lb-empty {
    display: grid;
    grid-template-columns: 42px 1fr auto auto;
    gap: 8px;
    align-items: center;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 7px 10px;
    font-size: 14px;
}
.lb-row--me { background: rgba(255, 210, 63, 0.18); box-shadow: inset 0 0 0 1px rgba(255,210,63,0.5); }
.lb-rank { font-weight: 800; opacity: 0.85; }
.lb-name { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-depth { opacity: 0.6; font-size: 12px; }
.lb-score { font-weight: 800; color: var(--accent); }
.lb-empty { justify-content: center; text-align: center; opacity: 0.6; grid-template-columns: 1fr; }

.howto-list { text-align: left; font-size: 14px; line-height: 1.7; margin: 0 0 4px; padding-left: 18px; }

.loading-bar-track {
    width: 220px; height: 10px;
    background: rgba(255,255,255,0.12);
    border-radius: 999px;
    overflow: hidden;
}
.loading-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #35d0ff, var(--accent));
    transition: width 0.2s ease;
}

.badge-pill {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(255,210,63,0.18);
    color: var(--accent);
    margin-top: 4px;
}

footer.site-footer {
    color: rgba(234,246,255,0.55);
    font-size: 12px;
    text-align: center;
    max-width: 620px;
    line-height: 1.6;
    padding-bottom: 10px;
}
footer.site-footer a { color: #7fd8ff; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

.pause-btn { position: absolute; }

@media (max-width: 480px) {
    .hud-stat { min-width: 66px; padding: 5px 9px; }
    .hud-stat .value { font-size: 16px; }
    .panel { padding: 16px 18px; }
}
