:root {
  --bg: #0a0c18;
  --panel: #141a33;
  --panel2: #1c2345;
  --line: #2b3566;
  --text: #eef0f8;
  --muted: #9aa3c7;
  --amber: #ffb020;
  --cyan: #3dd6f5;
  --gold: #ffe15d;
  --red: #f2545b;
  --green: #4cd97b;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
body { background: radial-gradient(1200px 600px at 20% -10%, #1d2a66 0%, transparent 60%),
  radial-gradient(900px 500px at 110% 110%, #3a1d4f 0%, transparent 55%), var(--bg); }
#app { position: fixed; inset: 0; }
.view { position: absolute; inset: 0; display: none; flex-direction: column; }
.view.on { display: flex; }
button { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; cursor: pointer; touch-action: manipulation; }
button:active { transform: translateY(1px); filter: brightness(1.2); }
button:disabled { opacity: .45; }
input, select { font: inherit; color: var(--text); background: #0d1124; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--cyan); border-color: transparent; }
h1 { font-size: 20px; margin: 0; letter-spacing: .5px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 2px; color: var(--gold); margin: 0 0 12px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 18px 0 8px; }
.big { width: 100%; font-weight: 800; font-size: 17px; letter-spacing: 1px; padding: 14px; border: 0; text-transform: uppercase; }
.amber { background: linear-gradient(180deg, #ffc451, #f09a0c); color: #2a1600; }
.cyan { background: linear-gradient(180deg, #6fe4fb, #1fb3d8); color: #00222b; }
.danger { background: #3a1420; border-color: #6b2333; color: #ffb3b8; }
.err { color: var(--red); min-height: 1.2em; margin: 6px 0; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; }
.center { text-align: center; }

.auth { margin: auto; width: min(380px, 92vw); padding: calc(20px + var(--safe-t)) 0 20px; }
#v-auth { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.logo { width: 100%; max-height: 24vh; object-fit: contain; display: block; margin: 0 auto 10px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button { flex: 1; background: transparent; }
.tabs button.on { background: var(--panel2); border-color: var(--cyan); color: var(--cyan); }
#f-auth label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
#f-auth label input { margin-top: 4px; }
.auth:not(.register) .only-register { display: none; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + var(--safe-t)) calc(14px + var(--safe-r)) 10px calc(14px + var(--safe-l));
  background: rgba(10, 12, 24, .7); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.top > * { flex: 0 0 auto; }
.top h1 { flex: 1; text-align: center; }
.logo-s { height: 40px; }
.me { display: flex; flex-direction: column; align-items: flex-end; padding: 6px 12px; line-height: 1.15; }
.me span { font-size: 12px; color: var(--gold); }
.back { background: transparent; border-color: transparent; padding-left: 0; color: var(--muted); }
.scroll { flex: 1; overflow-y: auto; padding: 14px calc(14px + var(--safe-r)) calc(20px + var(--safe-b)) calc(14px + var(--safe-l));
  -webkit-overflow-scrolling: touch; }
.scroll > * { max-width: 860px; margin-left: auto; margin-right: auto; }
.card { background: linear-gradient(180deg, rgba(28, 35, 69, .92), rgba(20, 26, 51, .92)); border: 1px solid var(--line);
  border-radius: 18px; padding: 16px; margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 720px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.join { display: flex; gap: 8px; margin-top: 10px; }
.join input { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 800; font-size: 20px; width: 40%; }
.join button { flex: 1; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .who { font-weight: 700; }
.list .meta { font-size: 12px; color: var(--muted); }
.list .empty { color: var(--muted); justify-content: center; }
.online { color: var(--muted); font-size: 14px; margin: 0; }
.online b { color: var(--green); font-weight: 600; }
.bottom { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.code-box { text-align: center; line-height: 1; }
.code-box small { display: block; font-size: 10px; letter-spacing: 3px; color: var(--muted); }
.code-box b { font-size: 28px; letter-spacing: 6px; color: var(--gold); }
.share { padding: 8px 12px; }
.seats { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 4px auto 10px; }
.seat { border-radius: 16px; padding: 14px; min-height: 96px; border: 2px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.seat.p1 { border-color: rgba(255, 176, 32, .5); }
.seat.p2 { border-color: rgba(61, 214, 245, .5); }
.seat .n { font-weight: 800; font-size: 18px; word-break: break-word; }
.seat.p1 .n { color: var(--amber); }
.seat.p2 .n { color: var(--cyan); }
.seat .e { font-size: 13px; color: var(--muted); }
.seat .st { margin-top: 6px; font-size: 12px; font-weight: 700; letter-spacing: 1px; padding: 3px 10px; border-radius: 99px; background: #0d1124; color: var(--muted); }
.seat .st.ok { background: rgba(76, 217, 123, .15); color: var(--green); }
.seat.empty .n { color: var(--muted); font-weight: 500; font-size: 15px; }
.vs { font-weight: 900; color: var(--muted); }
.ready { margin: 6px auto 14px; display: block; max-width: 420px; }
.ready.on { background: linear-gradient(180deg, #74eb9b, #2dbb62); color: #002910; }
.opts .orow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.opts .orow:last-child { border-bottom: 0; }
.opts .orow > span { font-size: 14px; }
.opts .orow small { display: block; color: var(--muted); font-size: 12px; }
.seg { display: inline-flex; background: #0d1124; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: 0 0 auto; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 7px 11px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--panel2); color: var(--gold); font-weight: 700; }
.seg.ro button:not(.on) { display: none; }

table.board { width: 100%; border-collapse: collapse; font-size: 15px; }
.board td, .board th { padding: 9px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.board th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.board td.num, .board th.num { text-align: right; font-variant-numeric: tabular-nums; }
.board tr.mine td { color: var(--gold); }
.board .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-left: 6px; vertical-align: middle; }
.board a { color: inherit; text-decoration: none; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.kpi { background: #0d1124; border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.kpi b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12px; }
.win { color: var(--green); }
.loss { color: var(--red); }

.choice { display: grid; gap: 8px; }
.choice button { text-align: left; display: block; }
.choice button small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.choice button.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.slider, .sel { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.slider input { flex: 1; padding: 0; accent-color: var(--gold); }
.sel select { flex: 1; }
.pw { display: grid; gap: 8px; margin-bottom: 14px; }

.game { background: #000; touch-action: none; user-select: none; -webkit-user-select: none; }
#screen { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.pad { position: absolute; inset: 0; pointer-events: none; display: none; }
.pad.on { display: block; }
.pad > div { position: absolute; display: flex; gap: 10px; pointer-events: none; }
.pb { pointer-events: auto; border-radius: 50%; width: 76px; height: 76px; font-size: 22px; font-weight: 900;
  background: rgba(28, 35, 69, .78); border: 2px solid rgba(154, 163, 199, .45); color: var(--text); padding: 0; touch-action: none; }
.pb.held { background: rgba(255, 225, 93, .35); border-color: var(--gold); }
.pb.fire { width: 92px; height: 92px; font-size: 15px; background: rgba(240, 154, 12, .75); border-color: var(--amber); color: #2a1600; }
.pb.swap { font-size: 12px; width: 62px; height: 62px; align-self: flex-end; }
.quit { position: absolute; top: calc(6px + var(--safe-t)); right: calc(6px + var(--safe-r)); width: 38px; height: 38px; border-radius: 50%;
  padding: 0; background: rgba(10, 12, 24, .6); border-color: rgba(154, 163, 199, .3); color: var(--muted); font-size: 16px; }
.banner { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); background: rgba(10, 12, 24, .9);
  border: 1px solid var(--line); padding: 14px 20px; border-radius: 14px; text-align: center; font-weight: 700; }
.result { position: absolute; inset: 0; background: rgba(6, 8, 18, .86); display: flex; align-items: flex-start; justify-content: center;
  padding: 16px calc(16px + var(--safe-r)) 16px calc(16px + var(--safe-l)); overflow-y: auto; }
.result .card { width: min(560px, 100%); margin: auto; text-align: center; }
.result .title { font-size: 26px; font-weight: 900; margin: 4px 0; }
.result .score { font-size: 40px; font-weight: 900; letter-spacing: 4px; }
.result .delta { font-weight: 800; }
.result table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; }
.result td { padding: 5px 4px; border-bottom: 1px solid var(--line); }
.result td:first-child { text-align: left; color: var(--muted); }
.result td.a { color: var(--amber); text-align: right; font-weight: 700; }
.result td.c { color: var(--cyan); text-align: right; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translateX(-50%); background: #20284f;
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 50; max-width: 90vw; text-align: center; }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; z-index: 40; }
.modal .box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; width: min(360px, 90vw); }
[hidden] { display: none !important; }
@media (max-height: 520px) {
  .result .title { font-size: 20px; }
  .result .score { font-size: 28px; }
  .result table { font-size: 13px; margin: 6px 0; }
  .result td { padding: 3px 4px; }
  .result .big { padding: 10px; font-size: 15px; }
  .pb { width: 64px; height: 64px; }
  .pb.fire { width: 80px; height: 80px; }
}
.safe-probe { position: fixed; visibility: hidden; pointer-events: none; padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
.skip { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--safe-b)); font-weight: 700; background: rgba(10, 12, 24, .82); }
.seat::before { content: ""; width: 48px; height: 48px; background-size: 48px 48px; image-rendering: pixelated; margin-bottom: 4px; }
.seat.p1::before { background-image: url(/assets/ui/bub0.png); }
.seat.p2::before { background-image: url(/assets/ui/bob0.png); }
.seat.empty::before { opacity: .25; filter: grayscale(1); }
.online i { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; background: url(/assets/ui/b3.png) center / 14px; image-rendering: pixelated; }
.board .dot { background: url(/assets/ui/b3.png) center / 10px; width: 10px; height: 10px; image-rendering: pixelated; }
h2::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; background: url(/assets/ui/b2.png) center / 12px; image-rendering: pixelated; }
