/* ── Variables ──────────────────────────────── */
:root {
  --bg:          #09091a;
  --panel:       #0f0f2a;
  --panel-edge:  #1a1a3e;
  --neon-gold:   #f5c842;
  --neon-pink:   #ff3fa4;
  --neon-cyan:   #00e5ff;
  --text:        #e8e8f5;
  --text-muted:  #6b6b9a;
  --called-bg:   #1c1c40;
  --called-lit:  #f5c842;
  --radius:      14px;
  --roller-h:    160px;
}

/* ── Reset ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* ── Starfield ───────────────────────────────── */
.starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  animation: twinkle var(--d, 3s) ease-in-out infinite;
  opacity: 0;
}
@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(0.8); }
  50%       { opacity: var(--o, 0.6); transform: scale(1); }
}

/* ── App Shell ───────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  width: min(680px, 96vw);
  padding: 2rem 0 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Header ──────────────────────────────────── */
.header {
  text-align: center;
  position: relative;
  padding-top: 1rem;
}
.logo-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--neon-gold);
  box-shadow: 0 0 18px var(--neon-gold), inset 0 0 18px rgba(245,200,66,0.15);
  margin: 0 auto 0.75rem;
  animation: pulse-ring 3s ease-in-out infinite;
}
@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 18px var(--neon-gold), inset 0 0 18px rgba(245,200,66,0.15); }
  50%       { box-shadow: 0 0 36px var(--neon-gold), inset 0 0 30px rgba(245,200,66,0.25); }
}
.title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(3.5rem, 12vw, 6rem);
  letter-spacing: 0.08em;
  color: var(--text);
  line-height: 1;
  text-shadow: 0 0 40px rgba(245,200,66,0.3);
}
.title-accent { color: var(--neon-pink); }
.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-top: 0.25rem;
}

/* ── Panel ───────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 2rem;
}
.hidden { display: none !important; }

/* ── Setup Panel ─────────────────────────────── */
.setup-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
}
.field-label {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.number-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.stepper {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--panel-edge);
  background: transparent;
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color .2s, color .2s, box-shadow .2s;
}
.stepper:hover {
  border-color: var(--neon-gold);
  color: var(--neon-gold);
  box-shadow: 0 0 12px rgba(245,200,66,0.3);
}
input#maxNumber {
  width: 110px;
  height: 56px;
  text-align: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.4rem;
  letter-spacing: 0.05em;
  background: var(--bg);
  color: var(--neon-gold);
  border: 2px solid var(--panel-edge);
  border-radius: 10px;
  outline: none;
  transition: border-color .2s;
  -moz-appearance: textfield;
}
input#maxNumber::-webkit-inner-spin-button,
input#maxNumber::-webkit-outer-spin-button { -webkit-appearance: none; }
input#maxNumber:focus { border-color: var(--neon-gold); box-shadow: 0 0 12px rgba(245,200,66,0.25); }

/* ── Buttons ─────────────────────────────────── */
.btn {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 0.1em;
  transition: transform .15s, box-shadow .15s, opacity .2s;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-start {
  background: var(--neon-gold);
  color: #09091a;
  font-size: 1.2rem;
  padding: 0.85rem 3rem;
  box-shadow: 0 4px 24px rgba(245,200,66,0.35);
}
.btn-start:hover { box-shadow: 0 4px 36px rgba(245,200,66,0.55); transform: translateY(-2px); }

.btn-call {
  background: linear-gradient(135deg, var(--neon-pink), #c0006a);
  color: #fff;
  font-size: 1.6rem;
  padding: 1rem 2.5rem;
  box-shadow: 0 4px 28px rgba(255,63,164,0.4);
  flex: 1;
}
.btn-call:hover:not(:disabled) { box-shadow: 0 6px 40px rgba(255,63,164,0.6); transform: translateY(-2px); }
.btn-call.rolling { animation: btn-pulse 0.35s ease-in-out infinite alternate; }
@keyframes btn-pulse {
  from { box-shadow: 0 4px 28px rgba(255,63,164,0.4); }
  to   { box-shadow: 0 4px 48px rgba(255,63,164,0.75); }
}

.btn-reset {
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 1rem 1.5rem;
  border: 2px solid var(--panel-edge);
}
.btn-reset:hover { border-color: var(--neon-cyan); color: var(--neon-cyan); box-shadow: 0 0 14px rgba(0,229,255,0.2); }

/* ── Game Panel ──────────────────────────────── */
.game-panel {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* ── Roller ──────────────────────────────────── */
.roller-wrap {
  text-align: center;
}
.roller-track {
  height: var(--roller-h);
  overflow: hidden;
  border-radius: 16px;
  background: var(--bg);
  border: 2px solid var(--panel-edge);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
/* shimmer edges */
.roller-track::before,
.roller-track::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 36px;
  z-index: 2;
  pointer-events: none;
}
.roller-track::before {
  top: 0;
  background: linear-gradient(to bottom, var(--bg), transparent);
}
.roller-track::after {
  bottom: 0;
  background: linear-gradient(to top, var(--bg), transparent);
}
.roller-number {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(5rem, 18vw, 8rem);
  color: var(--neon-gold);
  text-shadow: 0 0 40px rgba(245,200,66,0.6);
  line-height: 1;
  transition: color 0.3s;
  user-select: none;
}
.roller-number.rolling-flash {
  animation: num-flash 0.12s ease-in-out infinite alternate;
}
@keyframes num-flash {
  from { opacity: 0.5; transform: scaleY(0.9); }
  to   { opacity: 1;   transform: scaleY(1.05); }
}
.roller-number.reveal {
  animation: num-reveal 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes num-reveal {
  0%   { transform: scale(0.4) rotate(-6deg); opacity: 0; }
  100% { transform: scale(1)   rotate(0deg);  opacity: 1; }
}
.roller-label {
  margin-top: 0.6rem;
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  min-height: 1.2em;
}

/* ── Controls ────────────────────────────────── */
.game-controls {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
}

/* ── Stats ───────────────────────────────────── */
.stats-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  background: var(--bg);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid var(--panel-edge);
}
.stat { text-align: center; }
.stat-val {
  display: block;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2rem;
  color: var(--neon-cyan);
  line-height: 1;
}
.stat-lbl {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--panel-edge);
}

/* ── Board ───────────────────────────────────── */
.board-section { }
.board-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 6px;
}
.board-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(0.85rem, 2.5vw, 1.1rem);
  background: var(--called-bg);
  color: var(--text-muted);
  border: 1px solid var(--panel-edge);
  transition: background 0.3s, color 0.3s, box-shadow 0.3s, transform 0.3s;
  user-select: none;
}
.board-cell.lit {
  background: var(--neon-gold);
  color: #09091a;
  border-color: var(--neon-gold);
  box-shadow: 0 0 12px rgba(245,200,66,0.5);
  transform: scale(1.08);
  z-index: 1;
}
.board-cell.just-called {
  animation: cell-pop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes cell-pop {
  0%   { transform: scale(0.6); box-shadow: 0 0 30px rgba(245,200,66,0.9); }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1.08); box-shadow: 0 0 12px rgba(245,200,66,0.5); }
}

/* ── Confetti Burst ──────────────────────────── */
.confetti-piece {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 999;
  animation: confetti-fall var(--cf-dur, 1.2s) ease-out forwards;
}
@keyframes confetti-fall {
  0%   { transform: translate(0,0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translate(var(--cf-x), var(--cf-y)) rotate(var(--cf-r)) scale(0.4); opacity: 0; }
}

/* ── All-called message ──────────────────────── */
.all-called-msg {
  text-align: center;
  padding: 1rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(245,200,66,0.1), rgba(255,63,164,0.1));
  border: 1px solid var(--neon-gold);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  color: var(--neon-gold);
  letter-spacing: 0.1em;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 480px) {
  .panel { padding: 1.25rem; }
  .board { grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; }
  .board-cell { font-size: 0.75rem; }
  .btn-call { font-size: 1.3rem; padding: 0.9rem 1.5rem; }
}
