/* ==========================================================================
   Table Tennis Umpire Scoreboard - Modern High-Contrast Stylesheet
   ========================================================================== */

:root {
  --bg-primary: #0a0e17;
  --bg-surface: #121824;
  --bg-surface-elevated: #1a2234;
  --border-color: rgba(255, 255, 255, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.06);

  /* Player A Theme (Vibrant Coral / Crimson) */
  --player-a-primary: #ff3366;
  --player-a-glow: rgba(255, 51, 102, 0.35);
  --player-a-bg: rgba(255, 51, 102, 0.08);
  --player-a-active: #ff527b;

  /* Player B Theme (Electric Cyan / Sky Blue) */
  --player-b-primary: #00d2ff;
  --player-b-glow: rgba(0, 210, 255, 0.35);
  --player-b-bg: rgba(0, 210, 255, 0.08);
  --player-b-active: #33dcff;

  /* Neutral & Utility Colors */
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-gold: #fbbf24;
  --accent-green: #10b981;
  --accent-red: #ef4444;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-score: "Impact", "DIN Alternate", "Trebuchet MS", -apple-system, BlinkMacSystemFont, sans-serif;

  /* Header / Footer heights */
  --nav-height: 52px;
  --bottom-bar-height: 60px;
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ==========================================================================
   Top Header Navigation
   ========================================================================== */

.top-nav {
  height: var(--nav-height);
  min-height: var(--nav-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 20;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.table-badge {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  cursor: pointer;
  white-space: nowrap;
}

.match-info {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.nav-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.match-timer-display {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 1px;
  color: var(--accent-gold);
  background: rgba(251, 191, 36, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.96);
}

.icon-btn.active {
  background: rgba(16, 185, 129, 0.25);
  border-color: var(--accent-green);
  color: #34d399;
}

/* Compact Nav Icons on Narrow Mobile Screens */
@media (max-width: 640px) {
  .top-nav {
    padding: 0 6px;
  }
  .nav-right {
    gap: 3px;
  }
  .icon-btn {
    padding: 5px 6px;
  }
  .icon-btn .btn-text {
    display: none;
  }
  .icon-btn .icon {
    font-size: 1.05rem;
  }
}

/* ==========================================================================
   Match Status Notification Banner
   ========================================================================== */

.status-banner {
  background: linear-gradient(90deg, #1e293b, #0f172a);
  border-bottom: 1px solid var(--border-color);
  padding: 4px 12px;
  text-align: center;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #e2e8f0;
  transition: all 0.3s ease;
  z-index: 10;
}

.status-banner.highlight-deuce {
  background: linear-gradient(90deg, #7c2d12, #9a3412);
  color: #ffedd5;
  animation: pulse-banner 1.5s infinite;
}

.status-banner.highlight-gamepoint {
  background: linear-gradient(90deg, #831843, #9d174d);
  color: #fce7f3;
  animation: pulse-banner 1s infinite;
}

.status-banner.highlight-matchpoint {
  background: linear-gradient(90deg, #701a75, #86198f);
  color: #fdf4ff;
  animation: pulse-banner 0.8s infinite;
}

.status-banner.highlight-switch {
  background: linear-gradient(90deg, #1e3a8a, #1d4ed8);
  color: #dbeafe;
}

@keyframes pulse-banner {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

/* ==========================================================================
   Main Scoreboard Grid
   ========================================================================== */

.scoreboard-container {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 76px 1fr;
  height: calc(100% - var(--nav-height) - 28px - var(--bottom-bar-height));
  background-color: var(--bg-primary);
  overflow: hidden;
  position: relative;
}

/* Player Panels */
.player-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 14px;
  position: relative;
  transition: background-color 0.25s ease;
}

.player-panel.side-left {
  border-right: 1px solid var(--border-subtle);
}

.player-panel.side-right {
  border-left: 1px solid var(--border-subtle);
}

/* Theme per player (Moves with player when sides swap) */
.player-panel.theme-player-a {
  background: radial-gradient(circle at center, var(--player-a-bg) 0%, transparent 80%);
}

.player-panel.theme-player-a .player-name {
  color: var(--player-a-primary);
}

.player-panel.theme-player-a .score-number {
  color: #ffffff;
  text-shadow: 0 0 35px var(--player-a-glow);
}

.player-panel.theme-player-a .score-display-area:active {
  background: rgba(255, 51, 102, 0.15);
}

.player-panel.theme-player-b {
  background: radial-gradient(circle at center, var(--player-b-bg) 0%, transparent 80%);
}

.player-panel.theme-player-b .player-name {
  color: var(--player-b-primary);
}

.player-panel.theme-player-b .score-number {
  color: #ffffff;
  text-shadow: 0 0 35px var(--player-b-glow);
}

.player-panel.theme-player-b .score-display-area:active {
  background: rgba(0, 210, 255, 0.15);
}

/* Player Header */
.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding-bottom: 4px;
}

.name-box {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 70%;
}

.player-name {
  font-size: clamp(1.1rem, 2.8vw, 1.8rem);
  font-weight: 800;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-left .player-name {
  color: var(--player-a-primary);
}

.side-right .player-name {
  color: var(--player-b-primary);
}

/* Serving Paddle Badge */
.serve-indicator {
  font-size: 1.4rem;
  opacity: 0.15;
  filter: grayscale(100%);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-block;
  line-height: 1;
}

.serve-indicator.active {
  opacity: 1;
  filter: grayscale(0%);
  transform: scale(1.25);
  animation: paddle-bounce 1s infinite alternate ease-in-out;
}

@keyframes paddle-bounce {
  0% { transform: scale(1.15) translateY(0); }
  100% { transform: scale(1.3) translateY(-3px); }
}

/* Serve dots (how many serves remain: 1 or 2) */
.serve-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  opacity: 0.3;
}

.serve-dots.active {
  opacity: 1;
}

.serve-dots .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.serve-dots.active .dot.active {
  background: var(--accent-gold);
  box-shadow: 0 0 6px var(--accent-gold);
}

/* Games Won Display */
.games-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 3px 10px;
  min-width: 52px;
}

.games-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 700;
}

.games-count {
  font-size: clamp(1.4rem, 3.2vw, 2.2rem);
  font-family: var(--font-score);
  font-weight: 900;
  color: #ffffff;
  line-height: 1;
}

/* Score Display Area (The Monster Touch Zone!) */
.score-display-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 14px;
  margin: 6px 0;
  transition: transform 0.1s ease, background 0.15s ease;
  position: relative;
  overflow: hidden;
}

.score-display-area:active {
  transform: scale(0.975);
}

.side-left .score-display-area:active {
  background: rgba(255, 51, 102, 0.15);
}

.side-right .score-display-area:active {
  background: rgba(0, 210, 255, 0.15);
}

.score-number {
  font-family: var(--font-score);
  font-size: clamp(7rem, 24vw, 19rem);
  line-height: 0.9;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.7);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.side-left .score-number {
  color: #ffffff;
  text-shadow: 0 0 35px var(--player-a-glow);
}

.side-right .score-number {
  color: #ffffff;
  text-shadow: 0 0 35px var(--player-b-glow);
}

.touch-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.5;
  margin-top: 2px;
}

/* Player Footer Quick Controls */
.player-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.btn-sub {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 800;
  border-radius: 8px;
  height: 38px;
  width: 52px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-sub:active {
  background: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  border-color: var(--accent-red);
}

.btn-timeout {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 8px;
  height: 38px;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-timeout .t-badge {
  background: var(--accent-gold);
  color: #000;
  font-size: 0.7rem;
  font-weight: 900;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-timeout.used {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  border-color: transparent;
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-timeout.used .t-badge {
  background: var(--text-muted);
  color: #222;
}

.btn-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 8px;
  height: 38px;
  padding: 0 10px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-card.has-yellow {
  border-color: #fbbf24;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.15);
}

.btn-card.has-red {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.2);
}

/* ==========================================================================
   Center Controller (Referee Bridge)
   ========================================================================== */

.center-controller {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  padding: 8px 4px;
  z-index: 5;
}

.game-indicator-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  align-items: center;
}

.mini-game-item {
  font-size: 0.65rem;
  font-family: var(--font-score);
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  width: 90%;
  text-align: center;
  white-space: nowrap;
}

.mini-game-item.finished {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.1);
  font-weight: 700;
}

.mini-game-item.current {
  color: var(--accent-gold);
  border: 1px solid rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.1);
}

.referee-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  align-items: center;
}

.action-pill-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 8px;
  width: 62px;
  height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-pill-btn:active:not(:disabled) {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(0.95);
}

.action-pill-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.pill-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.pill-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   Bottom Floating Controller Bar
   ========================================================================== */

.bottom-controller {
  height: var(--bottom-bar-height);
  min-height: var(--bottom-bar-height);
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  z-index: 20;
}

.bottom-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 0;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.bottom-btn:active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.bottom-btn .b-icon {
  font-size: 1.1rem;
}

/* ==========================================================================
   ORIENTATION & DISPLAY MODES
   ========================================================================== */

/* 1. Landscape Orientation (Ideal referee stand facing table) */
@media (orientation: landscape) {
  .bottom-controller {
    display: none; /* In landscape, center-controller does the job, giving maximum height to score! */
  }

  .scoreboard-container {
    height: calc(100% - var(--nav-height) - 28px);
  }

  .score-number {
    font-size: clamp(8rem, 28vh, 19rem);
  }
}

/* 2. Portrait Orientation */
@media (orientation: portrait) {
  .scoreboard-container {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    height: calc(100% - var(--nav-height) - 28px - var(--bottom-bar-height));
  }

  .center-controller {
    display: none; /* Hide center strip in portrait, use bottom controller bar! */
  }

  .player-panel.side-left {
    border-right: none;
    border-bottom: 2px solid var(--border-color);
  }

  .player-panel.side-right {
    border-left: none;
  }

  .score-number {
    font-size: clamp(5.5rem, 20vw, 8.5rem);
  }
}

/* 3. Dual-Facing Tabletop Mode (.mode-dual-facing) */
/* When phone lies flat between player and umpire, Player A panel is flipped 180deg */
body.mode-dual-facing .player-panel.side-left {
  transform: rotate(180deg);
  border-right: none;
  border-bottom: 2px dashed var(--accent-gold);
}

body.mode-dual-facing .scoreboard-container {
  grid-template-columns: 1fr !important;
  grid-template-rows: 1fr 1fr !important;
}

body.mode-dual-facing .center-controller {
  display: none !important;
}

body.mode-dual-facing .bottom-controller {
  display: flex !important;
}

/* 4. Force 90° Clockwise Rotation (Landscape on Portrait phone) */
body.rotate-90 {
  position: fixed !important;
  width: 100vh !important;
  width: 100dvh !important;
  height: 100vw !important;
  height: 100dvw !important;
  top: 0 !important;
  left: 100vw !important;
  left: 100dvw !important;
  transform-origin: 0 0 !important;
  transform: rotate(90deg) !important;
  overflow: hidden !important;
}

/* 5. Force 270° Counter-Clockwise Rotation */
body.rotate-270 {
  position: fixed !important;
  width: 100vh !important;
  width: 100dvh !important;
  height: 100vw !important;
  height: 100dvw !important;
  top: 100vh !important;
  top: 100dvh !important;
  left: 0 !important;
  transform-origin: 0 0 !important;
  transform: rotate(-90deg) !important;
  overflow: hidden !important;
}

/* 6. Force 180° Inverted */
body.rotate-180 {
  transform: rotate(180deg) !important;
  transform-origin: center center !important;
}

/* Layout overrides when rotated 90° or 270° (Treat as Landscape!) */
body.rotate-90 .bottom-controller,
body.rotate-270 .bottom-controller {
  display: none !important;
}

body.rotate-90 .scoreboard-container,
body.rotate-270 .scoreboard-container {
  display: grid !important;
  grid-template-columns: 1fr 76px 1fr !important;
  grid-template-rows: 1fr !important;
  height: calc(100% - var(--nav-height) - 28px) !important;
}

body.rotate-90 .center-controller,
body.rotate-270 .center-controller {
  display: flex !important;
}

body.rotate-90 .player-panel.side-left,
body.rotate-270 .player-panel.side-left {
  border-right: 1px solid var(--border-subtle) !important;
  border-bottom: none !important;
}

body.rotate-90 .player-panel.side-right,
body.rotate-270 .player-panel.side-right {
  border-left: 1px solid var(--border-subtle) !important;
}

body.rotate-90 .score-number,
body.rotate-270 .score-number {
  font-size: clamp(5.5rem, 23vh, 15rem) !important;
}

/* Dialogs & Modals rotation adjustments */
body.rotate-90 .modal-dialog[open] {
  transform: rotate(90deg) !important;
  transform-origin: center center !important;
}

body.rotate-90 .modal-card {
  max-width: 85vh !important;
  max-height: 82vw !important;
  width: min(460px, 85vh) !important;
  overflow-y: auto !important;
}

body.rotate-270 .modal-dialog[open] {
  transform: rotate(-90deg) !important;
  transform-origin: center center !important;
}

body.rotate-270 .modal-card {
  max-width: 85vh !important;
  max-height: 82vw !important;
  width: min(460px, 85vh) !important;
  overflow-y: auto !important;
}

/* Toast alerts when rotated */
body.rotate-90 .toast-container {
  bottom: auto !important;
  top: 50% !important;
  left: 30px !important;
  right: auto !important;
  transform: translateY(-50%) rotate(90deg) !important;
}

body.rotate-270 .toast-container {
  bottom: auto !important;
  top: 50% !important;
  left: auto !important;
  right: 30px !important;
  transform: translateY(-50%) rotate(-90deg) !important;
}

/* ==========================================================================
   MODAL & DIALOG SYSTEM (<dialog>)
   ========================================================================== */

.modal-dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 90vw;
  width: 440px;
  margin: auto;
  overflow: visible;
}

.modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  color: var(--text-primary);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-header-badge {
  align-self: center;
  background: rgba(251, 191, 36, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(251, 191, 36, 0.3);
  font-size: 0.8rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 20px;
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 800;
  text-align: center;
}

.modal-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  text-align: center;
}

.switch-side-notice {
  background: rgba(37, 99, 235, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: #93c5fd;
}

.switch-side-notice .icon {
  font-size: 1.4rem;
}

/* Modal Actions */
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.modal-actions.column {
  flex-direction: column;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-large {
  padding: 14px 20px;
  font-size: 1rem;
}

.btn-primary {
  background: #2563eb;
  color: #ffffff;
}

.btn-primary:active {
  background: #1d4ed8;
}

.btn-secondary {
  background: #334155;
  color: #ffffff;
}

.btn-secondary:active {
  background: #1e293b;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-outline:active {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid var(--accent-red);
  color: #fca5a5;
}

.btn-danger:active {
  background: rgba(239, 68, 68, 0.4);
}

/* Timer Specific Modal Styling */
.timer-card {
  align-items: center;
  text-align: center;
}

.timer-circle-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
}

.timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 6;
}

.timer-progress {
  fill: none;
  stroke: var(--accent-gold);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.5s linear;
}

.timer-digits {
  position: absolute;
  font-family: var(--font-score);
  font-size: 2.6rem;
  font-weight: 900;
  color: #ffffff;
}

.timer-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Card Selection Grid */
.card-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.card-pick-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
  cursor: pointer;
  text-align: center;
}

.card-pick-btn:active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.97);
}

.card-pick-btn small {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.card-box {
  width: 22px;
  height: 32px;
  border-radius: 3px;
  display: inline-block;
}

.card-box.sm {
  width: 16px;
  height: 24px;
}

.yellow-card-box {
  background: #facc15;
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.5);
}

.red-card-box {
  background: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.card-pair {
  display: flex;
  gap: 4px;
}

/* Settings Form */
.settings-card {
  max-height: 85vh;
  overflow-y: auto;
  width: 480px;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.close-x {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.settings-group {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.settings-group legend {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-gold);
  padding: 0 6px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
}

input[type="text"], select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: #fff;
  padding: 8px 10px;
  font-size: 0.9rem;
  outline: none;
}

input[type="text"]:focus, select:focus {
  border-color: #3b82f6;
}

/* Switch Toggles */
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-primary);
}

.toggle-item input[type="checkbox"] {
  display: none;
}

.toggle-slider {
  width: 44px;
  height: 24px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle-item input:checked + .toggle-slider {
  background: #2563eb;
}

.toggle-item input:checked + .toggle-slider::after {
  transform: translateX(20px);
}

/* Tables & Summary */
.match-summary-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 0.85rem;
}

.summary-table th, .summary-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.summary-table th {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-weight: 700;
}

.summary-table tr:last-child td {
  border-bottom: none;
}

.report-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.stat-val {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 100;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  animation: toast-in 0.25s ease-out;
  pointer-events: auto;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
