:root {
  --gold: #e6b65c; --gold-soft: #f4dcae; --ink: #0d0805; --panel: rgba(16,10,6,.82);
  --line: rgba(230,182,92,.34); --text: #f5ecdc; --muted: #b8a78e;
  --green: #17a35a; --red: #c43a31; --amber: #e29a1d;
  --serif: Georgia, "DejaVu Serif", "Liberation Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "DejaVu Sans", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--text); font-family: var(--sans); }
button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#loading { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--ink); color: var(--gold); font: 20px var(--serif); padding: 20px; text-align: center; }
.load-box { width: min(380px, 100%); }
.load-title { font: 800 32px var(--serif); margin-bottom: 18px; letter-spacing: .02em; }
.load-bar { height: 10px; border-radius: 99px; background: rgba(230,182,92,.16); border: 1px solid var(--line); overflow: hidden; }
#load-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #d6962f, #f2c76f); transition: width .2s linear; }
.load-text { margin-top: 12px; font: 14px var(--sans); color: var(--gold-soft); font-variant-numeric: tabular-nums; }

/* Начален екран */
#splash { position: fixed; inset: 0; z-index: 40; background: var(--ink); }
#splash > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#splash .shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.82), transparent 46%); }
#splash .panel { position: absolute; left: 0; right: 0; bottom: max(28px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 0 16px; }
.stake-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; color: var(--gold-soft); font-size: 14px; }
#stakes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.stake { min-height: 40px; padding: 6px 14px; border-radius: 9px; border: 1px solid var(--line); background: rgba(0,0,0,.55); color: var(--gold-soft); font-weight: 700; font-size: 14px; transition: background .15s; }
.stake:hover { background: rgba(70,44,14,.8); }
.stake.on { background: var(--gold); color: #1a1006; border-color: var(--gold); }
#play { padding: 14px 54px; border: 0; border-radius: 12px; background: linear-gradient(#f2c76f, #d6962f); color: #1a1006; font: 800 20px var(--sans); letter-spacing: .02em; box-shadow: 0 8px 26px rgba(214,150,47,.4); transition: filter .15s; }
#play:hover { filter: brightness(1.08); }
#splash-info { color: var(--gold-soft); font-size: 14px; }

/* Слой върху сцената: кликовете минават към камерата, освен върху контролите */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud button, #hud input, #hud label, #log { pointer-events: auto; }

#top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: 10px 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); background: linear-gradient(to bottom, rgba(0,0,0,.6), transparent); }
.spacer { flex: 1; }
.group { display: inline-flex; align-items: center; gap: 6px; }
.check { cursor: pointer; }
.check input { accent-color: var(--amber); width: 15px; height: 15px; }
.pill { display: inline-block; padding: 3px 11px; border-radius: 99px; font-weight: 700; font-size: 13px; color: #fff; }
.pill.round { background: rgba(10,30,18,.86); color: #6ee7b7; border: 1px solid rgba(110,231,183,.3); padding: 5px 16px; font-size: 14px; }
.pill.gold { background: var(--amber); color: #1a1006; }
.lv-weak { background: var(--green); } .lv-medium { background: var(--amber); color: #1a1006; } .lv-strong { background: var(--red); }
.icon { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 17px; }
.icon:hover { background: rgba(70,44,14,.9); }

.tag { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; will-change: transform; transition: opacity .25s; }
.tag .row, #me { display: flex; align-items: center; gap: 7px; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 3px 13px 3px 3px; }
.ava { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.55); display: block; }
.meta { line-height: 1.15; white-space: nowrap; }
.name { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.chips { font-size: 13px; color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.dbtn { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: #fff; color: #111; font-size: 9px; }
.tag.active .row, #me.active { border-color: #ffd166; box-shadow: 0 0 16px 3px rgba(255,190,70,.7); animation: pulse 1s ease-in-out infinite; }
.tag.winner .row, #me.winner { border-color: #ffd166; background: rgba(120,78,12,.92); box-shadow: 0 0 20px 5px rgba(255,190,70,.75); }
.tag.folded { opacity: .55; } #me.folded { opacity: .6; }
.tag.out .ava { filter: grayscale(1); } .tag.out { opacity: .6; } .tag.out .chips { color: #fca5a5; }
@keyframes pulse { 50% { box-shadow: 0 0 7px 1px rgba(255,190,70,.4); } }
.badge { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 5px; color: #fff; white-space: nowrap; }
.badge:empty { display: none; }
.a-fold { background: #c43a31; } .a-check { background: #566273; } .a-call { background: #15935a; }
.a-bet, .a-raise { background: var(--amber); color: #1a1006; }
.mini { display: flex; gap: 3px; }
.mini-card { background: #fbf7ec; color: #14181f; border-radius: 4px; padding: 1px 5px; font-weight: 800; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.6); }
.mini-card.red { color: #c81e1e; }

.bet-label, .pot { position: absolute; left: 0; top: 0; will-change: transform; }
.bet-label { font-size: 12px; font-weight: 800; color: var(--gold-soft); background: rgba(0,0,0,.62); padding: 1px 7px; border-radius: 99px; }
.pot { display: inline-flex; gap: 4px; align-items: center; padding: 3px 13px; border-radius: 99px; background: rgba(0,0,0,.66); border: 1px solid var(--line); color: var(--gold); font-weight: 800; font-size: 18px; line-height: 1; }
.num { display: inline-flex; font-variant-numeric: tabular-nums; }
.reel { display: inline-block; overflow: hidden; height: 1em; width: .62em; }
.strip { display: flex; flex-direction: column; transition: transform .65s cubic-bezier(.22,1,.36,1); }
.strip span { height: 1em; line-height: 1em; text-align: center; }

#log { position: absolute; left: 12px; top: 64px; width: 204px; max-height: 30vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
#log-head { padding: 7px 11px; font-size: 12px; font-weight: 700; color: var(--gold); cursor: pointer; }
#log.collapsed #log-list { display: none; }
#log-list { list-style: none; margin: 0; padding: 0 9px 8px; overflow-y: auto; font-size: 12px; }
#log-list li { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 2px 0; }
#log-list .sep { justify-content: center; color: var(--muted); font-size: 11px; }
#log-list .sep.street { color: #6ee7b7; font-weight: 700; }
#log-list .badge { font-size: 10px; }

#adv { position: absolute; right: 12px; top: 64px; width: 230px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.adv-btn { min-height: 38px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-weight: 600; font-size: 13px; }
.adv-btn.on { background: var(--green); border-color: var(--green); }
.adv-panel { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: 13px; }
.adv-row { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; color: var(--muted); }
.adv-row b { color: var(--text); }
.adv-bar { height: 7px; border-radius: 9px; background: rgba(255,255,255,.14); overflow: hidden; margin: 7px 0; }
.adv-fill { height: 100%; } .adv-fill.good { background: var(--green); } .adv-fill.mid { background: var(--amber); } .adv-fill.bad { background: var(--red); }
.adv-tip { border-radius: 8px; padding: 6px 8px; font-weight: 700; }
.adv-tip.good { background: rgba(23,163,90,.25); color: #86efac; } .adv-tip.mid { background: rgba(226,154,29,.25); color: #fcd34d; } .adv-tip.bad { background: rgba(196,58,49,.28); color: #fca5a5; }
.adv-note { margin: 7px 0 0; color: var(--muted); font-size: 11px; }

#art { position: absolute; left: 50%; top: 43%; width: min(44vw, 460px); transform: translate(-50%,-50%) scale(.5); opacity: 0; filter: drop-shadow(0 0 28px rgba(251,191,36,.45)); }
#art.show { animation: art-in .55s cubic-bezier(.2,1.4,.4,1) forwards; }
@keyframes art-in { to { transform: translate(-50%,-50%) scale(1); opacity: 1; } }
#winner { position: absolute; left: 50%; bottom: 118px; transform: translateX(-50%); padding: 8px 20px; border-radius: 12px; background: rgba(0,0,0,.78); border: 1px solid rgba(230,182,92,.6); color: var(--gold); font-weight: 800; font-size: 17px; white-space: nowrap; max-width: calc(100vw - 24px); overflow: hidden; text-overflow: ellipsis; }

#over { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: min(560px, calc(100vw - 32px)); padding: 24px; text-align: center; background: rgba(12,7,4,.93); border: 2px solid var(--gold); border-radius: 16px; pointer-events: auto; }
#over-msg { font: 800 24px var(--serif); color: var(--gold); margin-bottom: 14px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.stats b { color: var(--text); }
.over-btns { display: flex; gap: 10px; justify-content: center; }

#dock { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; padding: 26px 14px max(12px, env(safe-area-inset-bottom)); background: linear-gradient(to top, rgba(0,0,0,.72), transparent); }
#me .ava { width: 48px; height: 48px; }
#next-note { color: var(--gold-soft); font-size: 14px; }
#controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.act { min-height: 46px; min-width: 96px; padding: 8px 18px; border-radius: 11px; border: 1px solid transparent; font-weight: 800; font-size: 15px; color: #fff; transition: filter .12s, opacity .12s; }
.act:not(:disabled):hover { filter: brightness(1.13); }
.act:disabled { opacity: .38; cursor: not-allowed; }
.act.fold { background: #8e2a23; } .act.call { background: #15935a; } .act.raise { background: var(--amber); color: #1a1006; }
.act.glow { box-shadow: 0 0 14px 2px rgba(52,211,153,.6); }
#raise-box { display: flex; flex-direction: column; gap: 5px; width: 230px; }
#raise-range { width: 100%; accent-color: var(--amber); height: 20px; }
.presets { display: flex; gap: 5px; }
.presets button { flex: 1; min-height: 30px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--gold-soft); font-weight: 700; font-size: 12px; }
.presets button:disabled { opacity: .4; cursor: not-allowed; }

@media (max-width: 760px) {
  #top { gap: 7px; padding: 8px; }
  .check { display: none; }
  #log { width: 168px; top: 104px; }
  #adv { top: 104px; width: 190px; }
  .ava { width: 30px; height: 30px; }
  .tag .row { padding-right: 9px; }
  .name { font-size: 11px; } .chips { font-size: 11.5px; }
  #dock { gap: 7px; padding-top: 12px; }
  #me .ava { width: 36px; height: 36px; }
  .act { min-width: 82px; padding: 8px 10px; }
  #raise-box { width: 100%; }
  #winner { font-size: 14px; bottom: 192px; }
  #art { width: 72vw; }
}
@media (prefers-reduced-motion: reduce) {
  .tag.active .row, #me.active { animation: none; }
  .strip { transition: none; }
}
