/* ?? Reset ??????????????????????????????????????????????????????????????? */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #041a09;
  --felt:       #072c0c;
  --felt-light: #093e14;
  --gold:       #d4af37;
  --gold-light: #f0d060;
  --gold-dim:   #9a7c1a;
  --text:       #fff8e1;
  --text-dim:   #b0c0a0;
  --win:        #ffe040;
  --lose:       #ff4444;
  --match-bg:   #d4af37;
  --match-text: #0a3c10;
  --slot-glow:  #00e5ff;
  --timer-green:#27ae60;
  --top-h:      54px;
  --bot-h:      88px;
}

/* ?? LOGIN OVERLAY ??????????????????????????????????????????????????? */
#login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
#login-overlay.hidden { display: none; }

#login-box {
  background: var(--felt);
  border: 2px solid var(--gold-dim);
  border-radius: 14px;
  padding: 40px 36px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: min(92vw, 360px);
  box-shadow: 0 0 40px rgba(212,175,55,.25);
}
#login-title {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--gold-light);
  text-shadow: 0 0 18px var(--gold);
}
#login-sub {
  font-size: .82rem;
  color: var(--text-dim);
  letter-spacing: 1px;
}
#login-input {
  width: 100%;
  padding: 11px 14px;
  background: #0a2e10;
  border: 1.5px solid var(--gold-dim);
  border-radius: 7px;
  color: var(--text);
  font-size: 1rem;
  letter-spacing: 1px;
  outline: none;
  text-align: center;
}
#login-input:focus { border-color: var(--gold); box-shadow: 0 0 8px rgba(212,175,55,.4); }
#login-error {
  min-height: 18px;
  font-size: .78rem;
  color: var(--lose);
  letter-spacing: .5px;
}
#login-btn {
  width: 100%;
  padding: 12px 0;
  background: linear-gradient(135deg, #1a6b2a, #0d4718);
  border: 1.5px solid var(--gold);
  border-radius: 8px;
  color: var(--gold-light);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background .2s, box-shadow .2s;
}
#login-btn:hover  { background: linear-gradient(135deg, #236032, #0f5a1e); box-shadow: 0 0 12px rgba(212,175,55,.35); }
#login-btn:active { background: #0d4718; }

/* ?? Full-page layout — NO body scroll ????????????????????????????????? */
html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Segoe UI', Arial, sans-serif;
  color: var(--text);
  user-select: none;
}

/* ?? TOP BAR (fixed) ??????????????????????????????????????????????????? */
#top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--top-h);
  background: #051a08;
  border-bottom: 2px solid var(--gold-dim);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  z-index: 100;
}

#top-left {
  display: flex;
  flex-direction: column;
  min-width: 76px;
}
#title-label {
  font-size: .95rem;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--gold-light);
  text-shadow: 0 0 10px var(--gold);
  line-height: 1;
}
#round-label {
  font-size: .6rem;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Timer block */
#timer-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  min-width: 110px;
}
#timer-phase {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--timer-green);
}
#timer-countdown {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--gold-light);
  line-height: 1;
}
#timer-track {
  width: 100%;
  height: 5px;
  background: rgba(255,255,255,.1);
  border-radius: 3px;
  overflow: hidden;
}
#timer-fill {
  height: 100%;
  background: var(--timer-green);
  border-radius: 3px;
  transition: width .9s linear;
}

/* Stats */
#stats-bar {
  display: flex;
  gap: 6px;
  margin-left: auto;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0,0,0,.4);
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  padding: 3px 10px;
  min-width: 68px;
}
.stat-label {
  font-size: .55rem;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.stat span:last-child {
  font-size: .95rem;
  font-weight: 700;
  color: var(--gold-light);
}
.stat.pending span:last-child { color: var(--win); }

/* ?? BOTTOM CONTROLS (fixed) ??????????????????????????????????????????? */
#controls {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bot-h);
  background: #051a08;
  border-top: 2px solid var(--gold-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  z-index: 100;
}

#coin-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}
.chip-label {
  font-size: .6rem;
  color: var(--text-dim);
  letter-spacing: 1px;
}
.chip {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 2px solid var(--gold-dim);
  background: radial-gradient(circle, #1a6b28 0%, #0a3c10 100%);
  color: var(--gold-light);
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, box-shadow .12s, transform .1s;
}
.chip:hover   { border-color: var(--gold-light); box-shadow: 0 0 8px var(--gold); transform: scale(1.08); }
.chip.selected {
  border-color: var(--win);
  background: radial-gradient(circle, #3a6b10 0%, #1a4c08 100%);
  box-shadow: 0 0 12px var(--win);
  color: var(--win);
}
.util-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 5px;
  border: 2px solid var(--gold-dim);
  background: rgba(0,0,0,.4);
  color: var(--gold-light);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: border-color .15s;
}
.util-btn:hover   { border-color: var(--gold-light); }
.util-btn:disabled{ opacity: .35; cursor: not-allowed; }

#btn-bar {
  display: flex;
  gap: 10px;
}
.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 20px;
  border: 2px solid var(--gold-dim);
  border-radius: 7px;
  background: linear-gradient(180deg, #1a6b28 0%, #0a3c10 100%);
  color: var(--gold-light);
  cursor: pointer;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  transition: transform .1s, box-shadow .15s;
}
.action-btn:hover  { transform: scale(1.04); box-shadow: 0 0 14px var(--gold); border-color: var(--gold); }
.action-btn:active { transform: scale(.97); }
.btn-icon { font-size: 1rem; }
.btn-text { white-space: nowrap; }

.action-btn#btn-claim {
  border-color: var(--win);
  background: linear-gradient(180deg, #3a6010 0%, #1a3008 100%);
  color: var(--win);
}
.action-btn#btn-claim:hover { box-shadow: 0 0 14px var(--win); }
.action-btn#btn-newgame {
  border-color: var(--lose);
  background: linear-gradient(180deg, #3a1010 0%, #1a0808 100%);
  color: var(--text);
}
.action-btn.hidden   { display: none; }
.action-btn.disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* ?? SCROLLABLE MAIN ??????????????????????????????????????????????????? */
#main {
  position: fixed;
  top: var(--top-h);
  bottom: var(--bot-h);
  left: 0; right: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 8px 4px;
  background: var(--felt);
}

/* ?? Drawn numbers ????????????????????????????????????????????????????? */
#slots-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0 6px;
}
#slots-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-label {
  font-size: .6rem;
  letter-spacing: 2px;
  color: var(--gold-dim);
  font-weight: 700;
}
#slots-row { display: flex; gap: 8px; }

.slot-box {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  border: 2px solid var(--gold-dim);
  background: rgba(0,0,0,.4);
  font-size: 1.4rem; font-weight: 700;
  color: var(--text-dim);
  transition: all .3s;
}
.slot-box.revealed {
  color: var(--gold-light);
  border-color: var(--gold);
  box-shadow: 0 0 12px var(--gold);
  background: rgba(212,175,55,.1);
}
.slot-box.special {
  color: var(--lose);
  border-color: var(--lose);
  box-shadow: 0 0 18px var(--lose);
  background: rgba(255,68,68,.12);
  animation: specialPulse .8s ease infinite;
}
@keyframes specialPulse {
  0%,100% { box-shadow: 0 0 18px var(--lose); }
  50%     { box-shadow: 0 0 36px var(--lose); }
}

/* Separator between the 5 draw slots and the bonus slot */
.slot-separator {
  width: 2px;
  height: 52px;
  background: var(--gold-dim);
  border-radius: 2px;
  opacity: .5;
  align-self: center;
}

/* Bonus slot */
.slot-box.bonus-slot {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  width: 58px;
  height: 62px;
  border-color: #7b5ea7;
  background: rgba(80,20,120,.25);
}
.slot-box.bonus-slot span {
  font-size: 1.3rem;
}
.bonus-label {
  font-size: .42rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #c084fc;
  line-height: 1;
}
/* Bonus = 0 (no bonus) */
.slot-box.bonus-slot.bonus-inactive {
  border-color: rgba(123,94,167,.4);
  background: rgba(0,0,0,.35);
  color: var(--text-dim);
}
.slot-box.bonus-slot.bonus-inactive .bonus-label { color: rgba(192,132,252,.4); }
/* Bonus = 1 (active — payout doubled) */
.slot-box.bonus-slot.bonus-active {
  border-color: #c084fc;
  background: rgba(140,60,255,.2);
  color: #f0c0ff;
  box-shadow: 0 0 18px rgba(192,132,252,.7);
  animation: bonusPulse .75s ease infinite alternate;
}
.slot-box.bonus-slot.bonus-active .bonus-label { color: #f0c0ff; }
@keyframes bonusPulse {
  from { box-shadow: 0 0 10px rgba(192,132,252,.5); }
  to   { box-shadow: 0 0 28px rgba(192,132,252,.95), 0 0 6px #fff; }
}

/* 2× badge that appears on win-results row when bonus is active */
.win-badge.bonus-win {
  border-color: #c084fc;
  color: #f0c0ff;
  background: rgba(140,60,255,.18);
  animation: bonusPulse .75s ease infinite alternate;
}

/* ?? Charts 3×2 grid ??????????????????????????????????????????????????? */
#charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.chart-card {
  background: rgba(0,0,0,.3);
  border: 1px solid var(--gold-dim);
  border-radius: 7px;
  overflow: hidden;
}
.chart-card.has-win {
  border-color: var(--win);
  box-shadow: 0 0 8px rgba(255,224,64,.35);
}
.chart-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px;
  background: rgba(0,0,0,.35);
  border-bottom: 1px solid rgba(212,175,55,.2);
}
.chart-title-text {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--gold-dim);
}
.chart-card.has-win .chart-title-text { color: var(--win); }

/* Per-chart bet controls inside title bar */
.chart-bet-inline {
  display: flex;
  align-items: center;
  gap: 3px;
}
.chart-bet-display {
  min-width: 36px;
  text-align: center;
  font-size: .75rem;
  font-weight: 800;
  color: var(--gold-light);
  background: rgba(0,0,0,.5);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  padding: 1px 4px;
}
.chart-bet-display.bet-zero {
  color: var(--text-dim);
  border-color: rgba(154,124,26,.35);
}
.chart-card.has-win .chart-bet-display { border-color: var(--win); color: var(--win); }
.chart-bet-btn {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1px solid var(--gold-dim);
  background: rgba(0,0,0,.5);
  color: var(--gold-light);
  font-size: .8rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: border-color .1s, transform .08s;
}
.chart-bet-btn.add-btn:hover { border-color: var(--win); color: var(--win); transform: scale(1.15); }
.chart-bet-btn.clr-btn:hover { border-color: var(--lose); color: var(--lose); transform: scale(1.15); }
.chart-bet-btn:disabled      { opacity: .3; cursor: not-allowed; }

/* Bingo table */
.bingo-table {
  width: 100%;
  border-collapse: collapse;
}
.bingo-table td {
  width: 20%;
  text-align: center; vertical-align: middle;
  font-size: .75rem; font-weight: 600;
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,.05);
  transition: background .25s, color .25s;
  padding: 0;
  height: 28px;
}
.bingo-table td.matched {
  background: var(--match-bg);
  color: var(--match-text);
  font-weight: 800;
}
.bingo-table td.win-line {
  background: #ffe040;
  color: #0a3c10;
  font-weight: 900;
  animation: winPulse .65s ease infinite alternate;
}
@keyframes winPulse {
  from { box-shadow: inset 0 0 4px #ffe040; }
  to   { box-shadow: inset 0 0 10px #fff, 0 0 10px #ffe040; }
}

/* Win badge strip inside chart card */
.chart-win-list {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px 4px;
  background: rgba(255,224,64,.06);
  border-top: 1px solid rgba(255,224,64,.2);
  justify-content: center;
}
.chart-win-badge {
  font-size: .58rem;
  font-weight: 700;
  color: var(--win);
  background: rgba(255,224,64,.1);
  border: 1px solid rgba(255,224,64,.35);
  border-radius: 8px;
  padding: 1px 5px;
  white-space: nowrap;
}

/* ?? Win results row ??????????????????????????????????????????????????? */
#win-results {
  min-height: 28px;
  padding: 4px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}
.win-badge {
  background: rgba(255,224,64,.12);
  border: 1px solid var(--win);
  border-radius: 16px;
  padding: 2px 10px;
  font-size: .68rem;
  font-weight: 700;
  color: var(--win);
}
.win-badge.slot-win  { border-color: var(--slot-glow); color: var(--slot-glow); background: rgba(0,229,255,.08); }
.win-badge.special-win { border-color: var(--lose); color: var(--lose); animation: specialPulse .8s infinite; }

/* ?? Toast ????????????????????????????????????????????????????????????? */
#message-toast {
  min-height: 20px;
  text-align: center;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-dim);
  padding: 2px 10px 4px;
}

/* ?? Responsive narrow screens ????????????????????????????????????????? */
@media (max-width: 520px) {
  :root { --top-h: 60px; --bot-h: 96px; }
  #charts-grid { grid-template-columns: repeat(2, 1fr); }
  .slot-box { width: 44px; height: 44px; font-size: 1.15rem; }
  #stats-bar .stat { min-width: 54px; padding: 3px 6px; }
}
