/* Battle Board — two-player game picker.
   Tokens, reset, body, Inter font, .chip, focus-visible, touch-action,
   .visually-hidden, and reduced-motion come from /assets/base.css. */

/* Battle-specific additions to the shared palette */
:root {
  --good: #27d17a;
  --error: #ff5d5d;

  /* Player identity colors */
  --player-a: var(--accent);            /* TagWhy purple */
  --player-a-soft: rgba(138, 124, 255, 0.18);
  --player-b: #ff7aa8;                  /* warm pink */
  --player-b-soft: rgba(255, 122, 168, 0.18);

  --card-bg: linear-gradient(160deg, #141826, #101321);
  --card-bg-primary: linear-gradient(160deg, #161a2d, #0f1220);
  --box-bg: radial-gradient(circle at 0 0, #272b4a 0, #181b2a 42%, #101320 78%);
  --inset-bg: #101322;
}

/* ============================================================
   APP WRAPPER
   ============================================================ */

.app {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 28px 44px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (max-width: 768px) {
  .app { padding: 28px 18px 30px; gap: 16px; }
}

@media (max-width: 480px) {
  .app { padding: 20px 12px 24px; }
}

/* ============================================================
   PAGE HEADER — centered, non-sticky
   ============================================================ */

.page-header {
  text-align: center;
  padding: 8px 0 4px;
}

.page-header h1 {
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.page-header h1 .accent { color: var(--accent); }

.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.muted { color: var(--muted); }

/* ============================================================
   TOOLBAR — mode toggle + reset
   ============================================================ */

.toolbar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  background: #161925;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.14s ease, background 0.14s ease,
              border-color 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 10px 22px rgba(138, 124, 255, 0.45);
}

.btn.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(138, 124, 255, 0.75);
}

.btn.ghost { background: #141622; }

.btn.ghost:hover:not(:disabled) {
  border-color: var(--accent);
  background: #1a2030;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
  pointer-events: none;
}

.btn.small {
  padding: 7px 12px;
  font-size: 13px;
}

/* Keyboard hint pills inside buttons */
.kbd-hint-inline {
  display: inline-block;
  padding: 1px 6px;
  font: 600 10px var(--font-mono);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.85);
}

@media (hover: none) and (pointer: coarse) {
  .kbd-hint-inline { display: none; }
}

/* Win buttons get player colors */
.win-btn {
  padding: 12px 22px;
  font-weight: 600;
  font-size: 15px;
  min-width: 120px;
  justify-content: center;
}

.win-btn .win-btn-label {
  flex: 1;
  text-align: center;
}

.win-a {
  background: var(--player-a);
  border-color: var(--player-a);
  color: #fff;
  box-shadow: 0 10px 22px var(--player-a-soft);
}

.win-a:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(138, 124, 255, 0.7);
}

.win-b {
  background: var(--player-b);
  border-color: var(--player-b);
  color: #fff;
  box-shadow: 0 10px 22px var(--player-b-soft);
}

.win-b:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(255, 122, 168, 0.65);
}

/* Tie button — neutral, smaller, between A and B */
.win-tie {
  background: #1a1e2c;
  border-color: rgba(167, 167, 192, 0.5);
  color: var(--muted);
  box-shadow: none;
  padding: 10px 14px;
  min-width: 74px;
  font-size: 13px;
  font-weight: 500;
  flex: 0 0 auto;
}

.win-tie:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(167, 167, 192, 0.85);
  background: #1f2335;
  transform: translateY(-1px);
}

.win-a, .win-b { flex: 1 1 0; }

/* Mode toggle pill */

.mode-toggle {
  background: #151922;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mode-pill {
  padding: 5px 11px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius-pill);
  background: transparent;
  border: none;
  color: var(--muted);
  transition: background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.mode-pill.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(138, 124, 255, 0.7);
}

.mode-pill:not(.active):hover {
  background: #1c2231;
  color: var(--text);
}

/* ============================================================
   LAYOUT
   ============================================================ */

.layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (min-width: 960px) {
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 24px;
    align-items: stretch;
  }
}

/* ============================================================
   CARD
   ============================================================ */

.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  padding: 22px 22px 24px;
  border-radius: var(--radius-lg);
  box-shadow: 0 22px 46px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    circle at top right,
    rgba(138, 124, 255, 0.08),
    transparent 60%
  );
}

.card-primary {
  background: var(--card-bg-primary);
}

.card > * { position: relative; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-header h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ============================================================
   SETUP
   ============================================================ */

.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

@media (max-width: 640px) {
  .setup-grid { grid-template-columns: 1fr; }
}

.setup-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 14px;
}

.setup-label {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.setup-input {
  padding: 9px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--inset-bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.setup-input::placeholder { color: rgba(167, 167, 194, 0.7); }

.setup-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(138, 124, 255, 0.3);
}

.setup-inline-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.setup-label.inline {
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}

.small-number {
  width: 70px;
  max-width: 90px;
  text-align: center;
  font-size: 15px;
  padding: 8px 10px;
}

.setup-players {
  grid-column: 1 / -1;
  align-items: center;
  text-align: center;
}

.players-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

.players-row .setup-input {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
}

.players-vs {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.setup-field-end {
  align-items: flex-end;
  justify-content: flex-end;
}

.setup-field-end .btn {
  width: 100%;
  justify-content: center;
  padding-top: 10px;
  padding-bottom: 10px;
}

.status-text {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.status-text strong { color: #fff; }

/* ============================================================
   INLINE NOTICE (replaces alert/confirm)
   ============================================================ */

.notice {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: notice-in 0.2s ease;
}

.notice-info {
  background: rgba(138, 124, 255, 0.1);
  border: 1px solid rgba(138, 124, 255, 0.4);
  color: var(--text);
}

.notice-warn {
  background: rgba(255, 93, 93, 0.08);
  border: 1px solid rgba(255, 93, 93, 0.35);
  color: #ffdada;
}

.notice-actions {
  display: flex;
  gap: 8px;
}

.notice-btn {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  font-family: inherit;
  opacity: 0.9;
}

.notice-btn:hover { opacity: 1; }

@keyframes notice-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   TOP PILLS
   ============================================================ */

.pill-bar {
  display: inline-flex;
  padding: 5px;
  border-radius: var(--radius-pill);
  background: #111526;
  border: 1px solid rgba(167, 167, 192, 0.5);
  gap: 5px;
  flex-wrap: wrap;
}

.pill {
  padding: 5px 12px;
  font-size: 13px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
}

.pill span {
  font-weight: 600;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   GAME BOXES (random / select / winner)
   ============================================================ */

.game-box {
  margin-top: 16px;
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--box-bg);
  border: 1px solid rgba(167, 167, 192, 0.4);
  animation: box-in 0.25s ease;
}

@keyframes box-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.game-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.game-sub {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}

/* Picker head: title + best-of stepper */
.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* Pending box: centered "next game" state with big CTA */
.pending-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 26px 18px;
  text-align: center;
}

.pending-box .game-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}

.pick-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: var(--radius-pill);
  box-shadow: 0 10px 28px rgba(138, 124, 255, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pick-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(138, 124, 255, 0.5);
}

.pick-btn .pick-btn-arrow {
  font-size: 18px;
  line-height: 1;
  transition: transform 0.15s ease;
}

.pick-btn:hover .pick-btn-arrow {
  transform: translateX(3px);
}

.remove-last {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 8px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

.remove-last:hover {
  color: var(--player-b, #ff7aa8);
}

.remove-last.hidden { display: none !important; }

/* Winner head: title + mini inner score */
.winner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* Compact best-of stepper */
.stepper {
  display: inline-flex;
  align-items: center;
  background: #111526;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 0;
  user-select: none;
}

.step-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  font-family: inherit;
}

.step-btn:hover:not(:disabled) {
  background: rgba(138, 124, 255, 0.22);
  color: #fff;
}

.step-btn:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

.stepper-label {
  min-width: 56px;
  text-align: center;
  padding: 0 4px;
  line-height: 1;
}

.stepper-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stepper-sub {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-top: 3px;
}

/* ============================================================
   ROLL OVERLAY (big centered modal with slot-machine reel)
   ============================================================ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.overlay.hidden { display: none !important; }

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 12, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: overlay-fade 0.2s ease;
}

@keyframes overlay-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.overlay-dialog {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  background: var(--card-bg, #12141e);
  border: 1px solid var(--line, rgba(167, 167, 192, 0.4));
  border-radius: var(--radius-md, 14px);
  padding: 22px 22px 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  animation: overlay-pop 0.22s ease;
}

@keyframes overlay-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.overlay-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.overlay-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: 1;
}

.overlay-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line, rgba(167, 167, 192, 0.4));
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.overlay-close:hover {
  background: #222740;
  color: #fff;
  border-color: var(--accent);
}

.overlay-body { display: block; }
.overlay-body.hidden { display: none !important; }

/* Slot-machine reel */

.reel-window {
  position: relative;
  height: 180px;
  overflow: hidden;
  border-radius: var(--radius-md, 14px);
  background: linear-gradient(180deg, #0a0c16 0%, #161a2c 50%, #0a0c16 100%);
  border: 1px solid var(--line, rgba(167, 167, 192, 0.35));
  mask-image: linear-gradient(180deg, transparent 0%, #000 25%, #000 75%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 25%, #000 75%, transparent 100%);
}

.reel-center {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 60px;
  transform: translateY(-50%);
  border-top: 1px solid rgba(138, 124, 255, 0.55);
  border-bottom: 1px solid rgba(138, 124, 255, 0.55);
  pointer-events: none;
  z-index: 2;
}

.reel-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 60px; /* centers the first item in the 180px window */
  transform: translateY(0);
  will-change: transform;
}

.reel-track.spinning {
  transition: transform 2.6s cubic-bezier(0.12, 0.72, 0.18, 1);
}

.reel-item {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  padding: 0 12px;
  text-align: center;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reel-item.landed {
  color: var(--accent);
  text-shadow: 0 0 24px rgba(138, 124, 255, 0.6);
}

.overlay-foot {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

/* Big chip grid for Select mode inside the overlay */

.overlay-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding: 2px;
}

.overlay-chip-grid .game-chip {
  padding: 16px 14px;
  font-size: 15px;
}

/* Select mode game list (legacy, unused but kept for safety) */

.game-list {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.game-chip {
  border-radius: var(--radius-pill);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid rgba(210, 215, 240, 0.9);
  background: #181c30;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s ease, border-color 0.12s ease,
              color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.game-chip:hover {
  border-color: var(--accent);
  background: #222740;
  color: #fff;
  transform: translateY(-1px);
}

.game-chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(138, 124, 255, 0.7);
}

.winner-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

/* Compact inner-game scoreboard next to the game title */
.mini-score {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: #111526;
  border: 1px solid var(--line);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.mini-a { color: var(--player-a); }
.mini-b { color: var(--player-b); }
.mini-sep { color: var(--muted); font-weight: 300; }

/* ============================================================
   HERO SCOREBOARD
   ============================================================ */

.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 18px 6px 14px;
  margin-bottom: 6px;
}

.player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.player-name {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-a .player-name { color: var(--player-a); }
.player-b .player-name { color: var(--player-b); }

.player-score {
  font-size: clamp(48px, 8vw, 76px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: color 0.25s ease, text-shadow 0.25s ease, transform 0.25s ease;
}

.player-a .player-score.lead {
  color: var(--player-a);
  text-shadow: 0 0 30px rgba(138, 124, 255, 0.4);
}

.player-b .player-score.lead {
  color: var(--player-b);
  text-shadow: 0 0 30px rgba(255, 122, 168, 0.4);
}

.player-score.bump {
  animation: score-bump 0.35s ease;
}

@keyframes score-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.score-sep {
  font-size: clamp(36px, 6vw, 52px);
  color: var(--muted);
  line-height: 1;
  font-weight: 300;
}

.series-meta {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
  min-height: 1.2em;
}

/* ============================================================
   STATUS DOT CHIP
   ============================================================ */

.series-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: #111526;
  border: 1px solid rgba(167, 167, 192, 0.4);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.series-status-chip[data-status="running"] {
  color: var(--accent);
  border-color: rgba(138, 124, 255, 0.5);
}

.series-status-chip[data-status="running"] .status-dot {
  background: var(--accent);
  animation: pulse 1.5s ease infinite;
}

.series-status-chip[data-status="finished"] {
  color: var(--good);
  border-color: rgba(39, 209, 122, 0.5);
}

.series-status-chip[data-status="finished"] .status-dot {
  background: var(--good);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(138, 124, 255, 0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(138, 124, 255, 0); }
}

/* ============================================================
   ROUNDS TABLE
   ============================================================ */

.rounds-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  margin-bottom: 2px;
}

.rounds-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.score-table,
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}

.score-table th,
.score-table td,
.history-table th,
.history-table td {
  padding: 7px 4px;
}

.score-table th,
.history-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid rgba(167, 167, 192, 0.4);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.score-table td,
.history-table td {
  border-bottom: 1px solid rgba(167, 167, 192, 0.15);
}

.score-table tbody tr {
  transition: background 0.15s ease;
}

.score-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.history-table { font-size: 12px; }

.score-table th:nth-child(1),
.score-table td:nth-child(1) {
  width: 24px;
  text-align: right;
  padding-right: 6px;
  color: var(--muted);
}

.score-table th:nth-child(3),
.score-table td:nth-child(3) {
  text-align: center;
  width: 90px;
}

.score-table th:nth-child(4),
.score-table td:nth-child(4) {
  text-align: right;
  width: 70px;
  font-variant-numeric: tabular-nums;
}

.score-empty,
.history-empty {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}

.history-empty { font-size: 12px; }

/* Result cell color-coding in rounds table */
.winner-a { color: var(--player-a); font-weight: 600; }
.winner-b { color: var(--player-b); font-weight: 600; }
.winner-tie {
  color: var(--muted);
  font-style: italic;
  font-weight: 500;
}

/* Highlight the round that clinched a game */
.round-decided td { background: rgba(138, 124, 255, 0.06); }

/* ============================================================
   LIBRARY & HISTORY SECTIONS
   ============================================================ */

/* Bottom card: library + history, side-by-side */
.card-bottom {
  padding: 22px 22px 20px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

@media (max-width: 768px) {
  .bottom-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }
}

.bottom-section {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.bottom-section + .bottom-section {
  position: relative;
}

@media (min-width: 769px) {
  .bottom-section + .bottom-section::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(167, 167, 192, 0.18);
  }
}

.bottom-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.bottom-title {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 600;
}

.library-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.library-input {
  padding: 7px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--inset-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  min-width: 160px;
}

.library-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  max-height: 190px;
  overflow-y: auto;
  margin-top: 4px;
}

@media (max-width: 640px) {
  .library-list { grid-template-columns: 1fr; }
}

.library-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  border-radius: var(--radius-pill);
  padding: 5px 9px;
  background: #121526;
  border: 1px solid rgba(167, 167, 192, 0.4);
  transition: border-color 0.12s ease, background 0.12s ease;
}

.library-item:hover {
  border-color: rgba(138, 124, 255, 0.5);
}

.library-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-remove {
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid rgba(255, 93, 93, 0.4);
  background: rgba(255, 93, 93, 0.08);
  color: #ff9c9c;
  line-height: 1;
}

.library-remove:hover {
  border-color: var(--error);
  background: rgba(255, 93, 93, 0.2);
}

/* ============================================================
   UTILITIES
   ============================================================ */

.hidden { display: none !important; }

#confettiCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 200;
}

/* Muted state */
.icon-btn[aria-pressed="false"] {
  opacity: 0.5;
}

.series-actions {
  display: flex;
  justify-content: center;
  margin: 10px 0 2px;
}

.series-actions.hidden { display: none !important; }

.sparkline-wrap {
  display: flex;
  justify-content: center;
  margin: 2px 0 6px;
  min-height: 40px;
}

#sparkline {
  width: 240px;
  height: 40px;
  max-width: 100%;
  opacity: 0.9;
}
