/* Crown Keno — Imperial Gold. Mobile-first from 320px; breakpoints 560/900/1200. */
:root {
  --bg: #140a24;
  --surface: #1e0f33;
  --surface-2: #2a1547;
  --line: #3d2560;
  --gold: #f0b429;
  --gold-soft: #ffd76b;
  --gold-deep: #b47b10;
  --ink: #1a0f05;
  --jade: #21c9a4;
  --ember: #e0453a;
  --text: #f6f0e6;
  --muted: #b6a7c9;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans Ethiopic", Tahoma, Arial, sans-serif;
  min-height: 100dvh;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 1440px;
  margin: 0 auto;
}

.label { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---- topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem clamp(0.5rem, 2vw, 1rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.balance-box { display: flex; align-items: center; gap: 0.45rem; min-width: 0; }
.crown-ico { flex: 0 0 auto; }
.balance-stack { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.balance-stack b { font-size: clamp(0.85rem, 3.4vw, 1.05rem); color: var(--gold-soft); white-space: nowrap; }

.chip {
  font-size: 0.68rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.chip.warn { color: var(--ink); background: var(--gold); border-color: var(--gold-deep); font-weight: 700; }

.draw-meta { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.draw-id-line { font-size: 0.72rem; color: var(--muted); }
.draw-id-line b { color: var(--text); }
#countdown {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: clamp(1rem, 4.5vw, 1.4rem);
  color: var(--gold);
  letter-spacing: 0.06em;
}

.top-actions { display: flex; align-items: center; gap: 0.4rem; }

.ghost-btn {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  padding: 0.4rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
}
.ghost-btn:hover { border-color: var(--gold-deep); }
.ghost-btn.active { background: var(--gold); color: var(--ink); border-color: var(--gold-deep); }

/* ---- layout ---- */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "play" "results" "side";
  gap: clamp(0.5rem, 1.5vw, 1rem);
  padding: clamp(0.4rem, 1.5vw, 1rem);
  flex: 1;
  width: 100%;
}

.play { grid-area: play; min-width: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.results-col { grid-area: results; min-width: 0; }
.side-panel { grid-area: side; min-width: 0; }

/* ---- reveal strip ---- */
.reveal-strip {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(2px, 0.7vw, 5px);
  min-height: clamp(26px, 7.4vw, 34px);
  align-items: center;
}
.reveal-strip .ball {
  width: clamp(22px, 6.6vw, 30px);
  height: clamp(22px, 6.6vw, 30px);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(10px, 2.9vw, 13px);
  font-weight: 800;
  color: var(--ink);
  background: radial-gradient(circle at 35% 30%, var(--gold-soft), var(--gold) 60%, var(--gold-deep));
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.reveal-strip .ball.hit {
  background: radial-gradient(circle at 35% 30%, #7ff0d8, var(--jade) 60%, #128268);
  color: var(--ink);
}

/* ---- board ---- */
.board {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: clamp(2px, 0.8vw, 6px);
}
.board .tile {
  aspect-ratio: 1;
  min-width: 0;
  border-radius: clamp(4px, 1vw, 8px);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: clamp(10px, 3.2vw, 16px);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  user-select: none;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.board .tile:hover { border-color: var(--gold-deep); }
.board .tile.selected {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold-deep);
}
.board .tile.drawn { border-color: var(--gold-deep); box-shadow: inset 0 0 0 2px var(--gold-deep); }
.board .tile.hit {
  background: var(--jade);
  color: var(--ink);
  border-color: var(--jade);
  box-shadow: none;
}

.pick-hint-row {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: clamp(0.72rem, 2.8vw, 0.85rem);
  color: var(--muted);
}
.pick-count { color: var(--gold-soft); font-weight: 700; font-variant-numeric: tabular-nums; }

.pays-row {
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.5rem;
  align-items: center;
}
.pays-row .pay-chip {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.1rem 0.4rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pays-row .pay-chip b { color: var(--gold-soft); }

/* ---- stake bar ---- */
.stake-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
  padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.2rem;
}
.pick-actions { display: flex; gap: 0.4rem; }
.pick-actions .ghost-btn { flex: 1; }

.stake-controls { display: flex; align-items: stretch; gap: 0.4rem; }
.step-btn {
  width: 44px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.step-btn:hover { border-color: var(--gold-deep); }
.stake-display {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.15rem 0.3rem;
  line-height: 1.15;
}
.stake-display b { color: var(--gold-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mod-btn {
  border: 1px solid var(--gold-deep);
  background: var(--surface-2);
  color: var(--gold-soft);
  border-radius: 10px;
  font-weight: 800;
  font-size: 0.72rem;
  padding: 0 0.55rem;
  min-height: 44px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.mod-btn:hover { background: var(--gold-deep); color: var(--ink); }

.bet-btn {
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold) 55%, var(--gold-deep));
  color: var(--ink);
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 14px rgba(240, 180, 41, 0.25);
}
.bet-btn:disabled {
  filter: grayscale(0.7) brightness(0.7);
  cursor: not-allowed;
  box-shadow: none;
}
#bet-amount { font-variant-numeric: tabular-nums; font-size: 0.9rem; font-weight: 800; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin-bottom: 0.5rem; }
.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.5rem 0.6rem;
  border-radius: 7px 7px 0 0;
  white-space: nowrap;
}
.tab:hover { color: var(--gold-soft); }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); background: rgba(240, 180, 41, 0.07); }
.tab.sub { font-size: 0.72rem; padding: 0.4rem 0.5rem; }

/* ---- side panel / feed ---- */
.side-panel, .results-col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.6rem;
}

.feed-list { display: flex; flex-direction: column; gap: 0.3rem; max-height: 420px; overflow-y: auto; }
.feed-row {
  display: grid;
  grid-template-columns: minmax(52px, auto) 1fr auto auto;
  gap: 0.45rem;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.35rem 0.5rem;
  font-size: 0.74rem;
}
.feed-row .who { color: var(--muted); font-weight: 700; }
.feed-row .picks { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.feed-row .stake { color: var(--gold-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.feed-row .status { font-weight: 700; white-space: nowrap; }
.feed-row .status.waiting { color: var(--muted); }
.feed-row .status.won { color: var(--jade); }
.feed-row .status.lost { color: var(--ember); }
.feed-row .status.refunded { color: var(--gold-soft); }
.feed-empty { color: var(--muted); font-size: 0.78rem; text-align: center; padding: 0.8rem 0; }

/* ---- results ---- */
/* Capped + scrollable: 20 draws of 20 numbers each otherwise pushed the
   mobile page past two full screens. */
.pane { min-height: 120px; max-height: 420px; overflow-y: auto; }
.results-table { width: 100%; border-collapse: collapse; font-size: 0.74rem; }
.results-table th, .results-table td {
  text-align: left;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.results-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.results-table td.combo { font-variant-numeric: tabular-nums; line-height: 1.7; }
.results-table .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55em;
  padding: 0 0.15em;
  margin: 0 1px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.72rem;
}
.results-table .wait-chip {
  color: var(--ink);
  background: var(--gold);
  border-radius: 6px;
  padding: 0.05rem 0.45rem;
  font-weight: 800;
  font-size: 0.7rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
}
.stats-grid .cell {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 0.62rem;
  line-height: 1.1;
  color: var(--text);
}
.stats-grid .cell .f { color: var(--gold-soft); font-weight: 700; }

.leaders-switch { display: flex; gap: 0.4rem; margin-bottom: 0.5rem; }

/* ---- fairness drawer ---- */
.fair-drawer { margin-top: 0.7rem; border-top: 1px solid var(--line); padding-top: 0.5rem; }
.fair-drawer summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
}
.fair-drawer summary::-webkit-details-marker { display: none; }
.fair-drawer[open] summary { color: var(--gold-soft); }
.fair-body { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.45rem; }
.fair-controls { display: flex; gap: 0.4rem; }
.fair-controls input {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  padding: 0.45rem 0.55rem;
  font: inherit;
}
.verify-out { font-size: 0.72rem; color: var(--muted); overflow-wrap: anywhere; }
.verify-out .v-ok { color: var(--jade); font-weight: 800; }
.verify-out .v-bad { color: var(--ember); font-weight: 800; }
.verify-out dl { margin: 0.3rem 0 0; }
.verify-out dt { color: var(--muted); margin-top: 0.35rem; font-size: 0.66rem; text-transform: uppercase; }
.verify-out dd { margin: 0.1rem 0 0; color: var(--text); font-family: Consolas, Menlo, monospace; font-size: 0.68rem; }

/* ---- toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--gold-deep);
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  font-size: 0.82rem;
  max-width: min(92vw, 420px);
  text-align: center;
  z-index: 50;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
}

/* ---- breakpoints ---- */
@media (min-width: 560px) {
  .board .tile { max-width: 44px; max-height: 44px; margin: 0 auto; width: 100%; }
  .board { justify-items: center; }
  .stake-bar { flex-direction: row; align-items: stretch; position: static; border-radius: 12px; }
  .pick-actions { flex-direction: column; }
  .stake-controls { flex: 1; }
  .bet-btn { min-width: 150px; }
  .toast { bottom: 24px; }
}

@media (min-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-areas:
      "play side"
      "results side";
    align-items: start;
  }
  .feed-list { max-height: 560px; }
}

@media (min-width: 1200px) {
  /* Cap the shell to the viewport so each rail scrolls internally, instead of
     hugging the top (dead zone) or growing the whole page. */
  .app { height: 100dvh; min-height: 0; }
  .layout {
    grid-template-columns: 300px minmax(0, 1fr) 360px;
    grid-template-areas: "side play results";
    align-items: stretch;
    min-height: 0;
    overflow: hidden;
  }
  .side-panel, .results-col { display: flex; flex-direction: column; min-height: 0; }
  .side-panel .feed-list, .results-col .pane { flex: 1; min-height: 0; max-height: none; overflow-y: auto; }
  .play { min-height: 0; overflow-y: auto; }
  .board .tile { max-width: 52px; max-height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---- Profit practices (presentation only) ---- */
.practice-banner { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; z-index: 60; text-align: center; }
.practice-banner[hidden] { display: none; }
.practice-banner-title { font-size: clamp(28px, 7vw, 54px); font-weight: 900; letter-spacing: 2px; color: #ffd166; text-shadow: 0 2px 18px rgba(0,0,0,.65); animation: practice-pop 450ms ease-out; }
.practice-banner.win .practice-banner-title { color: #9fe7b1; }
.practice-banner.big .practice-banner-title { color: #ffd166; }
.practice-banner.mega .practice-banner-title { color: #ffb703; font-size: clamp(34px, 8vw, 64px); }
.practice-banner.epic .practice-banner-title { color: #ff8fa3; font-size: clamp(38px, 9vw, 72px); }
.practice-banner.almost .practice-banner-title { color: #b9a8ff; font-size: clamp(22px, 5.5vw, 40px); }
.practice-banner-amount { font-size: clamp(20px, 5vw, 36px); font-weight: 800; color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
@keyframes practice-pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.board .tile.one-away { outline: 3px solid #b9a8ff; outline-offset: -3px; animation: tension-pulse 700ms ease-in-out infinite; }
@keyframes tension-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(185,168,255,0); } 50% { box-shadow: 0 0 0 6px rgba(185,168,255,.5); } }
.reveal-strip.tease .ball:last-child { animation: practice-pop 500ms ease-out; }
.stake-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.stake-chip { border: 1px solid rgba(255,255,255,.25); background: transparent; color: inherit; border-radius: 999px; padding: 4px 10px; font-weight: 700; cursor: pointer; }
.stake-chip.active { border-color: #ffd166; color: #ffd166; }
.stake-chip.anchor { border-color: #ffd166; box-shadow: 0 0 0 1px #ffd166, 0 0 14px rgba(255,209,102,.45); transform: scale(1.1); font-weight: 800; }
.rebet-btn { border-color: #ffd166; color: #ffd166; font-weight: 800; }
.recent-wins { display: flex; align-items: center; gap: 10px; overflow: hidden; padding: 4px 2px 8px; }
.recent-wins-strip { display: flex; gap: 14px; overflow: hidden; white-space: nowrap; }
.recent-win-row { font-size: 12px; color: #ffd166; animation: practice-pop 400ms ease-out; }
#sound-toggle.muted { opacity: .45; text-decoration: line-through; }
