/* The Relay — playful, light, fast. System fonts only; bright accent pops. */

:root {
  --bg: #fffaf3;
  --ink: #2b2b33;
  --muted: #8a8a96;
  --card: #ffffff;
  --line: #f0e8dc;
  --alpha: #ff5d5d;   /* team Alpha — hot coral */
  --bravo: #2ec4b6;   /* team Bravo — bright teal */
  --sun: #ffb703;     /* accent — sunshine */
  --violet: #8338ec;  /* accent — pop violet */
  --green: #43c465;
  --radius: 18px;
  --shadow: 0 4px 14px rgba(43, 43, 51, 0.08);
}

* { box-sizing: border-box; }

/* The dark palette, shared by every dark surface: the Grandmaster's command
   board, the player's board screen, the result screen and the board frame that
   practice mode mounts into. Declared on :root rather than on a list of views,
   because a custom property paints nothing on its own — it only does anything
   where something references it — and a list is one more place to forget to
   add a surface to. theme.js is this same vocabulary for the boards
   themselves; keep the two in step. */
:root {
  --gm-bg: #07091f;
  --gm-panel: #0c1230;
  --gm-panel-2: #111943;
  --gm-line: rgba(122, 140, 255, 0.25);
  --gm-line-soft: rgba(122, 140, 255, 0.13);

  --gm-text: #f7f8ff;
  --gm-muted: #9aa5cb;

  --gm-yellow: #ffd21c;
  --gm-cyan: #20d4e7;
  --gm-violet: #8a4dff;
  --gm-pink: #ff4f94;
  --gm-red: #ff5165;
  --gm-green: #42db83;
  --gm-amber: #ffa62b;

  --gm-radius-sm: 8px;
  --gm-radius-md: 14px;
  --gm-radius-lg: 20px;

  --gm-gap: 16px;
}

/* The hidden attribute must always win, even over classes that set display
   (e.g. .stage-overlay's flex — without this the overlay covers the page). */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  max-width: 720px;
  margin: 0 auto;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 0.3px;
}
/* Drawn, not typed: the wordmark should not be whichever flag the reader's
   system font happens to ship. */
.logo svg { width: 15px; height: 20px; color: #ffd21c; flex: none; }
.chip {
  background: var(--violet);
  color: #fff;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
}

.view { max-width: 720px; margin: 0 auto 16px; padding: 0 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 14px;
}

h1 { margin: 0 0 6px; font-size: 1.5rem; }
h2 { margin: 0 0 8px; font-size: 1.05rem; }
.sub { color: var(--muted); margin: 0 0 16px; }
.muted { color: var(--muted); font-weight: 400; }

label { display: block; font-weight: 700; font-size: 0.9rem; margin: 12px 0 4px; }
input {
  width: 100%;
  font-size: 1.05rem;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  outline: none;
}
input:focus { border-color: var(--sun); }

.btn {
  font-size: 1rem;
  font-weight: 800;
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  cursor: pointer;
  color: #fff;
  transition: transform 0.08s ease;
  min-height: 48px; /* comfy thumb target */
}
.btn:active { transform: scale(0.96); }
.team-alpha { background: var(--alpha); }
.team-bravo { background: var(--bravo); }
.team-auto  { background: var(--violet); }
.team-pick { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.team-pick .btn { flex: 1 1 30%; }

.error-line { color: var(--alpha); font-weight: 700; }

.games-link-row { margin: 18px 0 0; text-align: center; }
.games-link { color: var(--violet); font-weight: 700; text-decoration: none; }
.games-link:hover { text-decoration: underline; }

/* The lobby moved to lobby.css; its old rules lived here. */

.mini-btn {
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; font-weight: 800; cursor: pointer;
  padding: 4px 10px; min-height: 32px; font-size: 0.85rem;
}
.mini-btn:active { transform: scale(0.94); }
.mini-btn.kick { border-color: var(--alpha); color: var(--alpha); }
.host-controls { display: inline-flex; gap: 4px; }
.mini-btn:disabled { opacity: 0.35; cursor: not-allowed; }
/* Still worn by the host's end-session control once the race is on. */
.danger-btn { width: 100%; background: var(--alpha); margin-top: 6px; }

/* The end-session control rides along with the host once the race is on. */
.host-live {
  position: fixed; right: 14px; bottom: 14px; z-index: 40;
  max-width: 200px;
}
.host-live .btn { width: 100%; box-shadow: var(--shadow); }

/* T5.3 readiness strip */
.strip { padding: 12px 16px; }
.strip .team-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 3px 0; }
.strip .team-name { font-weight: 800; min-width: 74px; }
.strip .stage-tag {
  font-size: 0.75rem; font-weight: 800; color: #fff;
  border-radius: 999px; padding: 2px 9px;
}
.strip .alpha .stage-tag { background: var(--alpha); }
.strip .bravo .stage-tag { background: var(--bravo); }
.dot {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.8rem; font-weight: 600; color: var(--muted);
}
.dot::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  background: #d9d3c7; display: inline-block;
}
.dot.green::before { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.off { opacity: 0.45; }

/* countdown */
.timer-bar {
  height: 10px; border-radius: 999px; overflow: hidden;
  background: var(--line); margin: 0 12px 4px;
}
#timer-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--sun), var(--alpha));
  transition: width 0.25s linear;
}
.timer-label { text-align: center; font-weight: 800; margin-bottom: 10px; }

.prompt { font-weight: 700; font-size: 1.05rem; margin: 0 0 10px; }
/* Board controls moved to board.css, shared with practice mode. */

.rest { text-align: center; border: 2px solid var(--green); }
.rest-big { font-size: 1.6rem; font-weight: 800; }

.feed { list-style: none; margin: 0; padding: 0 8px; color: var(--muted); font-size: 0.85rem; }
.feed li { padding: 2px 0; }
.feed li.fresh { color: var(--ink); font-weight: 600; }

/* T5.4 stage transition + result */
.stage-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(131, 56, 236, 0.92); color: #fff; z-index: 40;
  /* Smaller than it was: the text now names a team instead of a bare number. */
  font-size: clamp(1.5rem, 5.5vw, 3.1rem); font-weight: 900;
  text-align: center; padding: 0 24px; line-height: 1.12;
  animation: pop-in 0.25s ease;
}
/* Your team moving and the rivals moving are opposite news, so they do not get
   the same colour. */
.stage-overlay.is-mine { background: rgba(48, 160, 82, 0.94); }
.stage-overlay.is-rival { background: rgba(30, 30, 38, 0.94); color: #ff8b8b; }
@keyframes pop-in { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.result-emoji { font-size: 4rem; text-align: center; }
#view-result { text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-weight: 700;
  padding: 10px 18px; border-radius: 999px; z-index: 50;
  animation: pop-in 0.2s ease;
}

/* v2: cleared card, wait-or-bonus choice, freeze, leader dashboard */
.bonus-badge {
  display: inline-block; margin-bottom: 8px;
  background: var(--alpha); color: #fff; font-weight: 800;
  border-radius: 999px; padding: 4px 12px; font-size: 0.8rem;
}

.choice-overlay {
  position: fixed; inset: 0; z-index: 45;
  display: flex; align-items: center; justify-content: center;
  background: rgba(43, 43, 51, 0.55);
}
.choice-box { max-width: 340px; text-align: center; }
.choice-box .btn { width: 100%; margin: 6px 0; }

.frozen-overlay {
  position: fixed; inset: 0; z-index: 46;
  display: flex; align-items: center; justify-content: center;
  background: rgba(46, 196, 182, 0.85); color: #fff;
  font-size: clamp(1.6rem, 7vw, 3rem); font-weight: 900;
  animation: pop-in 0.2s ease;
}

.claim-leader-btn { width: 100%; margin-top: 6px; }

.assign-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 6px 0; font-weight: 600;
}
.assign-select {
  font-size: 0.9rem; padding: 8px 10px; border-radius: 10px;
  border: 2px solid var(--line); background: var(--bg); font-weight: 700;
}

.leader-head { display: flex; align-items: center; justify-content: space-between; }
.currency-chip { background: var(--sun); color: var(--ink); }
.leader-roster { list-style: none; margin: 0 0 12px; padding: 0; }
.leader-roster li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; font-weight: 600; border-bottom: 1px dashed var(--line);
}
.pill {
  font-size: 0.75rem; font-weight: 800; border-radius: 999px;
  padding: 2px 10px; background: var(--line); color: var(--muted);
}
.pill.green { background: var(--green); color: #fff; }
.pill.bonus { background: var(--alpha); color: #fff; }
.leader-opponent { font-weight: 700; color: var(--muted); }

.perk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.perk-card {
  border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
}
.perk-card.attack { border-color: var(--alpha); }
.perk-card.defense { border-color: var(--bravo); }
.perk-name { font-weight: 800; }
.perk-card .mini-btn { align-self: stretch; }
.perk-card .mini-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.handoff-row { display: flex; gap: 10px; align-items: center; }
.handoff-row select { flex: 1; }

@media (max-width: 480px) {
  .card { padding: 14px; }
  h1 { font-size: 1.25rem; }
}

/* --- duels (the Duelist role) --- */
.duel-card { border: 2px solid var(--violet); }
#duel-title { color: var(--violet); letter-spacing: 0.04em; }
.duel-timer { margin: 0 0 12px; }
/* The round clock. The shell draws it for every duel game, beside the title on
   a Duelist's card and in the Grandmaster's duel watch. */
.duel-clock {
  float: right; min-width: 3.2em; text-align: center;
  font-weight: 900; font-variant-numeric: tabular-nums;
  color: var(--violet); background: var(--card);
  border: 2px solid var(--violet); border-radius: 999px; padding: 1px 10px;
}
.duel-clock.urgent {
  color: #fff; background: var(--alpha); border-color: var(--alpha);
  animation: duel-clock-pulse 0.6s ease-in-out infinite;
}
.gm-panel__head .duel-clock { float: none; font-size: 0.85rem; }
@keyframes duel-clock-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.09); }
}
@media (prefers-reduced-motion: reduce) {
  .duel-clock.urgent { animation: none; }
}
#duel-timer-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--violet), var(--alpha));
  transition: width 0.1s linear;
}

.duel-header {
  display: flex; align-items: center; justify-content: space-around;
  gap: 8px; margin-bottom: 10px;
}
.duel-seat { text-align: center; min-width: 88px; }
.duel-hand { font-size: 2.6rem; line-height: 1.2; }
.duel-name { font-weight: 800; font-size: 0.9rem; }
.duel-pips { color: var(--violet); letter-spacing: 3px; font-size: 1.1rem; }
.duel-versus { font-weight: 900; color: var(--muted); letter-spacing: 0.1em; }
.duel-status {
  text-align: center; font-weight: 800; min-height: 1.4em; margin-bottom: 10px;
}

.duel-moves { display: flex; gap: 10px; justify-content: center; }
.duel-move {
  font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 14px; min-width: 84px;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink);
  transition: transform 0.1s ease, border-color 0.1s ease;
}
.duel-move:hover:not(:disabled) {
  border-color: var(--violet); transform: translateY(-2px);
}
.duel-move:disabled { opacity: 0.45; cursor: default; }
.duel-move.chosen { border-color: var(--violet); opacity: 1; }
.duel-move-art { font-size: 1.8rem; }
.duel-move-label { font-size: 0.78rem; font-weight: 700; }

/* The reveal beat: the moment both hands are on the table. */
.duel-reveal .duel-hand { animation: duel-pop 0.35s ease; }
.duel-done .duel-status { font-size: 1.15rem; }
@keyframes duel-pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .duel-reveal .duel-hand { animation: none; }
  .duel-move { transition: none; }
}

/* --- the three stateful duels (Crown Duel, Number Clash, Bid War) ---------
   They share the header, the status line and the reveal beat above; what each
   adds is its own stage — a hand, a nine-cell grid, a bid stepper. Everything
   here is the same light Relay palette as the rest of the app: the handoff
   mockups are dark, but a duel is one card inside this page, not a second
   product. */
.duel-round {
  text-align: center; text-transform: uppercase; letter-spacing: 0.08em;
  font-size: 0.72rem; font-weight: 800; color: var(--muted); margin-bottom: 6px;
}
.duel-score { font-weight: 900; font-size: 1.1rem; color: var(--violet); }
.duel-sub { font-size: 0.72rem; color: var(--muted); }
.duel-stage { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.duel-note, .duel-guide {
  font-size: 0.75rem; color: var(--muted); text-align: center;
  margin: 4px 0 0; max-width: 34em;
}
.duel-guide { margin-top: 12px; }
/* "1 of 3 — choose two cards to destroy" */
.duel-step-label { font-weight: 800; margin: 0; }

/* Cards, numbers and quick bids are all the same pressable tile. */
.duel-cards, .duel-numbers, .duel-quick {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
.duel-card, .duel-number, .duel-quick-bid, .duel-step, .duel-lock, .duel-cancel {
  font-family: inherit; cursor: pointer; color: var(--ink);
  background: var(--card); border: 2px solid var(--line);
  border-radius: var(--radius); min-height: 44px;
  transition: transform 0.1s ease, border-color 0.1s ease;
}
.duel-card:hover:not(:disabled), .duel-number:hover:not(:disabled),
.duel-quick-bid:hover:not(:disabled), .duel-step:hover:not(:disabled),
.duel-lock:hover:not(:disabled) {
  border-color: var(--violet); transform: translateY(-2px);
}
.duel-card:disabled, .duel-number:disabled, .duel-quick-bid:disabled,
.duel-step:disabled, .duel-lock:disabled { opacity: 0.45; cursor: default; }
.duel-card.chosen, .duel-number.chosen, .duel-quick-bid.chosen {
  border-color: var(--violet); opacity: 1;
}

.duel-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 12px; min-width: 78px;
}
.duel-card-art { font-size: 1.7rem; }
.duel-card-label { font-size: 0.75rem; font-weight: 700; }
.duel-card-note {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--violet);
}
.duel-card.spent { text-decoration: line-through; }
/* A card marked for destruction. Nothing is spent until the confirm. */
.duel-card.burning { border-color: var(--alpha); background: #fff4f4; }

.duel-number {
  width: 52px; padding: 10px 0; font-size: 1.2rem; font-weight: 800;
}
.duel-number.spent { text-decoration: line-through; }

.duel-actions { display: flex; gap: 8px; }
.duel-lock {
  padding: 10px 20px; font-weight: 800; letter-spacing: 0.03em;
  border-color: var(--violet);
}
.duel-cancel { padding: 10px 16px; font-weight: 700; color: var(--muted); }

/* Bid War: the lots on offer, then the stepper that names an exact bid. */
.duel-prizes { display: flex; gap: 10px; justify-content: center; margin-bottom: 10px; }
.duel-prize {
  border: 2px solid var(--sun); border-radius: var(--radius);
  padding: 8px 18px; text-align: center; min-width: 104px;
}
.duel-prize--next { border-color: var(--line); opacity: 0.75; }
.duel-prize-label {
  font-size: 0.62rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
}
.duel-prize-value { font-size: 1.4rem; font-weight: 900; }
.duel-stepper { display: flex; align-items: center; gap: 10px; }
.duel-step { width: 44px; font-size: 1.3rem; font-weight: 900; }
.duel-bid-value {
  min-width: 84px; text-align: center; font-size: 1.8rem; font-weight: 900;
}
.duel-quick-bid { padding: 8px 14px; font-weight: 700; min-width: 52px; }

/* A short tail of resolved rounds — enough to read the run of play. */
.duel-log { margin-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.duel-log-row {
  display: flex; gap: 10px; justify-content: center; align-items: baseline;
  font-size: 0.75rem; color: var(--muted);
}
.duel-log-round { font-weight: 800; color: var(--ink); min-width: 26px; }
.duel-log-pair { font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .duel-card, .duel-number, .duel-quick-bid, .duel-step, .duel-lock {
    transition: none;
  }
}
@media (max-width: 480px) {
  .duel-number { width: 44px; }
  .duel-card { min-width: 64px; padding: 6px 8px; }
}

/* --- screen-effect perks (wobble / static / mirror / blackout) -------------
   Cosmetic sabotage the server stamps on ONE opponent. Every class lands on
   #puzzle-card only, so the HUD, the wait countdown and the body-level frozen
   overlay stay readable and correctly positioned. Transforms are hit-tested
   after they apply, so a click always lands on the tile you can see. Only
   `transform`, `opacity` and `filter` animate — nothing that triggers layout. */

.perk-desc { color: var(--muted); font-size: 0.75rem; line-height: 1.3; }

.fx-wobble { animation: fx-wobble 1.1s ease-in-out infinite; }
.fx-wobble .prompt { animation: fx-wobble-prompt 1.7s ease-in-out infinite; }
@keyframes fx-wobble {
  0%   { transform: translate(0, 0) rotate(0deg); }
  20%  { transform: translate(-5px, 2px) rotate(-0.9deg); }
  40%  { transform: translate(4px, -3px) rotate(1.1deg); }
  60%  { transform: translate(-3px, -2px) rotate(0.5deg); }
  80%  { transform: translate(5px, 3px) rotate(-1.2deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}
/* Deliberately out of phase with the card, so the card reads as unstable
   rather than as one clean shudder. */
@keyframes fx-wobble-prompt {
  0%   { transform: translate(0, 0) rotate(0deg); }
  33%  { transform: translate(4px, -2px) rotate(1deg); }
  66%  { transform: translate(-4px, 2px) rotate(-1deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

/* Flips the board, not the prompt: the instructions stay legible, the puzzle
   does not. A scaleX on the mount keeps clicks landing where they look. */
.fx-mirror #puzzle-mount { transform: scaleX(-1); }

.fx-static, .fx-blackout { position: relative; }
.fx-static::after, .fx-blackout::after {
  content: ""; position: absolute; inset: 0; z-index: 5;
  border-radius: var(--radius); pointer-events: none;
}
.fx-static::after {
  background-image: repeating-linear-gradient(
    0deg, rgba(0,0,0,0.55) 0 2px, rgba(255,255,255,0.35) 2px 4px);
  opacity: 0.5;
  animation: fx-static 0.32s steps(4) infinite;
}
@keyframes fx-static {
  0%   { transform: translateY(0); opacity: 0.5; }
  50%  { transform: translateY(-2px); opacity: 0.36; }
  100% { transform: translateY(-4px); opacity: 0.5; }
}
.fx-blackout::after { background: #05050a; }

@media (prefers-reduced-motion: reduce) {
  /* The perk must still cost the victim something — swap the motion for a
     legibility hit rather than silently doing nothing, which would make the
     buy a coin-flip on the victim's OS settings. */
  .fx-wobble, .fx-wobble .prompt { animation: none; }
  .fx-wobble #puzzle-mount { animation: fx-blur-pulse 1.4s ease-in-out infinite; }
  .fx-static::after { animation: none; }
  @keyframes fx-blur-pulse {
    0%, 100% { filter: blur(0); opacity: 1; }
    50%      { filter: blur(2.5px); opacity: 0.72; }
  }
}

/* The bomb console's only live element: on a dark-fuse board the Defuser's face
   shows no number, so this is the one clock in the match (GAME_DESIGN §2c). */
.bomb-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.6rem;
  text-align: center;
  padding: 0.4rem 0;
  color: #b3261e;
  background: #1b1b1b;
  border-radius: 6px;
  margin-bottom: 0.6rem;
}
