@import url('https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@400;600;800&display=swap');

.coin-icon {
    display:inline-flex;width:20px;height:20px;border-radius:50%;
    background:linear-gradient(135deg,#fde047,#ca8a04);border:2px solid #a16207;
    justify-content:center;align-items:center;font-size:11px;font-weight:900;
    color:#78350f;text-shadow:0 1px 0 rgba(255,255,255,0.3);
    box-shadow:0 2px 4px rgba(0,0,0,0.3);vertical-align:middle;
}
.coin-icon::after { content:'$'; }
.coin-icon-large { width: 22px; height: 22px; font-size: 12px; }
.coin-icon-small { width: 16px; height: 16px; font-size: 9px; }
.metrika-pixel { position: absolute; left: -9999px; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; background-color: #020617; overflow: hidden; }
body {
    background-color: #020617;
    color: #f8fafc;
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    touch-action: none; -webkit-user-select: none; user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Custom game cursor (desktop only) */
@media (hover: hover) and (pointer: fine) {
    body, #game-container, canvas {
        cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='12' fill='none' stroke='%2322c55e' stroke-width='2' opacity='0.7'/%3E%3Ccircle cx='16' cy='16' r='3' fill='%2322c55e' opacity='0.9'/%3E%3Cline x1='16' y1='2' x2='16' y2='8' stroke='%2322c55e' stroke-width='1.5' opacity='0.5'/%3E%3Cline x1='16' y1='24' x2='16' y2='30' stroke='%2322c55e' stroke-width='1.5' opacity='0.5'/%3E%3Cline x1='2' y1='16' x2='8' y2='16' stroke='%2322c55e' stroke-width='1.5' opacity='0.5'/%3E%3Cline x1='24' y1='16' x2='30' y2='16' stroke='%2322c55e' stroke-width='1.5' opacity='0.5'/%3E%3C/svg%3E") 16 16, crosshair;
    }
    button, .mode-btn, .action-btn, .icon-btn, #mouse-lock-btn {
        cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M5 2L5 22L10 17L15 24L18 22L13 15L20 15Z' fill='%2322c55e' stroke='%23166534' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E") 5 2, pointer;
    }
}

.top-bar {
    position: fixed; top: env(safe-area-inset-top, 8px); left: 0; right: 0;
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; z-index: 10; pointer-events: none;
}
.scores-wrapper { display: flex; flex-direction: column; gap: 4px; position: relative; pointer-events: auto; }
.score-primary {
    font-size: 1.4rem; font-weight: 800; color: #fff;
    display: flex; align-items: center; gap: 8px;
    position: relative;
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}
.score-primary.score-bump { transform: scale(1.15); }
.score-secondary {
    font-size: 0.85rem; font-weight: 600; color: #94a3b8;
    display: flex; align-items: center; gap: 4px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}
.score-label { color: #94a3b8; font-size: 0.85rem; font-weight: 600; }
.score-value { color: #fff; }
.snake-length { color: #94a3b8; font-size: 0.8rem; font-weight: 600; margin-top: 2px; }
.coin-ui {
    position: absolute;
    top: 65px;
    right: 25px;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(250,204,21,0.3);
    background: rgba(0,0,0,0.4);
    color: #facc15;
    font-size: 1.1rem;
    font-weight: 800;
}
.record-gold { color: #facc15; text-shadow: 0 0 10px rgba(250,204,21,0.4); }
.combo-badge {
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%); color: white;
    font-size: 0.7rem; padding: 3px 6px; border-radius: 6px; font-weight: 900;
    opacity: 0; transform: scale(0) translateY(-10px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: absolute; right: -30px; top: -5px;
    box-shadow: 0 3px 8px rgba(225, 29, 72, 0.4);
}
.combo-badge.active { opacity: 1; transform: scale(1) translateY(0); }
.controls-wrapper { display: flex; gap: 8px; pointer-events: auto; }
.icon-btn {
    background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255,255,255,0.06);
    width: 38px; height: 38px; border-radius: 12px;
    display: flex; justify-content: center; align-items: center;
    color: #94a3b8; cursor: pointer; transition: all 0.15s;
}
.icon-btn:active { transform: scale(0.88); background: rgba(255,255,255,0.15); }
.icon-btn.icon-off svg { opacity: 0.3; }
.icon-btn-active {
    background: rgba(59,130,246,0.45);
    border-color: rgba(125,211,252,0.35);
    color: #dbeafe;
}
.icon-btn-autopilot {
    border-color: rgba(45,212,191,0.42);
    background: linear-gradient(135deg, rgba(20,184,166,0.45), rgba(37,99,235,0.34));
    color: #ccfbf1;
    box-shadow: 0 0 18px rgba(45,212,191,0.22), inset 0 1px 0 rgba(255,255,255,0.12);
}

#game-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; }
#game-container canvas { display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
#overlayCanvas { z-index: 1; pointer-events: none; }

.overlay-menu {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(rgba(2, 6, 23, 0.82), rgba(2, 6, 23, 0.82)), url('assets/kosmos.webp') center/cover no-repeat;
    image-rendering: -webkit-optimize-contrast;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    z-index: 20; color: white; padding: 30px; text-align: center; gap: 8px;
}
.overlay-hidden { display: none !important; }
.menu-title {
    font-size: 2.8rem; font-weight: 800; margin: 0;
    background: linear-gradient(135deg, #4ade80 0%, #22d3ee 100%);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 20px rgba(74, 222, 128, 0.3));
}
.menu-subtitle { font-size: 0.95rem; color: #64748b; margin: -2px 0 6px 0; font-weight: 600; }
.mode-btn {
    background: rgba(30, 41, 59, 0.7); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px; padding: 14px 20px; width: 100%; max-width: 260px;
    color: #e2e8f0; font-size: 1.05rem; font-weight: 700;
    display: flex; align-items: center; gap: 12px; cursor: pointer;
    transition: all 0.15s; font-family: inherit;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.mode-btn:active { transform: scale(0.96); background: rgba(51, 65, 85, 0.9); }
.mode-icon { font-size: 1.5rem; }
.menu-fireflies {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}
.menu-title-front { position: relative; z-index: 1; }
.menu-progress {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: 100%;
    max-width: 340px;
    padding: 6px;
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.55);
}
.menu-progress-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    min-width: 0;
    padding: 5px 4px;
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    color: #f8fafc;
    font-size: 0.92rem;
    font-weight: 900;
}
.menu-progress-label {
    color: #94a3b8;
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}
.mode-card-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
    max-width: 340px;
}
.mode-card {
    position: relative;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    max-width: none;
    min-height: 78px;
    padding: 10px 12px;
    text-align: left;
}
.mode-card-primary {
    min-height: 112px;
    padding: 16px;
}
.mode-card.active {
    border-color: rgba(74, 222, 128, 0.42);
    background: rgba(22, 101, 52, 0.36);
}
.mode-card-infinite {
    border-color: rgba(56, 189, 248, 0.22);
    background: linear-gradient(135deg, rgba(30,41,59,0.78), rgba(14,116,144,0.30));
}
.mode-card-primary.mode-card-infinite {
    border-color: rgba(56, 189, 248, 0.55);
    background: linear-gradient(135deg, rgba(14,165,233,0.62), rgba(37,99,235,0.48));
    box-shadow: 0 14px 30px rgba(14,165,233,0.2), inset 0 1px 0 rgba(255,255,255,0.12);
}
.mode-card-infinite.active {
    border-color: rgba(56, 189, 248, 0.55);
    background: linear-gradient(135deg, rgba(14,116,144,0.48), rgba(79,70,229,0.32));
}
.mode-img-main { width: 54px; height: 54px; object-fit: contain; flex-shrink: 0; }
.mode-card-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.mode-label-main { color: #fff; font-size: 1rem; font-weight: 900; line-height: 1.12; }
.mode-card-primary .mode-label-main { font-size: 1.24rem; }
.mode-card-primary .mode-img-main { width: 68px; height: 68px; }
.mode-card-desc { color: #94a3b8; font-size: 0.78rem; font-weight: 700; line-height: 1.25; }
.mode-card-primary .mode-card-desc { color: rgba(255,255,255,0.84); font-size: 0.84rem; }
.mode-card-badge {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 6px;
    border-radius: 999px;
    background: rgba(34,197,94,0.16);
    color: #86efac;
    font-size: 0.62rem;
    font-weight: 900;
}
.mode-card.active .mode-card-badge { display: inline-flex; }
.menu-dock {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
    max-width: 340px;
    padding: 6px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.58);
}
.dock-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    min-height: 58px;
    padding: 7px 4px;
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px;
    background: rgba(30,41,59,0.62);
    color: #cbd5e1;
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1.05;
}
.dock-btn:active {
    transform: scale(0.96);
}
.dock-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}
.dock-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(59,130,246,0.20);
    color: #bfdbfe;
    font-size: 1.05rem;
    font-weight: 900;
}
.pause-panel {
    width: min(100%, 320px);
    padding: 22px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(15,23,42,0.84), rgba(15,23,42,0.64));
    box-shadow: 0 22px 60px rgba(0,0,0,0.38), inset 0 1px 0 rgba(255,255,255,0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.pause-kicker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 4px 10px;
    border: 1px solid rgba(56,189,248,0.22);
    border-radius: 999px;
    background: rgba(14,165,233,0.12);
    color: #bae6fd;
    font-size: 0.68rem;
    font-weight: 900;
    text-transform: uppercase;
}
.pause-title {
    margin: 10px 0 14px;
    color: #f8fafc;
    font-size: 2rem;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 10px 30px rgba(56,189,248,0.24);
}
.pause-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.pause-stat {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
    padding: 9px 8px;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    background: rgba(255,255,255,0.055);
}
.pause-stat-label {
    color: #94a3b8;
    font-size: 0.66rem;
    font-weight: 800;
    text-transform: uppercase;
}
.pause-stat-value {
    color: #fff;
    font-size: 1.05rem;
    font-weight: 900;
    line-height: 1.15;
    overflow-wrap: anywhere;
}
.pause-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.pause-resume-btn {
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid rgba(125,211,252,0.34);
    background: linear-gradient(135deg, #38bdf8 0%, #2563eb 48%, #4f46e5 100%);
    box-shadow: 0 14px 30px rgba(37,99,235,0.34), inset 0 1px 0 rgba(255,255,255,0.22);
}
.pause-menu-btn {
    min-height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-color: rgba(148,163,184,0.18);
    background: linear-gradient(135deg, rgba(51,65,85,0.92), rgba(30,41,59,0.78));
    color: #dbeafe;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 10px 20px rgba(0,0,0,0.20);
}
.pause-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: rgba(255,255,255,0.16);
    color: #fff;
    font-size: 0.78rem;
    line-height: 1;
}
.go-title { font-size: 2.2rem; font-weight: 800; margin: 0; color: #ef4444; text-shadow: 0 0 30px rgba(239,68,68,0.3); }
.go-score { font-size: 3.5rem; font-weight: 900; margin: 5px 0 20px 0; color: #fff; }
.btn-row { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 260px; }
.action-btn {
    border: none; border-radius: 14px; padding: 14px; color: white;
    font-size: 0.95rem; font-weight: 800; cursor: pointer;
    transition: all 0.15s; font-family: inherit;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.action-btn:active { transform: scale(0.96); }
.action-btn-disabled {
    opacity: 0.42;
    pointer-events: none;
}
.action-btn.primary { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.action-btn.secondary { background: rgba(51, 65, 85, 0.8); border: 1px solid rgba(255,255,255,0.08); }
.action-btn.resume { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }
.overlay-scroll {
    justify-content: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: max(calc(env(safe-area-inset-top, 0px) + 40px), 40px);
    padding-bottom: max(calc(env(safe-area-inset-bottom, 0px) + 160px), 180px);
}
.overlay-back {
    flex-shrink: 0;
    align-self: flex-start;
    margin: 0 0 12px calc(50% - 140px);
}
.overlay-title {
    flex-shrink: 0;
    margin: 0 0 12px 0;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 800;
}
.overlay-title-tight { margin-bottom: 6px; }
.help-content {
    width: 100%;
    max-width: 320px;
    flex-shrink: 0;
    margin: 0 auto;
    color: #cbd5e1;
    font-size: 0.85rem;
    line-height: 1.7;
    text-align: left;
}
.help-card {
    padding: 14px;
    margin-bottom: 10px;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    background: rgba(255,255,255,0.05);
}
.help-card-title {
    margin: 0 0 8px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 800;
}
.help-spaced { margin-top: 6px; }
.text-green { color: #4ade80; }
.text-sky { color: #38bdf8; }
.shop-balance {
    flex-shrink: 0;
    margin: 0 0 12px;
    padding: 6px 18px;
    border: 1px solid rgba(250,204,21,0.25);
    border-radius: 20px;
    background: linear-gradient(135deg,rgba(250,204,21,0.15),rgba(251,146,60,0.08));
    color: #fbbf24;
    font-size: 1.1rem;
    font-weight: 800;
}
.shop-content {
    width: 100%;
    max-width: 280px;
    flex-shrink: 0;
}
.shop-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 10px;
    padding: 4px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    background: rgba(15,23,42,0.75);
}
.shop-tab {
    min-height: 34px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #94a3b8;
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 900;
    cursor: pointer;
}
.shop-tab.active {
    background: linear-gradient(135deg, rgba(59,130,246,0.85), rgba(14,165,233,0.55));
    color: #fff;
    box-shadow: 0 8px 18px rgba(14,165,233,0.18);
}
.shop-panel {
    gap: 7px;
}
.shop-card {
    width: 100%;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    background: rgba(30,41,59,0.74);
    color: #e2e8f0;
    font-family: inherit;
    cursor: pointer;
}
.shop-card:disabled {
    cursor: default;
}
.shop-card-disabled {
    opacity: 0.58;
}
.shop-card-active {
    border-color: #3b82f6;
    background: rgba(30,64,175,0.25);
}
.shop-card-success {
    display: grid;
    place-items: center;
    min-height: 78px;
    border-color: #22c55e;
    background: rgba(34,197,94,0.2);
}
.shop-card-feedback {
    color: #22c55e;
    font-size: 1rem;
    font-weight: 900;
}
.upgrade-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 10px 12px;
    text-align: left;
}
.shop-card-main {
    min-width: 0;
}
.shop-card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.shop-card-title {
    color: #fff;
    font-size: 0.84rem;
    font-weight: 900;
    line-height: 1.15;
}
.shop-level {
    flex-shrink: 0;
    color: #93c5fd;
    font-size: 0.7rem;
    font-weight: 900;
}
.shop-card-desc,
.shop-next-effect {
    margin-top: 4px;
    color: #94a3b8;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
}
.shop-next-effect {
    color: #cbd5e1;
}
.shop-level-track {
    width: 100%;
    height: 6px;
    margin-top: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,0.1);
}
.shop-level-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #22c55e, #38bdf8);
}
.shop-level-fill-1 { width: 10%; }
.shop-level-fill-2 { width: 20%; }
.shop-level-fill-3 { width: 30%; }
.shop-level-fill-4 { width: 40%; }
.shop-level-fill-5 { width: 50%; }
.shop-level-fill-6 { width: 60%; }
.shop-level-fill-7 { width: 70%; }
.shop-level-fill-8 { width: 80%; }
.shop-level-fill-9 { width: 90%; }
.shop-level-fill-10 { width: 100%; }
.shop-card-action {
    align-self: center;
    flex-shrink: 0;
    min-width: 64px;
    color: #facc15;
    font-size: 0.78rem;
    font-weight: 900;
    text-align: right;
}
.shop-card-disabled .shop-card-action {
    color: #94a3b8;
}
.shop-card-max .shop-card-action,
.shop-card-active .shop-card-action {
    color: #4ade80;
}
.cosmetic-card {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    text-align: left;
}
.shop-swatch {
    width: 30px;
    height: 30px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 7px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18);
}
.shop-swatch-round {
    border-radius: 50%;
}
.shop-swatch-skin-classic { background: linear-gradient(135deg, #65a30d, #15803d); }
.shop-swatch-skin-fire { background: linear-gradient(135deg, #f97316, #b91c1c); }
.shop-swatch-skin-ice { background: linear-gradient(135deg, #38bdf8, #0369a1); }
.shop-swatch-skin-gold { background: linear-gradient(135deg, #fbbf24, #ca8a04); }
.shop-swatch-skin-pink { background: linear-gradient(135deg, #f472b6, #db2777); }
.shop-swatch-skin-neon { background: linear-gradient(135deg, #d946ef, #7c3aed); }
.shop-swatch-bg-space { background: url("assets/kosmos.webp") center/cover; }
.shop-swatch-bg-midnight { background: linear-gradient(180deg,#0f172a 0%,#1e1b4b 50%,#0f172a 100%); }
.shop-swatch-bg-desert { background: url("assets/pesok.webp") center/cover; }
.shop-swatch-bg-emerald { background: linear-gradient(135deg,#022c22 0%,#064e3b 40%,#0d9488 100%); }
.shop-swatch-bg-mars { background: url("assets/mars.webp") center/cover; }
.shop-swatch-bg-sunset { background: linear-gradient(180deg,#1c1917 0%,#7c2d12 40%,#c2410c 70%,#fbbf24 100%); }
.shop-swatch-bg-ocean { background: url("assets/water.webp") center/cover; }
.shop-swatch-bg-neonnight { background: linear-gradient(135deg,#0a0a0a 0%,#1e0a3c 30%,#4a044e 60%,#0a0a0a 100%); }
.cosmetic-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
}
.section-label {
    margin: 0 0 6px;
    color: #cbd5e1;
    font-size: 0.85rem;
    font-weight: 700;
}
.list-column {
    display: flex;
    flex-direction: column;
}
.list-column-spaced {
    gap: 6px;
    margin-bottom: 14px;
}
.modal-list {
    width: 100%;
    max-width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 14px;
}
.modal-list-quests { gap: 8px; }
.quest-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(59,130,246,0.25);
    border-radius: 10px;
    background: rgba(15,23,42,0.78);
}
.quest-panel-title {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 800;
}
.quest-panel-subtitle {
    margin-top: 2px;
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 600;
}
.quest-panel-count {
    min-width: 44px;
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(59,130,246,0.18);
    color: #bfdbfe;
    font-size: 0.78rem;
    font-weight: 900;
    text-align: center;
}
.quest-card {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    background: rgba(30,41,59,0.72);
}
.quest-card-completed {
    border-color: rgba(74,222,128,0.42);
}
.quest-card-top,
.quest-progress-row,
.quest-badges {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.quest-title {
    color: #fff;
    font-size: 0.84rem;
    font-weight: 800;
    line-height: 1.2;
}
.quest-reward {
    flex-shrink: 0;
    color: #facc15;
    font-size: 0.78rem;
    font-weight: 800;
}
.quest-badges {
    justify-content: flex-start;
    flex-wrap: wrap;
}
.quest-badge {
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(148,163,184,0.14);
    color: #cbd5e1;
    font-size: 0.66rem;
    font-weight: 800;
}
.quest-badge-medium {
    background: rgba(59,130,246,0.18);
    color: #bfdbfe;
}
.quest-badge-hard {
    background: rgba(239,68,68,0.16);
    color: #fecaca;
}
.quest-progress-row {
    color: #94a3b8;
    font-size: 0.73rem;
    font-weight: 700;
}
.quest-progress-track {
    width: 100%;
    height: 6px;
    overflow: hidden;
    border-radius: 3px;
    background: rgba(255,255,255,0.1);
}
.quest-progress-fill {
    height: 100%;
    background: #3b82f6;
    transition: width 0.3s;
}
.quest-progress-fill-done {
    background: #4ade80;
}
.modal-list-achievements { gap: 6px; }
.achievement-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 10px;
    background: rgba(30,41,59,0.7);
    opacity: 0.5;
}
.achievement-item-unlocked {
    border-color: rgba(250,204,21,0.3);
    opacity: 1;
}
.achievement-item-icon {
    font-size: 1.3rem;
}
.achievement-item-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}
.achievement-item-title {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 800;
}
.achievement-item-desc {
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 600;
}
.achievement-popup {
    position: fixed;
    top: -60px;
    left: 50%;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border: 2px solid #facc15;
    border-radius: 12px;
    background: rgba(15,23,42,0.95);
    transform: translateX(-50%);
    transition: top 0.4s ease;
    pointer-events: none;
}
.achievement-popup-icon { font-size: 1.5rem; }
.achievement-popup-text { color: #facc15; font-size: 0.9rem; font-weight: 700; }
.game-over-modal {
    justify-content: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: max(calc(env(safe-area-inset-top, 0px) + 30px), 30px);
    padding-bottom: max(calc(env(safe-area-inset-bottom, 0px) + 40px), 40px);
}
.go-title-large { margin: 0; font-size: 2.4rem; }
.go-subtitle {
    margin: 4px 0 0;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 600;
}
.go-score-large {
    margin: 0;
    font-size: 4rem;
    line-height: 1;
}
.coins-earned {
    display: none;
    margin: 4px 0;
    padding: 8px 20px;
    border: 1px solid rgba(250,204,21,0.3);
    border-radius: 12px;
    background: linear-gradient(135deg,rgba(250,204,21,0.15),rgba(251,146,60,0.1));
    color: #fbbf24;
    font-size: 1.1rem;
    font-weight: 800;
}
.coins-earned-visible {
    display: block;
}
.go-balance {
    margin: 4px 0;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 600;
}
.go-title-large {
    color: #ef4444;
    text-shadow: 0 10px 30px rgba(239,68,68,0.4);
}
.go-title-record {
    color: #facc15;
    text-shadow: 0 10px 30px rgba(250,204,21,0.4);
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 280px;
    margin: 8px 0;
}
.stats-grid-extra { margin: 0 0 12px; }
.stat-card {
    padding: 10px 6px;
    min-width: 0;
    border-radius: 12px;
    background: rgba(255,255,255,0.06);
    text-align: center;
}
.stat-icon { font-size: 1.5rem; }
.stat-value { color: #fff; font-size: 1.2rem; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.stat-label { color: #64748b; font-size: 0.7rem; font-weight: 600; line-height: 1.12; }
.revive-btn {
    padding: 14px;
    border: 1px solid rgba(168,85,247,0.5);
    background: linear-gradient(135deg,#7c3aed,#a855f7);
    box-shadow: 0 0 15px rgba(168,85,247,0.3);
    font-size: 1.05rem;
}
.restart-btn {
    padding: 16px;
    font-size: 1.1rem;
}

@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px) rotate(-1deg)} 75%{transform:translateX(5px) rotate(1deg)} }
.shake { animation: shake 0.3s ease-in-out; }
@keyframes heavyShake { 0%,100%{transform:translate(0,0)} 20%{transform:translate(-8px,6px)} 40%{transform:translate(8px,-6px)} 60%{transform:translate(-8px,-6px)} 80%{transform:translate(8px,6px)} }
.shake-heavy { animation: heavyShake 0.4s ease-in-out; }

@keyframes fireflyFloat {
    0%, 100% { transform: translate(0, 0); opacity: 0; }
    10% { opacity: 1; }
    50% { opacity: 0.6; }
    90% { opacity: 1; }
    95% { opacity: 0; }
}
@keyframes fireflyGlow {
    0%, 100% { box-shadow: 0 0 4px 2px currentColor; }
    50% { box-shadow: 0 0 12px 6px currentColor; }
}
.firefly {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: fireflyFloat var(--dur) ease-in-out infinite, fireflyGlow 2s ease-in-out infinite;
    animation-delay: var(--delay);
}

#classic-controls {
    position: fixed; bottom: max(env(safe-area-inset-bottom, 10px), 10px); left: 50%; transform: translateX(-50%);
    display: none; gap: 8px; pointer-events: auto; z-index: 5;
    grid-template-columns: repeat(3, 68px); grid-template-rows: repeat(2, 68px);
}
#classic-controls.visible { display: grid; }
#desktop-joystick {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 25;
    display: none;
    width: 100px;
    height: 100px;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    pointer-events: none;
}
#desktop-joystick.desktop-joystick-visible {
    display: block;
}
.desktop-joystick-arrow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    margin: -18px 0 0 -18px;
    transition: transform 0.08s ease-out;
}
.desktop-joystick-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
}
.desktop-joystick-dot-active {
    background: rgba(74,222,128,0.6);
}
#mouse-lock-btn {
    position: fixed;
    bottom: 30px;
    left: 145px;
    z-index: 25;
    display: none;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    cursor: pointer;
    font-size: 18px;
    user-select: none;
}
#mouse-lock-btn.mouse-lock-visible {
    display: flex;
}
#mouse-lock-btn.mouse-lock-active {
    border-color: rgba(74,222,128,0.4);
    background: rgba(74,222,128,0.2);
}
.c-btn {
    background: rgba(30, 41, 59, 0.65); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,0.1);
    display: flex; justify-content: center; align-items: center;
    color: rgba(255,255,255,0.5); transition: all 0.1s; touch-action: none; cursor: pointer;
}
.c-btn svg { width: 28px; height: 28px; fill: currentColor; }
.c-btn.active { background: rgba(59,130,246,0.7); color: white; transform: scale(0.92); border-color: rgba(59,130,246,0.8); }
.c-btn.up { grid-column:2; grid-row:1; border-radius: 18px 18px 6px 6px; }
.c-btn.left { grid-column:1; grid-row:2; border-radius: 18px 6px 6px 18px; }
.c-btn.down { grid-column:2; grid-row:2; border-radius: 6px 6px 18px 18px; }
.c-btn.right { grid-column:3; grid-row:2; border-radius: 6px 18px 18px 6px; }

/* Lift shoot button above D-pad when controls are visible */
#classic-controls.visible ~ #shoot-btn { bottom: 170px !important; }
.shoot-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 70px;
    height: 70px;
    border: 2px solid rgba(239,68,68,0.8);
    border-radius: 50%;
    background: rgba(239,68,68,0.3);
    color: #fff;
    font-size: 32px;
    user-select: none;
    -webkit-touch-callout: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 0 15px rgba(239,68,68,0.5);
}

/* ── Tutorial hint card ── */
#tutorial-hint {
    position: fixed;
    top: max(calc(env(safe-area-inset-top, 8px) + 82px), 92px);
    left: 50%;
    max-width: 360px;
    width: min(calc(100% - 36px), 360px);
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(10, 16, 30, 0.86);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: 0 10px 28px rgba(0,0,0,0.34), inset 0 1px 0 rgba(255,255,255,0.05);
    color: #f8fafc;
    font-family: 'Nunito', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.38;
    pointer-events: none;
    transform: translateX(-50%) translateY(-14px) scale(0.98);
    opacity: 0;
    transition: opacity 0.24s ease, transform 0.24s ease;
}
#tutorial-hint.hint-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}
#tutorial-hint.hint-hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-14px) scale(0.98);
}
#hint-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    border-radius: 8px;
    background: rgba(56, 189, 248, 0.14);
    box-shadow: inset 0 0 0 1px rgba(125, 211, 252, 0.12);
}
#hint-text {
    flex: 1;
    white-space: pre-line;
    overflow-wrap: anywhere;
    text-shadow: 0 1px 1px rgba(0,0,0,0.25);
}

.mode-toggle {
    display: flex; background: rgba(15, 23, 42, 0.9); border-radius: 12px;
    padding: 4px; border: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 16px; width: 100%; max-width: 260px;
}
.mode-toggle .toggle-btn {
    flex: 1; padding: 10px 8px; margin: 0; border: none; background: transparent; border-radius: 8px;
    color: #64748b; font-size: 0.85rem; font-weight: 700; cursor: pointer;
    transition: 0.2s; font-family: inherit; text-align: center;
}
.mode-toggle .toggle-btn.active {
    background: linear-gradient(135deg, #3b82f6, #2563eb); color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* ── Touch joystick (mobile only) ── */
#touch-joystick {
    position: fixed;
    z-index: 15;
    pointer-events: none;
    display: none;
}
#joystick-base {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    border: 2px solid rgba(255,255,255,0.12);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
#joystick-thumb {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.22);
    border: 2px solid rgba(255,255,255,0.3);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: opacity 0.15s;
}
#touch-joystick.active { display: block; }
#touch-joystick.fading { opacity: 0; transition: opacity 0.2s; }

@media (max-width: 430px) {
    .overlay-menu {
        padding-left: 18px;
        padding-right: 18px;
    }
    .overlay-scroll {
        padding-top: max(calc(env(safe-area-inset-top, 0px) + 28px), 28px);
        padding-bottom: max(calc(env(safe-area-inset-bottom, 0px) + 96px), 116px);
    }
    .overlay-back {
        margin-left: 0;
    }
    .overlay-title {
        font-size: 1.35rem;
    }
    .help-content {
        max-width: 100%;
        font-size: 0.82rem;
        line-height: 1.58;
    }
    .help-card {
        padding: 12px;
        border-radius: 10px;
    }
    .menu-progress,
    .mode-card-grid,
    .menu-dock,
    .shop-content,
    .modal-list,
    .stats-grid {
        max-width: 100%;
    }
    .menu-title {
        font-size: 2.35rem;
    }
    .menu-subtitle {
        margin-bottom: 4px;
    }
    .mode-img-main {
        width: 48px;
        height: 48px;
    }
    .mode-card {
        min-height: 72px;
        padding: 9px 10px;
    }
    .mode-card-primary {
        min-height: 104px;
        padding: 14px;
    }
    .mode-card-primary .mode-img-main {
        width: 62px;
        height: 62px;
    }
    .mode-card-desc {
        font-size: 0.74rem;
    }
    .dock-btn {
        min-height: 54px;
        font-size: 0.64rem;
    }
    .dock-img,
    .dock-emoji {
        width: 25px;
        height: 25px;
    }
    .game-over-modal {
        gap: 6px;
        padding-top: max(calc(env(safe-area-inset-top, 0px) + 22px), 22px);
        padding-bottom: max(calc(env(safe-area-inset-bottom, 0px) + 24px), 24px);
    }
    .go-title-large {
        font-size: clamp(1.85rem, 8vw, 2.25rem);
    }
    .go-score-large {
        font-size: clamp(3rem, 15vw, 3.8rem);
    }
    .stat-card {
        padding: 8px 5px;
        border-radius: 10px;
    }
    .stat-icon {
        font-size: 1.25rem;
    }
    .stat-value {
        font-size: 1rem;
    }
    .btn-row {
        max-width: 100%;
    }
}

@media (max-height: 700px) {
    .overlay-scroll {
        padding-top: max(calc(env(safe-area-inset-top, 0px) + 18px), 18px);
        padding-bottom: max(calc(env(safe-area-inset-bottom, 0px) + 64px), 76px);
    }
    .overlay-title {
        margin-bottom: 8px;
    }
    .game-over-modal {
        gap: 5px;
        padding-top: max(calc(env(safe-area-inset-top, 0px) + 18px), 18px);
        padding-bottom: max(calc(env(safe-area-inset-bottom, 0px) + 18px), 18px);
    }
    .go-title-large {
        font-size: 2rem;
    }
    .go-score-large {
        font-size: 3.1rem;
    }
    .stats-grid {
        gap: 6px;
        margin: 6px 0;
    }
    .stats-grid-extra {
        margin-bottom: 8px;
    }
    .action-btn {
        padding: 12px;
    }
    .pause-panel {
        width: min(100%, 300px);
        padding: 18px;
    }
    .pause-title {
        font-size: 1.75rem;
        margin-bottom: 12px;
    }
    .pause-stats {
        gap: 6px;
        margin-bottom: 12px;
    }
    .pause-stat {
        padding: 8px 6px;
    }
    .restart-btn {
        padding: 13px;
    }
    .menu-title {
        font-size: 2.05rem;
    }
    .menu-progress {
        padding: 5px;
    }
    .menu-progress-item {
        padding: 4px 3px;
    }
    .mode-card {
        min-height: 64px;
        gap: 9px;
    }
    .mode-card-primary {
        min-height: 88px;
        padding: 11px;
    }
    .mode-img-main {
        width: 42px;
        height: 42px;
    }
    .mode-card-primary .mode-img-main {
        width: 52px;
        height: 52px;
    }
    .mode-card-primary .mode-label-main {
        font-size: 1.08rem;
    }
    .menu-dock {
        padding: 5px;
    }
    .dock-btn {
        min-height: 48px;
        gap: 2px;
        padding: 5px 3px;
    }
    .dock-img,
    .dock-emoji {
        width: 22px;
        height: 22px;
    }
}

/* ── Landscape adjustments ── */
@media (orientation: landscape) {
    .top-bar { padding: 4px 16px; }
    .score-primary { font-size: 1.1rem; }
    .score-secondary { font-size: 0.75rem; }
    .icon-btn { width: 32px; height: 32px; border-radius: 10px; }
    #classic-controls {
        bottom: max(env(safe-area-inset-bottom, 8px), 8px);
        grid-template-columns: repeat(3, 52px);
        grid-template-rows: repeat(2, 52px);
        gap: 4px;
    }
    #tutorial-hint {
        top: max(calc(env(safe-area-inset-top, 4px) + 52px), 56px);
        max-width: 320px;
        font-size: 0.78rem;
        padding: 8px 12px;
    }
    #hint-icon { width: 30px; height: 30px; font-size: 1.05rem; border-radius: 8px; }
}

/* ── Preloader ── */
#preloader {
    position: fixed; inset: 0; z-index: 100000;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: radial-gradient(ellipse at center, #1e1b4b 0%, #020617 80%);
    font-family: 'Nunito', sans-serif;
    color: #f8fafc;
    transition: opacity 0.45s ease;
}
#preloader.hidden { opacity: 0; pointer-events: none; }
.preloader-snake {
    display: flex; gap: 8px; margin-bottom: 36px;
}
.preloader-snake span {
    width: 18px; height: 18px; border-radius: 50%;
    background: #4ade80;
    animation: preloader-bounce 1.1s ease-in-out infinite;
    box-shadow: 0 0 14px rgba(74, 222, 128, 0.55);
}
.preloader-snake span:nth-child(1) { animation-delay: 0s; }
.preloader-snake span:nth-child(2) { animation-delay: 0.10s; background: #65a30d; }
.preloader-snake span:nth-child(3) { animation-delay: 0.20s; background: #4ade80; }
.preloader-snake span:nth-child(4) { animation-delay: 0.30s; background: #65a30d; }
.preloader-snake span:nth-child(5) { animation-delay: 0.40s; background: #4ade80; }
.preloader-snake span:nth-child(6) { animation-delay: 0.50s; background: #14532d; }
@keyframes preloader-bounce {
    0%, 100% { transform: translateY(0); opacity: 0.8; }
    50% { transform: translateY(-18px); opacity: 1; }
}
.preloader-title {
    font-size: 2.4rem; font-weight: 900; letter-spacing: 2px;
    color: #fef08a;
    text-shadow: 0 0 24px rgba(254, 240, 138, 0.5);
}
.preloader-subtitle {
    font-size: 1rem; font-weight: 700;
    color: #a78bfa;
    margin-top: 4px; margin-bottom: 32px;
    letter-spacing: 4px;
}
.preloader-bar {
    width: 240px; height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px; overflow: hidden;
    margin-bottom: 14px;
}
#preloader-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #fef08a);
    width: 0%;
    border-radius: 4px;
    transition: width 0.25s ease;
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.6);
}
.preloader-status {
    font-size: 0.85rem; color: #94a3b8;
    min-height: 1.2em;
    margin-bottom: 28px;
}
.preloader-start {
    appearance: none; border: none; cursor: pointer;
    padding: 14px 48px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem; font-weight: 900; letter-spacing: 2px;
    color: #052e16;
    background: linear-gradient(135deg, #4ade80, #22c55e);
    border-radius: 14px;
    box-shadow: 0 6px 24px rgba(74, 222, 128, 0.5);
    transition: transform 0.18s ease, opacity 0.3s ease;
    opacity: 0;
}
.preloader-start.ready {
    opacity: 1;
    animation: preloader-pulse 1.6s ease-in-out infinite;
}
.preloader-start:disabled { cursor: default; }
.preloader-start:not(:disabled):hover { transform: translateY(-2px) scale(1.03); }
.preloader-start:not(:disabled):active { transform: translateY(0) scale(0.98); }
@keyframes preloader-pulse {
    0%, 100% { box-shadow: 0 6px 24px rgba(74, 222, 128, 0.5); }
    50% { box-shadow: 0 6px 36px rgba(74, 222, 128, 0.9); }
}

/* ── Menu corner buttons (sound toggle in start screen) ── */
.menu-corner-btn {
    position: absolute;
    top: max(env(safe-area-inset-top, 12px), 18px);
    right: 18px;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 12px;
    color: #e2e8f0;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.18s ease;
    z-index: 5;
}
.menu-corner-btn:hover { background: rgba(30, 41, 59, 0.9); transform: scale(1.05); }
.menu-corner-btn:active { transform: scale(0.94); }
.menu-corner-btn.icon-off {
    color: #94a3b8;
    background: rgba(15, 23, 42, 0.55);
}
