/* ========================================================
   RACK 'EM UP BILLIARDS - MODERN ARCADE POOL THEME
   Sleek Dark Mode • Neon Accents • Tactile Billiard Arena
   ======================================================== */

:root {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-card: #182032;
  --bg-card-hover: #1e293b;
  --border-color: #26334d;
  --border-active: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-green: #22c55e;
  --accent-blue: #38bdf8;
  --accent-gold: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #a855f7;
  --font-display: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-display);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ================= TOP NAVIGATION BAR ================= */
.pool-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
  flex-wrap: wrap;
}

.pool-nav-left, .pool-nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-nav-hub {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.btn-nav-hub:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
  color: #fff;
  transform: translateX(-2px);
}

.pool-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pool-brand-icon {
  font-size: 20px;
}

.pool-brand-text {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #ffffff 40%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Segmented Control Pills (Mode, Match Type, Felt) */
.pill-group {
  display: flex;
  background: #090e17;
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  gap: 2px;
}

.pill-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.pill-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.pill-btn.active {
  background: var(--border-active);
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.35);
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
}

.btn-icon.btn-accent {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border-color: #38bdf8;
  color: #fff;
}

.btn-icon.btn-accent:hover {
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.5);
  transform: translateY(-1px);
}

/* ================= SCOREBOARD & TURN HEADER ================= */
.pool-scoreboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  max-width: 1140px;
  margin: 0 auto;
  width: 100%;
  gap: 16px;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  min-width: 260px;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.player-card.active-turn {
  border-color: var(--accent-blue);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.3);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: #1e293b;
  border: 2px solid var(--border-color);
}

.player-card.active-turn .player-avatar {
  border-color: var(--accent-blue);
}

.player-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.player-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.player-name {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}

.suit-pill {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: var(--accent-gold);
  letter-spacing: 0.5px;
}

/* Mini ball tray */
.mini-ball-tray {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
}

.tray-placeholder {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}

.mini-ball {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  font-size: 8px;
  font-weight: 800;
  font-family: var(--font-mono);
  overflow: hidden;
  transition: opacity 0.2s, transform 0.2s;
}

.mini-ball.potted {
  opacity: 0.25;
  filter: grayscale(80%);
}

.mini-stripe {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  right: 0;
  background: inherit;
  z-index: 1;
}

.mini-ball span {
  position: relative;
  z-index: 2;
}

/* Center match status banner */
.match-status-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  flex: 1;
}

.turn-badge {
  font-size: 13px;
  font-weight: 800;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  background: #0f172a;
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.25);
  letter-spacing: 0.5px;
}

.target-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

/* ================= MAIN BILLIARDS CANVAS ARENA ================= */
.pool-arena-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 10px 24px 24px;
  position: relative;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1056 / 576;
  max-width: 1056px;
  background: #060911;
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.95), 0 0 100px rgba(16, 185, 129, 0.08), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#pool-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* 3D WebGL Canvas Arena Container */
.pool-3d-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 22px;
  overflow: hidden;
  cursor: crosshair;
  z-index: 1;
}

.pool-3d-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  outline: none;
}

#btn-dimension-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--accent-blue);
  font-weight: 800;
}
#btn-dimension-toggle:hover {
  border-color: var(--accent-blue);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

/* Floating notification banner on top of table */
.pool-table-toast {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  border: 1.5px solid var(--accent-blue);
  color: var(--accent-blue);
  padding: 8px 20px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.pool-table-toast span {
  color: var(--text-muted);
  font-weight: 500;
}

/* ================= SIDEBAR & BOTTOM CONTROLS ================= */
.pool-controls-deck {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1056px;
  margin-top: 14px;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}

.deck-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.deck-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* Power Bar Slider */
.power-control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.power-slider-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="range"].power-range {
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 8px;
  border-radius: var(--radius-full);
  background: #0f172a;
  outline: none;
  border: 1px solid var(--border-color);
  cursor: pointer;
}

input[type="range"].power-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  border: 2px solid #fff;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
  transition: transform 0.1s;
}

input[type="range"].power-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.power-percent-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  color: var(--accent-gold);
  min-width: 42px;
}

.btn-strike {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border: 1px solid #4ade80;
  color: #fff;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.35);
  transition: all 0.2s;
}

.btn-strike:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(34, 197, 94, 0.5);
}

.btn-strike:active {
  transform: translateY(1px);
}

/* Cue Ball Spin English Widget */
.spin-control-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.spin-widget-circle {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  position: relative;
  cursor: pointer;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.spin-crosshair-h, .spin-crosshair-v {
  position: absolute;
  background: rgba(148, 163, 184, 0.45);
}

.spin-crosshair-h {
  top: 50%;
  left: 4px;
  right: 4px;
  height: 1px;
}

.spin-crosshair-v {
  left: 50%;
  top: 4px;
  bottom: 4px;
  width: 1px;
}

.spin-widget-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  border: 1px solid #fff;
  position: absolute;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.8);
  pointer-events: none;
  transition: transform 0.05s ease-out;
}

/* ================= MODALS & OVERLAYS ================= */
.pool-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 13, 22, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: fadeIn 0.25s ease-out;
}

.pool-modal-card {
  background: #141b2d;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 620px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.pool-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.pool-modal-title {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s;
}

.btn-close-modal:hover {
  color: #fff;
}

/* Rules content */
.rules-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.rules-tab-btn {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.rules-tab-btn.active {
  background: var(--border-active);
  color: #0f172a;
  border-color: var(--border-active);
}

.rule-section {
  display: none;
}

.rule-section.active {
  display: block;
}

.rule-item {
  margin-bottom: 14px;
}

.rule-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-gold);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rule-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Victory celebration modal card */
.win-modal-card {
  text-align: center;
  border-color: #f59e0b;
  box-shadow: 0 0 50px rgba(245, 158, 11, 0.35);
}

.win-icon {
  font-size: 54px;
  margin-bottom: 12px;
  animation: bounce 1s infinite alternate;
}

.win-title {
  font-size: 26px;
  font-weight: 900;
  color: var(--accent-gold);
  margin-bottom: 8px;
}

.win-desc {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.win-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

@keyframes bounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .pool-navbar {
    padding: 10px 14px;
  }
  .player-card {
    min-width: 180px;
    padding: 8px 12px;
  }
  .pool-controls-deck {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ================= MATCH SCORE & SHOT CALLOUTS ================= */
.player-name-row .rack-score {
  margin-left: auto;
  min-width: 26px;
  padding: 1px 8px;
  border-radius: var(--radius-full);
  background: rgba(250, 204, 21, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.45);
  color: #facc15;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.win-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: #facc15;
  margin: -14px 0 22px;
}

.pool-callout {
  --callout-color: #facc15;
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%) scale(0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  opacity: 0;
  z-index: 60;
  text-align: center;
  white-space: nowrap;
}

.pool-callout strong {
  font-family: 'Manrope', sans-serif;
  font-size: clamp(22px, 4.2vw, 44px);
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--callout-color);
  text-shadow: 0 0 18px var(--callout-color), 0 4px 0 rgba(0, 0, 0, 0.6), 0 8px 24px rgba(0, 0, 0, 0.8);
}

.pool-callout span {
  font-size: clamp(12px, 1.6vw, 16px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.pool-callout.show {
  animation: calloutPop 1.9s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards;
}

@keyframes calloutPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(-4deg); }
  14%  { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(1deg); }
  24%  { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  78%  { opacity: 1; transform: translate(-50%, -58%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -75%) scale(0.95); }
}

@media (prefers-reduced-motion: reduce) {
  .pool-callout.show { animation: calloutFade 1.9s linear forwards; }
  @keyframes calloutFade { 0%, 80% { opacity: 1; transform: translate(-50%, -50%); } 100% { opacity: 0; transform: translate(-50%, -50%); } }
}

/* ================= LEADERBOARD ================= */
.win-board {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-green);
  margin: -12px 0 20px;
  min-height: 1em;
}
.win-board.is-error { color: var(--text-muted); }
.board-modal-card { max-width: 560px; }
.board-howto { font-size: 13px; color: var(--text-muted); margin: 0 0 14px; line-height: 1.5; }
.board-howto b { color: var(--text-main); }
.board-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.board-name-row label { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.board-name-row input {
  flex: 1 1 140px;
  min-width: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font: 600 14px var(--font-display);
  padding: 8px 10px;
}
.board-name-row input:focus { outline: none; border-color: var(--border-active); }
.board-who { font-size: 13px; color: var(--accent-blue); font-weight: 700; margin: 0 0 6px; }
.board-note { font-size: 12px; color: var(--accent-green); min-height: 1em; margin: 0 0 10px; }
.board-table-wrap { overflow-x: auto; }
.board-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.board-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
}
.board-table td { padding: 8px; border-bottom: 1px solid rgba(38, 51, 77, 0.5); color: var(--text-main); }
.board-table td:nth-child(1) { width: 36px; font-family: var(--font-mono); color: var(--text-muted); }
.board-table td:nth-child(2) { font-weight: 700; overflow-wrap: anywhere; }
.board-table td:nth-child(3) { font-family: var(--font-mono); font-weight: 800; color: var(--accent-gold); }
.board-table td:nth-child(4), .board-table td:nth-child(5) { font-family: var(--font-mono); color: var(--text-muted); white-space: nowrap; }
.board-table tr.is-me td { background: rgba(56, 189, 248, 0.1); }
.board-me tr:first-child td { border-top: 2px dashed var(--border-color); }
.board-status { font-size: 13px; color: var(--text-muted); text-align: center; margin: 12px 0 0; }

/* Group badges: which balls are yours */
.suit-pill.suit-solids {
  color: #1c1917;
  background: #facc15;
  border-color: #facc15;
}
.suit-pill.suit-stripes {
  color: #1c1917;
  background: repeating-linear-gradient(90deg, #f8fafc 0 6px, #facc15 6px 12px);
  border-color: #facc15;
}
.suit-pill { font-size: 11px; }
