:root {
  --ink: #1c140d;
  --ink-2: #2b2016;
  --sand: #f3e2bf;
  --sand-2: #e7cf9c;
  --bronze: #c98a3a;
  --bronze-2: #e3a857;
  --blood: #b5302a;
  --red: #e63946;
  --blue: #3a86ff;
  --muted: #a8977a;
  --panel: rgba(28, 20, 13, 0.92);
  --line: rgba(227, 168, 87, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--sand); font-family: 'Rubik', system-ui, sans-serif; }
body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
input { -webkit-user-select: text; user-select: text; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto; touch-action: pan-y;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 0%, rgba(201,138,58,0.35), transparent 60%), rgba(18, 12, 8, 0.78);
  backdrop-filter: blur(3px);
}
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.home-panel { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.logo { font-family: 'Cinzel', serif; font-weight: 900; font-size: clamp(34px, 8vw, 48px); line-height: 1; margin: 0; letter-spacing: 1px; color: var(--sand); text-shadow: 0 3px 0 var(--blood); }
.logo span { color: var(--bronze-2); }
.tagline { margin: 0 0 6px; color: var(--sand-2); line-height: 1.45; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input {
  font: 500 18px 'Rubik', sans-serif; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #120c07; color: var(--sand); outline: none;
}
.field input:focus { border-color: var(--bronze-2); box-shadow: 0 0 0 3px rgba(227,168,87,0.25); }
#codeInput { text-transform: uppercase; letter-spacing: 6px; font-family: 'Cinzel', serif; font-weight: 700; }
.join-row { display: flex; gap: 10px; align-items: flex-end; }
.grow { flex: 1; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.error { color: #ff8a80; min-height: 1em; margin: 0; }

.btn {
  font: 700 16px 'Rubik', sans-serif; padding: 13px 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--ink-2); color: var(--sand); transition: transform .08s, background .15s;
  min-height: 48px;
}
.btn:hover { background: #3a2b1d; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--bronze-2); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, var(--bronze-2), var(--bronze)); color: var(--ink); border-color: transparent; }
.btn-primary:hover { background: linear-gradient(180deg, #f0b866, #d4943f); }
.btn-small { font-size: 14px; padding: 9px 12px; min-height: 40px; }
.btn.on { background: var(--sand); color: var(--ink); }

/* ---------- lobby ---------- */
.lobby-wrap { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 14px; margin: auto; }
.lobby-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); }
.room-code { font-family: 'Cinzel', serif; font-weight: 900; font-size: 40px; letter-spacing: 8px; color: var(--bronze-2); line-height: 1.1; }
.mode-box { margin-left: auto; }
.mode-box-2 { margin-left: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: 4px; }
.seg button { font: 600 14px 'Rubik', sans-serif; padding: 10px 14px; background: transparent; color: var(--sand-2); border: 0; cursor: pointer; min-height: 40px; }
.seg button.on { background: var(--bronze-2); color: var(--ink); }
.seg button:disabled { cursor: default; }
.lobby-grid { display: grid; grid-template-columns: minmax(240px, 1fr) 2.2fr; gap: 14px; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; min-width: 0; }
.col h2 { font-family: 'Cinzel', serif; font-size: 18px; margin: 0 0 12px; }
.player-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.player-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,0.04); font-size: 15px; }
.player-list li.me { outline: 1px solid var(--bronze-2); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.p-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-cls { font-size: 12px; color: var(--muted); }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: rgba(255,255,255,0.08); }
.badge.ready { background: #2f6b3a; color: #d9ffd9; }
.badge.host { background: var(--bronze); color: var(--ink); }
.badge.red { background: var(--red); color: #fff; }
.badge.blue { background: var(--blue); color: #fff; }
.badge.off { background: #555; }
.x-btn { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; min-width: 32px; min-height: 32px; }
.x-btn:hover { color: #ff8a80; }
.swap-btn { background: none; border: 1px solid var(--line); color: var(--sand-2); border-radius: 6px; font-size: 11px; cursor: pointer; padding: 3px 6px; }
.host-tools, .team-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.team-pick { margin-top: 10px; }
.team-red { background: var(--red); border-color: transparent; color: #fff; }
.team-blue { background: var(--blue); border-color: transparent; color: #fff; }

.class-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.class-card {
  text-align: left; font: inherit; color: inherit; cursor: pointer; border-radius: 12px; padding: 12px;
  background: rgba(255,255,255,0.035); border: 2px solid transparent; display: flex; flex-direction: column; gap: 6px; position: relative;
}
.class-card:hover { background: rgba(255,255,255,0.07); }
.class-card:focus-visible { outline: 3px solid var(--bronze-2); outline-offset: 2px; }
.class-card.selected { border-color: var(--bronze-2); background: rgba(227,168,87,0.12); }
.class-card .swatch { height: 6px; border-radius: 3px; }
.class-card h3 { font-family: 'Cinzel', serif; font-size: 17px; margin: 0; }
.class-card .role { font-size: 12px; color: var(--bronze-2); text-transform: uppercase; letter-spacing: 1px; }
.class-card .stats { font-size: 12px; color: var(--muted); }
.class-card p { margin: 0; font-size: 12.5px; line-height: 1.35; color: var(--sand-2); }
.class-card p b { color: var(--sand); }
.class-card .pickers { display: flex; gap: 3px; flex-wrap: wrap; min-height: 12px; }
.class-card .pickers .dot { width: 10px; height: 10px; }

.lobby-foot { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 20px; display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; }
.rules { margin: 0; flex: 1; min-width: 260px; font-size: 14px; color: var(--sand-2); }
.foot-btns { display: flex; gap: 10px; }
#startHint { width: 100%; margin: 0; }

/* ---------- results ---------- */
.results-panel { width: 100%; max-width: 560px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.winner { font-family: 'Cinzel', serif; font-size: clamp(26px, 6vw, 38px); margin: 0; color: var(--bronze-2); }
.team-result { font-family: 'Cinzel', serif; font-size: 28px; }
.score-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.score-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 500; padding: 6px; }
.score-table td { padding: 8px 6px; border-top: 1px solid var(--line); }
.score-table tr.me td { color: var(--bronze-2); font-weight: 700; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; font-weight: 500; }
.hud-top { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); text-align: center; }
.timer { font-family: 'Cinzel', serif; font-weight: 900; font-size: 32px; text-shadow: 0 2px 6px rgba(0,0,0,0.7); }
.timer.sudden { color: #ff6b5b; }
.zone-info { font-size: 13px; text-shadow: 0 1px 4px rgba(0,0,0,0.9); }
.team-scores { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; font-family: 'Cinzel', serif; font-weight: 900; font-size: 26px; text-shadow: 0 2px 6px rgba(0,0,0,0.6); }
.ts { padding: 2px 14px; border-radius: 8px; color: #fff; }
.ts.red { background: rgba(230,57,70,0.85); }
.ts.blue { background: rgba(58,134,255,0.85); }
.ts-sep { font-size: 14px; }
.score-list { position: absolute; top: 10px; left: 12px; margin: 0; padding: 8px 10px; list-style: none; background: rgba(18,12,8,0.6); border-radius: 10px; font-size: 13px; min-width: 150px; }
.score-list li { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.score-list li.me { color: var(--bronze-2); font-weight: 700; }
.score-list .s { margin-left: auto; font-variant-numeric: tabular-nums; }
.feed { position: absolute; top: 10px; right: 56px; margin: 0; padding: 0; list-style: none; font-size: 13px; text-align: right; }
.feed li { background: rgba(18,12,8,0.6); padding: 4px 9px; border-radius: 6px; margin-bottom: 4px; animation: fade 4s forwards; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
.center-msg { position: absolute; top: 30%; left: 0; right: 0; text-align: center; font-family: 'Cinzel', serif; font-weight: 900; font-size: clamp(40px, 10vw, 84px); text-shadow: 0 4px 0 var(--blood), 0 8px 24px rgba(0,0,0,0.6); }
.sub-msg { position: absolute; top: 46%; left: 0; right: 0; text-align: center; font-size: 20px; font-weight: 700; text-shadow: 0 2px 6px rgba(0,0,0,0.9); }
.crosshair { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 2px solid rgba(255,255,255,0.85); border-radius: 50%; box-shadow: 0 0 3px rgba(0,0,0,0.8); }
.zone-arrow { position: absolute; left: 50%; top: 50%; font-size: 30px; color: #fff3c4; text-shadow: 0 0 8px rgba(255,200,80,0.9); display: none; }
.me-box { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); width: min(360px, 60vw); text-align: center; }
.me-line { font-size: 13px; margin-bottom: 5px; text-shadow: 0 1px 4px rgba(0,0,0,0.9); }
.hp-bar { position: relative; height: 18px; border-radius: 9px; background: rgba(0,0,0,0.55); overflow: hidden; border: 1px solid rgba(255,255,255,0.2); }
#hpFill { height: 100%; width: 100%; background: linear-gradient(90deg, #4caf50, #8bc34a); transition: width .15s; }
#hpText { position: absolute; inset: 0; font-size: 12px; line-height: 18px; font-weight: 700; }
.cds { position: absolute; right: 16px; bottom: 16px; display: flex; gap: 10px; }
.cd { --p: 0; width: 72px; height: 72px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: conic-gradient(rgba(0,0,0,0.65) calc(var(--p) * 1turn), rgba(227,168,87,0.85) 0); border: 2px solid rgba(255,255,255,0.4); font-size: 11px; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }
.cd .key { font-weight: 700; font-size: 13px; }
.lock-hint { position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%); background: rgba(18,12,8,0.8); padding: 10px 16px; border-radius: 10px; font-size: 15px; }

#tags { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.tag { position: absolute; transform: translate(-50%, -100%); text-align: center; font-size: 12px; font-weight: 700; white-space: nowrap; text-shadow: 0 1px 3px rgba(0,0,0,0.9); }
.tag .bar { width: 56px; height: 6px; margin: 2px auto 0; border-radius: 3px; background: rgba(0,0,0,0.6); overflow: hidden; }
.tag .bar i { display: block; height: 100%; background: #e63946; }
.tag.ally .bar i { background: #4caf50; }
.dmg { position: absolute; transform: translate(-50%, -50%); font-family: 'Cinzel', serif; font-weight: 900; font-size: 18px; color: #fff; text-shadow: 0 2px 3px rgba(0,0,0,0.9); animation: rise .8s forwards; }
.dmg.mine { color: #ffd166; font-size: 22px; }
.dmg.txt { color: #9be7ff; font-size: 15px; }
@keyframes rise { to { transform: translate(-50%, -160%); opacity: 0; } }

/* ---------- touch ---------- */
#touch { position: fixed; inset: 0; z-index: 12; }
#joyZone { position: absolute; left: 0; top: 0; bottom: 0; width: 40%; touch-action: none; }
#lookZone { position: absolute; right: 0; top: 0; bottom: 0; width: 60%; touch-action: none; }
#joyBase { position: absolute; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.3); left: 60px; bottom: 50px; pointer-events: none; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px; border-radius: 50%; background: rgba(255,255,255,0.45); }
.tbtn { position: absolute; border-radius: 50%; border: 2px solid rgba(255,255,255,0.5); background: rgba(28,20,13,0.45); color: #fff; font-size: 28px; touch-action: none; --p: 0; }
.tbtn-atk { width: 86px; height: 86px; right: 24px; bottom: 30px; font-size: 34px; }
.tbtn-abl { width: 68px; height: 68px; right: 40px; bottom: 132px; background: conic-gradient(rgba(0,0,0,0.6) calc(var(--p) * 1turn), rgba(227,168,87,0.6) 0); }
.tbtn-jump { width: 64px; height: 64px; right: 128px; bottom: 26px; }
.tbtn:active { background: rgba(227,168,87,0.6); }
body.touch .cds { display: none; }
body.touch .me-box { bottom: 8px; width: min(280px, 40vw); }
body.touch .crosshair { width: 10px; height: 10px; margin: -5px 0 0 -5px; }
body.touch .score-list { font-size: 11px; min-width: 120px; }

/* ---------- settings ---------- */
.gear { position: fixed; top: 8px; right: 8px; z-index: 30; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: rgba(18,12,8,0.7); color: var(--sand); font-size: 20px; cursor: pointer; }
.settings { position: fixed; top: 56px; right: 8px; z-index: 31; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; width: 230px; font-size: 14px; }
.settings label { display: flex; flex-direction: column; gap: 4px; }
.settings label.check { flex-direction: row; align-items: center; gap: 8px; }

.rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  body.in-match .rotate { display: flex; position: fixed; inset: 0; z-index: 50; background: var(--ink); color: var(--sand); align-items: center; justify-content: center; font-size: 22px; padding: 24px; text-align: center; font-family: 'Cinzel', serif; }
}

@media (max-width: 860px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .class-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mode-box { margin-left: 0; }
  .room-code { font-size: 32px; }
}
@media (max-height: 500px) and (pointer: coarse) {
  .timer { font-size: 22px; }
  .center-msg { font-size: 48px; }
}

/* ---------- v2: teams, buffs, invite ---------- */
.team-green { background: #2ecc71; border-color: transparent; color: #08210f; }
.team-gold { background: #f4b400; border-color: transparent; color: #2a1d00; }
.team-btn.current { outline: 3px solid var(--sand); outline-offset: 2px; }
.team-pick .btn { flex: 1 1 45%; }
.badge.green { background: #2ecc71; color: #08210f; }
.badge.gold { background: #f4b400; color: #2a1d00; }
.ts.green { background: rgba(46,204,113,0.85); }
.ts.gold { background: rgba(244,180,0,0.9); }
.invite-box { display: flex; flex-direction: column; gap: 4px; }
.invite-url { font-size: 12px; color: var(--muted); -webkit-user-select: all; user-select: all; max-width: 280px; overflow-wrap: anywhere; }
.buffs { display: flex; justify-content: center; gap: 6px; min-height: 22px; margin-bottom: 4px; }
.buff { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; color: #1c140d; }
.buff.pw { background: #ff6b5b; }
.buff.sp { background: #ffd23f; }
.tag .icons { color: #ffd23f; margin-left: 3px; }
.score-list .star { color: #ffd23f; }
.join-row .btn-primary { min-width: 140px; }
.player-list li { flex-wrap: wrap; }
.player-list .p-name { min-width: 84px; }

/* ---------- v3: mobile full screen, no zoom, compact phone lobby ---------- */
html, body { height: 100%; height: 100dvh; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
* { touch-action: manipulation; }
#game, #touch, #touch * { touch-action: none; }
body { position: fixed; inset: 0; }
#game { height: 100dvh; }

/* keep HUD and controls clear of the notch / rounded corners */
.score-list { left: calc(12px + env(safe-area-inset-left)); }
.feed { right: calc(56px + env(safe-area-inset-right)); }
.gear { right: calc(8px + env(safe-area-inset-right)); }
.fs-btn { right: calc(56px + env(safe-area-inset-right)); }
.settings { right: calc(8px + env(safe-area-inset-right)); }
.cds { right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); }
.tbtn-atk { right: calc(24px + env(safe-area-inset-right)); bottom: calc(30px + env(safe-area-inset-bottom)); }
.tbtn-abl { right: calc(40px + env(safe-area-inset-right)); bottom: calc(132px + env(safe-area-inset-bottom)); }
.tbtn-jump { right: calc(128px + env(safe-area-inset-right)); bottom: calc(26px + env(safe-area-inset-bottom)); }
#joyZone { left: env(safe-area-inset-left); }
.screen { padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }

.ios-tip { width: 100%; margin: 0; padding: 8px 10px; border-radius: 10px; background: rgba(227,168,87,0.15); border: 1px solid var(--line); font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ios-tip .x-btn { margin-left: auto; }
.class-detail { display: none; }

/* phones (and any short landscape screen): compact lobby */
@media (max-height: 520px), (max-width: 600px) {
  .screen { align-items: flex-start; }
  .lobby-wrap { gap: 8px; padding-right: 44px; }
  .ios-tip { font-size: 12px; padding: 5px 8px; flex-wrap: nowrap; }
  .ios-tip .x-btn { min-height: 26px; padding: 0 4px; }
  .lobby-head { padding: 8px 12px; gap: 8px 12px; align-items: center; }
  .room-code { font-size: 26px; letter-spacing: 5px; }
  .seg button { padding: 6px 9px; min-height: 34px; font-size: 13px; }
  .btn-small { min-height: 36px; padding: 6px 10px; font-size: 13px; }
  .invite-url { display: none; }
  .lobby-grid { grid-template-columns: minmax(200px, 1fr) 2fr; gap: 8px; }
  .col { padding: 10px; }
  .col h2 { font-size: 15px; margin-bottom: 8px; }
  .player-list li { padding: 5px 8px; font-size: 13px; flex-wrap: nowrap; }
  .player-list .p-cls { display: none; }
  .player-list .p-name { min-width: 0; }
  .player-list .badge { font-size: 10px; padding: 2px 5px; }
  .class-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .class-card { padding: 7px; gap: 2px; min-height: 0; }
  .class-card h3 { font-size: 13px; }
  .class-card .role, .class-card .stats { font-size: 10px; letter-spacing: 0; }
  .class-card p { display: none; }
  .class-detail { display: block; margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: rgba(227,168,87,0.1); font-size: 12.5px; line-height: 1.4; color: var(--sand-2); }
  .class-detail b { color: var(--sand); }
  .lobby-foot { position: sticky; bottom: 0; z-index: 25; border-radius: 12px; box-shadow: 0 -8px 20px rgba(0,0,0,0.45); padding: 8px max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); gap: 6px 12px; }
  .lobby-foot .rules { display: none; }
  #startHint { width: auto; flex: 1; order: -1; }
  .foot-btns .btn { min-height: 44px; padding: 8px 16px; }
  .home-panel { padding: 18px; gap: 10px; }
  .logo { font-size: 32px; }
  .tagline { font-size: 14px; }
  .results-panel { padding: 16px; gap: 8px; }
  .score-table td { padding: 5px 6px; }
}
@media (max-width: 600px) {
  .lobby-grid { grid-template-columns: 1fr; }
}

/* ---------- v4: Kill the King ---------- */
.mode-info { margin: 10px 0 0; font-size: 13px; line-height: 1.4; color: var(--sand-2); }
.draft-panel { width: 100%; max-width: 860px; display: flex; flex-direction: column; gap: 10px; padding: 18px; margin: auto; }
.draft-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.draft-head h2 { font-family: 'Cinzel', serif; margin: 2px 0 0; font-size: 24px; }
.draft-timer { font-family: 'Cinzel', serif; font-weight: 900; font-size: 44px; line-height: 1; color: var(--bronze-2); text-align: center; min-width: 70px; }
.draft-timer small { display: block; font-size: 11px; letter-spacing: 2px; color: var(--muted); font-family: 'Rubik', sans-serif; }
.draft-timer.hurry { color: #ff6b5b; }
.draft-steps { margin: 0; padding-left: 20px; font-size: 13.5px; color: var(--sand-2); display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 18px; }
.form-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.form-seg button { font: 700 15px 'Rubik', sans-serif; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--ink-2); color: var(--sand); cursor: pointer; min-height: 40px; letter-spacing: 1px; }
.form-seg button.on { background: var(--bronze-2); color: var(--ink); border-color: transparent; }
.pitch { display: grid; grid-template-columns: 70px repeat(3, 1fr); gap: 8px; padding: 10px; border-radius: 12px; background: linear-gradient(90deg, rgba(255,255,255,0.03), rgba(255,255,255,0.07)); border: 1px solid var(--line); }
.pitch .lane { display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.pitch .lane-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); text-align: center; }
.pitch .king-spot { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; color: var(--bronze-2); text-align: center; gap: 2px; }
.pitch .king-spot span { font-size: 28px; }
.slot { font: inherit; color: inherit; text-align: left; border-radius: 9px; padding: 7px 9px; background: rgba(0,0,0,0.3); border: 2px solid transparent; cursor: pointer; display: flex; flex-direction: column; gap: 1px; min-height: 48px; }
.slot .s-cls { font-weight: 700; font-size: 14px; }
.slot .s-who { font-size: 11.5px; color: var(--muted); }
.slot.mine { background: rgba(227,168,87,0.22); }
.slot.mine .s-who { color: var(--bronze-2); font-weight: 700; }
.slot.human:not(.mine) .s-who { color: var(--sand); }
.slot.sel { border-color: var(--sand); }
.slot:focus-visible { outline: 3px solid var(--bronze-2); outline-offset: 2px; }
.draft-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; }
.slot-info { font-size: 14px; }
.draft-classes { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.draft-classes button, .death-classes button { font: 700 12.5px 'Rubik', sans-serif; padding: 8px 4px; border-radius: 8px; border: 2px solid transparent; background: rgba(255,255,255,0.06); color: var(--sand); cursor: pointer; min-height: 44px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.draft-classes button i, .death-classes button i { display: block; width: 22px; height: 5px; border-radius: 3px; }
.draft-classes button.on, .death-classes button.on { border-color: var(--bronze-2); background: rgba(227,168,87,0.18); }
.draft-classes button:disabled { opacity: 0.4; cursor: not-allowed; }
.draft-note { margin: 0; }

.king-bars { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); display: flex; gap: 14px; }
.kb { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,0.9); }
.kbar { width: 130px; height: 12px; border-radius: 6px; background: rgba(0,0,0,0.55); overflow: hidden; border: 1px solid rgba(255,255,255,0.3); }
.kbar i { display: block; height: 100%; width: 100%; transition: width .2s; }
.kb.red .kbar i { background: var(--red); }
.kb.blue .kbar i { background: var(--blue); }
.kb b { min-width: 30px; }
.timer.frenzy { color: #ff6b5b; animation: pulse .6s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }

.death { position: fixed; inset: 0; z-index: 15; display: flex; align-items: center; justify-content: center; background: rgba(20, 6, 6, 0.55); padding: 16px; }
.death-panel { width: 100%; max-width: 640px; max-height: 100%; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.death-title { font-family: 'Cinzel', serif; font-weight: 900; font-size: 26px; color: #ff8a80; }
.death-timer { font-size: 16px; }
.death-timer b { font-size: 26px; color: var(--bronze-2); }
.death-classes { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
.death-table-wrap { max-height: 180px; overflow-y: auto; }
.death-stats { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.death-stats th { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 500; text-align: left; padding: 3px 4px; }
.death-stats td { padding: 4px; border-top: 1px solid var(--line); }
.death-stats tr.me td { color: var(--bronze-2); font-weight: 700; }

@media (max-height: 520px), (max-width: 600px) {
  .draft-panel { padding: 10px 12px; gap: 6px; }
  .draft-head h2 { font-size: 18px; }
  .draft-timer { font-size: 32px; }
  .draft-steps { font-size: 11.5px; grid-template-columns: repeat(3, 1fr); }
  .pitch { grid-template-columns: 48px repeat(3, 1fr); padding: 6px; gap: 5px; }
  .slot { padding: 4px 6px; min-height: 36px; }
  .slot .s-cls { font-size: 12px; }
  .slot .s-who { font-size: 10px; }
  .draft-classes button, .death-classes button { font-size: 10.5px; min-height: 36px; padding: 4px 2px; }
  .draft-note { display: none; }
  .form-seg button { padding: 5px 9px; min-height: 34px; font-size: 13px; }
  .death-panel { padding: 10px; gap: 5px; }
  .death-title { font-size: 20px; }
  .death-table-wrap { max-height: 110px; }
  .king-bars { top: 44px; gap: 8px; }
  .kbar { width: 80px; }
}
@media (max-width: 600px) {
  .draft-classes, .death-classes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .draft-steps { grid-template-columns: 1fr; }
}

/* ---------- v4.1: draft layout fixes ---------- */
.draft-hint { display: none; margin: 0; font-size: 12px; color: var(--sand-2); }
.draft-steps { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.draft-steps li { flex: 1 1 200px; }
.draft-body { display: flex; flex-direction: column; gap: 10px; }
.draft-side { display: flex; flex-direction: column; gap: 10px; }
.draft-side .form-seg { order: -1; }
.pitch .lane { justify-content: flex-start; }
.pitch .king-spot { justify-content: center; }
.frenzy-tag { align-self: center; font-size: 12px; font-weight: 900; color: #fff; background: #d62828; padding: 2px 8px; border-radius: 99px; animation: pulse .6s infinite alternate; }

@media (max-height: 520px), (max-width: 600px) {
  #draft.screen { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .draft-panel { max-height: 100%; overflow-y: auto; gap: 4px; padding: 8px 10px; }
  .draft-head h2 { font-size: 15px; }
  .draft-head .eyebrow { font-size: 10px; }
  .draft-timer { font-size: 26px; min-width: 44px; }
  .draft-timer small { font-size: 9px; }
  .draft-steps { display: none; }
  .draft-hint { display: block; font-size: 11px; }
  .draft-body { display: grid; grid-template-columns: 1.25fr 1fr; gap: 8px; align-items: start; }
  .draft-side { gap: 6px; }
  .pitch { grid-template-columns: 34px repeat(3, 1fr); gap: 4px; padding: 5px; }
  .pitch .king-spot { font-size: 9px; }
  .pitch .king-spot span { font-size: 18px; }
  .pitch .lane { gap: 4px; }
  .pitch .lane-title { font-size: 9px; letter-spacing: 0.5px; }
  .slot { padding: 3px 5px; min-height: 32px; border-width: 2px; }
  .slot .s-cls { font-size: 11px; }
  .slot .s-who { font-size: 9.5px; }
  .form-seg { gap: 4px; }
  .form-seg button { padding: 3px 6px; min-height: 30px; font-size: 12px; letter-spacing: 0; flex: 1 1 28%; }
  .draft-bottom { min-height: 0; gap: 6px; }
  .slot-info { font-size: 11.5px; }
  #takeSlotBtn { min-height: 32px; padding: 4px 10px; font-size: 12px; }
  .draft-classes { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .draft-classes button { min-height: 34px; font-size: 10.5px; padding: 3px 2px; }
  .king-bars { top: 40px; }
  body.ktk .zone-info { display: none; }
}
@media (max-width: 600px) {
  .draft-body { grid-template-columns: 1fr; }
}
body.ktk .zone-info { display: none; }

.tag.far > div:first-of-type { display: none; }
.tag.far .bar { width: 36px; height: 4px; }
body.touch.ktk .score-list li:nth-child(n+5) { display: none; }
/* phones: keep things scrolled into view clear of the pinned Ready/Start bar */
@media (max-height: 520px), (max-width: 600px) { #lobby.screen { scroll-padding-bottom: 70px; } }

/* ---------- v5: MVP cards, crowd vote ---------- */
.mvp-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 4px 0; }
.mvp { position: relative; padding: 10px 8px; border-radius: 12px; text-align: center; background: linear-gradient(160deg, rgba(227,168,87,0.22), rgba(28,20,13,0.6)); border: 1px solid rgba(227,168,87,0.5); display: flex; flex-direction: column; gap: 2px; animation: cardIn .5s both; }
.mvp:nth-child(2) { animation-delay: .12s; } .mvp:nth-child(3) { animation-delay: .24s; } .mvp:nth-child(4) { animation-delay: .36s; }
@keyframes cardIn { from { transform: translateY(14px) scale(.95); opacity: 0; } }
.mvp .ic { font-size: 26px; line-height: 1; }
.mvp .tt { font-family: 'Cinzel', serif; font-weight: 900; font-size: 13px; color: var(--bronze-2); letter-spacing: .5px; }
.mvp .nm { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mvp .st { font-size: 11.5px; color: var(--sand-2); }
.mvp.me { border-color: var(--sand); box-shadow: 0 0 0 2px rgba(243,226,191,0.35); }
.crowd { display: flex; flex-direction: column; gap: 5px; }
.crowd-spots { display: flex; flex-wrap: wrap; gap: 5px; }
.crowd-spots button { font: 600 12px 'Rubik', sans-serif; padding: 6px 10px; border-radius: 99px; border: 2px solid rgba(199,125,255,0.5); background: rgba(199,125,255,0.12); color: var(--sand); cursor: pointer; min-height: 34px; }
.crowd-spots button.on { background: rgba(199,125,255,0.45); border-color: #c77dff; }
.crowd-spots button b { margin-left: 4px; color: #e0b3ff; }
.buff.au { background: #f4d35e; }
@media (max-height: 520px), (max-width: 600px) {
  .mvp-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .mvp { padding: 6px 4px; }
  .mvp .ic { font-size: 18px; } .mvp .tt { font-size: 10px; } .mvp .nm { font-size: 12px; } .mvp .st { font-size: 10px; }
  .crowd-spots button { padding: 3px 8px; min-height: 28px; font-size: 11px; }
}

/* ---------- v6: finale, draft ready ---------- */
.results-panel { max-width: 720px; }
.draft-head { flex-wrap: wrap; }
.draft-ready { margin-left: auto; display: flex; flex-direction: column; align-items: center; gap: 2px; }
#draftReadyBtn.on { background: #2f6b3a; color: #e8ffe8; border-color: transparent; }
#hud.finale::before, #hud.finale::after { content: ''; position: absolute; left: 0; right: 0; height: 11vh; background: #000; z-index: 2; animation: bars .6s ease-out both; }
#hud.finale::before { top: 0; } #hud.finale::after { bottom: 0; }
@keyframes bars { from { height: 0; } }
#hud.finale > *:not(.finale-banner) { opacity: 0; transition: opacity .4s; }
.finale-banner { position: absolute; left: 0; right: 0; top: 34%; text-align: center; z-index: 3; animation: slam .7s cubic-bezier(.2, 1.6, .4, 1) both; }
#finaleTitle { font-family: 'Cinzel', serif; font-weight: 900; font-size: clamp(38px, 9vw, 96px); line-height: 1; text-shadow: 0 5px 0 rgba(0,0,0,0.6), 0 0 40px rgba(0,0,0,0.6); }
#finaleSub { margin-top: 10px; font-size: clamp(15px, 2.6vw, 24px); font-weight: 700; text-shadow: 0 2px 8px rgba(0,0,0,0.9); }
@keyframes slam { from { transform: scale(2.4); opacity: 0; } }
body.finale #touch, body.finale #tags .tag, body.finale #lockHint { display: none !important; }

/* ---------- v7: death, bot labels, class info, results layout ---------- */
.you-died { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-family: 'Cinzel', serif; font-weight: 900; font-size: clamp(48px, 12vw, 120px); color: #ff3b30; letter-spacing: 4px; text-shadow: 0 6px 0 #3a0000, 0 0 40px rgba(255,59,48,0.6); animation: died 1.5s ease-out both; z-index: 4; }
@keyframes died { 0% { transform: scale(2.6); opacity: 0; } 15% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(0.96); } }
#hud:has(.you-died:not(.hidden))::before { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(255,0,0,0) 40%, rgba(160,0,0,0.55)); animation: died 1.5s ease-out both; }
.death { animation: fadeIn .35s ease-out both; }
@keyframes fadeIn { from { opacity: 0; } }
.tag .botlbl { font-size: 10px; font-weight: 500; color: #d8cdb8; margin-top: -1px; }
.tag.far .botlbl { display: none; }
.class-card .spec { font-size: 12px; color: #e0b3ff; font-weight: 700; }
.draft-classes button, .death-classes button { gap: 1px; }
.draft-classes button .cn, .death-classes button .cn { font-size: 13px; }
.draft-classes button small, .death-classes button small { font-weight: 500; font-size: 10px; color: var(--sand-2); line-height: 1.2; text-align: center; }
.tbtn-abl { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.tbtn-name { font-size: 9px; font-weight: 700; margin-top: 3px; max-width: 64px; text-align: center; }

.results-panel { width: 100%; max-width: 1040px; display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 18px; text-align: left; align-items: start; }
.res-left { display: flex; flex-direction: column; gap: 12px; text-align: center; }
.res-right { min-width: 0; }
.res-table-wrap { max-height: min(72vh, 660px); overflow-y: auto; border-radius: 10px; border: 1px solid var(--line); }
.res-table-wrap thead th { position: sticky; top: 0; background: #241a11; z-index: 1; }
.team-result { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; font-family: 'Rubik', sans-serif; font-size: 16px; font-weight: 700; }
.team-result .ts { font-size: 15px; padding: 6px 12px; white-space: nowrap; }
.res-left .mvp-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.score-table td.is-bot { color: var(--muted); }
.score-table td.is-bot small { font-size: 11px; }
.score-table td.is-human { font-weight: 700; }
@media (max-height: 520px), (max-width: 600px) {
  .results-panel { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 10px; padding: 10px; max-height: 100%; }
  .res-left { gap: 6px; }
  .winner { font-size: 20px; }
  .team-result .ts { font-size: 12px; padding: 3px 8px; }
  .res-left .mvp-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .res-table-wrap { max-height: calc(100dvh - 40px); }
  .score-table { font-size: 12px; }
  .score-table td { padding: 4px; }
  .draft-classes button small, .death-classes button small { font-size: 8.5px; }
  .draft-classes button .cn, .death-classes button .cn { font-size: 11px; }
  .death-classes button { min-height: 0; }
}
@media (max-width: 600px) { .results-panel { grid-template-columns: 1fr; } }
@media (max-height: 520px), (max-width: 600px) {
  #results.screen { padding-right: max(56px, env(safe-area-inset-right)); }
  .results-panel { overflow-y: auto; }
  .res-left .mvp .st { font-size: 9.5px; }
  #againHint { margin: 0; }
}

/* death pacing: the panel fades in over a second, after a beat of watching the fight */
.death { animation: fadeIn 1s ease-out both; }
.you-died { font-size: clamp(40px, 9vw, 92px); animation-duration: 1.3s; }

/* ---------- v9: kill cam, King call-outs, emotes ---------- */
.killcam { position: absolute; left: 50%; top: 62%; transform: translateX(-50%); background: rgba(30,6,6,0.82); border: 1px solid rgba(255,90,80,0.6); padding: 8px 16px; border-radius: 10px; font-size: 16px; font-weight: 700; white-space: nowrap; text-shadow: 0 1px 2px #000; animation: fadeIn .4s .35s both; }
.killcam b { color: #ff8a80; }
.death-by { font-size: 14px; color: #ffb3ab; margin-top: -4px; }
.king-alert { position: absolute; top: 88px; left: 50%; transform: translateX(-50%); background: #b3001b; color: #fff; font-weight: 900; padding: 6px 14px; border-radius: 99px; font-size: 15px; letter-spacing: .5px; box-shadow: 0 0 18px rgba(255,0,0,0.6); animation: pulse .45s infinite alternate; white-space: nowrap; }
.king-arrow { color: #ffd23f; font-size: 34px; text-shadow: 0 0 10px rgba(255,60,60,0.95); }
.emote-hint { position: absolute; right: 180px; bottom: 26px; font-size: 12px; color: var(--sand-2); background: rgba(18,12,8,0.55); padding: 4px 8px; border-radius: 8px; }
body.touch .emote-hint { display: none; }
.emote { display: block; font-size: 26px; line-height: 1; margin-bottom: 2px; animation: pop .25s cubic-bezier(.2,1.8,.4,1) both; }
@keyframes pop { from { transform: scale(0); } }
.tag.selftag .n, .tag.selftag .icons, .tag.selftag .bar, .tag.selftag .botlbl { display: none; }
.tbtn-emote { width: 52px; height: 52px; right: calc(128px + env(safe-area-inset-right)); bottom: calc(108px + env(safe-area-inset-bottom)); font-size: 24px; }
.emote-wheel { position: absolute; right: calc(186px + env(safe-area-inset-right)); bottom: calc(100px + env(safe-area-inset-bottom)); display: flex; gap: 6px; background: rgba(18,12,8,0.75); padding: 6px; border-radius: 30px; }
.emote-wheel button { width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255,255,255,0.12); font-size: 24px; touch-action: none; }
@media (max-height: 520px) { .king-alert { top: 62px; font-size: 12px; } }

/* ---------- v10: squad commands ---------- */
.order-bar { position: absolute; top: 112px; left: 50%; transform: translateX(-50%); background: rgba(18,12,8,0.78); border: 1px solid var(--line); padding: 4px 12px; border-radius: 99px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.order-toast { position: absolute; top: 40%; left: 0; right: 0; text-align: center; font-family: 'Cinzel', serif; font-weight: 900; font-size: clamp(26px, 5vw, 46px); text-shadow: 0 3px 0 rgba(0,0,0,0.6), 0 0 20px rgba(0,0,0,0.5); animation: slam .5s cubic-bezier(.2,1.6,.4,1) both; }
.order-toast small { display: block; font-family: 'Rubik', sans-serif; font-size: 14px; font-weight: 700; color: var(--sand); }
.squad-hint { position: absolute; left: 12px; bottom: 16px; font-size: 12px; background: rgba(18,12,8,0.6); padding: 5px 9px; border-radius: 8px; color: var(--sand-2); max-width: 300px; }
.squad-hint b { color: var(--bronze-2); }
body.touch .squad-hint { display: none; }
.tbtn-order { width: 52px; height: 52px; right: calc(186px + env(safe-area-inset-right)); bottom: calc(108px + env(safe-area-inset-bottom)); font-size: 22px; }
.order-wheel { position: absolute; right: calc(100px + env(safe-area-inset-right)); bottom: calc(214px + env(safe-area-inset-bottom)); display: flex; gap: 5px; background: rgba(18,12,8,0.8); padding: 6px; border-radius: 14px; }
.order-wheel button { width: 58px; height: 52px; border-radius: 10px; border: 0; background: rgba(255,255,255,0.12); color: #fff; font-size: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; touch-action: none; }
.order-wheel button span { font-size: 9px; font-weight: 700; margin-top: 2px; }
@media (max-height: 520px) { .order-bar { top: 82px; font-size: 11px; } }
.kg-shield { font-style: normal; margin-right: 3px; }

/* hit marker: four ticks around the crosshair that flash when your attack lands */
.hit-marker { position: absolute; left: 50%; top: 50%; width: 0; height: 0; opacity: 0; pointer-events: none; }
.hit-marker i { position: absolute; width: 3px; height: 11px; margin: -5.5px 0 0 -1.5px; background: #fff; border-radius: 2px; box-shadow: 0 0 3px rgba(0,0,0,0.9); }
.hit-marker i:nth-child(1) { transform: rotate(45deg) translateY(-12px); }
.hit-marker i:nth-child(2) { transform: rotate(135deg) translateY(-12px); }
.hit-marker i:nth-child(3) { transform: rotate(225deg) translateY(-12px); }
.hit-marker i:nth-child(4) { transform: rotate(315deg) translateY(-12px); }
.hit-marker.show { animation: hitmark .28s ease-out; }
.hit-marker.kill i { background: #ff3b30; height: 15px; box-shadow: 0 0 6px rgba(255,59,48,0.9); }
.hit-marker.kill.show { animation: hitmark .5s ease-out; }
@keyframes hitmark { 0% { opacity: 1; transform: scale(1.5); } 40% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.1); } }

/* ---------- v11: simpler draft and class cards ---------- */
.class-card .cstat { font-size: 13px; color: var(--sand-2); }
.draft-row { display: flex; flex-direction: column; gap: 6px; }
.draft-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--bronze-2); font-weight: 700; }
.draft-label b { color: var(--sand); }
.choice-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice-seg button { font: 700 16px 'Rubik', sans-serif; padding: 10px 8px; border-radius: 10px; border: 2px solid var(--line); background: var(--ink-2); color: var(--sand); cursor: pointer; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.choice-seg button small { font-size: 11px; font-weight: 500; color: var(--muted); }
.choice-seg button.on { background: var(--bronze-2); color: var(--ink); border-color: transparent; }
.choice-seg button.on small { color: #3b2a16; }
.choice-seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.draft-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.link-btn { background: none; border: 0; color: var(--bronze-2); font: 700 14px 'Rubik', sans-serif; cursor: pointer; padding: 4px 0; text-decoration: underline; text-underline-offset: 3px; }
.customize { display: flex; flex-direction: column; gap: 6px; }
.customize p { margin: 0; }
.slot:disabled { opacity: 0.6; cursor: not-allowed; }
@media (max-height: 520px), (max-width: 600px) {
  .draft-row { gap: 3px; }
  .draft-label { font-size: 10px; }
  .choice-seg { gap: 5px; }
  .choice-seg button { font-size: 13px; min-height: 40px; padding: 4px; }
  .choice-seg button small { font-size: 9.5px; }
  .draft-foot { gap: 8px; }
  .link-btn { font-size: 12px; }
  .class-card .cstat { font-size: 10.5px; }
  .class-card .spec { font-size: 10.5px; }
}

/* ---------- v12: phone polish ---------- */
/* keep screens clear of the settings button */
@media (max-height: 520px), (max-width: 600px) {
  #draft.screen { padding-right: max(56px, env(safe-area-inset-right)); }
  .lobby-head .eyebrow { display: none; }
  .lobby-head { padding: 6px 10px; }
  .room-code { font-size: 22px; letter-spacing: 4px; }
  .mode-info { font-size: 11.5px; margin-top: 6px; }
  .ios-tip { font-size: 11px; padding: 3px 8px; }
  .lobby-grid { grid-template-columns: minmax(170px, 0.8fr) 2fr; }
  .center-msg, .order-toast { font-size: clamp(26px, 7vw, 52px); }
  .you-died { font-size: clamp(34px, 9vw, 64px); }
  .death-title { font-size: 18px; }
  .death-timer { font-size: 14px; } .death-timer b { font-size: 20px; }
}
/* phones in a match: emote + squad buttons tucked under the settings gear, out of the action */
body.touch .tbtn-emote, body.touch .tbtn-order { width: 42px; height: 42px; font-size: 20px; bottom: auto; right: calc(8px + env(safe-area-inset-right)); }
body.touch .tbtn-emote { top: 54px; }
body.touch .tbtn-order { top: 102px; }
body.touch .emote-wheel { bottom: auto; top: 50px; right: calc(56px + env(safe-area-inset-right)); }
body.touch .order-wheel { bottom: auto; top: 98px; right: calc(56px + env(safe-area-inset-right)); }
body.touch .feed { font-size: 11px; max-width: 46vw; right: calc(56px + env(safe-area-inset-right)); }
body.touch .feed li:nth-child(n+3) { display: none; }
body.touch .kb { font-size: 10px; }
body.touch .kbar { width: 72px; height: 9px; }
body.touch .frenzy-tag { font-size: 10px; padding: 1px 6px; }
body.touch .score-list { font-size: 10px; padding: 5px 7px; min-width: 104px; }
body.touch .order-bar { font-size: 11px; top: 74px; }
/* short phones (iPhone SE size): smaller controls */
@media (max-height: 400px) and (pointer: coarse) {
  #joyBase { width: 96px; height: 96px; left: 40px; bottom: 30px; }
  #joyKnob { width: 44px; height: 44px; margin: -22px; }
  .tbtn-atk { width: 70px; height: 70px; font-size: 28px; right: calc(18px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); }
  .tbtn-abl { width: 56px; height: 56px; font-size: 22px; right: calc(26px + env(safe-area-inset-right)); bottom: calc(96px + env(safe-area-inset-bottom)); }
  .tbtn-jump { width: 50px; height: 50px; font-size: 22px; right: calc(98px + env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom)); }
  .tbtn-name { font-size: 8px; }
  body.touch .me-box { width: min(240px, 38vw); bottom: 4px; }
  .me-line { font-size: 10px; margin-bottom: 2px; }
  .hp-bar { height: 14px; } #hpText { font-size: 10px; line-height: 14px; }
  .timer { font-size: 20px; }
  .king-bars { top: 30px; }
  body.touch .order-bar { top: 52px; }
  .zone-info { font-size: 10px; }
}
/* phones: the feed sits under the button column on the right, away from the King bars */
body.touch .feed { top: 150px; right: calc(8px + env(safe-area-inset-right)); font-size: 10px; max-width: 40vw; }
@media (max-height: 340px) { .ios-tip { display: none !important; } }

/* ---------- v13: match-start goal banner, enemy King arrow ---------- */
.goal-banner { position: absolute; top: 15%; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); text-align: center; padding: 10px 28px 12px; background: linear-gradient(180deg, rgba(18,12,8,0.82), rgba(18,12,8,0.62)); border-top: 4px solid var(--team, #f3e2bf); border-bottom: 4px solid var(--team, #f3e2bf); border-radius: 14px; box-shadow: 0 0 28px color-mix(in srgb, var(--team, #f3e2bf) 45%, transparent); animation: goalIn .6s cubic-bezier(.2,1.6,.4,1) both; pointer-events: none; z-index: 2; transition: opacity .5s; }
@keyframes goalIn { from { transform: translateX(-50%) scale(1.6); opacity: 0; } }
.goal-banner.out { opacity: 0; }
.goal-title { font-family: 'Cinzel', serif; font-weight: 900; text-transform: uppercase; font-size: clamp(26px, 5.6vw, 58px); line-height: 1.05; color: #fff3c4; text-shadow: 0 3px 0 var(--blood), 0 6px 18px rgba(0,0,0,0.7); }
.goal-team { margin-top: 6px; font-size: clamp(16px, 2.6vw, 26px); font-weight: 800; color: var(--sand-2); text-shadow: 0 2px 6px rgba(0,0,0,0.9); }
.goal-team b { font-size: 1.25em; letter-spacing: 1px; text-shadow: 0 0 12px currentColor, 0 2px 4px #000; }
#hud.goal .center-msg { top: 47%; font-size: clamp(34px, 7vw, 64px); }
#hud.goal .sub-msg { top: 63%; }
.enemy-arrow { color: #ff2b2b; font-size: 40px; text-shadow: 0 0 12px rgba(255,40,40,0.95), 0 0 2px #000; }
@media (max-height: 520px) {
  .goal-banner { top: 58px; padding: 6px 18px 8px; border-width: 3px; }
  .goal-title { font-size: clamp(22px, 5vw, 36px); }
  .goal-team { font-size: 15px; margin-top: 3px; }
  #hud.goal .center-msg { top: 52%; font-size: 40px; }
  #hud.goal .sub-msg { top: 70%; font-size: 15px; }
}
/* King bar labels never wrap into the timer */
.kb span { white-space: nowrap; }
@media (max-height: 400px) and (pointer: coarse) {
  .goal-title { font-size: clamp(19px, 4.3vw, 30px); }
  .goal-team { font-size: 13px; }
  .goal-banner { top: 50px; padding: 5px 14px 6px; }
}

/* lobby How to play: goal line + key chips */
.how-goal { font-size: 15px; color: var(--sand); margin-bottom: 8px; }
.how-goal b { color: #fff3c4; }
.how-keys { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.how-key { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--sand-2); white-space: nowrap; }
.how-key kbd { font-family: inherit; font-weight: 800; font-size: 12px; color: #1c140d; background: var(--sand); border-radius: 6px; padding: 2px 7px; box-shadow: 0 2px 0 rgba(0,0,0,0.45); }

/* ---------- v14: Play Now, how-it-works modal, tips, reconnect, share ---------- */
.btn-play { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 20px; padding: 12px 16px; }
.btn-play small { font-size: 12px; font-weight: 600; opacity: .85; }
.how-btn { align-self: center; font-size: 14px; }
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.62); display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal-panel { width: 100%; max-width: 540px; max-height: calc(100dvh - 24px); overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-panel h2 { margin: 0; font-family: 'Cinzel', serif; }
.how-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.how-steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.4; color: var(--sand-2); }
.how-steps li > span { font-size: 26px; line-height: 1; flex: none; width: 32px; text-align: center; }
.how-steps b { color: var(--sand); }
.tip-box { position: absolute; left: 50%; bottom: 118px; transform: translateX(-50%); max-width: min(620px, calc(100vw - 32px)); background: rgba(18,12,8,0.88); border: 1px solid var(--bronze-2, #e9c46a); border-radius: 12px; padding: 8px 14px; font-size: 15px; font-weight: 600; text-align: center; color: #f3e2bf; box-shadow: 0 4px 18px rgba(0,0,0,0.5); animation: fadeIn .3s both; pointer-events: none; z-index: 2; }
.tip-box kbd { font-family: inherit; font-weight: 800; font-size: 12px; color: #1c140d; background: var(--sand); border-radius: 5px; padding: 1px 6px; }
@media (max-height: 520px) { .tip-box { bottom: 64px; font-size: 12px; padding: 5px 10px; max-width: calc(100vw - 300px); min-width: 220px; } }
.reconnect { position: fixed; inset: 0; z-index: 50; background: rgba(10,6,4,0.72); display: flex; align-items: center; justify-content: center; gap: 14px; color: #f3e2bf; font-size: 20px; text-align: left; }
.reconnect small { display: block; font-size: 13px; color: var(--sand-2); margin-top: 3px; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 4px solid rgba(255,255,255,0.2); border-top-color: var(--sand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.res-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.settings small { color: var(--muted); font-size: 11px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-x { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,0.06); color: var(--sand); font-size: 16px; cursor: pointer; }
@media (max-height: 430px) {
  .modal-panel { padding: 12px 16px; gap: 8px; }
  .modal-panel h2 { font-size: 20px; }
  .how-steps { gap: 6px; }
  .how-steps li { font-size: 13px; line-height: 1.3; }
  .how-steps li > span { font-size: 20px; width: 24px; }
  .btn-play { font-size: 17px; padding: 8px 12px; }
}
body:not(.touch) .tip-box { bottom: 150px; }
