/* ============================================================
   Emerald Keno — dark casino lounge theme
   Palette & rules per DESIGN.md §7
   ============================================================ */

:root {
  --bg: #101314;
  --felt-hi: #0C352A;
  --felt-lo: #0A2B22;
  --gold: #D9B45B;
  --gold-hi: #F3DFA0;
  --ivory: #EFE6D3;
  --amber: #E8A33D;
  --loss: #C4574F;
  --win: #6FBF8F;
  --panel: #171B1C;
  --hairline: rgba(217, 180, 91, 0.25);
  --font-display: "Palatino", "Palatino Linotype", "Georgia", serif;
  --font-ui: "Avenir Next", "Avenir", "Segoe UI", system-ui, sans-serif;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ivory);
  font-family: var(--font-ui);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Vignette + faint spotlight centred on the board */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 50% 42%, rgba(217, 180, 91, 0.05), transparent 70%),
    radial-gradient(ellipse 120% 100% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
  z-index: 1;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.4; }
button:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold-hi);
  outline-offset: 2px;
}

/* ---------- top bar ---------- */

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--hairline);
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}
.brand span { color: var(--ivory); }

.brand-credit {
  font-size: 0.66rem;
  letter-spacing: 0.09em;
  color: rgba(239, 230, 211, 0.45);
  margin-top: 2px;
}

.balances { display: flex; gap: 26px; flex-wrap: wrap; }

.balance { display: flex; align-items: baseline; gap: 8px; }

.balance-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(239, 230, 211, 0.55);
}

.balance-value {
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--gold-hi);
}

.pill-btn {
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s;
}
.pill-btn:hover { background: var(--gold); color: #14100a; }

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

.icon-btn {
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--ivory);
  font-size: 1rem;
  padding: 6px 10px;
  transition: border-color 0.15s, background 0.15s;
}
.icon-btn:hover:not(:disabled) { border-color: var(--gold); background: rgba(217, 180, 91, 0.08); }

/* ---------- table area: 3 panels ---------- */

.table-area {
  position: relative;
  z-index: 2;
  flex: 1;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 230px;
  gap: 18px;
  align-items: start;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 16px;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
  text-align: center;
}

/* paytable */

.paytable-hint {
  font-size: 0.85rem;
  line-height: 1.5;
  color: rgba(239, 230, 211, 0.65);
  text-align: center;
  padding: 8px 2px;
}

.paytable-picks {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(239, 230, 211, 0.55);
  text-align: center;
  margin-bottom: 10px;
}

.paytable-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(239, 230, 211, 0.07);
}
.paytable-row:last-child { border-bottom: none; }

.paytable-pay {
  color: var(--gold-hi);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* results */

.results-head, .results-row {
  display: grid;
  grid-template-columns: 2.2em 2.6em 1fr;
  gap: 6px;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
}

.results-head {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(239, 230, 211, 0.5);
  padding: 0 4px 6px;
  border-bottom: 1px solid var(--hairline);
}

.results-rows { min-height: 208px; }

.results-row {
  font-size: 0.88rem;
  padding: 5px 4px;
  border-bottom: 1px solid rgba(239, 230, 211, 0.06);
}
.results-row span:last-child { text-align: right; }

.net-win { color: var(--win); }
.net-loss { color: var(--loss); }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 0.8rem;
  color: rgba(239, 230, 211, 0.65);
}
.pager .icon-btn { font-size: 0.7rem; padding: 4px 8px; }

.session-net {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
  text-align: center;
  font-size: 0.85rem;
  color: rgba(239, 230, 211, 0.65);
}
.session-net span { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- board card ---------- */

.board-card {
  background: radial-gradient(ellipse 110% 100% at 50% 0%, var(--felt-hi), var(--felt-lo));
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 18px 20px 14px;
  box-shadow:
    0 0 0 4px rgba(217, 180, 91, 0.08),
    0 18px 50px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(243, 223, 160, 0.15);
}

/* draw tray: 20 sockets in 2 rows of 10 */

.draw-tray {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  margin-bottom: 14px;
  justify-items: center;
}

.tray-socket {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px dashed rgba(239, 230, 211, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: transform 0.15s;
}

.tray-socket.filled {
  border: none;
  background: var(--ivory);
  color: #1a1d1e;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.tray-socket.filled.hit {
  background: linear-gradient(160deg, var(--gold-hi), var(--gold));
  color: #14100a;
  box-shadow: 0 0 10px rgba(243, 223, 160, 0.7), 0 2px 5px rgba(0, 0, 0, 0.4);
}

/* number grid */

.grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}

.cell {
  aspect-ratio: 1 / 1;
  min-width: 0;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: rgba(0, 0, 0, 0.28);
  color: var(--ivory);
  font-size: clamp(0.75rem, 1.4vw, 1rem);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, color 0.15s, opacity 0.3s;
}

.cell:hover:not(:disabled) {
  border-color: var(--gold);
  background: rgba(217, 180, 91, 0.1);
}

/* picked: gold ring + slight lift */
.cell.picked {
  border: 2px solid var(--gold);
  color: var(--gold-hi);
  font-weight: 700;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5), 0 0 6px rgba(217, 180, 91, 0.25);
}

/* drawn (not picked): amber lamp glow */
.cell.drawn {
  background: radial-gradient(circle at 50% 35%, rgba(232, 163, 61, 0.85), rgba(160, 100, 25, 0.65));
  border-color: var(--amber);
  color: #fff8ec;
  text-shadow: 0 0 6px rgba(255, 220, 150, 0.8);
  box-shadow: 0 0 12px rgba(232, 163, 61, 0.45);
}

/* caught (picked + drawn): white-hot gold */
.cell.caught {
  background: radial-gradient(circle at 50% 35%, #fff3cf, var(--gold));
  border-color: var(--gold-hi);
  color: #241a05;
  font-weight: 700;
  box-shadow: 0 0 18px rgba(243, 223, 160, 0.8), 0 0 40px rgba(217, 180, 91, 0.35);
}

/* after settle: un-caught picks dim */
.cell.dimmed { opacity: 0.45; }

@keyframes draw-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.14); }
  100% { transform: scale(1); }
}
.cell.pulse { animation: draw-pulse 0.25s ease-out; }

/* result banner */

.result-banner {
  min-height: 44px;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-align: center;
  color: rgba(239, 230, 211, 0.75);
}

.result-banner.win {
  color: var(--gold-hi);
  text-shadow: 0 0 14px rgba(243, 223, 160, 0.5);
}

.result-banner.bigwin {
  color: var(--gold-hi);
  font-size: 1.3rem;
  text-shadow: 0 0 20px rgba(243, 223, 160, 0.9);
}

.result-banner.loss { color: rgba(239, 230, 211, 0.55); }
.result-banner.notice { color: var(--amber); }

/* ---------- bottom controls ---------- */

.controls {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 34px;
  flex-wrap: wrap;
  padding: 14px 22px 20px;
  border-top: 1px solid var(--hairline);
}

.steppers { display: flex; gap: 26px; flex-wrap: wrap; }

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

.stepper-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(239, 230, 211, 0.55);
}

.stepper-value {
  min-width: 4.2em;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--gold-hi);
}

.step-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  font-size: 1.05rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.step-btn:hover:not(:disabled) { background: var(--gold); color: #14100a; }

.action-buttons { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.ghost-btn {
  padding: 9px 18px;
  border-radius: 9px;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 0.15s, color 0.15s;
}
.ghost-btn:hover:not(:disabled) { background: rgba(217, 180, 91, 0.14); }

.ghost-btn.danger { border-color: var(--loss); color: var(--loss); }
.ghost-btn.danger:hover:not(:disabled) { background: rgba(196, 87, 79, 0.12); }

.play-btn {
  padding: 11px 34px;
  border-radius: 10px;
  border: 1px solid var(--gold-hi);
  background: linear-gradient(170deg, var(--gold-hi), var(--gold) 60%, #b28f3e);
  color: #241a05;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 4px 14px rgba(217, 180, 91, 0.3);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}
.play-btn:hover:not(:disabled) {
  filter: brightness(1.07);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(217, 180, 91, 0.4);
}
.play-btn:active:not(:disabled) { transform: translateY(0); }

.quickpick-group { display: flex; align-items: center; gap: 6px; }

.quickpick-group select {
  background: var(--panel);
  color: var(--ivory);
  border: 1px solid var(--hairline);
  border-radius: 7px;
  padding: 7px 6px;
  font-size: 0.85rem;
}

/* ---------- stats dialog ---------- */

.stats-dialog {
  background: var(--panel);
  color: var(--ivory);
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 24px 28px;
  max-width: 480px;
  width: calc(100vw - 40px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7);
}
.stats-dialog::backdrop { background: rgba(0, 0, 0, 0.65); }

.stats-list {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 18px;
  font-size: 0.9rem;
  margin-bottom: 18px;
}
.stats-list dt { color: rgba(239, 230, 211, 0.6); }
.stats-list dd { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.stats-subtitle {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.heat-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
}

.heat-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  border-radius: 4px;
  color: rgba(239, 230, 211, 0.8);
  background:
    linear-gradient(rgba(232, 163, 61, calc(var(--heat, 0) * 0.85)), rgba(232, 163, 61, calc(var(--heat, 0) * 0.85))),
    rgba(0, 0, 0, 0.3);
}

.stats-note {
  font-size: 0.72rem;
  color: rgba(239, 230, 211, 0.45);
  margin-top: 8px;
  font-style: italic;
}

.stats-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
}

/* ---------- fx canvas ---------- */

.fx-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

/* ---------- responsive: stack panels below the board ---------- */

@media (max-width: 900px) {
  .table-area {
    grid-template-columns: 1fr;
    padding: 14px;
  }
  .board-card { order: -1; }
  .tray-socket { width: 24px; height: 24px; font-size: 0.65rem; }
  .topbar { justify-content: center; }
  .controls { gap: 16px; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
