:root {
  --ink: #0f1c31;
  --ink-2: #172a46;
  --ink-3: #1f3758;
  --glass: rgba(13, 24, 43, 0.76);
  --glass-2: rgba(13, 24, 43, 0.52);
  --fill: rgba(255, 255, 255, 0.06);
  --fill-2: rgba(255, 255, 255, 0.1);
  --fill-3: rgba(255, 255, 255, 0.16);
  --line: rgba(255, 255, 255, 0.1);
  --line-2: rgba(255, 255, 255, 0.2);
  --text: #f5f8fc;
  --muted: rgba(235, 242, 252, 0.66);
  --faint: rgba(235, 242, 252, 0.42);
  --accent: #ffb547;
  --accent-2: #ff9330;
  --accent-ink: #3a2300;
  --accent-soft: rgba(255, 181, 71, 0.14);
  --sea: #5fd4e6;
  --good: #5fd88f;
  --bad: #ff6b6b;
  --blue: #2f7bf6;
  --radius: 16px;
  --r-sm: 10px;
  --r-lg: 22px;
  --sh-1: 0 2px 10px rgba(0, 0, 0, 0.22);
  --sh-2: 0 18px 50px rgba(0, 0, 0, 0.42);
  --display: 'Jua', 'Fredoka', ui-rounded, system-ui, sans-serif;
  --ui: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, sans-serif;
  --num: 'Fredoka', 'Pretendard Variable', ui-rounded, system-ui, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text); font-family: var(--ui); overflow: hidden; overscroll-behavior: none; -webkit-font-smoothing: antialiased; letter-spacing: -0.005em; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: 0.5; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { flex: none; }

#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; touch-action: none; }
#stage canvas.world { position: absolute; inset: 0; display: block; touch-action: none; }
#screens { position: absolute; inset: 0; pointer-events: none; }
#screens > * { pointer-events: auto; }

/* ---------- shared ---------- */

.screen { position: absolute; inset: 0; display: flex; animation: fade-in 0.28s ease both; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.big {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px;
  min-height: 50px; padding: 10px 18px; border-radius: 14px; background: var(--fill-2);
  border: 1px solid var(--line); text-align: left; font-weight: 650; font-size: 16px;
  transition: transform 0.12s ease, background 0.2s, border-color 0.2s;
}
.big:active:not(:disabled) { transform: scale(0.97); }
.big small { font-weight: 500; font-size: 13px; color: var(--muted); }
.primary { background: linear-gradient(180deg, #ffc86c, #ff9d2e); color: var(--accent-ink); border-color: transparent; box-shadow: 0 6px 18px rgba(255, 157, 46, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.55); }
.primary small { color: rgba(58, 35, 0, 0.72); }
.danger { color: #ffd0d0; background: rgba(255, 107, 107, 0.14); }
h1, h2, h3, h4 { margin: 0; font-family: var(--display); font-weight: 400; letter-spacing: 0; }
.hidden { display: none !important; }
@media (hover: hover) {
  .big:hover:not(:disabled):not(.primary), .cta:hover:not(.primary), .rig-tile:hover, .map-card:hover, .rung:hover, .home-links button:hover, .ladder-card:hover { background: var(--fill-3); }
  .primary:hover:not(:disabled) { filter: brightness(1.05); }
}

.seg { display: flex; gap: 2px; background: rgba(0, 0, 0, 0.25); border-radius: 999px; padding: 3px; border: 1px solid var(--line); }
.seg button { flex: 1 1 0; padding: 6px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 650; color: var(--muted); min-height: 34px; white-space: nowrap; transition: background 0.18s, color 0.18s; }
.seg button small { font-size: 11.5px; font-weight: 500; color: var(--faint); margin-left: 4px; }
.seg .on { background: var(--text); color: var(--ink); box-shadow: var(--sh-1); }
.seg .on small { color: rgba(15, 28, 49, 0.6); }
.seg.wide { border-radius: 14px; }
.seg.wide button { border-radius: 11px; min-height: 42px; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.tag.ok { background: rgba(95, 216, 143, 0.16); color: var(--good); }
.tag.next { background: var(--accent); color: var(--accent-ink); }
.pips { display: inline-flex; gap: 4px; }
.pips i { width: 18px; height: 6px; border-radius: 3px; background: var(--fill-3); }
.pips i.on { background: linear-gradient(90deg, var(--accent), var(--accent-2)); box-shadow: 0 0 8px rgba(255, 157, 46, 0.45); }

/* ---------- home ---------- */

.home { flex-direction: column; justify-content: center; padding: calc(16px + var(--sat)) calc(24px + var(--sar)) calc(16px + var(--sab)) calc(24px + var(--sal)); background: linear-gradient(90deg, rgba(9, 18, 34, 0.86) 0%, rgba(9, 18, 34, 0.55) 38%, rgba(9, 18, 34, 0) 70%); }
.home-top { position: absolute; top: calc(14px + var(--sat)); left: calc(18px + var(--sal)); right: calc(18px + var(--sar)); display: flex; justify-content: space-between; align-items: center; gap: 12px; pointer-events: none; }
.home-top > * { pointer-events: auto; }
.home-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; animation: rise 0.45s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
.logo { display: flex; align-items: center; gap: 12px; }
.logo-mark canvas { display: block; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35)); }
.wordmark { display: flex; flex-direction: column; }
.wordmark small { font: 700 12px var(--num); letter-spacing: 0.32em; color: var(--accent); margin-left: 2px; }
.logo h1 { font-size: clamp(42px, min(10vh, 13vw), 72px); line-height: 1; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.22), 0 10px 30px rgba(0, 0, 0, 0.3); }
.tagline { margin: 0; font-size: 15px; line-height: 1.5; color: var(--muted); max-width: 34ch; text-wrap: pretty; word-break: keep-all; }
.home-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.cta { display: flex; align-items: center; gap: 14px; min-height: 66px; padding: 10px 14px 10px 12px; border-radius: 18px; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); text-align: left; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: transform 0.12s, background 0.2s; }
.cta:active { transform: scale(0.98); }
.cta-ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.1); }
.cta.primary { background: linear-gradient(180deg, #ffc86c, #ff9d2e); border-color: transparent; color: var(--accent-ink); box-shadow: 0 8px 22px rgba(255, 157, 46, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.55); }
.cta.primary .cta-ico { background: rgba(255, 255, 255, 0.35); }
.cta-ico svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cta-txt { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.cta-txt b { font-size: 18px; font-weight: 750; }
.cta-txt small { font-size: 13px; color: var(--muted); font-weight: 500; }
.cta.primary .cta-txt small { color: rgba(58, 35, 0, 0.72); }
.chev svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0.7; }
.ladder-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 14px; background: var(--fill); border: 1px solid var(--line); text-align: left; transition: background 0.2s; }
.lc-txt { display: flex; flex-direction: column; }
.lc-txt small { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.lc-txt b { font-size: 15px; font-weight: 750; }
.home-links { display: flex; gap: 8px; }
.home-links button { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 12px; color: var(--muted); font-weight: 650; font-size: 14px; background: var(--fill); transition: background 0.2s, color 0.2s; }
.home-links button:hover { color: var(--text); }
.home-links svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lang-switch { background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.lang-switch button { padding: 5px 12px; min-height: 30px; flex: none; }

/* ---------- setup ---------- */

.setup { flex-direction: column; background: radial-gradient(120% 90% at 20% 0%, rgba(34, 64, 104, 0.9), rgba(11, 21, 38, 0.95) 60%); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.bar { display: flex; align-items: center; gap: 12px; padding: calc(12px + var(--sat)) calc(18px + var(--sar)) 10px calc(18px + var(--sal)); }
.bar h2 { font-size: 24px; white-space: nowrap; }
.back { width: 42px; height: 42px; border-radius: 12px; background: var(--fill-2); display: grid; place-items: center; flex: none; transition: background 0.2s; }
.back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.back:hover { background: var(--fill-3); }
.summary { flex: 1; min-width: 0; display: flex; gap: 6px; overflow: hidden; justify-content: flex-end; }
.summary span { padding: 5px 10px; border-radius: 999px; background: var(--fill); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.start { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 20px 0 24px; border-radius: 13px; font-weight: 800; font-size: 17px; flex: none; }
.start svg { width: 16px; height: 16px; fill: currentColor; }
.setup-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(240px, 0.8fr) 1.6fr; gap: 18px; padding: 4px calc(18px + var(--sar)) calc(16px + var(--sab)) calc(18px + var(--sal)); }
.hero { align-self: start; max-height: 100%; display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--r-lg); background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)); border: 1px solid var(--line); overflow-y: auto; animation: rise 0.35s ease both; }
.hero-pic { height: 132px; display: grid; place-items: center; border-radius: 16px; background: radial-gradient(60% 70% at 50% 80%, rgba(255, 200, 120, 0.25), transparent 70%), radial-gradient(90% 60% at 50% 100%, rgba(95, 212, 230, 0.18), transparent 70%); }
.hero-pic canvas { filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.35)); }
.hero-head h3 { font-size: 26px; }
.hero-head p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.45; word-break: keep-all; }
.hero-shots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.shot-card { position: relative; display: flex; flex-direction: column; gap: 1px; padding: 8px 10px 8px 34px; border-radius: 12px; background: var(--fill); border: 1px solid var(--line); }
.shot-card kbd { position: absolute; left: 9px; top: 10px; }
.shot-card b { font-size: 13.5px; font-weight: 700; }
.shot-card small { font: 600 11px var(--num); color: var(--muted); }
.shot-card.two b { color: #ffd59a; }
.hero-stats { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.bars { display: grid; gap: 6px; }
.stat { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.stat em { font-style: normal; }
.stat i { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) calc(var(--v) * 100%), var(--fill-2) 0); }
.hero-win { display: flex; align-items: center; gap: 6px; }
.hero-win span { display: flex; flex-direction: column; line-height: 1.2; }
.hero-win small { font-size: 11px; color: var(--muted); font-weight: 600; }
.hero-win b { font: 600 15px var(--num); }
.warc-bg { fill: rgba(255, 255, 255, 0.07); }
.warc-on { fill: rgba(255, 181, 71, 0.55); stroke: var(--accent); stroke-width: 1.2; }

.picker { display: flex; flex-direction: column; min-height: 0; gap: 10px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); align-self: flex-start; }
.tabs button { padding: 7px 18px; border-radius: 10px; font-weight: 700; font-size: 14.5px; color: var(--muted); transition: background 0.18s, color 0.18s; }
.tabs button.on { background: var(--fill-3); color: var(--text); }
.pane { display: none; flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 2px 2px 8px; }
.pane.on { display: block; animation: rise 0.25s ease both; }
.rig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.rig-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px 9px; border-radius: 16px; background: var(--fill); border: 1.5px solid transparent; transition: background 0.18s, border-color 0.18s, transform 0.12s; }
.rig-tile:active { transform: scale(0.97); }
.rig-tile .pic { width: 56px; height: 56px; }
.rig-tile b { font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.rig-tile.on, .map-card.on, .rung.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px rgba(255, 181, 71, 0.12); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 10px; }
.map-card { display: flex; flex-direction: column; gap: 6px; padding: 6px 6px 9px; border-radius: 16px; background: var(--fill); border: 1.5px solid transparent; text-align: left; transition: background 0.18s, border-color 0.18s, transform 0.12s; }
.map-card:active { transform: scale(0.98); }
.map-card .thumb { display: block; aspect-ratio: 160 / 72; border-radius: 11px; overflow: hidden; background: linear-gradient(180deg, #3b6ea8, #9cc6e8); }
.map-card .thumb canvas { display: block; width: 100%; height: 100%; }
.map-txt { display: flex; flex-direction: column; gap: 1px; padding: 0 4px; min-width: 0; }
.map-txt b { font-size: 14px; font-weight: 700; }
.map-txt small { font-size: 11.5px; color: var(--muted); line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field h4 { font: 700 13px var(--ui); color: var(--muted); letter-spacing: 0.02em; }
.ladder { display: grid; gap: 6px; }
.rung { display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; border-radius: 14px; background: var(--fill); border: 1.5px solid transparent; text-align: left; transition: background 0.18s, border-color 0.18s; }
.rung-n { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font: 700 15px var(--num); background: var(--fill-2); flex: none; }
.rung.done .rung-n { background: rgba(95, 216, 143, 0.2); color: var(--good); }
.rung.on .rung-n { background: var(--accent); color: var(--accent-ink); }
.rung-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rung-txt b { font-size: 14.5px; font-weight: 700; }
.rung-txt small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 900px) { .summary { visibility: hidden; } }
@media (max-height: 500px) {
  .bar { padding-top: calc(8px + var(--sat)); padding-bottom: 6px; }
  .bar h2 { font-size: 20px; }
  .setup-body { grid-template-columns: minmax(210px, 0.75fr) 1.6fr; gap: 12px; padding-bottom: calc(10px + var(--sab)); }
  .hero { padding: 10px; gap: 8px; }
  .hero-pic { height: 74px; }
  .hero-pic canvas { width: 76px !important; height: 76px !important; }
  .hero-head h3 { font-size: 19px; }
  .hero-head p { font-size: 12px; }
  .shot-card { padding: 6px 8px 6px 30px; }
  .shot-card kbd { top: 8px; left: 7px; }
  .shot-card b { font-size: 12.5px; }
  .hero-stats .warc { width: 40px; height: 40px; }
  .stat { font-size: 11px; grid-template-columns: 36px 1fr; }
  .tabs button { padding: 5px 14px; font-size: 13.5px; }
  .rig-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
  .rig-tile { padding: 6px 4px 7px; }
  .rig-tile .pic { width: 46px; height: 46px; }
  .rig-tile .pic canvas { width: 46px !important; height: 46px !important; }
  .rig-tile b { font-size: 12.5px; }
  .map-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .field { margin-bottom: 10px; gap: 6px; }
  .rung { padding: 6px 10px 6px 6px; }
  .rung-n { width: 28px; height: 28px; }
  .seg.wide button { min-height: 38px; }
}

/* ---------- modal sheets ---------- */

.modal { align-items: center; justify-content: center; background: rgba(5, 11, 22, 0.58); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); padding: calc(12px + var(--sat)) 16px calc(12px + var(--sab)); }
.sheet { width: min(420px, 100%); max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 22px; border-radius: 24px; background: linear-gradient(180deg, #213a5c, #15263f); border: 1px solid var(--line-2); box-shadow: var(--sh-2), inset 0 1px 0 rgba(255, 255, 255, 0.08); animation: pop 0.3s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
.sheet.wide { width: min(520px, 100%); }
@keyframes pop { from { transform: scale(0.94) translateY(6px); opacity: 0; } }
.sheet h2 { font-size: 28px; text-align: center; }
.sheet .big { align-items: center; text-align: center; }
.sheet .row { display: flex; gap: 10px; flex-wrap: wrap; }
.sheet .row .big { flex: 1 1 0; white-space: nowrap; }
.toggles { display: flex; flex-direction: column; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px; border-bottom: 1px solid var(--line); font-weight: 550; font-size: 15px; }
.toggle-row:last-child { border-bottom: 0; }
.switch { width: 50px; height: 30px; border-radius: 999px; background: var(--fill-3); position: relative; transition: background 0.2s; flex: none; }
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s cubic-bezier(0.3, 1.4, 0.5, 1); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
.switch.on { background: var(--good); }
.switch.on i { transform: translateX(20px); }
.howto ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; line-height: 1.55; font-size: 15px; word-break: keep-all; }
.howto ol li::marker { color: var(--accent); font-weight: 700; }
.result-head { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.result-head > small { font-size: 12.5px; font-weight: 650; color: var(--muted); }
.result-title { font-size: 48px !important; line-height: 1; }
.result.win .result-title { color: var(--accent); text-shadow: 0 0 28px rgba(255, 181, 71, 0.5); }
.result.lose .result-title { color: #b9c6dc; }
.cleared { margin: 0; padding: 6px 14px; border-radius: 999px; background: rgba(95, 216, 143, 0.16); color: var(--good); font-weight: 700; font-size: 14px; animation: pop 0.4s 0.3s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
.result-ladder { display: flex; align-items: center; gap: 10px; }
.result-ladder small { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.board { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.board li { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; border-radius: 14px; background: var(--fill); border-left: 4px solid var(--team); animation: rise 0.3s ease both; }
.board li:nth-child(2) { animation-delay: 0.05s; }
.board li:nth-child(3) { animation-delay: 0.1s; }
.board li:nth-child(4) { animation-delay: 0.15s; }
.board li.out { opacity: 0.6; }
.board li.mvp { background: var(--accent-soft); }
.board .pic { width: 40px; height: 40px; flex: none; }
.board .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.board .who b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board .who small { font-size: 12px; color: var(--muted); }
.mvp-tag { background: var(--accent); color: var(--accent-ink); }
.board .num { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.board .num b { font: 600 18px var(--num); font-variant-numeric: tabular-nums; }
.board .num small { font-size: 10.5px; color: var(--muted); }
@media (max-height: 500px) {
  .result .sheet.wide { width: min(780px, 100%); display: grid; grid-template-columns: 0.8fr 1.25fr; grid-template-rows: 1fr auto; gap: 10px 16px; padding: 14px 16px; }
  .result .result-head { grid-row: 1 / 3; justify-content: center; }
  .result .board, .result .sheet .row { grid-column: 2; }
  .result .board { margin: 0; gap: 4px; }
  .result-title { font-size: 38px !important; }
  .board li { padding: 3px 10px 3px 4px; }
  .board .pic { width: 30px; height: 30px; }
  .board .pic canvas { width: 30px !important; height: 30px !important; }
  .board .who b { font-size: 13.5px; }
  .board .num b { font-size: 15px; }
  .board .num small { display: none; }
  .result .sheet .row .big { min-height: 42px; padding: 6px 10px; font-size: 14px; }
  .cleared { font-size: 12.5px; padding: 4px 10px; }
}
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stats-table th { font-weight: 500; color: var(--muted); font-size: 12px; text-align: right; padding: 4px; }
.stats-table td { padding: 7px 4px; border-top: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.stats-table td:first-child { text-align: left; font-weight: 600; }
.stats-table td:nth-child(2) { text-align: left; color: var(--muted); }
.stats-table tr.out td { opacity: 0.55; }

/* ---------- match HUD ---------- */

.hud { position: absolute; inset: 0; pointer-events: none; font-family: var(--ui); }
.hud > *, .hud button { pointer-events: auto; }
.panel, .hud-btn, .strip, .wind, .dials, .hud-left, .shot, .mv, .jump { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.hud-btn { width: 44px; height: 44px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); display: grid; place-items: center; box-shadow: var(--sh-1); transition: background 0.18s; }
.hud-btn:hover { background: rgba(30, 50, 80, 0.85); }
.hud-btn svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.hud-top { position: absolute; top: calc(10px + var(--sat)); left: calc(12px + var(--sal)); right: calc(12px + var(--sar)); display: flex; align-items: flex-start; gap: 10px; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.strip { display: flex; gap: 4px; padding: 4px; border-radius: 16px; background: var(--glass-2); border: 1px solid var(--line); box-shadow: var(--sh-1); }
.face { position: relative; width: 40px; height: 44px; border-radius: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: rgba(255, 255, 255, 0.05); opacity: 0.72; transition: opacity 0.25s, background 0.25s, transform 0.25s; }
.face canvas { width: 32px !important; height: 32px !important; }
.face .hpbar { width: 30px; height: 4px; border-radius: 2px; background: rgba(0, 0, 0, 0.35); overflow: hidden; }
.face .hpbar em { display: block; height: 100%; background: var(--team); border-radius: 2px; }
.face.now { opacity: 1; background: rgba(255, 255, 255, 0.16); box-shadow: inset 0 0 0 2px var(--accent); }
.face.me:not(.now) { box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.4); }
.wind { position: absolute; left: 50%; transform: translateX(-50%); display: grid; grid-template-columns: auto 96px auto; align-items: center; gap: 10px; padding: 6px 14px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); box-shadow: var(--sh-1); }
.wind-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.wind-num { font: 600 24px var(--num); min-width: 1.4em; text-align: center; font-variant-numeric: tabular-nums; }
.wind-arrow { height: 12px; border-radius: 6px; background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.14) 0 1px, transparent 1px 9.6px), rgba(255, 255, 255, 0.08); position: relative; display: flex; justify-content: center; }
.wind-arrow::before { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: rgba(255, 255, 255, 0.4); }
.wind-arrow i { position: absolute; left: 50%; top: 2px; height: 8px; max-width: 50%; width: 0; border-radius: 0 4px 4px 0; background: linear-gradient(90deg, #8fe3ff, #ffffff); transition: width 0.4s cubic-bezier(0.2, 1.2, 0.4, 1); }
.wind-arrow i::after { content: ''; position: absolute; right: -6px; top: -3px; border: 7px solid transparent; border-left: 7px solid #fff; border-right: 0; }
.wind-arrow.left i { left: auto; right: 50%; border-radius: 4px 0 0 4px; background: linear-gradient(270deg, #8fe3ff, #ffffff); }
.wind-arrow.left i::after { right: auto; left: -6px; border-left: 0; border-right: 7px solid #fff; }
.wind.calm .wind-arrow i::after { display: none; }

.banner { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%) scale(0.8); font-family: var(--display); font-size: clamp(28px, 7vh, 46px); color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3), 0 6px 24px rgba(0, 0, 0, 0.4); opacity: 0; pointer-events: none !important; white-space: nowrap; }
.banner.show { animation: banner 1.3s ease both; }
.banner.mine { color: var(--accent); }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); } 28% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1); } }
.toast { position: absolute; left: 50%; top: calc(66px + var(--sat)); transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); font-weight: 650; font-size: 14.5px; opacity: 0; pointer-events: none !important; white-space: nowrap; }
.toast.show { animation: toast 2.2s ease both; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -8px); } 12%, 82% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
.recenter { position: absolute; right: calc(12px + var(--sar)); top: calc(64px + var(--sat)); width: auto; padding: 0 14px; font-weight: 650; font-size: 13px; }

.aimonly { opacity: 0; transform: translateY(14px); transition: opacity 0.25s, transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1); pointer-events: none !important; }
.aimonly * { pointer-events: none !important; }
.hud.aiming .aimonly { opacity: 1; transform: none; pointer-events: auto !important; }
.hud.aiming .aimonly * { pointer-events: auto !important; }
/* Touch: two thumb clusters in the bottom corners; the space between stays the world. */
.controls { position: absolute; inset: 0; }
.hud.aiming .controls { pointer-events: none !important; }
.hud-left { position: absolute; left: calc(12px + var(--sal)); bottom: calc(10px + var(--sab)); display: flex; flex-direction: column; gap: 6px; width: 220px; padding: 6px; border-radius: 20px; background: var(--glass-2); border: 1px solid var(--line); box-shadow: var(--sh-1); }
.hud-right { position: absolute; right: calc(12px + var(--sar)); bottom: calc(10px + var(--sab)); display: flex; align-items: flex-end; gap: 10px; }
.hud.lefty .hud-left { left: auto; right: calc(12px + var(--sar)); }
.hud.lefty .hud-right { right: auto; left: calc(12px + var(--sal)); flex-direction: row-reverse; }
.shots { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border-radius: 15px; background: rgba(0, 0, 0, 0.22); }
.shot { position: relative; min-height: 46px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; backdrop-filter: none; -webkit-backdrop-filter: none; transition: background 0.18s, color 0.18s; color: var(--muted); }
.shot b { font-size: 13.5px; font-weight: 700; white-space: nowrap; color: var(--text); }
.shot small { font: 600 10.5px var(--num); color: var(--faint); }
.shot.on { background: var(--accent); color: var(--accent-ink); box-shadow: var(--sh-1); }
.shot.on b { color: var(--accent-ink); }
.shot.on small { color: rgba(58, 35, 0, 0.7); }
.move { display: grid; grid-template-columns: 48px 1fr 48px; gap: 6px; align-items: center; }
.mv { height: 48px; border-radius: 14px; background: var(--fill-2); display: grid; place-items: center; touch-action: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.mv:active { background: rgba(255, 255, 255, 0.25); }
.mv svg { width: 22px; height: 22px; stroke: #fff; stroke-width: 2.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.move .mid { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.jump { position: relative; height: 30px; border-radius: 10px; background: var(--fill-2); color: #fff; font-size: 12.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 5px; touch-action: manipulation; backdrop-filter: none; -webkit-backdrop-filter: none; }
.jump svg { width: 17px; height: 17px; stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.jump:active { background: rgba(255, 255, 255, 0.25); }
.jump:disabled { opacity: 0.35; }
.fuel { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 600; color: var(--muted); }
.fuel i { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
.fuel em { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #59d38a, #b5f08f); transition: width 0.15s; }
.nextturn { font-size: 11.5px; color: var(--muted); font-weight: 550; padding: 0 4px; min-height: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dials { display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 18px; background: var(--glass-2); border: 1px solid var(--line); box-shadow: var(--sh-1); }
.dial { display: grid; grid-template-columns: 30px 44px 56px 44px; align-items: center; gap: 2px; }
.dial span { font-size: 11px; color: var(--muted); font-weight: 700; text-align: center; }
.dial .val { font: 600 24px var(--num); text-align: center; font-variant-numeric: tabular-nums; }
.step { width: 44px; height: 44px; border-radius: 12px; background: var(--fill-2); font-size: 22px; font-weight: 600; touch-action: none; }
.step:active { background: rgba(255, 255, 255, 0.28); }
.pbar { position: relative; height: 6px; margin: 2px 4px 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); }
.pbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, #ffd36b, #ff8a3c 70%, #ff5a3c); }
.pbar .last { position: absolute; top: -7px; width: 0; height: 0; border: 5px solid transparent; border-top: 7px solid #fff; transform: translateX(-5px); }
.pad { position: relative; width: 124px; height: 120px; border-radius: 24px; background: radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02) 70%), var(--glass-2); border: 1px solid var(--line-2); touch-action: none; display: grid; place-items: center; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: border-color 0.2s, background 0.2s; }
.pad-cross { position: absolute; width: 48px; height: 48px; top: 26px; left: calc(50% - 24px); fill: none; stroke: rgba(255, 255, 255, 0.35); stroke-width: 2; stroke-linecap: round; }
.pad.active { border-color: var(--accent); background: rgba(255, 181, 71, 0.15); }
.pad-hint { position: absolute; bottom: 12px; left: 0; right: 0; font-size: 10.5px; color: var(--muted); text-align: center; font-weight: 650; white-space: nowrap; }
.pad.active .pad-hint, .pad.active .pad-cross { opacity: 0; }
.pad-dot { position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); opacity: 0; transition: opacity 0.15s; }
.pad.active .pad-dot { opacity: 1; }
.fire { position: relative; width: 88px; height: 88px; flex: none; border-radius: 50%; background: radial-gradient(circle at 50% 32%, #ff9466, #ec4a2e 58%, #b92c1c); box-shadow: 0 10px 24px rgba(232, 68, 43, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.45), inset 0 -4px 0 rgba(0, 0, 0, 0.2); display: grid; place-items: center; font-family: var(--display); font-size: 22px; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); transition: transform 0.1s, filter 0.2s; }
.fire:hover { filter: brightness(1.06); }
.fire:active { transform: scale(0.94); }
.fire .ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); }
.fire .ring circle { fill: none; stroke: rgba(255, 255, 255, 0.85); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 289; stroke-dashoffset: calc(289 * (1 - var(--left, 1))); transition: stroke 0.3s; }
.fire.urgent .ring circle { stroke: #ffd36b; }
.fire .secs { position: absolute; bottom: 11px; font: 700 12px var(--num); }
.fire.urgent { animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.05); } }

/* Shorter phones in landscape: tighten the clusters. */
@media (max-height: 400px) {
  .pad { width: 108px; height: 104px; }
  .pad-cross { top: 20px; }
  .fire { width: 80px; height: 80px; font-size: 20px; }
  .dial { grid-template-columns: 28px 40px 50px 40px; }
  .step { width: 40px; height: 40px; }
  .dial .val { font-size: 21px; }
  .hud-left { width: 200px; gap: 5px; padding: 5px; }
  .shot, .mv { min-height: 42px; height: 42px; }
  .face { width: 36px; height: 40px; }
  .face canvas { width: 28px !important; height: 28px !important; }
  .face .hpbar { width: 26px; }
}
@media (max-width: 720px) {
  .hud-left { width: 184px; }
  .shot b { font-size: 12.5px; }
  .pad { width: 96px; }
  .strip .face:nth-child(n + 5) { display: none; }
}

/* A computer: one control deck along the bottom, keys on every control. */
.hud.desk .controls { inset: auto; left: 0; right: 0; bottom: calc(14px + var(--sab)); margin: 0 auto; width: fit-content; max-width: calc(100vw - 24px); display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 10px; border-radius: 26px; background: var(--glass); border: 1px solid var(--line); box-shadow: var(--sh-2); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.hud.aiming.desk .controls { pointer-events: auto !important; }
.hud.desk .hud-left, .hud.desk .hud-right { position: static; }
.hud.desk .hud-left { flex-direction: row; align-items: center; width: auto; padding: 0; gap: 10px; background: none; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.hud.desk .shots { width: 220px; }
.hud.desk .move { width: 200px; }
.hud.desk .nextturn { display: none; }
.hud.desk .hud-right { align-items: center; gap: 12px; }
.hud.desk .dials { background: rgba(0, 0, 0, 0.18); box-shadow: none; border: 0; padding: 4px; backdrop-filter: none; -webkit-backdrop-filter: none; }
.hud.desk .dial { grid-template-columns: 30px 34px 52px 34px; }
.hud.desk .step { width: 34px; height: 34px; border-radius: 10px; font-size: 18px; }
.hud.desk .dial .val { font-size: 21px; }
.hud.desk .fire { width: 76px; height: 76px; font-size: 19px; }
.hud.desk .fire .secs { bottom: 9px; }
.hud.lefty.desk .hud-right { flex-direction: row; }
.hud.desk .recenter { top: calc(66px + var(--sat)); }
.hud.desk .nextdesk { display: block; }

/* ---------- portrait ---------- */

#rotate { position: absolute; inset: 0; display: none; place-items: center; text-align: center; background: rgba(10, 20, 38, 0.94); z-index: 10; }
#rotate > div { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px; }
#rotate b { font-family: var(--display); font-weight: 400; font-size: 24px; }
#rotate small { color: var(--muted); font-size: 15px; }
.phone-icon { width: 44px; height: 76px; border: 3px solid #fff; border-radius: 10px; animation: tilt 2s ease-in-out infinite; margin-bottom: 10px; }
@keyframes tilt { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (max-width: 600px) {
  .in-match #rotate { display: grid; }
  .home { align-items: flex-end; background: linear-gradient(0deg, rgba(10, 20, 38, 0.92) 0%, rgba(10, 20, 38, 0.6) 55%, rgba(10, 20, 38, 0) 85%); }
  .setup-body { grid-template-columns: 1fr; overflow-y: auto; }
  .summary { display: none; }
}

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

/* ---------- sign-in and profile ---------- */

.me-chip { display: flex; align-items: center; gap: 9px; padding: 4px 14px 4px 4px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); line-height: 1.2; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.me-chip > span:last-child { display: flex; flex-direction: column; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(180deg, #ffc86c, #ff9d2e); color: var(--accent-ink); font-weight: 800; font-size: 15px; }
.me-chip b { font-size: 14px; }
.me-chip small { font-size: 11.5px; color: var(--muted); }
.home-msg { margin: 0; padding: 10px 14px; border-radius: 12px; background: rgba(255, 107, 107, 0.16); color: #ffd6d6; font-size: 14px; }
.signin-title { font-size: 22px; margin-top: 4px; }
.tagline.small { font-size: 13.5px; }
.google { flex-direction: row; align-items: center; justify-content: center; gap: 12px; background: #fff; color: #1f1f1f; border-color: #fff; }
.google b { font-weight: 600; }
.g-logo { width: 20px; height: 20px; background: conic-gradient(from -45deg, #ea4335 0 25%, #4285f4 0 50%, #34a853 0 75%, #fbbc05 0); border-radius: 50%; -webkit-mask: radial-gradient(circle, transparent 0 4.5px, #000 5px); mask: radial-gradient(circle, transparent 0 4.5px, #000 5px); }
.fine { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.fine a, .home a { color: var(--text); }
.name-input, .code-input { width: 100%; min-height: 52px; padding: 0 16px; border-radius: 14px; border: 2px solid var(--line); background: rgba(0, 0, 0, 0.25); color: var(--text); font: 600 18px var(--ui); -webkit-user-select: text; user-select: text; }
.name-input:focus, .code-input:focus { outline: none; border-color: var(--accent); }
.code-input { letter-spacing: 0.3em; text-transform: uppercase; text-align: center; font-family: var(--display); font-size: 24px; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.join-row .big { align-items: center; }
.wait-note { margin: 0; color: var(--muted); font-size: 14px; text-align: center; align-self: center; flex: 1; }
#netbadge { position: absolute; left: 50%; bottom: calc(12px + var(--sab)); transform: translate(-50%, 20px); padding: 8px 16px; border-radius: 999px; background: rgba(255, 181, 71, 0.95); color: var(--accent-ink); font-weight: 700; font-size: 14px; opacity: 0; transition: all 0.3s; z-index: 20; pointer-events: none; }
#netbadge.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- lobby ---------- */

.lobby { flex-direction: column; background: radial-gradient(120% 90% at 20% 0%, rgba(34, 64, 104, 0.9), rgba(11, 21, 38, 0.95) 60%); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.lobby .code { font-family: var(--display); letter-spacing: 0.12em; color: var(--accent); }
.share { min-height: 44px; padding: 0 20px; border-radius: 12px; background: rgba(255, 255, 255, 0.12); font-weight: 700; }
.lobby-body { flex: 1; display: grid; grid-template-columns: 1.3fr 1fr; grid-template-areas: "seats opts" "chat opts"; align-content: start; gap: 4px 18px; padding: 4px calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal)); overflow-y: auto; }
.lobby-body .seats-col { grid-area: seats; }
.lobby-body .opts-col { grid-area: opts; }
.lobby-body .chat-col { grid-area: chat; }
.lobby-body h3 { font: 700 13px var(--ui); color: var(--muted); margin: 8px 0 8px; letter-spacing: 0.02em; }
.seats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.seat { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 14px; background: var(--fill); border: 1px solid var(--line); border-left: 4px solid var(--team); }
.seat.mine { background: rgba(255, 181, 71, 0.1); }
.seat.off { opacity: 0.55; }
.seat .pic { flex: none; width: 44px; height: 44px; }
.seat .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.seat .who b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .who b small { color: var(--muted); font-weight: 500; }
.seat .who > small { font-size: 11.5px; color: var(--muted); }
.wins { font-style: normal; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 11px; vertical-align: 2px; }
.chip { min-height: 36px; padding: 0 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.team { background: var(--team); color: #fff; }
.chip:disabled { opacity: 0.9; }
.rigpick { display: flex; align-items: center; gap: 2px; }
.rigname { min-width: 52px; text-align: center; font-size: 13px; font-weight: 600; }
.arrow { width: 36px; height: 36px; border-radius: 10px; background: rgba(255, 255, 255, 0.1); font-size: 22px; line-height: 1; }
.x { width: 36px; height: 36px; border-radius: 10px; font-size: 22px; color: var(--muted); }
.add-bot { margin-top: 8px; width: 100%; min-height: 44px; border-radius: 14px; border: 1.5px dashed rgba(255, 255, 255, 0.3); color: var(--muted); font-weight: 600; }
.start-match { margin-top: 14px; width: 100%; align-items: center !important; }
.lobby .opts-col .toggle-row { border: 0; }
.map-grid.small { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 6px; max-height: 236px; overflow-y: auto; padding: 2px; }
.map-grid.small .map-card { padding: 4px 4px 6px; border-radius: 12px; }
.map-grid.small .map-card .thumb { border-radius: 8px; }
.map-grid.small .map-txt small { display: none; }
.map-grid.small .map-txt b { font-size: 12.5px; }
.map-card:disabled { opacity: 1; }
.map-card:disabled:not(.on) { opacity: 0.6; }
.lobby .opts .opt, .lobby .opts { }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { flex: 1 1 0; min-width: 0; min-height: 42px; padding: 6px 10px; border-radius: 12px; background: var(--fill); border: 1.5px solid transparent; font-weight: 650; font-size: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; white-space: nowrap; transition: background 0.18s, border-color 0.18s; }
.opt small { font-size: 11px; color: var(--muted); font-weight: 500; }
.opt.on { border-color: var(--accent); background: var(--accent-soft); }
.ltoast { top: auto !important; bottom: calc(20px + var(--sab)); }

/* ---------- online HUD ---------- */

.away { position: absolute; left: 50%; bottom: calc(20px + var(--sab)); transform: translateX(-50%); min-height: 52px; padding: 0 24px; border-radius: 16px; font-weight: 700; font-size: 16px; background: linear-gradient(180deg, #ffc768, #ff9f2e); color: var(--accent-ink); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
@media (orientation: portrait) and (max-width: 600px) {
  .lobby-body { grid-template-columns: 1fr; grid-template-areas: "seats" "chat" "opts"; }
}
@media (min-width: 1100px) {
  .lobby-body { grid-template-columns: 1.25fr 1fr 1fr; grid-template-areas: "seats opts chat"; gap: 18px 28px; }
  .chat.dock .chat-log { height: clamp(220px, 52vh, 520px); }
}
/* Wide screens: keep menus at a readable width instead of stretching edge to edge. */
@media (min-width: 1100px) {
  .setup .bar, .lobby .bar, .setup-body, .lobby-body { width: 100%; max-width: 1240px; margin-left: auto; margin-right: auto; }
}

/* ---------- keyboard ---------- */

kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px; background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.2); border-bottom-width: 2px; font: 700 11px var(--num); color: var(--text); line-height: 1; white-space: nowrap; }
.hud:not(.desk) .deskonly { display: none !important; }
.hud-gap { flex: 1; }
.hud.desk .pad { display: none; }
.shot kbd { position: absolute; top: 4px; left: 5px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
.shot.on kbd { background: rgba(58, 35, 0, 0.18); border-color: rgba(58, 35, 0, 0.25); color: var(--accent-ink); }
.jump kbd { position: absolute; top: -7px; right: -5px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; background: var(--ink-2); }
.fire kbd { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); background: var(--ink-2); }
.gauge { display: flex; flex-direction: column; gap: 7px; width: clamp(200px, calc(100vw - 1040px), 420px); }
.gauge-bar { position: relative; height: 18px; border-radius: 9px; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(255, 255, 255, 0.2) calc(10% - 1px) 10%), rgba(0, 0, 0, 0.3); border: 1px solid var(--line); }
.gauge-bar .g-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 9px; background: linear-gradient(90deg, #ffd36b, #ff8a3c 70%, #ff5a3c); box-shadow: 0 0 12px rgba(255, 138, 60, 0.5); }
.gauge-bar .g-last { position: absolute; top: -9px; width: 0; height: 0; border: 6px solid transparent; border-top: 8px solid #fff; transform: translateX(-6px); }
.gauge-keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px 10px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.gauge-keys span { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.gauge-keys kbd { min-width: 17px; height: 17px; font-size: 10px; padding: 0 4px; }
@media (max-width: 1099px) { .gauge { display: none !important; } }
@media (min-width: 1100px) { .hud.desk .pbar { display: none; } }
.keys-sheet { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 32px)); max-height: calc(100% - 120px); overflow-y: auto; padding: 18px 20px; border-radius: 20px; background: linear-gradient(180deg, #213a5c, #172a45); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); z-index: 6; animation: pop 0.22s ease both; }
.keys-sheet h3 { font-size: 22px; margin-bottom: 10px; }
.keys-sheet dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; align-items: center; }
.keys-sheet dt { display: flex; gap: 4px; align-items: center; justify-content: flex-end; }
.keys-sheet dt i { font-style: normal; color: var(--muted); }
.keys-sheet dd { margin: 0; font-size: 14px; }

/* ---------- chat ---------- */

.chat-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; -webkit-user-select: text; user-select: text; }
.chat-log li { width: fit-content; max-width: 100%; padding: 4px 10px; border-radius: 10px; background: rgba(10, 18, 32, 0.62); font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; transition: opacity 0.8s; }
.chat-log li b { margin-right: 6px; font-weight: 700; color: #cfe0f5; }
.chat-log li.me b::after { content: ''; }
.chat-log li.emote span { color: #ffe2b0; }
.chat-log li.sys { color: var(--muted); font-size: 13px; background: rgba(10, 18, 32, 0.4); }
.chat-quick { display: flex; flex-wrap: wrap; gap: 5px; }
.chat-quick button { display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.1); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chat-quick kbd { min-width: 16px; height: 16px; font-size: 10px; padding: 0 3px; }
@media not ((hover: hover) and (pointer: fine)) { .chat-quick kbd { display: none; } }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin: 0; }
.chat-input { min-width: 0; min-height: 42px; padding: 0 12px; border-radius: 12px; border: 2px solid var(--line); background: rgba(0, 0, 0, 0.3); color: var(--text); font: 500 15px var(--ui); -webkit-user-select: text; user-select: text; }
.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-send { padding: 0 14px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; }
.chat.float { position: absolute; left: calc(10px + var(--sal)); top: calc(62px + var(--sat)); width: min(400px, 44vw); display: flex; flex-direction: column; gap: 6px; z-index: 4; pointer-events: none; }
.chat.float .chat-log { max-height: 30vh; overflow: hidden; justify-content: flex-end; }
.chat.float li.old { opacity: 0; }
.chat.float:not(.open) li:nth-last-child(n + 4) { display: none; }
.chat.float:not(.open) .chat-quick, .chat.float:not(.open) .chat-form, .chat.float.open:not(.typing) .chat-form { display: none; }
.chat.float.open { pointer-events: auto; padding: 8px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.chat.float.open li { opacity: 1; transition: none; }
.chat.dock kbd { display: none; }
.chat.float.open .chat-log { max-height: 34vh; overflow-y: auto; justify-content: flex-start; }
.chat.dock { display: flex; flex-direction: column; gap: 8px; }
.chat.dock .chat-log { height: clamp(110px, 26vh, 260px); overflow-y: auto; padding: 8px; border-radius: 14px; background: rgba(0, 0, 0, 0.2); }
.chat.dock .chat-log li { background: rgba(255, 255, 255, 0.06); }
.chat.dock .chat-log:empty::before { content: attr(data-empty); color: var(--muted); font-size: 13px; padding: 4px; }
.no-chat .chat, .no-chat .chat-col { display: none !important; }
@media (max-height: 400px) {
  .chat.float { top: calc(54px + var(--sat)); }
  .chat.float:not(.open) .chat-log li { font-size: 12.5px; padding: 3px 8px; }
  .chat.float.open .chat-log { max-height: 26vh; }
  .chat-quick button { min-height: 30px; }
}

/* Lobby seats on short phones: longer rig names must not squeeze the player's name. */
.seat .who { min-width: 72px; }
.rigname { max-width: 104px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-height: 500px) {
  .seat { gap: 6px; padding: 4px 6px; }
  .seat .pic { width: 36px; height: 36px; }
  .seat .pic canvas { width: 36px !important; height: 36px !important; }
  .seat .chip { min-height: 32px; padding: 0 10px; font-size: 12px; }
  .seat .arrow, .seat .x { width: 30px; height: 30px; font-size: 18px; }
  .rigname { min-width: 0; max-width: 80px; font-size: 12px; }
}
@media (max-width: 720px) {
  .wind { grid-template-columns: 64px auto; gap: 7px; padding: 6px 10px; left: 62%; }
  .wind-label { display: none; }
}

/* The secret code box in the solo menu, and the note when Wookie helped. */
.code-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 0; }
.code-box { min-width: 0; min-height: 46px; padding: 0 14px; border-radius: 13px; border: 1.5px solid var(--line); background: rgba(0, 0, 0, 0.25); color: var(--text); font: 600 15px var(--ui); -webkit-user-select: text; user-select: text; }
.code-box:focus { outline: none; border-color: var(--accent); }
.code-row .big { min-height: 46px; padding: 0 18px; }
.cheat-note { margin: 0; padding: 5px 12px; border-radius: 999px; background: rgba(255, 207, 51, 0.16); color: #ffd84a; font-weight: 650; font-size: 13px; }
@media (max-height: 500px) {
  .sheet { padding: 14px 18px; gap: 8px; }
  .sheet h2 { font-size: 22px; }
  .toggle-row { min-height: 40px; font-size: 14px; }
  .sheet .big { min-height: 42px; }
}
