:root {
  --bg: #05080f;
  --panel: rgba(11, 17, 29, 0.9);
  --panel-2: #0e1522;
  --line: rgba(140, 170, 255, 0.16);
  --text: #e6eefc;
  --dim: #8592ab;
  --blue: #2fb8ff;
  --blue-l: #9be6ff;
  --blue-d: #0a4f7d;
  --red: #ff3d5a;
  --red-l: #ffa3b1;
  --red-d: #7d0f22;
  --energy: #ffcf3a;
  --good: #6dffb0;
  --bad: #ff5a6e;
  --font: 'Rajdhani', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --fx: 0px; --fy: 0px; --fw: 360px; --fh: 576px; --tile: 18px;
  --top-h: 56px; --bot-h: 160px; --safe-top: 0px; --safe-bottom: 0px;
  --lp-x: 0px; --lp-w: 300px; --rp-x: 0px; --rp-w: 320px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
}

button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; padding: 0; }

#app { position: fixed; inset: 0; overflow: hidden; }
#game { position: absolute; left: 0; top: 0; display: block; touch-action: none; }
#safe-probe {
  position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ============================================================ scoreboard */
#scoreboard { position: absolute; z-index: 5; display: grid; align-items: center; pointer-events: none; }
.sb-team { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sb-team.blue { --tc: var(--blue); --tl: var(--blue-l); }
.sb-team.red { --tc: var(--red); --tl: var(--red-l); }
.sb-name { font-weight: 700; font-size: 12px; letter-spacing: 0.14em; color: var(--tc); white-space: nowrap; }
.sb-name em {
  font-style: normal; font-size: 9px; letter-spacing: 0.08em; padding: 0 4px; margin-left: 2px;
  border-radius: 3px; background: var(--tc); color: #04121c; vertical-align: 1px;
}
.sb-row { display: flex; align-items: center; gap: 7px; }
.sb-score { font-weight: 700; font-size: 24px; line-height: 1; color: var(--tc); min-width: 14px; text-shadow: 0 0 12px var(--tc); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sb-score small { font-size: 0.55em; margin-left: 1px; opacity: 0.8; }
.sb-bar { position: relative; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin-top: 3px; width: 100%; max-width: 150px; }
.sb-bar i { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0); background: var(--tc); box-shadow: 0 0 8px var(--tc); transition: transform 0.2s; }
.mode-tall #sb-right .sb-bar { align-self: flex-end; }
.mode-tall #sb-right .sb-bar i { transform-origin: right center; }
.sb-team.lead .sb-name::after { content: ' ▲'; font-size: 9px; }
.sb-pips { display: flex; gap: 3px; flex-wrap: nowrap; }
.pip {
  display: block; flex: none; width: calc(var(--w, 30) * 0.32px); height: 10px; border-radius: 2px; border: 1.5px solid rgba(255, 255, 255, 0.28);
  background: linear-gradient(90deg, var(--tc) calc(var(--dmg, 0) * 100%), rgba(255, 255, 255, 0.05) 0);
  transition: border-color 0.2s;
}
.pip.hit { border-color: var(--tl); box-shadow: 0 0 6px color-mix(in srgb, var(--tc) 50%, transparent); }
.pip-t2 { border-radius: 6px; }
.pip.down { background: var(--tc); border-color: var(--tl); box-shadow: 0 0 8px var(--tc); }

#sb-clock {
  text-align: center; padding: 3px 14px 2px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.4); border: 1px solid var(--line); min-width: 88px;
}
#sb-phase { font-weight: 700; font-size: 10px; letter-spacing: 0.18em; color: var(--dim); white-space: nowrap; }
#sb-time { font-weight: 700; font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
#sb-clock[data-phase='regular'] #sb-phase { color: var(--text); }
#sb-clock[data-phase='overtime'] #sb-phase { color: #ff8a3d; }
/* phone: "OT · SUDDEN DEATH" set tighter so the clock stays as narrow as in regular time (no squeeze on the scores) */
.mode-tall #sb-clock[data-phase='overtime'] { padding-left: 10px; padding-right: 10px; }
.mode-tall #sb-clock[data-phase='overtime'] #sb-phase { font-size: 9px; letter-spacing: 0.04em; }
#sb-clock.low #sb-time { color: var(--bad); animation: pulse 1s infinite; }

/* ============================================================ hand + energy */
#hand-panel { position: absolute; z-index: 5; display: grid; gap: 6px 8px; }
#next-wrap { grid-area: next; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.next-label { font-weight: 700; font-size: 10px; letter-spacing: 0.18em; color: var(--dim); }
#hand { grid-area: hand; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; align-items: end; min-height: 0; }

.card {
  position: relative; width: 100%; max-height: 100%; aspect-ratio: 0.78; justify-self: center;
  border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: linear-gradient(180deg, #1c2740, #111827 70%);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 10px rgba(0, 0, 0, 0.4);
  cursor: grab; touch-action: none; container-type: inline-size;
  transition: transform 0.12s ease, border-color 0.12s, box-shadow 0.12s, opacity 0.12s;
}
#hand .card { height: auto; }
.card-art { width: 54%; color: #dbe9ff; display: grid; place-items: center; }
.card-art svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 0 6px rgba(120, 200, 255, 0.35)); }
.card-art canvas { width: 100%; height: auto; display: block; }
.card.is-real .card-art { width: 78%; margin-top: -4%; }
.card.is-real { background: linear-gradient(180deg, #22304d, #131c2e 70%); border-color: rgba(155, 230, 255, 0.28); }
/* Category colour (unit · defense · infra · strike): frame tint, top stripe, tag and art glow */
.card { --kc: #8fd3ff; }
.card[data-kind='defense'] { --kc: #ffb547; }
.card[data-kind='infra'] { --kc: #5cf0a0; }
.card[data-kind='strike'] { --kc: #c49bff; }
.card.is-real {
  border-color: color-mix(in srgb, var(--kc) 38%, transparent);
  background:
    radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--kc) 16%, transparent), transparent 70%),
    linear-gradient(180deg, #202c46, #10182a 72%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 -18px 24px -18px color-mix(in srgb, var(--kc) 30%, transparent), 0 4px 12px rgba(0, 0, 0, 0.45);
}
.card.is-real::before {
  content: ''; position: absolute; left: 14%; right: 14%; top: 0; height: 2px; border-radius: 0 0 2px 2px;
  background: var(--kc); box-shadow: 0 0 8px var(--kc); opacity: 0.85;
}
.card.is-real .card-art canvas { filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 10px color-mix(in srgb, var(--kc) 22%, transparent)); }
.card.is-air .card-art { color: var(--blue-l); }
.card-name {
  font-weight: 700; font-size: clamp(9px, 2.6vw, 14px); font-size: clamp(9px, 15cqw, 16px); letter-spacing: 0.04em; text-transform: uppercase;
  color: #b9c6dd; max-width: 94%; text-align: center; line-height: 1.02; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere;
}
.card-cost {
  position: absolute; top: -7px; left: -7px; width: 25px; height: 25px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 15px; color: #1b1300;
  background: radial-gradient(circle at 35% 30%, #fff1a8, #ffcf3a 45%, #c98a00);
  box-shadow: 0 0 0 2px #0b111c, 0 0 10px rgba(255, 207, 58, 0.5);
}
.card::after {
  content: attr(data-tag); position: absolute; top: 5px; right: 7px;
  font-weight: 700; font-size: 9px; letter-spacing: 0.08em; color: var(--kc, var(--blue-l)); opacity: 0.9;
}
.card-lock {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: rgba(4, 7, 13, 0.66);
  clip-path: inset(0 0 calc(100% - var(--lock, 0%)) 0);
}
.card.ready { border-color: rgba(255, 207, 58, 0.4); }
.card.is-real.ready { border-color: color-mix(in srgb, #ffcf3a 60%, var(--kc)); }
.card.selected {
  transform: translateY(-9px) scale(1.05); border-color: var(--energy);
  box-shadow: 0 0 0 2px rgba(255, 207, 58, 0.45), 0 12px 24px rgba(0, 0, 0, 0.55);
}
.card.dragging { opacity: 0.4; }
.card.pop { animation: pop 0.28s ease-out; }
.card.mini { width: 100%; max-width: 64px; cursor: default; opacity: 0.85; }
.card.mini .card-art { width: 50%; }
.card.mini .card-cost { width: 19px; height: 19px; font-size: 12px; top: -5px; left: -5px; }
.card.mini::after { display: none; }

#energy { grid-area: energy; display: flex; align-items: center; gap: 8px; height: 28px; }
#energy-num {
  flex: none; width: 30px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 700; font-size: 19px; color: #1b1300;
  background: radial-gradient(circle at 35% 30%, #fff1a8, #ffcf3a 50%, #c98a00);
  box-shadow: 0 0 12px rgba(255, 207, 58, 0.45);
}
#energy-track {
  position: relative; flex: 1; height: 16px; border-radius: 8px; overflow: hidden;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line);
}
#energy-fill {
  position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0.5);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 45%), linear-gradient(90deg, #f0a000, #ffd84d);
  box-shadow: 0 0 14px rgba(255, 200, 60, 0.6), inset -3px 0 6px rgba(255, 250, 220, 0.9);
}
#energy-segs { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--segs, 15), 1fr); }
#energy-segs i { border-right: 1px solid rgba(0, 0, 0, 0.45); }
#energy-segs i:last-child { border-right: 0; }
#energy.boost #energy-fill {
  background: linear-gradient(90deg, #ff7a00, #ffe14d, #ff7a00); background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
/* REPAIR: one tap, whole team (8 energy -> +300 HP to your most damaged tower) */
#repair {
  position: relative; flex: none; height: 28px; padding: 0 9px 0 7px; border-radius: 8px; overflow: hidden;
  display: flex; align-items: center; gap: 5px; touch-action: manipulation;
  background: linear-gradient(180deg, #1d2a1e, #101a12); border: 1px solid rgba(120, 255, 170, 0.28);
  transition: transform 0.1s, border-color 0.15s, filter 0.15s;
}
#repair::before { /* charge: how much of the cost we have */
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: var(--fill, 0%);
  background: linear-gradient(90deg, rgba(120, 255, 170, 0.08), rgba(120, 255, 170, 0.28)); pointer-events: none;
}
#repair .r-icon { position: relative; font-style: normal; font-size: 14px; line-height: 1; color: #9dffc6; }
#repair .r-name { position: relative; font-weight: 700; font-size: 11px; letter-spacing: 0.1em; color: #d8ffe6; }
#repair .r-cost {
  position: relative; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 5px;
  font-weight: 700; font-size: 12px; color: #1b1300; background: radial-gradient(circle at 35% 30%, #fff1a8, #ffcf3a 50%, #c98a00);
}
#repair.locked { filter: saturate(0.35) brightness(0.7); }
#repair.ready { border-color: #6dffa8; box-shadow: 0 0 10px rgba(109, 255, 168, 0.4); }
#repair.ready:active { transform: scale(0.94); }
#repair.flash { animation: repairflash 0.5s ease-out; }

.sb-status { font-weight: 700; font-size: 10px; letter-spacing: 0.1em; color: #ff9a52; min-height: 0; white-space: nowrap; }
.sb-status:empty { display: none; }

/* ============================================================ lab panel */
#lab-toggle {
  position: absolute; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 11px; background: var(--panel); border: 1px solid var(--line); color: var(--text);
}
#lab-toggle svg { width: 20px; height: 20px; }
#lab-toggle span { font-weight: 700; font-size: 8px; letter-spacing: 0.14em; margin-top: -1px; }

#lab {
  position: absolute; z-index: 20; background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  scrollbar-width: thin; scrollbar-color: #2a3550 transparent;
}
.lab-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 10px; background: linear-gradient(var(--panel) 75%, transparent); }
.lab-title { font-weight: 700; font-size: 17px; letter-spacing: 0.2em; }
.lab-sub { font-weight: 600; font-size: 11px; color: var(--dim); letter-spacing: 0.04em; }
.lab-close { width: 32px; height: 32px; border-radius: 8px; background: #17203a; font-size: 14px; }
.lab-body { padding: 0 14px 16px; }
.lab-sec { padding: 10px 0 12px; border-top: 1px solid var(--line); }
.lab-sec h3 { margin: 0 0 8px; font-weight: 700; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }
.lab-sec h3 small { font-weight: 600; letter-spacing: 0.04em; text-transform: none; opacity: 0.8; margin-left: 4px; }

.layout-group + .layout-group { margin-top: 8px; }
.lg-title { font-weight: 700; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); margin: 0 0 4px; }
.layout-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
.layout-opt {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 5px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; min-width: 0;
}
.layout-opt canvas { display: block; max-width: 100%; height: auto; }
.layout-opt b { font-size: 22px; line-height: 1; margin-top: 2px; }
.layout-opt span { font-weight: 700; font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.layout-opt.on { border-color: var(--energy); background: #1a2133; box-shadow: 0 0 0 1px rgba(255, 207, 58, 0.3); }
.layout-opt small { font-weight: 600; font-size: 10px; color: var(--dim); opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.layout-opt.on span { color: var(--energy); }

.arena-card { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start; }
.arena-card .layout-info { margin-top: 0; }
.arena-schematic { display: block; border-radius: 6px; }
.layout-info { margin-top: 10px; font-size: 13px; line-height: 1.35; font-weight: 500; }
.layout-info p { margin: 4px 0 8px; color: #c3cee2; }
.li-name { font-weight: 700; font-size: 16px; }
.li-name span { font-weight: 600; font-size: 12px; color: var(--dim); margin-left: 4px; }
.li-link { font-weight: 700; font-size: 12px; color: var(--energy); margin-left: 6px; text-decoration: none; white-space: nowrap; }
a.btn { display: inline-block; color: inherit; text-decoration: none; }
.li-towers { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.li-towers th { text-align: left; font-weight: 700; color: var(--dim); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; padding: 2px 4px; }
.li-towers td { padding: 3px 4px; border-top: 1px solid rgba(255, 255, 255, 0.05); }
.li-towers tfoot td { color: var(--dim); font-weight: 700; }
.dot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; vertical-align: 0; }
.dot-t1 { background: var(--blue); border-radius: 2px; }
.dot-t2 { background: var(--blue); border-radius: 50%; }
.li-pc { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.li-pc ul { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.li-pc li { position: relative; padding-left: 13px; margin-bottom: 3px; color: #c3cee2; }
.li-pc .pros li::before { content: '+'; position: absolute; left: 0; color: var(--good); font-weight: 700; }
.li-pc .cons li::before { content: '–'; position: absolute; left: 0; color: var(--bad); font-weight: 700; }

.row { display: flex; gap: 6px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.row .lbl { font-weight: 600; font-size: 12px; color: var(--dim); margin-right: 4px; }
.row .seg { flex: 1; }
.seg { display: flex; gap: 2px; padding: 2px; border-radius: 9px; background: #0a101b; border: 1px solid var(--line); }
.seg button { flex: 1; padding: 7px 4px; border-radius: 7px; font-weight: 700; font-size: 12px; color: var(--dim); white-space: nowrap; }
.seg button.on { background: #26324d; color: var(--text); }
.btn { padding: 8px 13px; border-radius: 9px; background: #18223a; border: 1px solid var(--line); font-weight: 700; font-size: 13px; letter-spacing: 0.04em; }
.btn.primary { background: linear-gradient(#2b93dc, #1c68a3); border-color: #45b0ff; }
.btn.on { background: #3a2e12; border-color: var(--energy); color: var(--energy); }

.tog { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 13px; padding: 5px 0; cursor: pointer; }
.tog input { position: absolute; opacity: 0; pointer-events: none; }
.tog span { position: relative; flex: none; width: 32px; height: 18px; border-radius: 9px; background: #263046; transition: background 0.15s; }
.tog span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #c9d3e6; transition: transform 0.15s; }
.tog input:checked + span { background: var(--blue); }
.tog input:checked + span::after { transform: translateX(14px); background: #fff; }
.tog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.hint { margin: 6px 0 0; font-size: 11px; color: var(--dim); font-weight: 500; }
.troop-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; }
.troop-opt {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 4px 4px; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
}
.troop-opt span { font-weight: 700; font-size: 11px; letter-spacing: 0.02em; text-align: center; line-height: 1.05; }
.troop-kind { grid-column: 1 / -1; font-weight: 700; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); margin-top: 4px; }
/* Deck builder (Arena Lab → Deck) */
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 5px; }
.deck-opt {
  position: relative; display: flex; flex-direction: column; align-items: center; padding: 3px 2px 2px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; opacity: 0.55;
}
.deck-opt.on { opacity: 1; border-color: var(--energy); background: #1a2133; box-shadow: 0 0 0 1px rgba(255, 207, 58, 0.25); }
.deck-opt span { font-weight: 700; font-size: 9px; line-height: 1.05; text-align: center; letter-spacing: 0.01em; }
.deck-opt b { position: absolute; top: 1px; left: 3px; font-size: 10px; color: var(--energy); }
.deck-count { font-weight: 700; font-size: 12px; }
.deck-count.bad { color: var(--bad); }
.mech-list { margin: 6px 0 0; padding: 0; list-style: none; font-size: 11px; }
.mech-list li { padding: 2px 0; border-top: 1px solid rgba(255, 255, 255, 0.05); }
.mech-list li b { display: inline-block; width: 38px; }
.mech-list li.pass b { color: var(--good); }
.mech-list li.fail b { color: var(--bad); }
.troop-opt small { font-weight: 700; font-size: 10px; color: var(--energy); }
.troop-opt.on { border-color: var(--energy); background: #1a2133; }
.troop-info { margin-top: 8px; font-size: 13px; line-height: 1.35; }
.troop-info p { margin: 4px 0 8px; color: #c3cee2; }
.bench td small { color: var(--dim); font-weight: 700; margin-left: 3px; }
.bench tr.r-win td:nth-child(2) { color: var(--good); font-weight: 700; }
.bench tr.r-loss td:nth-child(2) { color: var(--bad); font-weight: 700; }
.bench tr.r-trade td:nth-child(2) { color: var(--energy); font-weight: 700; }
.check { font-weight: 700; font-size: 12px; margin: 4px 0 6px; }
.check.good { color: var(--good); }
.check.bad { color: var(--bad); }
.check ul { margin: 4px 0 0; padding-left: 16px; font-weight: 500; color: #e9b6be; }
.btn:disabled { opacity: 0.5; cursor: progress; }

/* ============================================================ overlays */
#banner {
  position: absolute; z-index: 8; left: var(--fx); width: var(--fw); top: calc(var(--fy) + var(--fh) * 0.4);
  text-align: center; pointer-events: none; opacity: 0; transform: scale(0.88); transition: opacity 0.18s, transform 0.18s;
}
#banner.show { opacity: 1; transform: scale(1); }
.b-main {
  font-weight: 700; font-size: clamp(34px, calc(var(--fw) * 0.15), 88px); line-height: 1; letter-spacing: 0.04em;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.45), 0 0 30px rgba(0, 0, 0, 0.6);
}
.b-sub { margin-top: 6px; font-weight: 700; font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; color: #c3cee2; text-shadow: 0 2px 6px #000; }
#banner.count .b-main, #banner.energy .b-main { color: var(--energy); }
#banner.ot .b-main { color: #ff8a3d; }
#banner.good .b-main, #banner.bad .b-main { font-size: clamp(24px, calc(var(--fw) * 0.09), 50px); }
#banner.good .b-main { color: var(--good); }
#banner.bad .b-main { color: var(--bad); }

#toast {
  position: absolute; z-index: 9; left: calc(var(--fx) + var(--fw) / 2); top: calc(var(--fy) + var(--fh) * 0.58);
  transform: translate(-50%, 6px); padding: 7px 15px; border-radius: 999px; white-space: nowrap;
  background: rgba(8, 12, 21, 0.92); border: 1px solid var(--line); font-weight: 700; font-size: 13px; letter-spacing: 0.04em;
  pointer-events: none; opacity: 0; transition: opacity 0.15s, transform 0.15s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#stats {
  position: absolute; z-index: 7; left: calc(var(--fx) + 6px); top: calc(var(--fy) + 6px); margin: 0;
  font: 600 11px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; color: #b8f5d0;
  background: rgba(0, 0, 0, 0.55); padding: 4px 6px; border-radius: 6px; pointer-events: none; white-space: pre;
}

#result {
  position: absolute; z-index: 15; left: var(--fx); top: var(--fy); width: var(--fw); height: var(--fh);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: rgba(3, 6, 11, 0.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); border-radius: 10px;
  animation: fadein 0.35s ease-out;
}
#result[hidden] { display: none; }
.res-title { font-weight: 700; font-size: clamp(42px, calc(var(--fw) * 0.17), 96px); line-height: 1; letter-spacing: 0.06em; text-shadow: 0 4px 0 rgba(0, 0, 0, 0.5); }
.res-victory .res-title { color: var(--energy); }
.res-defeat .res-title { color: var(--bad); }
.res-draw .res-title { color: #cfd8e6; }
.res-reason { font-weight: 700; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: #c3cee2; }
.res-score { display: flex; align-items: center; gap: 14px; font-weight: 700; font-size: 40px; margin: 6px 0; }
.res-score .blue { color: var(--blue); }
.res-score .red { color: var(--red); }
.res-score i { font-style: normal; color: var(--dim); font-size: 24px; }
.res-meta { font-weight: 600; font-size: 12px; color: var(--dim); }
.res-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ============================================================ TALL (phones / portrait) */
.mode-tall #scoreboard {
  top: var(--safe-top); left: 58px; right: 8px; height: var(--top-h);
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px;
}
.mode-tall #sb-right { align-items: flex-end; }
.mode-tall #sb-right .sb-row { flex-direction: row-reverse; }
.mode-tall #lab-toggle { top: calc(var(--safe-top) + (var(--top-h) - 42px) / 2); left: 8px; }
.mode-tall #hand-panel {
  left: 0; right: 0; bottom: 0; height: calc(var(--bot-h) + var(--safe-bottom));
  padding: 8px 10px calc(8px + var(--safe-bottom));
  grid-template-columns: minmax(40px, 0.72fr) 4fr; grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: 'energy energy' 'next hand';   /* the energy bar sits above the cards */
  background: linear-gradient(180deg, rgba(5, 8, 15, 0), rgba(5, 8, 15, 0.9) 18%);
}
.mode-tall #hand { height: 100%; }
.mode-tall #hand .card { max-height: 100%; height: 100%; width: auto; max-width: 100%; }
.mode-tall #lab {
  top: 0; bottom: 0; left: 0; width: min(92%, 400px); border-radius: 0 16px 16px 0; border-left: 0;
  padding-top: var(--safe-top); transform: translateX(-104%); transition: transform 0.22s ease;
  box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
}
.mode-tall #lab.open { transform: translateX(0); }

/* ============================================================ WIDE (PC / landscape) */
.mode-wide #lab-toggle, .mode-wide .lab-close, .mode-wide #res-lab { display: none; }
.mode-wide #lab { left: var(--lp-x); width: var(--lp-w); top: 12px; bottom: 12px; border-radius: 16px; }
.mode-wide #scoreboard {
  left: var(--rp-x); width: var(--rp-w); top: var(--fy);
  grid-template-columns: 1fr; gap: 10px; padding: 14px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
}
.mode-wide #sb-left { order: 1; }
.mode-wide #sb-clock { order: 2; padding: 6px 14px; }
.mode-wide #sb-right { order: 3; }
.mode-wide #sb-time { font-size: 40px; }
.mode-wide .sb-name { font-size: 14px; }
.mode-wide .sb-score { font-size: 30px; }
.mode-wide .pip { width: calc(var(--w, 30) * 0.42px); height: 12px; }
/* PC: the hand sits right under the arena, energy bar on top (same reading order as phones) */
.mode-wide #hand-panel {
  left: var(--hand-x); width: var(--hand-w); top: var(--hand-y); height: var(--hand-h);
  padding: 6px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  grid-template-columns: minmax(48px, 0.7fr) 4fr; grid-template-rows: 24px minmax(0, 1fr);
  grid-template-areas: 'energy energy' 'next hand'; gap: 6px 10px;   /* = HAND_PAD 42 in layout.js */
}
.mode-wide #repair { height: 24px; }
.mode-wide #hand { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; height: 100%; justify-items: center; }
.mode-wide #hand .card { max-height: 100%; height: 100%; width: auto; max-width: 100%; }
.mode-wide .card-cost { width: 30px; height: 30px; font-size: 18px; top: -9px; left: -9px; }
.mode-wide #next-wrap { justify-content: center; min-height: 0; }

.mode-wide #energy { height: 24px; }
.mode-wide #energy-num { width: 30px; height: 24px; font-size: 17px; }
.mode-wide #energy-track { height: 14px; border-radius: 10px; }

/* hover only where a real mouse exists */
@media (hover: hover) and (pointer: fine) {
  .card:hover { border-color: rgba(255, 255, 255, 0.35); }
  .layout-opt:hover, .btn:hover, .seg button:hover { filter: brightness(1.2); }
}

@keyframes pop { 0% { transform: scale(0.7); opacity: 0.2; } 100% { transform: scale(1); opacity: 1; } }
@keyframes pulse { 50% { opacity: 0.55; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes repairflash { 0% { box-shadow: 0 0 0 0 rgba(160, 255, 200, 0.9); } 100% { box-shadow: 0 0 0 10px rgba(109, 255, 168, 0); } }

/* ============================================================ SHARP UI
   Crisp esports look layered over the rules above: tight corners instead of pills, hard 1px edges
   and flat light/shadow lines instead of soft glows, corner brackets on the panels, chip-style cost
   badges, a name plate on every card. Kept as one block so it is easy to tune or remove. */
html, body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: geometricPrecision; }
:root { --edge: rgba(150, 180, 255, 0.22); --brk: rgba(190, 215, 255, 0.55); }

/* panels: small radius + corner brackets */
#lab, .mode-wide #scoreboard, .mode-wide #hand-panel {
  border-radius: 6px; border-color: var(--edge);
  background:
    linear-gradient(var(--brk), var(--brk)) left top / 14px 2px no-repeat,
    linear-gradient(var(--brk), var(--brk)) left top / 2px 14px no-repeat,
    linear-gradient(var(--brk), var(--brk)) right top / 14px 2px no-repeat,
    linear-gradient(var(--brk), var(--brk)) right top / 2px 14px no-repeat,
    linear-gradient(var(--brk), var(--brk)) left bottom / 14px 2px no-repeat,
    linear-gradient(var(--brk), var(--brk)) left bottom / 2px 14px no-repeat,
    linear-gradient(var(--brk), var(--brk)) right bottom / 14px 2px no-repeat,
    linear-gradient(var(--brk), var(--brk)) right bottom / 2px 14px no-repeat,
    linear-gradient(180deg, rgba(16, 24, 40, 0.94), rgba(9, 14, 24, 0.94));
}
.mode-tall #lab { border-radius: 0 6px 6px 0; }
#sb-clock { border-radius: 4px; border-color: var(--edge); background: rgba(3, 6, 12, 0.6); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06); }
.mode-wide #sb-clock { border-top: 2px solid var(--brk); }
/* phones: the scoreboard sits straight on the board's backdrop, so each team gets a dark plate with a team edge
   (reads on the light and the dark boards alike) */
.mode-tall .sb-team {
  padding: 4px 9px 5px; border-radius: 4px; background: rgba(6, 10, 18, 0.9); border: 1px solid var(--edge);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 8px rgba(0, 0, 0, 0.22);
}
.mode-tall #sb-left { border-left: 3px solid var(--tc); }
.mode-tall #sb-right { border-right: 3px solid var(--tc); }
.mode-tall #sb-clock { background: rgba(6, 10, 18, 0.9); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 8px rgba(0, 0, 0, 0.22); }
.sb-score { text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6), 0 0 6px color-mix(in srgb, var(--tc) 45%, transparent); }
.sb-name em { border-radius: 2px; }
.sb-bar { border-radius: 0; height: 3px; }
.sb-bar i { box-shadow: none; }
.pip { border-radius: 1px; border-width: 1px; }
.pip-t2 { border-radius: 1px; transform: skewX(-12deg); }
.pip.down, .pip.hit { box-shadow: none; }

/* cards */
.card { border-radius: 5px; }
.card.is-real {
  border-color: color-mix(in srgb, var(--kc) 55%, transparent);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--kc) 14%, transparent), transparent 46%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, #1c2740, #0d1424 78%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), inset 0 -1px 0 rgba(0, 0, 0, 0.6), 0 3px 0 rgba(0, 0, 0, 0.45), 0 6px 14px rgba(0, 0, 0, 0.4);
}
.card.is-real::before { left: 0; right: 0; top: 0; height: 3px; border-radius: 4px 4px 0 0; box-shadow: none; opacity: 1; }
.card.is-real .card-art canvas { filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.55)); }
.card-name {
  width: 100%; max-width: 100%; margin-top: auto; padding: 3px 3px 4px; border-radius: 0 0 4px 4px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.5)); border-top: 1px solid color-mix(in srgb, var(--kc) 35%, transparent);
  color: #e3ebf7; letter-spacing: 0.06em;
}
.card.is-real { justify-content: flex-end; }
.card.is-real .card-art { margin: auto 0 0; width: 88%; }
.card.mini { justify-content: center; }
.card.mini .card-art, .card.mini.is-real .card-art { margin: 0; width: 100%; }
.card::after { top: 6px; right: 6px; padding: 1px 4px; border-radius: 2px; background: rgba(3, 6, 12, 0.55); letter-spacing: 0.1em; }
.card-cost {
  border-radius: 5px;
  background: linear-gradient(135deg, #fff3b0, #ffcf3a 45%, #c98a00);
  box-shadow: 0 0 0 2px #070b13, 0 2px 0 2px rgba(0, 0, 0, 0.45);
}
.card-lock { border-radius: inherit; background: rgba(4, 7, 13, 0.7); }
.card.ready { border-color: rgba(255, 207, 58, 0.55); }
.card.selected { box-shadow: 0 0 0 2px var(--energy), 0 3px 0 rgba(0, 0, 0, 0.45), 0 14px 24px rgba(0, 0, 0, 0.55); }

/* energy */
#energy-num { border-radius: 4px; box-shadow: 0 0 0 2px #070b13, 0 2px 0 2px rgba(0, 0, 0, 0.4); background: linear-gradient(135deg, #fff3b0, #ffcf3a 50%, #c98a00); }
#energy-track, .mode-wide #energy-track { border-radius: 2px; background: rgba(0, 0, 0, 0.45); border-color: var(--edge); transform: skewX(-14deg); }
#energy-fill { box-shadow: inset -2px 0 0 rgba(255, 250, 220, 0.95); background: linear-gradient(180deg, rgba(255, 255, 255, 0.38) 0 28%, rgba(255, 255, 255, 0) 28%), linear-gradient(90deg, #f0a000, #ffd84d); }
#energy-segs i { border-right: 2px solid rgba(5, 8, 14, 0.75); }
#repair { border-radius: 4px; }
#repair .r-cost { border-radius: 3px; }

/* lab + buttons */
#lab-toggle, .lab-close { border-radius: 5px; }
.btn, .seg, .seg button, .layout-opt, .troop-opt, .deck-opt, .arena-schematic { border-radius: 4px; }
.seg button { border-radius: 3px; }
.btn.primary { background: linear-gradient(180deg, #3aa6f0, #1c68a3); border-color: #6cc4ff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 2px 0 rgba(0, 0, 0, 0.5); }
.lab-sec h3 { display: flex; align-items: center; gap: 6px; }
.lab-sec h3::before { content: ''; width: 3px; height: 10px; background: var(--brk); flex: none; }
.troop-opt.on, .deck-opt.on, .layout-opt.on { box-shadow: inset 0 0 0 1px var(--energy); }
#toast { border-radius: 4px; border-color: var(--edge); }
#result { border-radius: 4px; }

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

/* ============================================================ ONLINE 1V1
   Room-code lobby (src/ui/online.js), the connection pill and the online result buttons. */
#online-toggle {
  position: absolute; z-index: 6; display: none; flex-direction: column; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 4px; background: rgba(6, 10, 18, 0.9); border: 1px solid var(--edge, var(--line));
  color: var(--energy); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 8px rgba(0, 0, 0, 0.22);
}
#online-toggle svg { width: 20px; height: 20px; }
#online-toggle span { font-weight: 700; font-size: 8px; letter-spacing: 0.14em; margin-top: -1px; }
.mode-tall #online-toggle { display: flex; left: 8px; top: calc(var(--safe-top) + var(--top-h) + 8px); }
.online-live #online-toggle { display: none !important; }

#net-pill {
  position: absolute; z-index: 8; top: calc(var(--fy) + 6px); left: calc(var(--fx) + var(--fw) - 6px); transform: translateX(-100%);
  padding: 3px 8px; border-radius: 3px; white-space: nowrap; pointer-events: none;
  font-weight: 700; font-size: 11px; letter-spacing: 0.08em; color: var(--good);
  background: rgba(6, 10, 18, 0.85); border: 1px solid var(--edge, var(--line));
}
#net-pill[hidden] { display: none; }
#net-pill::before { content: '●'; margin-right: 5px; }
#net-pill.warn { color: var(--energy); }
#net-pill.bad { color: var(--bad); animation: pulse 1s infinite; }

#online {
  position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(3, 6, 11, 0.62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fadein 0.2s ease-out;
}
#online[hidden] { display: none; }
.on-card {
  width: min(100%, 380px); max-height: 100%; overflow-y: auto; padding: 14px 16px 16px; border-radius: 6px;
  border: 1px solid var(--edge, var(--line)); border-top: 2px solid var(--brk, var(--line));
  background: linear-gradient(180deg, rgba(16, 24, 40, 0.97), rgba(9, 14, 24, 0.97));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55); touch-action: pan-y;
}
.on-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.on-title { font-weight: 700; font-size: 20px; letter-spacing: 0.16em; color: var(--energy); }
.on-x { width: 32px; height: 32px; font-size: 16px; color: var(--dim); border-radius: 4px; }
.on-body { display: flex; flex-direction: column; gap: 10px; }
.on-sub { margin: 0; font-weight: 600; font-size: 14px; color: #c3cee2; line-height: 1.3; }
.on-field { display: flex; flex-direction: column; gap: 4px; }
.on-field span { font-weight: 700; font-size: 11px; letter-spacing: 0.14em; color: var(--dim); text-transform: uppercase; }
#online input {
  width: 100%; min-width: 0; padding: 9px 11px; border-radius: 4px; border: 1px solid var(--edge, var(--line));
  background: rgba(3, 6, 12, 0.8); color: var(--text); font: 600 16px var(--font); letter-spacing: 0.04em; outline: none;
  -webkit-user-select: text; user-select: text; touch-action: manipulation;
}
#online input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(47, 184, 255, 0.2); }
#online .btn { padding: 10px 14px; font-size: 14px; touch-action: manipulation; }
.on-wide { width: 100%; }
.on-or { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 11px; letter-spacing: 0.14em; color: var(--dim); text-transform: uppercase; }
.on-or i { flex: 1; height: 1px; background: var(--line); }
.on-join { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
#online .on-code { text-transform: uppercase; letter-spacing: 0.4em; font-size: 22px; text-align: center; font-weight: 700; }
.on-err { min-height: 0; font-weight: 700; font-size: 13px; color: var(--bad); }
.on-err:empty { display: none; }
.on-deck { font-weight: 600; font-size: 12px; color: var(--dim); line-height: 1.35; border-top: 1px solid var(--line); padding-top: 8px; }
.on-deck b { color: #c3cee2; letter-spacing: 0.08em; margin-right: 4px; text-transform: uppercase; font-size: 11px; }
.on-deck small { display: block; margin-top: 2px; font-size: 11px; opacity: 0.8; }
.on-bigcode {
  text-align: center; font-weight: 700; font-size: 58px; line-height: 1.05; letter-spacing: 0.24em; padding-left: 0.24em;
  color: var(--energy); text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5); -webkit-user-select: text; user-select: text;
}
.on-linkrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
#online .on-link { font-size: 13px; color: var(--dim); }
.on-status { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; color: #c3cee2; padding: 4px 0; }
.on-spin {
  width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.15); border-top-color: var(--energy);
  animation: onspin 0.8s linear infinite;
}
@keyframes onspin { to { transform: rotate(360deg); } }

/* deploy sent, not executed yet (input delay): dimmed, can't be played twice */
.card.pending { opacity: 0.45; filter: saturate(0.4); pointer-events: none; }

/* online result screen */
#res-leave { display: none; }
#result.is-online #res-leave { display: inline-block; }
#result.is-online #res-lab { display: none; }
#result.no-rematch #res-rematch { display: none; }
.res-note { font-weight: 700; font-size: 13px; color: var(--energy); min-height: 0; }
.res-note:empty { display: none; }
.res-notice .res-title { color: #cfd8e6; font-size: clamp(30px, calc(var(--fw) * 0.1), 60px); }

/* ============================================================ PHONE LAYOUT ON A PC
   Arena Lab → Layout → Phone (or ?layout=phone): the phone layout in a phone-shaped column in the middle of the window
   (main.js relayout() sizes #app; the pointer maths subtract its offset). */
#app.phone-frame { box-shadow: 0 0 0 1px rgba(150, 180, 255, 0.18), 0 30px 90px rgba(0, 0, 0, 0.65); }
html:has(#app.phone-frame), body:has(#app.phone-frame) { background: #020409; }

/* online: each player's ping (ms to the game server) next to their name */
.sb-ping { display: none; margin-left: 5px; font-size: 10px; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; color: var(--dim); vertical-align: 1px; }
.sb-ping:not(:empty) { display: inline; }
.sb-ping::before { content: '●'; margin-right: 2px; font-size: 8px; vertical-align: 1px; }
.sb-ping.good { color: var(--good); }
.sb-ping.ok { color: var(--energy); }
.sb-ping.bad { color: var(--bad); }
.mode-wide .sb-ping { font-size: 12px; }
/* phones: no room on the name line, so the ping hangs just under each team's plate (outer edge) */
.mode-tall .sb-team { position: relative; }
.mode-tall .sb-ping:not(:empty) {
  position: absolute; top: calc(100% + 3px); margin: 0; padding: 1px 6px; border-radius: 3px; white-space: nowrap;
  background: rgba(6, 10, 18, 0.88); border: 1px solid var(--edge, var(--line)); line-height: 1.3;
}
.mode-tall #sb-left .sb-ping { left: -3px; }
.mode-tall #sb-right .sb-ping { right: -3px; }

/* ============================================================ CARDS KEEP THEIR SHAPE (any window size)
   The card row is a size container: each card is as large as fits BOTH its column and the row height, with its
   0.78 shape. (Before, the height was pinned to the row and the width squeezed by narrow columns, so cards
   stretched into thin strips on smaller laptop windows.) Badge, tag and name scale with the card's own width
   (the card is an inline-size container). */
#hand { container-type: size; }
#hand .card, .mode-tall #hand .card, .mode-wide #hand .card {
  width: min(100%, calc(100cqh * 0.78)); height: auto; max-width: none; max-height: none; aspect-ratio: 0.78;
  min-height: 0; /* the shape wins over the content's own height */
}
#hand .card .card-cost, .mode-wide #hand .card .card-cost {
  --cs: clamp(19px, 27cqw, 32px);
  width: var(--cs); height: var(--cs); font-size: calc(var(--cs) * 0.6); top: calc(var(--cs) * -0.3); left: calc(var(--cs) * -0.3);
}
#hand .card::after {
  font-size: clamp(7px, 8cqw, 10px); top: clamp(3px, 5cqw, 7px); right: clamp(3px, 5cqw, 7px); padding: 1px clamp(2px, 3cqw, 5px);
  letter-spacing: 0.06em;
}
#hand .card .card-name { font-size: clamp(8px, 11.5cqw, 15px); padding: 0.25em 0.2em 0.3em; }
/* PC: the NEXT preview is ~80% of a hand card, so the eye lands on the playable cards first */
.mode-wide #next-wrap { container-type: size; gap: 4px; }
.mode-wide #next-card { width: min(86cqw, calc((100cqh - 18px) * 0.78 * 0.8)); height: auto; max-width: none; max-height: none; }

/* Arena Lab on narrow panels (small laptop windows): the arena diagram goes above its description instead of
   beside it, so the tower table never pushes the text out of the panel. */
#lab { container-type: inline-size; }
@container (max-width: 330px) {
  .arena-card { grid-template-columns: minmax(0, 1fr); }
  .li-towers th, .li-towers td { padding-left: 3px; padding-right: 3px; }
}

/* ============================================================ PC: ARENA LAB AS A DRAWER
   layout.js docks the Arena Lab only when that costs the board nothing; on short / narrow windows it becomes a
   drawer like on phones (LAB button top-left, 1V1 under it), so the arena gets the whole middle of the screen. */
.mode-wide.lab-drawer #lab {
  left: 0; top: 0; bottom: 0; width: min(92%, 380px); border-radius: 0 6px 6px 0; border-left: 0;
  padding-top: var(--safe-top); transform: translateX(-104%); transition: transform 0.22s ease;
  box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
}
.mode-wide.lab-drawer #lab.open { transform: translateX(0); }
.mode-wide.lab-drawer #lab-toggle { display: flex; left: 12px; top: calc(var(--safe-top) + 12px); }
.mode-wide.lab-drawer .lab-close { display: block; }
.mode-wide.lab-drawer #online-toggle { display: flex; left: 12px; top: calc(var(--safe-top) + 62px); }
.mode-wide.lab-drawer #res-lab { display: inline-block; }

/* ============================================================ PC SCOREBOARD ALIGNED TO THE BOARD
   The opponent's block sits level with their towers (top of the board), the clock level with the river, your block
   level with your towers (bottom): each number is next to what it describes (layout.js sets --sb-top/-river/-bottom). */
.mode-wide #scoreboard {
  top: var(--sb-top); height: calc(var(--sb-bottom) - var(--sb-top)); padding: 0; display: block;
  background: none; border: 0; box-shadow: none;
}
.mode-wide #scoreboard > * { position: absolute; left: 0; right: 0; }
.mode-wide .sb-team {
  padding: 10px 14px 11px; border-radius: 6px; border: 1px solid var(--edge);
  background: linear-gradient(180deg, rgba(16, 24, 40, 0.95), rgba(9, 14, 24, 0.95));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 6px 18px rgba(0, 0, 0, 0.22);
}
.mode-wide #sb-left { top: 0; border-left: 3px solid var(--tc); }
.mode-wide #sb-right { bottom: 0; border-left: 3px solid var(--tc); }
.mode-wide #sb-clock { top: calc(var(--sb-river) - var(--sb-top)); transform: translateY(-50%); }

/* very small hand cards (short laptop windows): a slightly smaller portrait leaves the name its two lines */
@container (max-width: 62px) {
  .card.is-real .card-art { width: 74%; }
  .card .card-name { padding: 0.15em 0.1em 0.2em; }
}
.mode-wide #sb-clock {
  padding: 8px 14px 10px; border-radius: 6px; border: 1px solid var(--edge); border-top: 2px solid var(--brk);
  background: linear-gradient(180deg, rgba(10, 16, 28, 0.97), rgba(5, 9, 17, 0.97));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 6px 18px rgba(0, 0, 0, 0.22);
}

/* ============================================================ FULL SCREEN (PC / Mac, src/ui/fullscreen.js)
   Bottom-right corner: empty in the PC layout (scoreboard ends at the board's near edge, the dock is centred). */
#fs-toggle {
  position: fixed; z-index: 7; right: 12px; bottom: calc(var(--safe-bottom) + 12px); display: none; align-items: center; gap: 7px;
  height: 32px; padding: 0 11px 0 9px; border-radius: 4px; background: rgba(6, 10, 18, 0.88); border: 1px solid var(--edge, var(--line));
  color: #c3cee2; font-weight: 700; font-size: 11px; letter-spacing: 0.14em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 12px rgba(0, 0, 0, 0.22);
}
#fs-toggle svg { width: 16px; height: 16px; }
#fs-toggle .fs-out, .is-fs #fs-toggle .fs-in { display: none; }
.is-fs #fs-toggle .fs-out { display: block; }
.can-fs.mode-wide #fs-toggle, .can-fs.phone-frame #fs-toggle { display: flex; }
@media (hover: hover) and (pointer: fine) { #fs-toggle:hover { color: #fff; border-color: var(--brk, var(--line)); } }
/* 1V1 panel option */
.on-check { display: flex; align-items: flex-start; gap: 9px; font-weight: 700; font-size: 13px; color: #c3cee2; cursor: pointer; }
.on-check input { width: 16px !important; height: 16px; margin: 1px 0 0; padding: 0 !important; accent-color: var(--energy); flex: none; }
.on-check small { display: block; font-weight: 600; font-size: 11px; color: var(--dim); margin-top: 1px; }

/* ============================================================ PC: SPACING UNIT + FULL SCREEN BUTTON IN THE RAIL
   --u (layout.js) is the one spacing unit. The full screen button sits in the scoreboard rail, bottom-aligned with
   the card dock, as wide as the rail; the LAB / 1V1 buttons keep the top-left corner on that same unit. */
.can-fs.mode-wide #fs-toggle {
  left: var(--rp-x); right: auto; width: var(--rp-w); top: calc(var(--dock-bottom) - 34px); bottom: auto; height: 34px;
  justify-content: center; border-radius: 6px;
}
.mode-wide.lab-drawer #lab-toggle { left: var(--u, 12px); top: calc(var(--safe-top) + var(--u, 12px)); }
.mode-wide.lab-drawer #online-toggle { left: var(--u, 12px); top: calc(var(--safe-top) + var(--u, 12px) + 50px); }

/* ============================================================ ENERGY QUEUE (src/input/deployQueue.js)
   A card dropped before you can pay for it waits on the board; its hand card is marked QUEUED (dashed gold frame,
   a pill at the bottom). Dragging a card back over the hand lights its slot: let go there = cancel. */
.card-queue {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); display: none; pointer-events: none; z-index: 2;
  padding: 1px 5px; border-radius: 3px; background: var(--energy); color: #1b1300;
  font-weight: 800; font-size: 9px; font-size: clamp(8px, 11cqw, 11px); letter-spacing: 0.12em; white-space: nowrap;
  box-shadow: 0 0 0 1px #0b111c, 0 0 10px rgba(255, 207, 58, 0.55);
}
.card.queued .card-queue { display: block; animation: pulse 1.1s ease-in-out infinite; }
.card.queued, .card.is-real.queued { border: 1px dashed var(--energy); box-shadow: 0 0 0 1px rgba(255, 207, 58, 0.35), 0 0 14px rgba(255, 207, 58, 0.25); }
.card.home, .card.dragging.home { opacity: 1; border-color: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55), 0 0 16px rgba(255, 255, 255, 0.25); }

/* DISCARDED cards (2026-11-24): Arena Lab card list + record (src/ui/lab.js discardHtml) */
.troop-kind.discarded { color: #ff9e6b; }
.troop-kind.discarded small { color: inherit; opacity: 0.7; font-weight: 500; }
.troop-opt.gone { opacity: 0.55; filter: grayscale(0.7); }
.troop-opt.gone.on { opacity: 1; filter: none; }
.discard-rec { margin: 6px 0 8px; padding: 8px 10px; border: 1px solid rgba(255, 140, 90, 0.55); border-radius: 8px; background: rgba(255, 120, 60, 0.1); font-size: 12px; line-height: 1.45; }
.discard-rec b { color: #ff9e6b; letter-spacing: 0.06em; }
.discard-rec ul { margin: 4px 0; padding-left: 18px; }
.discard-rec p { margin: 4px 0; }
.discard-rec small { opacity: 0.75; }
