:root {
  --bg: #0d0a07;
  --glass: rgba(24, 19, 14, 0.84);
  --glass-2: rgba(255, 240, 215, 0.06);
  --line: rgba(232, 200, 140, 0.22);
  --ink: #f4ead8;
  --ink-2: #c9b89c;
  --ink-3: #8c7c64;
  --gold: #d6aa5c;
  --gold-2: #f1d39a;
  --gold-deep: #a97a32;
  --red: #c0392b;
  --font-display: 'Unbounded', 'Manrope', sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;
  --r-pill: 999px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font-body); }
body { overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

#board { position: fixed; inset: 0; display: block; touch-action: none; z-index: 0; }
#app { position: fixed; inset: 0; z-index: 1; display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr); pointer-events: none; }
#app > * { pointer-events: auto; }
#stage { position: relative; min-height: 0; pointer-events: none !important; }

/* Заставка */
#loading { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 45%, #2f2419 0%, #15100b 55%, #0a0806 100%); transition: opacity 600ms var(--ease); }
#loading.done { opacity: 0; pointer-events: none; }
.load-art { display: flex; flex-direction: column; align-items: center; gap: 18px; width: min(420px, 82vw); }
.wordmark { font-family: var(--font-display); font-weight: 700; font-style: italic; letter-spacing: -0.03em; line-height: 1; font-size: clamp(34px, 7.4vw, 62px); white-space: nowrap; }
.wordmark span { color: #fbf3e4; }
.wordmark b { font-weight: 700; background: linear-gradient(180deg, var(--gold-2), var(--gold) 60%, var(--gold-deep)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.wm-sub { display: flex; align-items: center; gap: 12px; width: 100%; color: #e9dcc6; font-size: 11px; font-weight: 700; letter-spacing: .34em; }
.wm-sub i { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(233, 200, 140, .55), transparent); }
.wm-sub span { white-space: nowrap; }
.load-track { position: relative; width: 100%; height: 6px; margin-top: 28px; border-radius: 6px; background: rgba(255, 255, 255, .07); }
.load-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 6px; background: linear-gradient(90deg, #7a5a2c, var(--gold) 60%, var(--gold-2)); box-shadow: 0 0 14px rgba(214, 170, 92, .45); }
.load-runner { position: absolute; top: 50%; left: 0; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #ece6d8 55%, #b9ae98); box-shadow: 0 0 0 2px rgba(214, 170, 92, .9) inset, 0 0 0 4px #f4f1ea inset, 0 4px 14px rgba(0, 0, 0, .6); }
.load-runner::after { content: ''; position: absolute; inset: 9px; border-radius: 50%; border: 2px solid var(--gold); }
.load-note { margin: 6px 0 0; font-size: 12px; color: var(--ink-3); letter-spacing: .08em; text-align: center; min-height: 1.4em; }
.load-2d { display: block; margin: 18px auto 0; padding: 10px 18px; border-radius: 999px; border: 1px solid rgba(214,177,106,.55); background: rgba(214,177,106,.12); color: #f1dfb8; font: 600 13px/1.2 inherit; letter-spacing: .04em; cursor: pointer; }
.load-2d[hidden] { display: none; }

/* Кнопки-кружки */
.round { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: rgba(20, 15, 10, .8); color: var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 18px; transition: transform 160ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease); }
.round:hover { border-color: rgba(232, 200, 140, .5); }
.round:active { transform: scale(.94); }
.snd[aria-pressed="false"] { color: var(--ink-3); }
#btnView[aria-pressed="true"] { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #22170b; border-color: transparent; }

/* HUD */
.hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 14px 6px; min-width: 0; }
.score-pill { display: flex; align-items: center; justify-content: space-between; gap: 6px; background: var(--glass); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 5px; box-shadow: var(--shadow); min-width: 0; flex: 1 1 auto; max-width: 480px; }
.side { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--r-pill); min-width: 0; transition: background 200ms var(--ease), color 200ms var(--ease); }
.side.on { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #22170b; }
.side .name { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side b { font-family: var(--font-display); font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 1.2em; text-align: center; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.dot.white { background: #efe7d8; box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .35) inset; }
.dot.black { background: #151515; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .35) inset; }
.mid { display: flex; flex-direction: column; align-items: center; padding: 0 6px; line-height: 1.15; }
.mid span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--gold-2); }
.mid small { font-size: 11px; color: var(--ink-2); }
.hud-btns { display: flex; gap: 8px; flex: none; }

.toast { position: absolute; left: 50%; top: 10px; transform: translate(-50%, -8px); background: rgba(20, 15, 10, .86); border: 1px solid var(--line); color: var(--ink); padding: 10px 18px; border-radius: var(--r-pill); font-size: 14px; font-weight: 600; opacity: 0; transition: opacity 220ms var(--ease), transform 220ms var(--ease); pointer-events: none; max-width: 92vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Нижняя панель */
.controls { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 14px; padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); max-width: 760px; width: 100%; margin: 0 auto; }
.turn { font-family: var(--font-display); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--glass); border: 1px solid var(--line); color: var(--gold-2); padding: 10px 16px; border-radius: var(--r-pill); white-space: nowrap; }
.hint { grid-column: 1 / -1; font-size: 13px; color: var(--ink-2); text-align: center; min-height: 18px; text-shadow: 0 1px 6px rgba(0, 0, 0, .9); }
.slider-wrap { display: block; background: var(--glass); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 0 18px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, rgba(214, 170, 92, .25), rgba(214, 170, 92, .6), rgba(214, 170, 92, .25)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(214, 170, 92, .45); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; border-radius: 50%; margin-top: -13px; background: radial-gradient(circle at 35% 30%, #fff, #ece6d8 60%, #b9ae98); box-shadow: 0 0 0 3px var(--gold) inset, 0 4px 12px rgba(0, 0, 0, .6); }
input[type=range]::-moz-range-thumb { width: 30px; height: 30px; border: 0; border-radius: 50%; background: #f1ece2; box-shadow: 0 0 0 3px var(--gold) inset; }
input[type=range]:disabled { opacity: .4; }

/* Меню */
#menu { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(18px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(10, 8, 6, .55) 0%, rgba(10, 8, 6, 0) 22%, rgba(10, 8, 6, 0) 48%, rgba(10, 8, 6, .72) 100%); overflow-y: auto; }
.menu-top { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 14px; display: flex; gap: 8px; }
.menu-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 4px; filter: drop-shadow(0 4px 18px rgba(0, 0, 0, .7)); }
.menu-logo .wordmark { font-size: clamp(30px, 6vw, 52px); }
.menu-logo .wm-sub { font-size: 10px; letter-spacing: .26em; }
.panel { width: min(440px, 100%); background: linear-gradient(180deg, rgba(36, 28, 20, .93), rgba(18, 14, 10, .96)); border: 1px solid var(--line); border-radius: 22px; padding: 18px 16px 14px; box-shadow: var(--shadow), 0 1px 0 rgba(255, 235, 200, .08) inset; -webkit-user-select: text; user-select: text; }
.ptitle { font-size: 12px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--gold-2); margin: 0 4px 12px; }
.opts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--glass-2); border: 1px solid transparent; cursor: pointer; transition: border-color 160ms var(--ease), background 160ms var(--ease); }
.opt input, .seg input { position: absolute; opacity: 0; pointer-events: none; }
.ico { width: 38px; height: 38px; flex: none; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 240, 215, .06); color: var(--ink-2); }
.ot { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ot b { font-size: 15px; font-weight: 700; }
.ot small { font-size: 12px; color: var(--ink-2); }
.chk { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 1.5px solid var(--ink-3); }
.opt:has(input:checked) { border-color: rgba(232, 200, 140, .65); background: rgba(214, 170, 92, .12); }
.opt:has(input:checked) .ico { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #22170b; }
.opt:has(input:checked) .chk { border-color: var(--gold-2); background: radial-gradient(circle, var(--gold-2) 0 5px, transparent 6px); }
.opt:has(input:focus-visible), .seg label:has(input:focus-visible) { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.seg-row { display: flex; align-items: center; gap: 10px; margin: 0 2px 8px; }
.sl { width: 74px; flex: none; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.seg { flex: 1; display: flex; padding: 3px; border-radius: 12px; background: rgba(0, 0, 0, .35); border: 1px solid rgba(232, 200, 140, .12); }
.seg label { flex: 1; position: relative; }
.seg span { display: grid; place-items: center; min-height: 36px; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--ink-2); cursor: pointer; transition: background 160ms var(--ease), color 160ms var(--ease); white-space: nowrap; padding: 0 6px; }
.seg label:has(input:checked) span { background: rgba(214, 170, 92, .2); color: var(--gold-2); box-shadow: 0 0 0 1px rgba(232, 200, 140, .4) inset; }
.cta { width: 100%; display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 52px; margin-top: 8px; border-radius: 14px; border: 0; background: linear-gradient(180deg, var(--gold-2), var(--gold) 55%, var(--gold-deep)); color: #22170b; font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .14em; box-shadow: 0 8px 24px rgba(214, 170, 92, .25), 0 1px 0 rgba(255, 255, 255, .5) inset; transition: transform 160ms var(--ease), filter 160ms var(--ease); }
.cta:hover { filter: brightness(1.06); }
.cta:active { transform: scale(.985); }
.cta.ghost { background: transparent; color: var(--gold-2); box-shadow: 0 0 0 1px var(--line) inset; font-family: var(--font-body); letter-spacing: .02em; font-size: 14px; min-height: 44px; }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-top: 12px; font-size: 12px; }
.links a, .lnk { color: var(--ink-2); background: none; border: 0; padding: 4px 0; text-decoration: none; font-size: 12px; }
.links a:hover, .lnk:hover { color: var(--gold-2); }

/* Оверлеи: правила, итог */
.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(8, 6, 4, .6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); overflow-y: auto; }
.sheet { position: relative; width: min(560px, 100%); background: linear-gradient(180deg, rgba(36, 28, 20, .95), rgba(18, 14, 10, .97)); border: 1px solid var(--line); border-radius: 24px; padding: 28px 26px 22px; box-shadow: var(--shadow); max-height: calc(100dvh - 32px); overflow-y: auto; -webkit-user-select: text; user-select: text; }
.sheet.wide { width: min(680px, 100%); }
h2 { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; margin: 0 0 10px; line-height: 1.05; letter-spacing: -0.01em; font-size: clamp(24px, 5vw, 34px); color: #fbf3e4; }
h2 span { display: block; color: var(--gold); font-size: .42em; margin-top: 6px; letter-spacing: .14em; }
.lead { color: var(--ink-2); font-size: 15px; line-height: 1.5; margin: 0 0 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.btn { flex: 1 1 160px; display: inline-flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 52px; padding: 6px 6px 6px 22px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 240, 215, .05); color: var(--ink); font-weight: 700; font-size: 14px; letter-spacing: .08em; text-decoration: none; transition: transform 160ms var(--ease), filter 160ms var(--ease); }
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(180deg, var(--gold-2), var(--gold) 55%, var(--gold-deep)); color: #22170b; border-color: transparent; }
.arr { width: 40px; height: 40px; border-radius: 10px; background: rgba(0, 0, 0, .18); position: relative; flex: none; }
.arr::after { content: ''; position: absolute; left: 13px; top: 14px; width: 10px; height: 10px; border-top: 2.5px solid currentColor; border-right: 2.5px solid currentColor; transform: rotate(45deg); }
.arr.lilac { background: rgba(214, 170, 92, .16); color: var(--gold-2); }
.close { position: absolute; right: 16px; top: 16px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 240, 215, .05); font-size: 22px; color: var(--ink); }
.tabs { display: flex; gap: 8px; margin: 14px 0 6px; }
.tab { min-height: 38px; padding: 0 18px; border-radius: var(--r-pill); border: 1px solid var(--line); background: transparent; color: var(--ink-2); font-weight: 700; }
.tab.on { background: rgba(214, 170, 92, .2); color: var(--gold-2); border-color: rgba(232, 200, 140, .5); }
.steps { padding-left: 22px; margin: 12px 0 0; color: var(--ink-2); }
.steps li { margin-bottom: 10px; line-height: 1.5; font-size: 15px; }
.steps b { color: var(--ink); }
.steps li::marker { color: var(--gold); font-weight: 700; }
.note { font-size: 13px; color: var(--ink-2); background: rgba(214, 170, 92, .1); border: 1px solid rgba(214, 170, 92, .2); padding: 10px 14px; border-radius: 12px; }
.res-score { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 4px 0 18px; }
.res-score div { display: flex; flex-direction: column; align-items: center; }
.res-score small { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--ink-2); letter-spacing: .06em; }
.res-score b, .res-score span { font-family: var(--font-display); font-size: 46px; color: var(--gold-2); }
.promo { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.promo p { margin: 0 0 6px; font-size: 14px; color: var(--ink-2); line-height: 1.5; }
#result { background: linear-gradient(180deg, rgba(8, 6, 4, 0) 30%, rgba(8, 6, 4, .7)); backdrop-filter: none; -webkit-backdrop-filter: none; align-items: end; }

@media (max-width: 520px) {
  .hud { padding-left: 8px; padding-right: 8px; gap: 6px; }
  .round { width: 38px; height: 38px; font-size: 16px; }
  .round svg { width: 18px; height: 18px; }
  .hud-btns { gap: 5px; }
  .score-pill { padding: 3px; gap: 2px; }
  .side { padding: 5px 8px; gap: 5px; }
  .side .name { font-size: 10.5px; letter-spacing: 0; }
  .side b { font-size: 16px; }
  .dot { display: none; }
  .side .name { font-size: 10px; }
  .menu-logo { margin-top: 48px; }
  .menu-logo .wordmark { font-size: 30px; }
  .mid { display: none; }
  .turn { font-size: 10.5px; padding: 9px 12px; }
  .sheet { padding: 24px 18px 18px; }
  .ot small { font-size: 11.5px; }
  .sl { width: 64px; font-size: 10px; }
  .seg span { font-size: 12px; }
}
@media (max-height: 700px) {
  .opt { padding: 7px 10px; }
  .ico { width: 32px; height: 32px; }
  .seg span { min-height: 32px; }
  .cta { min-height: 46px; }
  .panel { padding: 14px 14px 10px; }
  .ptitle { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
#menu { backdrop-filter: none; -webkit-backdrop-filter: none; display: flex; align-items: center; justify-content: space-between; }

/* Кнопка удара: удерживать — сила, отпустить — удар */
.shot { --p: 0; position: relative; overflow: hidden; min-width: 112px; height: 52px; padding: 0 22px; border: 0; border-radius: var(--r-pill); background: linear-gradient(180deg, var(--gold-2), var(--gold) 55%, var(--gold-deep)); color: #22170b; font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .14em; box-shadow: 0 8px 24px rgba(214, 170, 92, .3), 0 1px 0 rgba(255, 255, 255, .5) inset; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; transition: transform 120ms var(--ease), filter 160ms var(--ease); }
.shot .shot-fill { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(var(--p)); background: linear-gradient(90deg, #f3d9a4, #d2462f); opacity: .9; }
.shot .shot-t { position: relative; }
.shot.charging { transform: scale(1.05); }
.shot:disabled { filter: grayscale(.7) brightness(.55); box-shadow: none; }
.shot:not(:disabled) { animation: shotPulse 2.2s ease-in-out infinite; }
.shot.charging, .shot:disabled { animation: none; }
@keyframes shotPulse { 0%, 100% { box-shadow: 0 8px 24px rgba(214, 170, 92, .3); } 50% { box-shadow: 0 0 0 6px rgba(232, 200, 140, .18), 0 8px 28px rgba(214, 170, 92, .5); } }
.coach-card { max-width: 440px; }
.steps { list-style: none; margin: 6px 0 10px; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: st; }
.steps li { display: flex; gap: 14px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--glass-2); counter-increment: st; }
.st-ico { flex: none; width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; color: var(--gold-2); background: rgba(214, 170, 92, .1); position: relative; }
.st-ico::after { content: counter(st); position: absolute; top: -6px; left: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--gold); color: #22170b; font: 700 11px/20px var(--font-display); text-align: center; font-style: normal; }
.steps b { display: block; font-size: 15px; margin-bottom: 2px; }
.steps small { font-size: 13px; color: var(--ink-2); line-height: 1.35; }
.coach-pro { font-size: 12.5px; color: var(--ink-3); margin: 0 0 4px; text-align: center; }
.howto { margin: 0 0 12px; }
@media (max-width: 520px) {
  .controls { grid-template-columns: 1fr auto; gap: 4px 8px; padding-left: 10px; padding-right: 10px; }
  .controls .turn { display: none; }
  .shot { min-width: 96px; height: 48px; padding: 0 16px; font-size: 14px; }
  .hint { font-size: 12px; }
}
#coach { display: grid; place-items: center; } #coach[hidden] { display: none; } .coach-card { margin: auto; width: min(440px, 100%); }

/* окна поверх игры не заходят под кнопки шапки: крестик не лежит над «Меню» */
#rules, #coach { padding-top: calc(64px + env(safe-area-inset-top)); place-items: start center; }
@media (min-height: 820px) { #rules, #coach { place-items: center; } }
#rules .sheet, #coach .sheet { max-height: calc(100dvh - 80px - env(safe-area-inset-top)); }
