/* XTS mobile game UI — design handoff v3 §02 (palette, type, components) and §03 (layout).
   One dark look by design; every colour comes from the tokens below. */

:root {
  --bg: #121614;
  --panel: #1d2321;
  --panel-2: #252c29;
  --line: #2f3734;
  --gold: #b99851;      /* champagne gold: primary actions, borders */
  --gold-hi: #ffe280;   /* highlight: self seat, live values */
  --silver: #b4c8d2;    /* secondary buttons, brand */
  --hero: #a4d7ff;      /* Hero identity only */
  --text: #f2f0e8;
  --text-2: #b5bbb5;
  --good: #8fd19e;
  --bad: #ff9a8a;

  --gold-grad: linear-gradient(180deg, #e9cf8c 0%, #c8a65e 45%, #a8873f 100%);
  --panel-grad: linear-gradient(180deg, #222927, #1a201e);

  --f-ui: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r-panel: 16px;
  --r-sheet: 24px;
  --tabs-h: 56px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(120% 40% at 50% 0%, #1b2220 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 14px/22px var(--f-ui);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
[hidden] { display: none !important; }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) calc(var(--tabs-h) + var(--s5) + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}

/* ------------------------------------------------------------ brand bar */
.top { height: 48px; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.logo { width: 104px; height: auto; display: block; }
.balance {
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: 36px; max-width: 60%;
  padding: 0 var(--s3) 0 var(--s2);
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel);
  font-size: 14px; line-height: 20px;
}
.balance span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coin { flex: none; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f6e2a6, var(--gold) 55%, #7d6430); }

.view { display: grid; gap: var(--s3); padding-top: var(--s3); }
.page-title { margin: var(--s2) 0 0; font-size: 24px; line-height: 32px; font-weight: 600; }

/* ------------------------------------------------------------ scenes */
.scenes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; min-height: 44px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); padding: 3px; }
.scene {
  border: 0; background: none; border-radius: 9px; color: var(--text-2);
  font-size: 14px; line-height: 20px; padding: 0 var(--s2); min-height: 38px;
  display: grid; place-items: center; text-align: center;
}
.scene[aria-selected="true"] { background: var(--gold-grad); color: #1c1608; font-weight: 600; box-shadow: inset 0 1px 0 rgba(255,255,255,.35); }
.scene .off { display: block; font-size: 12px; line-height: 16px; }
.scene:disabled { opacity: .55; }

/* ------------------------------------------------------------ round bar */
.round-bar { min-height: 40px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s3); padding: var(--s2) var(--s3); border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.round-id { display: flex; gap: var(--s3); align-items: baseline; flex-wrap: wrap; }
.round-id span:first-child { font-weight: 600; }
.occ { color: var(--text-2); }
.occ b { color: var(--gold-hi); font-weight: 600; font-size: 18px; }
.status { font-size: 12px; line-height: 18px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--gold); color: var(--gold-hi); white-space: nowrap; }
.status.full { border-color: var(--hero); color: var(--hero); }
.status.new { border-color: var(--line); color: var(--text-2); }

.mine { display: grid; gap: var(--s2); }
.mine-label { font-size: 12px; line-height: 18px; color: var(--text-2); }
.mine-list { display: flex; gap: var(--s2); overflow-x: auto; padding-bottom: 2px; }
.mine-chip { flex: none; min-height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); padding: 0 var(--s3); font-size: 12px; line-height: 18px; color: var(--text-2); }
.mine-chip[aria-current="true"] { border-color: var(--gold-hi); color: var(--text); }

/* ------------------------------------------------------------ arena */
.arena { position: relative; width: 100%; margin-top: var(--s1); }
.stage { position: absolute; inset: 0; pointer-events: none; }
.stage::before {
  content: ""; position: absolute;
  inset: var(--stage-inset, 22px);
  border-radius: var(--stage-radius, 28px);
  background:
    radial-gradient(60% 50% at 50% 55%, rgba(255, 226, 128, .10), transparent 70%),
    linear-gradient(180deg, #1f2624, #161b19);
  box-shadow: inset 0 0 0 1px rgba(185, 152, 81, .35), inset 0 10px 30px rgba(0,0,0,.45), 0 12px 30px -18px rgba(0,0,0,.9);
}
.arena[data-mode="ellipse"] .stage::before { border-radius: 50%; }
.arena[data-mode="grid"] .stage::before { inset: 0 0 auto 0; height: var(--mascot-h, 170px); border-radius: 50% / 40%; }

.mascot { position: absolute; margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; pointer-events: none; overflow: hidden; }
.mascot img { display: block; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 10px 14px rgba(0,0,0,.55)); user-select: none; }
.temp-tag { font-size: 12px; line-height: 18px; color: var(--text-2); opacity: .7; }
.arena.hero-reveal .mascot img { filter: drop-shadow(0 0 18px rgba(164, 215, 255, .55)) drop-shadow(0 10px 14px rgba(0,0,0,.55)); }

.seats { position: absolute; inset: 0; }
.seat {
  position: absolute; width: 44px; height: 44px; transform: translate(-50%, -50%);
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel-grad);
  display: grid; grid-template-rows: 14px 1fr; justify-items: center; align-items: center;
  padding: 2px 0 3px; color: var(--text-2);
  transition: box-shadow .2s, border-color .2s, transform .2s, opacity .2s;
}
.seat .no { font-size: 12px; line-height: 14px; color: var(--text-2); }
.seat svg { width: 18px; height: 18px; }
.seat .plus { stroke: currentColor; stroke-width: 2; fill: none; opacity: .7; }
.seat.taken { border-color: rgba(185, 152, 81, .7); background: linear-gradient(180deg, #3a3222, #262119); color: var(--gold-hi); }
.seat.taken .no { color: #e6d6a8; }
.seat.taken svg { fill: currentColor; }
.seat.self { border: 2px solid var(--gold-hi); box-shadow: 0 0 12px rgba(255, 226, 128, .45); }
.seat .badge {
  position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%);
  font-size: 12px; line-height: 16px; padding: 0 6px; border-radius: 6px; white-space: nowrap;
  background: var(--gold-hi); color: #1c1608; font-weight: 600;
}
.seat.hero { border: 2px solid var(--hero); color: var(--hero); box-shadow: 0 0 18px rgba(164, 215, 255, .6); }
.seat.hero .badge { background: var(--hero); color: #0d1a24; }
.seat.spot { transform: translate(-50%, -50%) scale(1.12); box-shadow: 0 0 0 3px rgba(255, 226, 128, .5), 0 0 26px rgba(255, 226, 128, .7); }
.seat.enter { animation: seat-in .24s ease-out; }
@keyframes seat-in { from { opacity: 0; transform: translate(-50%, -50%) scale(.96); } }
.arena.dim .seat:not(.spot):not(.hero) { opacity: .55; }

.focus-text {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 6px 14px; border-radius: 999px; background: rgba(18, 22, 20, .85); border: 1px solid var(--gold);
  font-size: 14px; line-height: 20px; color: var(--gold-hi); white-space: nowrap;
}

.remaining { margin: 0; text-align: center; color: var(--text-2); }
.remaining b { color: var(--gold-hi); }

/* ------------------------------------------------------------ entry */
.fee { min-height: 44px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0 6px; padding: var(--s2) var(--s3); border-radius: 12px; background: var(--panel); border: 1px solid var(--line); text-align: center; }
.fee b { color: var(--gold-hi); font-size: 18px; line-height: 26px; }

.btn-primary, .btn-secondary {
  min-height: 52px; padding: 0 20px; border: 0;
  font-size: 16px; line-height: 24px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  transition: transform 80ms, filter 120ms;
}
/* 6px cut corners; the touch area stays the full rectangle */
.btn-primary {
  color: #1c1608; background: var(--gold-grad);
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
}
.btn-primary:active:not(:disabled) { transform: translateY(1px); filter: brightness(.95); }
.btn-primary:disabled { filter: grayscale(.7) brightness(.6); }
.btn-primary.state-joined { background: var(--panel-2); color: var(--gold-hi); filter: none; box-shadow: inset 0 0 0 1px var(--gold); }
.btn-secondary { background: var(--panel-2); color: var(--silver); border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line); font-weight: 500; }
.btn-secondary:active { transform: translateY(1px); }
.btn-secondary.wide { width: 100%; margin-top: var(--s3); }
#join-btn { width: 100%; }

.rules { display: grid; justify-items: center; gap: 2px; text-align: center; color: var(--text-2); font-size: 12px; line-height: 18px; }
.rules p { margin: 0; }
.link { background: none; border: 0; color: var(--silver); min-height: 44px; padding: 0 var(--s3); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }

/* ------------------------------------------------------------ panels */
.panel { border-radius: var(--r-panel); background: var(--panel); border: 1px solid var(--line); padding: var(--s4); }
.label { font-size: 12px; line-height: 18px; color: var(--text-2); }
.amount { font-size: 32px; line-height: 40px; font-weight: 600; }
.hint { margin: 0; font-size: 12px; line-height: 18px; color: var(--text-2); }
.sec { margin: var(--s3) 0 0; font-size: 18px; line-height: 26px; font-weight: 600; }
.notice { margin: 0; font-size: 12px; line-height: 18px; color: var(--text-2); padding: var(--s2) var(--s3); border-left: 2px solid var(--gold); }

.claim-hero { display: grid; justify-items: center; text-align: center; gap: var(--s1); }
.claim-cat { width: 120px; height: 120px; object-fit: contain; margin-bottom: var(--s2); }
.claim-hero .amount { color: var(--gold-hi); }
.claim-hero .btn-primary { width: 100%; margin-top: var(--s3); }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; padding: var(--s3); }
.stats3 > div { display: grid; gap: 2px; }
.stats3 > div + div { border-left: 1px solid var(--line); }
.stats3 b { font-size: 18px; line-height: 26px; font-weight: 600; }
.plans { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.plan { border-radius: 12px; background: var(--panel); border: 1px solid var(--line); padding: var(--s3); display: grid; gap: 6px; }
.plan-top, .plan-bottom { display: flex; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; font-size: 12px; line-height: 18px; color: var(--text-2); }
.plan-top b { color: var(--text); font-size: 14px; font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: #0f1312; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--gold); border-radius: 3px; }
.empty { color: var(--text-2); text-align: center; padding: var(--s5) var(--s3); border: 1px dashed var(--line); border-radius: 12px; }

.wallet-main { display: grid; gap: var(--s1); }
.wallet-sub { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin: var(--s3) 0; padding-top: var(--s3); border-top: 1px solid var(--line); }
.wallet-sub > div { display: grid; }
.wallet-sub b { font-size: 18px; line-height: 26px; font-weight: 600; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }

.rows { list-style: none; margin: 0; padding: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--panel); }
.rows li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--s3); padding: var(--s3) var(--s4); border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.rows li.none { display: block; text-align: center; color: var(--text-2); }
.rows .sub { font-size: 12px; line-height: 18px; color: var(--text-2); }
.rows .val { text-align: right; }
.rows .plus { color: var(--good); }
.tag { font-size: 12px; line-height: 18px; padding: 0 8px; border-radius: 999px; border: 1px solid currentColor; justify-self: end; align-self: center; }
.tag.hero { color: var(--hero); }
.tag.pending { color: var(--gold-hi); }
.tag.paid { color: var(--good); }
.tag.rejected { color: var(--bad); }
.tag.open { color: var(--text-2); }

.me-card { display: grid; gap: 2px; }
.me-card b { font-size: 18px; line-height: 26px; }
.settings { padding: 0 var(--s4); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 56px; border-top: 1px solid var(--line); }
.set-row:first-child { border-top: 0; }
.link-row { width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; padding: 0; text-align: left; color: var(--text); }
.seg { display: inline-flex; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); padding: 2px; }
.seg button { border: 0; background: none; color: var(--text-2); min-height: 36px; min-width: 56px; padding: 0 var(--s3); border-radius: 8px; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--gold); }

/* ------------------------------------------------------------ tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  padding: 0 max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
  background: rgba(16, 20, 18, .96); border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.tab { flex: 1; max-width: 140px; height: var(--tabs-h); border: 0; background: none; color: var(--text-2); display: grid; place-items: center; align-content: center; gap: 2px; font-size: 12px; line-height: 16px; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tab svg .dot { fill: currentColor; stroke: none; }
.tab[aria-current="page"] { color: var(--gold-hi); font-weight: 600; }
.tab[aria-current="page"] svg { stroke-width: 2; }

/* ------------------------------------------------------------ sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; animation: fade .22s ease-out; }
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0; background: #1a201e; border: 1px solid var(--line); border-bottom: 0;
  padding: var(--s4) max(20px, env(safe-area-inset-right, 0px)) calc(var(--s5) + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  animation: rise .22s ease-out;
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s3); }
.sheet-head h2 { margin: 0; font-size: 18px; line-height: 26px; }
.sheet-head h2.hero-title { color: var(--hero); font-size: 24px; line-height: 32px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: none; display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; stroke: var(--text-2); stroke-width: 2; stroke-linecap: round; }
.sheet-body { display: grid; gap: var(--s3); }
.kv { display: grid; gap: 0; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.kv div { display: flex; justify-content: space-between; gap: var(--s3); padding: 10px var(--s4); border-top: 1px solid var(--line); }
.kv div:first-child { border-top: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; }
.kv .total dd { color: var(--gold-hi); font-size: 18px; font-weight: 600; }
.kv .neg dd { color: var(--text-2); }
.kv .pos dd { color: var(--good); }
.note { margin: 0; font-size: 12px; line-height: 18px; color: var(--text-2); }
.err { margin: 0; min-height: 18px; font-size: 12px; line-height: 18px; color: var(--bad); }
.sheet .btn-primary, .sheet .btn-secondary { width: 100%; }
.big-num { text-align: center; font-size: 32px; line-height: 40px; font-weight: 600; }
.big-num small { font-size: 14px; color: var(--text-2); font-weight: 400; margin-left: 4px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 12px; line-height: 18px; color: var(--text-2); }
.input-wrap { display: flex; align-items: center; gap: var(--s2); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px 6px 4px 14px; }
.input-wrap:focus-within { border-color: var(--gold); }
.input-wrap input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font: 600 20px/28px var(--f-ui); padding: 8px 0; }
.input-wrap input.text { font-weight: 400; font-size: 16px; }
.input-wrap .btn-secondary { min-height: 36px; padding: 0 12px; font-size: 14px; }
.quote { display: flex; justify-content: space-between; align-items: baseline; padding: var(--s3) var(--s4); border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.quote b { font-size: 20px; color: var(--gold-hi); }
.steps { margin: 0; padding-left: 20px; display: grid; gap: var(--s3); }

/* ------------------------------------------------------------ toast */
.toast {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 60;
  max-width: calc(100% - 32px); padding: 8px 16px; border-radius: 12px;
  background: #222a27; border: 1px solid var(--line); color: var(--text); font-size: 14px; line-height: 20px; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.toast.bad { border-color: #6b3a33; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
