/* ═══════════════════════════════════════════════════════
   STACK CONTROL POKER · Royal Flush Design System
   Two themes — VELVET (dark felt) · MARBLE (light cream)
═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700;800;900&family=Instrument+Serif:ital@0;1&family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  /* ── VELVET (default) ────────────────────────── */
  --bg:            #0a0e0a;
  --bg-1:          #10160f;
  --bg-2:          #16201a;
  --bg-3:          #1d2a21;
  --felt:          #143020;
  --felt-deep:     #0c1f14;
  --surface:       rgba(22, 32, 26, 0.78);
  --surface-2:     rgba(30, 44, 36, 0.85);
  --surface-hover: rgba(40, 58, 48, 0.92);

  --ink:           #f5efde;
  --ink-2:         #d8d0bd;
  --ink-3:         #a09a86;
  --ink-mute:      #6b6857;
  --ink-faint:     #3d3c33;

  --gold:          #d4af37;
  --gold-1:        #e8c96a;
  --gold-2:        #f4d160;
  --gold-deep:     #8a6f1f;
  --gold-soft:     rgba(212, 175, 55, 0.14);

  --red:           #d63449;
  --red-1:         #ff4d62;
  --red-deep:      #8a1a28;
  --red-soft:      rgba(214, 52, 73, 0.14);

  --neon:          #00ff9d;
  --neon-1:        #5affc0;
  --neon-deep:     #00a060;
  --neon-soft:     rgba(0, 255, 157, 0.12);

  --cyan:          #36e2ff;
  --cyan-soft:     rgba(54, 226, 255, 0.12);

  --border:        rgba(212, 175, 55, 0.16);
  --border-2:      rgba(245, 239, 222, 0.07);
  --border-strong: rgba(212, 175, 55, 0.32);

  --shadow-card:   0 8px 32px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(245, 239, 222, 0.04) inset;
  --shadow-lift:   0 16px 48px rgba(0, 0, 0, 0.7), 0 1px 0 rgba(245, 239, 222, 0.06) inset;
  --shadow-glow:   0 0 0 1px rgba(212, 175, 55, 0.3), 0 8px 28px rgba(212, 175, 55, 0.18);

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  --font-display: 'Cinzel', 'Times New Roman', serif;
  --font-editorial: 'Instrument Serif', 'Times New Roman', serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  --vp-w: 420px;       /* mobile column on desktop */

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

/* ── MARBLE (light) ─────────────────────────── */
body.theme-marble {
  --bg:            #f5efde;
  --bg-1:          #ede4cb;
  --bg-2:          #e3d7b8;
  --bg-3:          #d6c8a4;
  --felt:          #1a3a26;
  --felt-deep:     #0f2a18;
  --surface:       rgba(255, 250, 235, 0.92);
  --surface-2:     rgba(255, 252, 240, 0.98);
  --surface-hover: rgba(250, 244, 220, 1);

  --ink:           #15170f;
  --ink-2:         #353624;
  --ink-3:         #6a6a55;
  --ink-mute:      #989374;
  --ink-faint:     #c7c0a3;

  --gold:          #8a6f1f;
  --gold-1:        #a88835;
  --gold-2:        #b8941a;
  --gold-deep:     #5d4a10;
  --gold-soft:     rgba(138, 111, 31, 0.12);

  --red:           #b8202e;
  --red-1:         #d63449;
  --red-deep:      #6b0f1a;
  --red-soft:      rgba(184, 32, 46, 0.10);

  --neon:          #007f4c;
  --neon-1:        #00a065;
  --neon-deep:     #004d2d;
  --neon-soft:     rgba(0, 127, 76, 0.10);

  --cyan:          #0a6a8a;
  --cyan-soft:     rgba(10, 106, 138, 0.10);

  --border:        rgba(20, 30, 20, 0.12);
  --border-2:      rgba(20, 30, 20, 0.06);
  --border-strong: rgba(138, 111, 31, 0.4);

  --shadow-card:   0 6px 24px rgba(80, 60, 20, 0.10), 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  --shadow-lift:   0 12px 36px rgba(80, 60, 20, 0.18), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  --shadow-glow:   0 0 0 1px rgba(138, 111, 31, 0.3), 0 6px 20px rgba(138, 111, 31, 0.18);
}

* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:active { transform: scale(0.97); }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: var(--gold-soft); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Backdrop : pattern + ambient glows ── */
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(ellipse 60% 60% at 15% 0%, var(--gold-soft), transparent 60%),
    radial-gradient(ellipse 60% 60% at 85% 100%, var(--red-soft), transparent 60%),
    radial-gradient(ellipse 50% 50% at 50% 50%, var(--neon-soft), transparent 70%);
  opacity: 0.85;
}
body::after {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    repeating-linear-gradient(45deg, rgba(212,175,55,.025) 0 1px, transparent 1px 22px),
    repeating-linear-gradient(-45deg, rgba(214,52,73,.018) 0 1px, transparent 1px 22px);
  opacity: 0.6;
}
body.theme-marble::after {
  background-image:
    repeating-linear-gradient(45deg, rgba(138,111,31,.05) 0 1px, transparent 1px 22px),
    repeating-linear-gradient(-45deg, rgba(184,32,46,.03) 0 1px, transparent 1px 22px);
}

/* ── App container : mobile-first column ── */
.app-root {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex; justify-content: center;
}
.viewport {
  width: 100%;
  max-width: var(--vp-w);
  min-height: 100vh;
  position: relative;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-1) 100%);
  overflow: hidden;
  box-shadow: 0 0 80px rgba(0,0,0,.6), 0 0 0 1px var(--border-2);
  display: flex; flex-direction: column;
}
@media (min-width: 720px) {
  .app-root { padding: 24px 0; }
  .viewport { border-radius: 32px; min-height: calc(100vh - 48px); max-height: 920px; }
}

/* ── Typography ── */
.font-display { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.06em; }
.font-editorial { font-family: var(--font-editorial); font-weight: 400; }
.font-mono { font-family: var(--font-mono); font-feature-settings: 'tnum' 1; }
.eyebrow {
  font-family: var(--font-body);
  font-size: 10px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-3);
}

/* ── Card primitive ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-card);
}
.card-lift { box-shadow: var(--shadow-lift); }
.card-gold { border-color: var(--border-strong); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-family: var(--font-body); font-weight: 600; font-size: 13px;
  letter-spacing: 0.04em;
  transition: all 0.18s var(--ease);
  border: 1px solid transparent;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-deep) 100%);
  color: #0d0d08;
  font-weight: 700;
  box-shadow: 0 6px 22px rgba(212, 175, 55, 0.35), 0 1px 0 rgba(255,255,255,0.2) inset;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-neon {
  background: var(--neon-soft);
  border-color: var(--neon);
  color: var(--neon);
  font-weight: 700;
  text-shadow: 0 0 12px var(--neon-soft);
}
.btn-red {
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--red-1);
}
.btn-pill {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 11px;
}

/* ── Input ── */
.input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  color: var(--ink);
  font-family: var(--font-body); font-size: 14px;
  outline: none;
  transition: all 0.18s var(--ease);
}
.input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
  background: var(--bg-1);
}
.input::placeholder { color: var(--ink-mute); }

/* ── Suit motifs ── */
.suit-red { color: var(--red); }
.suit-black { color: var(--ink-2); }
.suit-gold { color: var(--gold-1); }

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(0, 255, 157, 0.5); }
  70% { box-shadow: 0 0 0 14px rgba(0, 255, 157, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 255, 157, 0); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulseOnline {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--neon), 0 0 12px rgba(0,255,157,0.4); }
  50%       { opacity: 0.7; box-shadow: 0 0 3px var(--neon), 0 0 6px rgba(0,255,157,0.2); }
}
@keyframes confetti-fall {
  0% { transform: translateY(-100vh) rotate(0); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0.6; }
}
@keyframes glow-text {
  0%, 100% { text-shadow: 0 0 12px var(--gold-soft); }
  50% { text-shadow: 0 0 28px var(--gold-1), 0 0 56px var(--gold-soft); }
}

.anim-fade-up { animation: fadeUp 0.5s var(--ease-out) both; }
.anim-fade-in { animation: fadeIn 0.4s var(--ease-out) both; }
.anim-float { animation: float 4s ease-in-out infinite; }
.anim-glow { animation: glow-text 2.6s ease-in-out infinite; }

.stagger > * { animation: fadeUp 0.5s var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: 0.04s; }
.stagger > *:nth-child(2) { animation-delay: 0.08s; }
.stagger > *:nth-child(3) { animation-delay: 0.12s; }
.stagger > *:nth-child(4) { animation-delay: 0.16s; }
.stagger > *:nth-child(5) { animation-delay: 0.20s; }
.stagger > *:nth-child(6) { animation-delay: 0.24s; }
.stagger > *:nth-child(7) { animation-delay: 0.28s; }
.stagger > *:nth-child(8) { animation-delay: 0.32s; }
.stagger > *:nth-child(9) { animation-delay: 0.36s; }
.stagger > *:nth-child(10) { animation-delay: 0.40s; }
.stagger > *:nth-child(n+11) { animation-delay: 0.44s; }

/* live pulse dot */
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--neon);
  box-shadow: 0 0 0 0 var(--neon);
  animation: pulseRing 1.8s infinite;
}

/* ── Drawer ── */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s both;
}
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 84%; max-width: 340px; z-index: 100;
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg) 100%);
  border-right: 1px solid var(--border);
  box-shadow: 8px 0 40px rgba(0,0,0,0.6);
  display: flex; flex-direction: column;
  animation: slideInLeft 0.35s var(--ease-out) both;
}

/* ── Bottom sheet ── */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.22s both;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: var(--vp-w);
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg) 100%);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border-top: 1px solid var(--border-strong);
  padding: 20px;
  max-height: 86vh;
  overflow-y: auto;
  animation: sheetUp 0.32s var(--ease-out) both;
  box-shadow: 0 -12px 60px rgba(0,0,0,0.7);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle {
  width: 40px; height: 4px;
  background: var(--ink-faint); border-radius: 4px;
  margin: 0 auto 16px;
}

/* ── FAB ── */
.fab {
  position: absolute;
  bottom: 24px; right: 20px;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-deep) 100%);
  color: #0a0a05;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 32px rgba(212,175,55,0.45), 0 1px 0 rgba(255,255,255,0.3) inset;
  z-index: 50;
  transition: transform 0.18s var(--ease);
}
.fab:hover { transform: scale(1.05); }
.fab:active { transform: scale(0.94); }
.fab.fab-neon {
  background: linear-gradient(135deg, var(--neon) 0%, var(--neon-deep) 100%);
  color: #03130b;
  box-shadow: 0 10px 32px rgba(0,255,157,0.42);
}
.fab.fab-red {
  background: linear-gradient(135deg, var(--red-1) 0%, var(--red-deep) 100%);
  color: #fff;
  box-shadow: 0 10px 32px rgba(214,52,73,0.42);
}

/* ── Confetti ── */
.confetti-host { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 300; }
.confetti-bit {
  position: absolute; top: -20px;
  width: 10px; height: 14px;
  animation: confetti-fall linear forwards;
}

/* ── Number tickers ── */
.ticker {
  display: inline-block;
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1;
  font-variant-numeric: tabular-nums;
}

/* ── Misc helpers ── */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
  margin: 12px 0;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
}
.chip-gold { color: var(--gold-1); border-color: var(--border-strong); background: var(--gold-soft); }
.chip-red { color: var(--red-1); border-color: var(--red); background: var(--red-soft); }
.chip-neon { color: var(--neon); border-color: var(--neon); background: var(--neon-soft); }

.tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.felt-bg {
  background:
    radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-deep) 70%, #08130d 100%);
}

/* ── Page transitions ── */
.page-enter {
  animation: pageEnter 0.34s var(--ease-out) both;
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(8px); filter: blur(4px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(180deg, var(--bg) 0%, rgba(10,14,10,0) 100%);
  backdrop-filter: blur(10px);
}
body.theme-marble .topbar {
  background: linear-gradient(180deg, var(--bg) 0%, rgba(245,239,222,0) 100%);
}
.topbar-icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-2);
  transition: all 0.18s var(--ease);
}
.topbar-icon-btn:hover { background: var(--surface-hover); color: var(--gold-1); border-color: var(--border-strong); }

/* ── Misc ── */
.skel {
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

/* ── Bottom safe pad (so FAB doesn't cover content) ── */
.scroll-region {
  flex: 1; overflow-y: auto;
  padding: 0 16px 120px;
}

/* ── Section header ── */
.section-h {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 18px 0 10px;
}
.section-h h2 {
  font-family: var(--font-editorial);
  font-style: italic;
  font-size: 22px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* ── Buyin chip viz ── */
.poker-chip {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}
.poker-chip::before {
  content: '';
  position: absolute; inset: 3px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255,255,255,0.45);
}

/* ── Drawer items ── */
.drawer-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin: 2px 12px;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 14px;
  transition: all 0.18s var(--ease);
  position: relative;
}
.drawer-item:hover { background: var(--surface); color: var(--ink); }
.drawer-item.active {
  background: linear-gradient(90deg, var(--gold-soft), transparent);
  color: var(--gold-1);
}
.drawer-item.active::before {
  content: ''; position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 3px; border-radius: 3px;
  background: var(--gold);
}
.drawer-item svg { width: 22px; height: 22px; flex-shrink: 0; }

/* tweaks panel inside react: it positions itself via the starter */

/* table view chip stack visual */
.chipstack { position: relative; width: 30px; height: 30px; }
.chipstack > div { position: absolute; left: 0; right: 0; height: 6px; border-radius: 50%; box-shadow: 0 1px 0 rgba(0,0,0,0.3) inset; }

/* hide outline on inputs */
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline: none; }

/* helpers for layout */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.center { display: flex; align-items: center; justify-content: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* avatars */
.avatar {
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--gold-deep) 0%, var(--felt) 100%);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
  overflow: hidden;
  position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* gradient text */
.grad-gold {
  background: linear-gradient(135deg, var(--gold-1) 0%, var(--gold) 50%, var(--gold-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.grad-red {
  background: linear-gradient(135deg, var(--red-1) 0%, var(--red-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
