/* ==========================================================================
   KENO LITE — late-night high-limit room
   Mobile-first. No external assets of any kind: no fonts, no images, no CDN.
   ========================================================================== */

:root {
  --felt-900: #0b2818;
  --felt-700: #14402a;
  --felt-500: #1d5738;
  --rail-900: #1a1210;
  --rail-700: #2b1f1a;
  --gold-500: #d4af37;
  --gold-300: #f0d878;
  --ivory: #f5f0e1;
  --red-500: #a8322d;
  --teal-500: #2e6f6a;
  --win-glow: rgba(240, 216, 120, .55);

  --serif: Georgia, 'Times New Roman', Times, serif;
  --mono: Consolas, 'SF Mono', 'Roboto Mono', Menlo, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --gap: 4px;
  --radius: 10px;
  --tap: 44px;
}

* { box-sizing: border-box; }

html {
  background: var(--rail-900);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sans);
  color: var(--ivory);
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(212, 175, 55, .13), transparent 60%),
    radial-gradient(90% 60% at 50% 105%, rgba(46, 111, 106, .16), transparent 65%),
    linear-gradient(180deg, var(--felt-900) 0%, #08200f 55%, var(--rail-900) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

.room {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 10px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* The dealer's rail: metrics + controls stay pinned to the thumb zone so the
   game is playable one-handed without chasing the Deal button up the page. */
.rail {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
  margin-top: auto;
  background:
    linear-gradient(180deg, rgba(8, 26, 15, .55) 0%, rgba(8, 26, 15, .97) 7%, rgba(8, 26, 15, .99) 100%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.rail::before {
  content: '';
  position: absolute;
  left: -12px;
  right: -12px;
  top: 0;
  bottom: 0;
  z-index: -1;
  background: inherit;
}

.cap {
  font-family: var(--serif);
  font-size: .62rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(245, 240, 225, .58);
}

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- masthead */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(212, 175, 55, .28);
}

.wordmark {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.32rem;
  line-height: 1;
  letter-spacing: .16em;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
}

.wordmark .w1 {
  color: var(--gold-300);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .6), 0 0 18px rgba(212, 175, 55, .35);
}

.wordmark .w2 {
  font-size: .58rem;
  letter-spacing: .52em;
  color: rgba(245, 240, 225, .55);
  margin-top: 4px;
  padding-left: 2px;
}

.bankblock {
  display: flex;
  align-items: center;
  gap: 8px;
}

.balance {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}

.balance .num {
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--gold-300);
  letter-spacing: .02em;
}

/* ----------------------------------------------------------------- status */

.status {
  margin: 0;
  min-height: 2.4em;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--serif);
  font-size: .84rem;
  font-style: italic;
  color: rgba(245, 240, 225, .8);
  padding: 0 4px;
}

.status.win { color: var(--gold-300); font-style: normal; letter-spacing: .04em; }

/* ------------------------------------------------------------------ board */

.boardwrap { position: relative; }

.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--gap);
  padding: 6px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(29, 87, 56, .55), rgba(11, 40, 24, .85));
  border: 1px solid rgba(212, 175, 55, .22);
  box-shadow:
    inset 0 1px 0 rgba(245, 240, 225, .06),
    0 10px 26px rgba(0, 0, 0, .5);
}

.cell {
  -webkit-appearance: none;
  appearance: none;
  min-height: var(--tap);
  height: 44px;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid rgba(212, 175, 55, .22);
  background: linear-gradient(180deg, rgba(245, 240, 225, .085), rgba(0, 0, 0, .25));
  color: rgba(245, 240, 225, .88);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: transform .12s ease, background .18s ease, border-color .18s ease, color .18s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.cell:active { transform: scale(.94); }

.cell[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--gold-300), var(--gold-500));
  border-color: var(--gold-300);
  color: #2a1d05;
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(240, 216, 120, .35), 0 2px 10px rgba(212, 175, 55, .3);
}

.cell.drawn {
  background: linear-gradient(180deg, var(--teal-500), #1d4a47);
  border-color: rgba(240, 216, 120, .4);
  color: var(--ivory);
}

.cell.drawn::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 7px;
  border: 1px solid rgba(245, 240, 225, .18);
  pointer-events: none;
}

.cell.hit {
  background: linear-gradient(180deg, var(--gold-300), var(--gold-500));
  border-color: var(--ivory);
  color: #2a1d05;
  font-weight: 800;
  animation: pop .5s ease-out;
  box-shadow: 0 0 0 2px rgba(245, 240, 225, .5), 0 0 18px var(--win-glow);
}

.cell.miss { opacity: .42; }

.cell:disabled { cursor: default; }
.cell:focus-visible,
button:focus-visible {
  outline: 2px solid var(--gold-300);
  outline-offset: 2px;
}

@keyframes pop {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 var(--win-glow); }
  40%  { transform: scale(1.16); box-shadow: 0 0 0 10px rgba(240, 216, 120, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 2px rgba(245, 240, 225, .5), 0 0 18px var(--win-glow); }
}

/* wash + banner: the big-win moment, CSS only */

.wash {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(70% 60% at 50% 50%, rgba(240, 216, 120, .55), rgba(212, 175, 55, .12) 60%, transparent 78%);
}

.wash.go { animation: wash 1.5s ease-out; }

@keyframes wash {
  0%   { opacity: 0; }
  18%  { opacity: 1; }
  100% { opacity: 0; }
}

.banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 42%;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ivory);
  text-shadow: 0 2px 14px rgba(0, 0, 0, .9), 0 0 26px var(--win-glow);
}

.banner.go { animation: banner 1.6s ease-out; }

@keyframes banner {
  0%   { opacity: 0; transform: scale(.82); }
  20%  { opacity: 1; transform: scale(1.04); }
  70%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

/* ---------------------------------------------------------------- metrics */

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
}

.metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 4px 5px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(43, 31, 26, .75), rgba(26, 18, 16, .8));
  border: 1px solid rgba(212, 175, 55, .18);
}

.metric .num { font-size: 1.05rem; font-weight: 700; color: var(--ivory); }
.metric.live .num { color: var(--gold-300); }

/* --------------------------------------------------------------- paytable */

.pays {
  border-radius: var(--radius);
  border: 1px solid rgba(212, 175, 55, .22);
  background: linear-gradient(180deg, rgba(26, 18, 16, .8), rgba(11, 40, 24, .5));
  overflow: hidden;
}

.pays-head {
  margin: 0;
  padding: 7px 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: .72rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold-300);
  background: rgba(0, 0, 0, .25);
  border-bottom: 1px solid rgba(212, 175, 55, .18);
}

.pays-head .rtp {
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .04em;
  text-transform: none;
  color: rgba(245, 240, 225, .5);
}

.pays-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: .82rem;
}

.pays-table th {
  font-family: var(--serif);
  font-weight: 400;
  font-size: .58rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(245, 240, 225, .65);
  text-align: right;
  padding: 5px 10px;
}

.pays-table th:first-child { text-align: left; }

.pays-table td {
  padding: 6px 10px;
  text-align: right;
  border-top: 1px solid rgba(245, 240, 225, .07);
  color: rgba(245, 240, 225, .84);
}

.pays-table td:first-child {
  text-align: left;
  font-weight: 700;
  color: var(--ivory);
}

.pays-table td.odds { color: rgba(245, 240, 225, .42); font-size: .74rem; }
.pays-table tr.empty td { text-align: center; color: rgba(245, 240, 225, .45); font-style: italic; }

.pays-table tr.top td { color: var(--gold-300); }

.pays-table tr.won td {
  background: rgba(212, 175, 55, .2);
  color: var(--gold-300);
  animation: rowpulse 1.2s ease-out 2;
}

@keyframes rowpulse {
  0%, 100% { background: rgba(212, 175, 55, .14); }
  50%      { background: rgba(240, 216, 120, .38); }
}

/* --------------------------------------------------------------- controls */

.controls { display: flex; flex-direction: column; gap: 7px; }

/* Two lines: [ BET  −  n  +   TURBO ] then a full-width row of chips, so every
   chip keeps a 44px-plus target at 375px. */
.betrow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.betcap { flex: 0 0 auto; }

/* Turbo is the only ghost button on this row; park it at the right edge. */
.betrow > .ghost { margin-left: auto; flex: 0 0 auto; }

.chips {
  display: flex;
  gap: 5px;
  flex: 1 0 100%;
  min-width: 0;
}

.chip {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 0;
  min-width: 0;
  min-height: var(--tap);
  border-radius: 50% / 22%;
  border: 2px dashed rgba(245, 240, 225, .3);
  background: linear-gradient(180deg, var(--rail-700), var(--rail-900));
  color: rgba(245, 240, 225, .78);
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, border-color .18s ease, color .18s ease;
}

.chip:active { transform: translateY(1px); }

.chip[aria-pressed="true"] {
  border-color: var(--gold-300);
  border-style: solid;
  color: var(--gold-300);
  background: linear-gradient(180deg, #3a2a12, #241806);
  box-shadow: 0 0 12px rgba(212, 175, 55, .3);
}

.chip:disabled { opacity: .3; cursor: default; }

.stepper {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.step {
  -webkit-appearance: none;
  appearance: none;
  width: var(--tap);
  min-height: var(--tap);
  border-radius: var(--radius);
  border: 1px solid rgba(212, 175, 55, .3);
  background: linear-gradient(180deg, rgba(43, 31, 26, .9), rgba(26, 18, 16, .95));
  color: var(--gold-300);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.step:disabled { opacity: .32; cursor: default; }

.betnum {
  min-width: 3.6em;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ivory);
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.ghost {
  -webkit-appearance: none;
  appearance: none;
  min-height: var(--tap);
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid rgba(212, 175, 55, .3);
  background: rgba(26, 18, 16, .7);
  color: rgba(245, 240, 225, .86);
  font-family: var(--serif);
  font-size: .78rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ghost u { text-decoration: none; border-bottom: 1px solid rgba(212, 175, 55, .5); }
.ghost:disabled { opacity: .34; cursor: default; }
.ghost.toggle[aria-pressed="true"] {
  color: var(--gold-300);
  border-color: var(--gold-300);
  background: linear-gradient(180deg, #3a2a12, #241806);
}
.ghost.danger { color: #e9a29e; border-color: rgba(168, 50, 45, .6); }

.bankblock .ghost { font-size: .66rem; padding: 0 12px; }

.play {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 52px;
  border-radius: 12px;
  border: 1px solid var(--gold-300);
  background: linear-gradient(180deg, var(--gold-300), var(--gold-500) 60%, #a8842a);
  color: #241806;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .26em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(212, 175, 55, .22);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .1s ease, filter .18s ease;
}

.play:active { transform: translateY(2px); }
.play:disabled {
  filter: grayscale(.75) brightness(.6);
  box-shadow: none;
  cursor: default;
}
.play.small { min-height: var(--tap); font-size: .8rem; letter-spacing: .14em; width: auto; padding: 0 18px; }

.rebuy {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: var(--tap);
  border-radius: var(--radius);
  border: 1px solid var(--red-500);
  background: linear-gradient(180deg, #b03b35, #7d221e);
  color: var(--ivory);
  font-family: var(--serif);
  font-size: .88rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}

/* ----------------------------------------------------------------- footer */

.foot {
  margin-top: 2px;
  padding: 10px 0 calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(212, 175, 55, .18);
  text-align: center;
}

.foot p { margin: 0 0 3px; }

.promise {
  font-size: .68rem;
  color: rgba(245, 240, 225, .5);
  line-height: 1.5;
}

.sib {
  font-family: var(--serif);
  font-size: .64rem;
  font-style: italic;
  letter-spacing: .08em;
  color: rgba(245, 240, 225, .32);
}

/* ------------------------------------------------------------------ modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(5, 12, 8, .78);
  padding: 12px;
  overflow-y: auto;
}

.modal[hidden] { display: none; }

.sheet {
  width: 100%;
  max-width: 460px;
  border-radius: 16px;
  border: 1px solid rgba(212, 175, 55, .35);
  background: linear-gradient(180deg, #12331f, var(--rail-900));
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .6);
}

.sheet h2 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold-300);
}

.subhead {
  margin: 16px 0 8px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: .68rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(245, 240, 225, .5);
}

.ledger {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  font-size: .82rem;
}

.ledger dt {
  font-family: var(--serif);
  color: rgba(245, 240, 225, .62);
  font-size: .78rem;
}

.ledger dd {
  margin: 0;
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ivory);
}

.ledger dd.up { color: var(--gold-300); }
.ledger dd.down { color: #e9a29e; }

.hist { display: flex; flex-direction: column; gap: 5px; }

.histrow {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: .68rem;
}

.histrow .k {
  flex: 0 0 3.6em;
  color: rgba(245, 240, 225, .5);
}

.histrow .bars { display: flex; flex: 1 1 auto; gap: 3px; min-width: 0; }

.histrow .bar {
  flex: 1 1 0;
  min-width: 0;
  height: 20px;
  border-radius: 4px;
  background: rgba(245, 240, 225, .08);
  position: relative;
  overflow: hidden;
  text-align: center;
  line-height: 20px;
  font-size: .6rem;
  color: rgba(245, 240, 225, .82);
}

.histrow .bar i {
  position: absolute;
  left: 0; bottom: 0; top: 0;
  background: linear-gradient(90deg, rgba(46, 111, 106, .85), rgba(212, 175, 55, .6));
  z-index: 0;
}

.histrow .bar span { position: relative; z-index: 1; }

.legend { margin-top: 7px; font-style: italic; }

.fineprint {
  margin: 14px 0 0;
  font-size: .66rem;
  line-height: 1.5;
  color: rgba(245, 240, 225, .65);
}

.sheet-actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
}

/* ------------------------------------------------------------ wider pane */

@media (min-width: 430px) {
  .cell { height: 50px; font-size: 1.08rem; }
  .wordmark { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cell.hit,
  .wash.go,
  .banner.go,
  .pays-table tr.won td { animation: none; }
  .banner.go { opacity: 1; }
  * { transition-duration: .01ms !important; }
}
