:root { --ink: #f2efe6; --mute: #9aa3ad; --gold: #ffc94a; --green: #46e08a; --bad: #ff6a5a; --card: rgba(18, 22, 28, .92); --line: rgba(255,255,255,.12); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d121c; color: var(--ink); font-family: Rubik, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud-top { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 16px; display: flex; gap: 14px; align-items: center; padding: 8px 14px; border-radius: 12px; background: rgba(12,16,22,.7); font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.hud-top b { color: var(--gold); font-size: 20px; }
.hud-top b.bad { color: var(--bad); }
.hud-top .en { width: 70px; height: 8px; border-radius: 5px; background: rgba(255,255,255,.15); overflow: hidden; }
.hud-top .en i { display: block; height: 100%; width: calc(var(--k, 1) * 100%); background: linear-gradient(90deg, #ff6a5a, #ffc94a 40%, #7bd88f 70%); }
.hud-goal { position: absolute; top: calc(max(12px, env(safe-area-inset-top)) + 50px); left: 16px; max-width: min(520px, calc(100% - 32px)); font-size: 14px; color: #e6e2d6; text-shadow: 0 1px 3px #000; }
.hud-goal:empty { display: none; }
.hud-order { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 14px; padding: 8px 16px; border-radius: 12px; background: rgba(20,60,40,.82); border: 1px solid rgba(70,224,138,.5); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-order .bad { color: var(--bad); }
.hud-hint { position: absolute; bottom: 110px; left: 50%; transform: translateX(-50%); padding: 8px 16px; border-radius: 10px; background: rgba(12,16,22,.78); font-weight: 700; font-size: 16px; white-space: nowrap; }
.hud-hint:empty, .hud-hint[hidden] { display: none; }
.hud-spd { position: absolute; right: 20px; bottom: 20px; display: grid; grid-template-columns: auto auto; align-items: end; gap: 2px 10px; padding: 10px 16px; border-radius: 14px; background: rgba(12,16,22,.72); font-variant-numeric: tabular-nums; }
.hud-spd b { font-size: 44px; font-weight: 900; line-height: 1; }
.hud-spd small { color: var(--mute); font-weight: 700; }
.hud-spd i { grid-column: 1; font-style: normal; width: 36px; height: 36px; border-radius: 50%; border: 4px solid #e33; background: #fff; color: #111; display: grid; place-items: center; font-weight: 900; font-size: 14px; }
.hud-spd i[hidden] { display: none; }
.hud-spd em { grid-column: 2; grid-row: 2; font-style: normal; font-weight: 900; font-size: 22px; color: var(--gold); }
.hud-spd.over b { color: var(--bad); }
#mini { position: absolute; left: 16px; bottom: 16px; width: 200px; height: 200px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255,255,255,.25), 0 6px 20px rgba(0,0,0,.4); }

#center { position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%) scale(.8); z-index: 6; font-weight: 900; font-size: clamp(48px, 12vw, 110px); color: #fff; text-shadow: 0 6px 0 rgba(0,0,0,.35); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
#center.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#toasts { position: fixed; right: 16px; top: max(12px, env(safe-area-inset-top)); z-index: 7; display: grid; gap: 8px; width: min(380px, calc(100% - 32px)); pointer-events: none; }
.toast { padding: 10px 14px; border-radius: 10px; background: var(--card); border-left: 4px solid var(--gold); font-size: 15px; transition: opacity .5s, transform .5s; }
.toast.bad { border-color: var(--bad); }
.toast.good { border-color: var(--green); }
.toast.off { opacity: 0; transform: translateX(20px); }

/* панель мест и телефона */
#panel { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: rgba(5,8,12,.45); overflow: auto; }
#panel[hidden] { display: none; }
.card { width: min(480px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px 22px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.card.wide { width: min(720px, 100%); }
.card h2 { margin: 0 0 10px; font-size: 22px; font-weight: 900; }
.card h3 { margin: 14px 0 6px; font-size: 16px; }
.card p { margin: 8px 0; line-height: 1.45; font-size: 15px; }
.card .bad { color: var(--bad); }
.muted { color: var(--mute); }
.acts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 14px; }
.btn { font: inherit; font-weight: 700; font-size: 15px; text-align: left; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--ink); cursor: pointer; }
.btn small { display: block; font-weight: 500; font-size: 12px; color: var(--mute); margin-top: 2px; }
.btn:hover:not([disabled]), .btn:focus-visible { background: rgba(255,255,255,.14); outline: 2px solid var(--gold); outline-offset: 0; }
.btn.main { background: var(--gold); color: #1a1a1a; border-color: var(--gold); }
.btn.main small { color: #4a3d10; }
.btn[disabled] { opacity: .4; cursor: default; }
.lots, .log { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; font-size: 14px; }
.lots li, .log li { padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.05); }
.nodes { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; }
.nodes span { display: inline-flex; align-items: center; gap: 6px; }
.nodes i { width: 40px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #7bd88f calc(var(--k) * 100%), rgba(255,255,255,.15) 0); }
.keys, .res { width: 100%; border-collapse: collapse; font-size: 14px; }
.keys td, .res td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
.keys td:first-child { font-weight: 700; white-space: nowrap; }
.res tr.me td { color: var(--gold); font-weight: 700; }
.res td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
#bigMap { display: block; width: min(640px, 100%); aspect-ratio: 1; border-radius: 10px; cursor: crosshair; }

/* мини-игра мойки */
.dish { display: grid; gap: 10px; justify-items: center; }
.dish-top { display: flex; flex-wrap: wrap; gap: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dish canvas { width: min(520px, 100%); height: auto; border-radius: 12px; touch-action: none; cursor: grab; }
.dish-hint { font-size: 14px; color: var(--mute); text-align: center; }
.dish-btns { display: flex; gap: 8px; }

/* экран загрузки */
#boot { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at 50% 40%, #24443a, #0d121c 70%); transition: opacity .5s; }
#boot.off { opacity: 0; pointer-events: none; }
.boot-box { width: min(440px, 100%); }
.boot-title { font-weight: 900; font-size: clamp(30px, 8vw, 48px); margin-bottom: 18px; }
.boot-title span { color: var(--gold); }
.boot-bar { height: 10px; border-radius: 6px; background: rgba(255,255,255,.1); overflow: hidden; }
.boot-bar i { display: block; height: 100%; background: var(--gold); transform: scaleX(0); transform-origin: 0 50%; transition: transform .2s ease-out; }
.boot-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; font-weight: 700; }
.boot-row b { color: var(--gold); font-variant-numeric: tabular-nums; }
.boot-steps { list-style: none; padding: 0; margin: 16px 0 0; font-size: 14px; color: var(--mute); display: grid; gap: 6px; }
.boot-steps li::before { content: '○'; display: inline-block; width: 22px; }
.boot-steps li.on { color: var(--ink); }
.boot-steps li.on::before { content: '◐'; color: var(--gold); }
.boot-steps li.ok::before { content: '✓'; color: #7bd88f; }
#bootDet { display: block; margin-top: 14px; font-size: 12px; color: var(--mute); min-height: 1.3em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#boot.err .boot-bar i { background: var(--bad); }

@media (max-width: 640px) {
  .hud-top { font-size: 14px; gap: 10px; padding: 6px 10px; }
  .hud-top b { font-size: 16px; }
  .hud-order { top: auto; bottom: 150px; font-size: 13px; gap: 10px; }
  #mini { width: 120px; height: 120px; }
  .hud-spd b { font-size: 32px; }
  .hud-goal { font-size: 12px; top: calc(max(12px, env(safe-area-inset-top)) + 40px); }
  #toasts { top: auto; bottom: 200px; }
  .acts { grid-template-columns: 1fr; }
}
