/* Глибока шахта — тепла печерна тема. ПК (≥1100px): ліва панель HUD+меню, права панель — завжди відкрита.
   Телефон: HUD зверху, меню знизу, панель — висувний лист поверх шахти (шахта не змінює масштаб). */
:root {
    --bg: #0b0806; --panel: rgba(28, 20, 14, .94); --line: rgba(255, 214, 160, .12); --t1: #f5ecdf; --t2: #c4ad93; --t3: #8d7860;
    --gold: #fbbf24; --gold2: #fde68a; --ok: #4ade80; --bad: #f87171; --rune: #a78bfa;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--t1); font: 14px/1.4 Rubik, system-ui, sans-serif; user-select: none; }
#cv { position: fixed; inset: 0; display: block; touch-action: none; }
button { font: inherit; color: inherit; }
.off { display: none !important; }

/* ---------- ліва панель / HUD ---------- */
#side { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; padding: 16px 14px; display: flex; flex-direction: column; gap: 14px; background: linear-gradient(180deg, rgba(20,14,10,.96), rgba(12,8,6,.96)); border-right: 1px solid var(--line); z-index: 5; }
.hud { display: flex; flex-direction: column; gap: 10px; }
.brand b { display: block; font-size: 20px; font-weight: 900; color: var(--gold2); letter-spacing: .01em; }
.brand small { color: var(--t3); font-size: 12px; }
.coins { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.coins b { font-size: 24px; font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; }
.coin { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fef3c7, #f59e0b 60%, #b45309); box-shadow: 0 0 0 2px rgba(0,0,0,.3); flex: none; }
.rate { display: flex; flex-direction: column; padding: 0 4px; }
.rate span { font-weight: 700; color: var(--ok); }
.rate small { color: var(--t3); font-size: 12px; }
.runes { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; background: rgba(167,139,250,.1); border: 1px solid rgba(167,139,250,.25); cursor: pointer; }
.runes i { font-style: normal; font-weight: 900; color: var(--rune); font-size: 18px; }
.runes b { color: #ddd6fe; } .runes small { color: var(--t3); margin-left: auto; }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.nav button { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 0; border-radius: 12px; background: none; color: var(--t2); cursor: pointer; text-align: left; font-weight: 500; }
.nav button:hover { background: rgba(255,255,255,.04); }
.nav button.on { background: rgba(245,158,11,.14); color: var(--gold2); }
.nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.dot { position: absolute; left: 30px; top: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 2px #120c08; }

/* ---------- права панель ---------- */
#panel { position: fixed; right: 0; top: 0; bottom: 0; width: 380px; background: var(--panel); border-left: 1px solid var(--line); z-index: 6; display: flex; flex-direction: column; }
#panel header { display: flex; align-items: center; gap: 10px; padding: 16px 16px 10px; }
#panel h2 { margin: 0; font-size: 18px; font-weight: 800; flex: 1; }
#panel .x { width: 36px; height: 36px; border-radius: 10px; border: 0; background: rgba(255,255,255,.06); cursor: pointer; display: none; }
#panelBody { flex: 1; overflow-y: auto; padding: 0 16px 20px; }

/* ---------- блоки панелі ---------- */
.card { background: rgba(0,0,0,.28); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.card h3 { margin: 0 0 6px; font-size: 14px; color: var(--t2); font-weight: 600; }
.stats { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 10px; font-size: 13px; align-items: center; }
.stats span { color: var(--t2); } .stats b { text-align: right; font-variant-numeric: tabular-nums; } .stats em { color: var(--ok); font-style: normal; text-align: right; font-variant-numeric: tabular-nums; }
.mile { margin-top: 8px; font-size: 12px; color: var(--t3); }
.mile .bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); margin-top: 4px; overflow: hidden; } .mile .bar i { display: block; height: 100%; background: var(--gold); }
.mult { display: flex; gap: 4px; margin: 10px 0 8px; }
.mult button { flex: 1; padding: 6px 0; border-radius: 9px; border: 1px solid var(--line); background: rgba(0,0,0,.25); color: var(--t2); cursor: pointer; font-weight: 700; font-size: 12px; }
.mult button.on { background: rgba(245,158,11,.18); color: var(--gold2); border-color: rgba(245,158,11,.4); }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px; padding: 8px 12px; border-radius: 12px; border: 0; cursor: pointer; font-weight: 800; font-size: 15px; background: #3f3f46; color: #d4d4d8; }
.btn.gold { background: linear-gradient(180deg, #fbbf24, #d97706); color: #2a1503; }
.btn.green { background: linear-gradient(180deg, #4ade80, #16a34a); color: #052e16; }
.btn.rune { background: linear-gradient(180deg, #a78bfa, #7c3aed); color: #fff; }
.btn.ghost { background: rgba(255,255,255,.06); color: var(--t1); font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; filter: grayscale(.4); }
.btn small { font-weight: 600; opacity: .8; }
.man { display: flex; gap: 12px; align-items: center; }
.man canvas { width: 56px; height: 56px; flex: none; }
.man b { display: block; } .man small { color: var(--t2); font-size: 12px; display: block; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover { background: rgba(255,255,255,.03); }
.row .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; flex: none; }
.row .t { flex: 1; min-width: 0; } .row .t b { display: block; font-size: 14px; } .row .t small { color: var(--t3); font-size: 12px; }
.row .r { text-align: right; font-size: 12px; color: var(--t2); } .row .r b { display: block; color: var(--t1); font-size: 13px; }
.up { color: var(--ok); font-weight: 800; }
.neck { color: var(--bad); font-size: 11px; font-weight: 700; }
.ach { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.ach .medal { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #27272a; color: #71717a; font-weight: 900; flex: none; }
.ach.got .medal { background: radial-gradient(circle at 35% 35%, #fef3c7, #f59e0b); color: #78350f; }
.ach b { display: block; font-size: 13px; } .ach small { color: var(--t3); font-size: 12px; }
.note { color: var(--t3); font-size: 12px; margin: 6px 0 0; }
.big { font-size: 30px; font-weight: 900; color: var(--gold2); }

/* ---------- модалка й тости ---------- */
#modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal .box { width: 100%; max-width: 420px; background: #1c140e; border: 1px solid rgba(245,158,11,.35); border-radius: 18px; padding: 20px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
#modal h2 { margin: 0 0 8px; color: var(--gold2); font-size: 20px; }
#modal p { color: var(--t2); margin: 0 0 14px; line-height: 1.5; }
#modal .btns { display: flex; gap: 8px; }
#toasts { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 15; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: rgba(28,20,14,.96); border: 1px solid var(--line); border-radius: 12px; padding: 9px 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.45); animation: tin .25s ease-out; max-width: 90vw; }
.toast.gold { border-color: rgba(251,191,36,.6); color: var(--gold2); }
.toast.bad { border-color: rgba(248,113,113,.5); }
@keyframes tin { from { transform: translateY(-8px); opacity: 0; } }

/* ---------- телефон / вузьке вікно ---------- */
@media (max-width: 1099px) {
    #side { inset: 0 0 auto 0; width: auto; height: auto; padding: 0; background: none; border: 0; display: block; pointer-events: none; }
    .hud { position: fixed; top: 0; left: 0; right: 0; height: 58px; padding: 6px 10px; flex-direction: row; align-items: center; gap: 8px; background: rgba(14,10,7,.94); border-bottom: 1px solid var(--line); pointer-events: auto; padding-top: max(6px, env(safe-area-inset-top)); }
    .brand { display: none; }
    .coins { padding: 6px 10px; border-radius: 12px; } .coins b { font-size: 19px; } .coin { width: 18px; height: 18px; }
    .rate { flex: 1; min-width: 0; } .rate span { font-size: 13px; } .rate small { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .runes { padding: 5px 8px; } .runes small { display: none; }
    .nav { position: fixed; left: 0; right: 0; bottom: 0; height: 66px; flex-direction: row; gap: 0; margin: 0; background: rgba(14,10,7,.96); border-top: 1px solid var(--line); pointer-events: auto; padding-bottom: env(safe-area-inset-bottom); }
    .nav button { flex: 1; flex-direction: column; gap: 3px; padding: 8px 0 6px; border-radius: 0; font-size: 11px; text-align: center; }
    .nav button.on { background: none; }
    .dot { left: calc(50% + 6px); top: 6px; }
    #panel { top: auto; left: 0; width: auto; max-height: 72vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; bottom: 66px; transition: transform .2s ease; box-shadow: 0 -12px 40px rgba(0,0,0,.5); }
    #panel.closed { transform: translateY(calc(100% + 90px)); visibility: hidden; pointer-events: none; }
    #panel { transition: transform .2s ease, visibility .2s; }
    #panel .x { display: grid; place-items: center; }
    #toasts { top: calc(64px + env(safe-area-inset-top)); width: 92vw; }
    .toast { font-size: 13px; padding: 7px 11px; border-radius: 10px; text-align: center; }
}
