:root {
  --felt: #1F7A40;
  --felt-2: #15602f;
  --line: #E6C24E;
  --gold: #e8b84a;
  --red: #d0211c;
  --black: #141414;
  --green: #1e8a36;
  --ink: #d7e2f2;
  --cyan: #45c6f0;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #05070d;
  color: var(--ink);
  user-select: none;
  /* The UI is a fixed 1280x576 canvas scaled uniformly to the viewport, so all
     type is authored in px and must NOT be re-inflated by an OS/WebView
     accessibility font scale ("large text"). Without this, Android/iOS text
     autosizing enlarges labels past their cells and the board/HUD distorts. */
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
/* Fixed-canvas stage: everything is authored at 1280x576 and uniformly
   scaled to the viewport (letterboxed), so the whole UI zooms as one image
   and keeps identical proportions on every phone/screen size. Because the
   stage is transformed, descendant position:fixed elements (.screen, .modal)
   resolve against the stage box, so they scale together automatically. */
#stage {
  position: fixed; left: 50%; top: 50%;
  width: 1280px; height: 576px;
  transform: translate(-50%, -50%) scale(var(--scale, 1));
  transform-origin: center center;
  overflow: hidden;
  background: linear-gradient(180deg, #0a1b2e, #0b2e1c 55%, #081224);
}
#app {
  height: 100%;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- HUD ---------- */
.hud {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 16px 6px; padding: 6px 14px;
  background: rgba(10,10,10,.80); border-radius: 999px;
  border: 1px solid rgba(58,66,80,.9);
}
.hud-item { display: flex; flex-direction: column; line-height: 1.1; }
.hud-item .lbl { display: none; }
.hud-item .val { font-size: 16px; font-weight: 900; color: #fff; }
.hud-item.status { margin-left: 8px; font-size: 13px; font-weight: 900; color: #bbd0ee; }
.stake-wrap {
  margin-left: auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.stake-wrap::before { content: 'TOTAL '; color: #e8d57a; font-size: 14px; font-weight: 900; }
.stake-wrap .val { color: #e8d57a; display: inline; }
.timer-wrap { margin-left: auto; }
.timer {
  display: inline-flex; align-items: center; justify-content: center; gap: 0;
  min-width: 72px; height: 30px; border-radius: 999px;
  background: transparent; color: #ffc85c; font-weight: 900; font-size: 24px;
  box-shadow: 0 0 12px rgba(231,193,76,.5);
}
.timer::before { content: '⏱ 0:'; font-size: 15px; margin-right: 3px; }
.add-btn {
  border: none; cursor: pointer;
  background: linear-gradient(180deg, #21c065, #149a4c);
  color: #fff; font-weight: 900; font-size: 14px; letter-spacing: .5px;
  height: 32px; padding: 0 14px; border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.add-btn:active { transform: translateY(1px); }

/* ---------- Service banner ---------- */
.banner {
  padding: 7px 14px; font-size: 13px; font-weight: 700; color: #fff;
  text-align: center; background: #14507a;
}
.banner[data-kind="kill"] { background: #7a1414; }
.banner[data-kind="maint"] { background: #7a5a14; }

/* ---------- Modal (Add Money) ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(0,0,0,.7);
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(420px, 92vw);
  background: #14181f; border: 1px solid rgba(231,193,76,.35);
  border-radius: 14px; padding: 18px 18px 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
}
.modal-title { margin: 0 0 4px; color: var(--gold); font-size: 18px; }
.modal-sub { margin: 0 0 12px; font-size: 12px; color: #9ca3af; }
.modal-input {
  width: 100%; padding: 10px 12px; font-size: 16px;
  border-radius: 8px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.06); color: var(--ink); margin-bottom: 10px;
}
.modal-presets { display: flex; gap: 8px; margin-bottom: 10px; }
.modal-presets .preset {
  flex: 1; padding: 8px 0; cursor: pointer;
  border: 1px solid rgba(231,193,76,.5); border-radius: 8px;
  background: transparent; color: var(--gold); font-weight: 700; font-size: 13px;
}
.modal-presets .preset:active { background: rgba(231,193,76,.15); }
.modal-msg { min-height: 18px; font-size: 12px; color: #b7e4ff; font-weight: 600; margin-bottom: 10px; }
.wallet-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.wallet-tabs .wtab {
  flex: 1; padding: 8px 0; cursor: pointer; font-size: 13px; font-weight: 700;
  border: 1px solid rgba(255,255,255,.18); border-radius: 8px;
  background: rgba(255,255,255,.04); color: #9ca3af;
}
.wallet-tabs .wtab.active { border-color: var(--gold); color: var(--gold); background: rgba(231,193,76,.12); }
.wallet-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; max-height: 160px; overflow-y: auto; }
.wallet-list .wl-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.05); font-size: 12px;
}
.wallet-list .wl-amt { font-weight: 700; color: var(--ink); }
.wallet-list .wl-st { font-weight: 700; font-size: 11px; }
.wallet-list .wl-st.pending { color: #f0c04c; }
.wallet-list .wl-st.approved { color: #6fb3ff; }
.wallet-list .wl-st.paid { color: #58d68d; }
.wallet-list .wl-st.rejected { color: #ff7a7a; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .act { flex: 1; }

/* ---------- Table ---------- */
.table-area {
  flex: 1; display: flex; gap: 12px; padding: 0 8px 4px; min-height: 0;
}
.wheel-pane {
  position: relative; flex: 0 0 38%; display: grid; place-items: center; min-width: 0;
}
#wheel { width: 100%; max-width: 360px; aspect-ratio: 1 / 1; }
.result-badge {
  position: absolute; top: 8px; right: 8px;
  min-width: 40px; height: 40px; padding: 0 8px;
  display: grid; place-items: center; border-radius: 10px;
  font-weight: 800; font-size: 20px; color: #fff;
  opacity: 0; transform: scale(.6); transition: .3s;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
}
.result-badge.show { opacity: 1; transform: scale(1); }
.result-badge[data-color="red"] { background: var(--red); }
.result-badge[data-color="black"] { background: var(--black); }
.result-badge[data-color="green"] { background: var(--green); }

.board-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* history */
.history { display: flex; gap: 4px; margin-bottom: 4px; flex-wrap: nowrap; overflow: hidden; }
.hist {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 4px;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff;
}
.hist[data-color="red"] { background: var(--red); }
.hist[data-color="black"] { background: var(--black); }
.hist[data-color="green"] { background: var(--green); }

/* ---------- Board ---------- */
#board { flex: 1; min-height: 0; position: relative; }
.felt {
  height: 100%;
  display: flex; flex-direction: column; gap: 5px;
  background:
    linear-gradient(180deg, #2c8a4d, #15602f) padding-box,
    linear-gradient(180deg, #7a4b1e, #3a2410) border-box;
  border: 7px solid transparent;
  border-radius: 16px;
  padding: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(255,227,106,.35),
    0 5px 18px rgba(0,0,0,.55);
}
.felt-top { display: flex; gap: 4px; flex: 3.6 1 0; min-height: 0; }
.numbers {
  flex: 1; min-width: 0;
  display: grid; grid-template-columns: repeat(12, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: 0; position: relative;
}
.columns { flex: 0 0 34px; display: grid; grid-template-rows: repeat(3, 1fr); gap: 3px; }
/* align under the 12-number area: left = columns(34)+gap(4), right = zero(42)+gap(4) */
.dozens { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 0 46px 0 38px; flex: 1 1 0; }
.outside { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: 0 46px 0 38px; flex: 1 1 0; }

.cell {
  position: relative;
  display: grid; place-items: center;
  border: 1px solid #E6C24E;
  border-radius: 0;
  color: #fff; font-weight: 900; font-size: 18px;
  cursor: pointer; padding: 4px; min-height: 0;
  font-family: inherit; text-align: center; line-height: 1.05;
  background: #1F7A40;
  overflow: hidden;
}
.numbers .cell, .columns .cell, .dozens .cell, .outside .cell {
  width: 100%;
  height: 100%;
}
.cell .lbl { position: relative; z-index: 2; }
.numbers .cell.red, .numbers .cell.black { background: #1F7A40 !important; border-color: #E6C24E; }
.numbers .cell.red .lbl, .numbers .cell.black .lbl {
  width: min(86%, 42px); aspect-ratio: 1 / 1; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.55);
  color: #fff; font-size: 18px; font-weight: 900;
}
.numbers .cell.red .lbl { background: #d0211c; }
.numbers .cell.black .lbl { background: #141414; }
.cell.green { background: #1F7A40; border-color: #E6C24E; }
.cell.outside { background: #1F7A40; color: #fff; border-color: #E6C24E; border-radius: 6px; font-size: 12px; }
.cell.outside .lbl { white-space: nowrap; }
.columns .cell.outside { border-radius: 0; font-size: 9px; padding: 0 2px; }
.columns .cell.outside .lbl {
  display: block;
  width: 100%;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  white-space: normal;
  text-shadow: 0 1px 2px rgba(0,0,0,.75);
}
.cell.zero { flex: 0 0 42px; font-size: 22px; border-radius: 50%; border: 2px solid #E6C24E; }
.cell:active { filter: brightness(1.25); }
.cell.diamond .lbl { display: none; }
.cell.diamond::after {
  content: ''; width: 26px; height: 26px; transform: rotate(45deg); border-radius: 2px;
  border: 1px solid rgba(255,255,255,.9);
}
.cell.diamond.red::after { background: var(--red); }
.cell.diamond.black::after { background: var(--black); }
.cell.diamond { background: #1F7A40; border-color: #E6C24E; }

/* Covered cell turns gold when a chip rides on this number (mirrors Android). */
.cell.selected {
  box-shadow: 0 0 0 2px #FFE36A, 0 0 10px rgba(255,210,74,.7);
  border: 2px solid #FFE36A; z-index: 4;
  background: #C79A2B;
  animation: selectedCellPop .22s ease-out, selectedCellGlow 1.1s ease-in-out infinite alternate;
}
.numbers .cell.selected.red, .numbers .cell.selected.black { background: #C79A2B !important; border-color: #FFE36A; }
.numbers .cell.selected .lbl { border-color: #FFE36A; }
.cell.zero.selected { background: #C79A2B; border-color: #FFE36A; }
.cell.selected::before {
  content: ''; position: absolute; inset: 0; border-radius: 4px;
  background: rgba(199,154,43,.18); pointer-events: none;
}
@keyframes selectedCellPop { from { transform: scale(.96); } to { transform: none; } }
@keyframes selectedCellGlow {
  from { box-shadow: 0 0 0 2px #ffe36a, 0 0 6px rgba(255,210,74,.45); }
  to { box-shadow: 0 0 0 2px #ffe36a, 0 0 15px rgba(255,210,74,.85); }
}

/* inner-bet hotspots */
.hotspots { position: absolute; inset: 0; pointer-events: none; }
.hot {
  position: absolute; width: 20px; height: 20px;
  transform: translate(-50%, -50%);
  border-radius: 6px; pointer-events: auto; cursor: pointer; z-index: 5;
}
.hot:hover { background: rgba(231,193,76,.55); box-shadow: 0 0 0 2px rgba(231,193,76,.7); }
.hot.corner { z-index: 6; border-radius: 50%; }

/* Touch devices (iPhone/iPad): no :hover, so give hotspots a faint always-on
   marker and a larger, finger-friendly tap target. */
@media (hover: none), (pointer: coarse) {
  .hot {
    background: rgba(231,193,76,.14);
    box-shadow: inset 0 0 0 1px rgba(231,193,76,.30);
  }
  .hot:active { background: rgba(231,193,76,.6); box-shadow: 0 0 0 2px rgba(231,193,76,.8); }
}

/* placed chips */
.placed-chip {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 8px; font-weight: 900; color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.6), inset 0 0 0 3px rgba(255,255,255,.18);
  z-index: 8; pointer-events: none;
}
.placed-chip, .chip { background-image: repeating-conic-gradient(rgba(255,255,255,.95) 0 10deg, transparent 10deg 30deg), radial-gradient(circle at center, var(--chip,#888) 0 58%, #fff 59% 64%, var(--chip,#888) 65%); }
.placed-chip[data-color="red"], .chip[data-color="red"]       { --chip: #c1272d; background-color: #c1272d; }
.placed-chip[data-color="green"], .chip[data-color="green"]   { --chip: #2e9e4f; background-color: #2e9e4f; }
.placed-chip[data-color="blue"], .chip[data-color="blue"]     { --chip: #1e78d6; background-color: #1e78d6; }
.placed-chip[data-color="orange"], .chip[data-color="orange"] { --chip: #e98a1f; background-color: #e98a1f; }
.placed-chip[data-color="purple"], .chip[data-color="purple"] { --chip: #8e3fb0; background-color: #8e3fb0; }

/* ---------- Controls ---------- */
.controls {
  display: grid; align-items: center; gap: 8px;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  padding: 4px 8px 6px; background: transparent;
  position: relative;
}
.chipbar {
  display: flex; gap: 8px; justify-content: center;
  justify-self: center; padding: 8px 14px;
  border-radius: 999px; background: rgba(8,12,18,.95);
  border: 1px solid #3a4250;
}
.chip {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid #fff;
  font-weight: 900; font-size: 12px; color: #fff !important; cursor: pointer;
  font-family: inherit; transition: transform .1s;
  text-shadow: 0 1px 2px rgba(0,0,0,.75);
}
.chip.sel { width: 50px; height: 50px; transform: translateY(-4px); box-shadow: 0 0 0 5px rgba(255,200,92,.95); }

.actions {
  position: static; z-index: 12;
  display: flex; gap: 8px; justify-self: end;
}
.act {
  padding: 8px 12px; border-radius: 8px; border: 1px solid rgba(231,193,76,.5);
  background: #14302350; color: var(--ink); font-weight: 900; font-size: 10px;
  cursor: pointer; font-family: inherit;
}
.act:active { filter: brightness(1.3); }
.act.spin { background: var(--gold); color: #222; border: none; padding: 8px 18px; }
#btnSpin { display: none; }
#btnSpin.ready { display: inline-flex; align-items: center; animation: spinReady 1.1s ease-in-out infinite; }
@keyframes spinReady {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231,193,76,.55); }
  50% { transform: scale(1.06); box-shadow: 0 0 14px 4px rgba(231,193,76,.65); }
}
#btnRebet { background: #2e7d32; border-color: #66bb6a; color: #fff; }
#btnDouble { background: #7b1fa2; border-color: #ba68c8; color: #fff; }
#btnUndo { background: #f9a825; border-color: #ffd54f; color: #1a1a1a; }
#btnClear { background: #d32f2f; border-color: #ef5350; color: #fff; }
.pl-pill, .auto-pill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(26,34,48,.80);
  border-radius: 999px; padding: 8px 12px;
  font-size: 10px; font-weight: 900; color: #9ca3af;
  white-space: nowrap;
}
.pl-pill b { color: #2ccb74; font-size: 12px; }
.pl-pill b[data-kind="win"] { color: #44e08a; }
.pl-pill b[data-kind="lose"] { color: #ff7676; }
.pl-pill b[data-kind="even"] { color: #cbd5e1; }
.auto-pill b { color: #9ca3af; font-size: 10px; }
.auto-pill span { font-size: 13px; }

/* ---------- Message toast ---------- */
.message {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.85); color: #fff; padding: 10px 18px; border-radius: 24px;
  font-weight: 700; opacity: 0; pointer-events: none; transition: .25s; z-index: 50;
}
.message.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.message[data-kind="win"] { background: #15803d; }
.message[data-kind="lose"] { background: #b91c1c; }

/* ---------- In-table chat panel ---------- */
.chat-panel {
  position: absolute; top: 64px; right: 12px; z-index: 95;
  width: 320px; max-height: 380px; display: flex; flex-direction: column;
  background: rgba(8,16,26,.96); border: 1px solid rgba(232,194,78,.45);
  border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5); overflow: hidden;
}
/* The class sets display:flex, which would otherwise beat the UA [hidden]{display:none}
   rule and leave the panel permanently on top of the board — eating split/corner
   clicks on the right-hand numbers. Keep the panel truly hidden until the 💬 toggle. */
.chat-panel[hidden] { display: none; }
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: rgba(232,194,78,.12);
  border-bottom: 1px solid rgba(232,194,78,.25);
}
.chat-title { font-weight: 800; color: var(--gold); font-size: 13px; letter-spacing: .3px; }
.chat-close {
  background: none; border: none; color: #cbd5e1; font-size: 15px; cursor: pointer;
  width: 26px; height: 26px; border-radius: 50%;
}
.chat-close:hover { background: rgba(255,255,255,.1); }
.chat-log {
  flex: 1; min-height: 120px; overflow-y: auto; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.chat-msg { display: flex; flex-direction: column; max-width: 92%; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-name { font-size: 10px; color: #9fb2c8; font-weight: 700; margin-bottom: 1px; }
.chat-badge {
  font-style: normal; font-size: 8px; font-weight: 800; letter-spacing: .4px;
  background: var(--gold); color: #1a1205; padding: 1px 5px; border-radius: 6px; margin-left: 3px;
}
.chat-msg.op .chat-text { background: rgba(232,194,78,.18); border: 1px solid rgba(232,194,78,.4); }
.chat-text {
  background: rgba(255,255,255,.08); color: #e6edf5; padding: 5px 9px;
  border-radius: 10px; font-size: 12.5px; line-height: 1.3; word-break: break-word;
}
.chat-msg.mine .chat-text { background: #15602f; }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid rgba(255,255,255,.08); }
.chat-input {
  flex: 1; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.15);
  color: #fff; border-radius: 18px; padding: 7px 12px; font-size: 13px; outline: none;
}
.chat-input:focus { border-color: var(--gold); }
.chat-send {
  background: var(--gold); color: #1a1205; border: none; border-radius: 18px;
  padding: 0 14px; font-weight: 800; cursor: pointer; font-size: 12px;
}
.chat-send:active { transform: translateY(1px); }

/* Friends panel (reuses .chat-panel base) */
.friends-panel { max-height: 440px; }
.friend-search { border-top: none; border-bottom: 1px solid rgba(255,255,255,.08); }
.friends-body { flex: 1; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 10px; }
.friends-group-title { font-size: 10px; font-weight: 800; letter-spacing: .5px; color: #9fb2c8; text-transform: uppercase; margin-bottom: 4px; }
.friends-list, #friendSearchResults { display: flex; flex-direction: column; gap: 4px; }
.friend-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); border-radius: 10px;
}
.friend-dot { width: 8px; height: 8px; border-radius: 50%; background: #5a6b7d; flex: none; }
.friend-dot.online { background: #38d16a; box-shadow: 0 0 6px #38d16a; }
.friend-name { flex: 1; font-size: 13px; color: #e6edf5; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-act { border: none; border-radius: 12px; padding: 4px 10px; font-size: 11px; font-weight: 800; cursor: pointer; }
.friend-act.dm { background: var(--gold); color: #1a1205; }
.friend-act.add { background: #15602f; color: #fff; }
.friend-act.rm { background: rgba(255,255,255,.12); color: #cbd5e1; }
.friends-empty { font-size: 12px; color: #9fb2c8; opacity: .8; padding: 6px 2px; }

/* ASK 7 — always-on desks (Support/Manager/Payments) + Table channel + Invite */
.chat-contacts {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,.08); align-items: center;
}
.chat-chan {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.15);
  color: #cbd5e1; border-radius: 14px; padding: 4px 10px; font-size: 11px;
  font-weight: 700; cursor: pointer; line-height: 1;
}
.chat-chan:hover { background: rgba(255,255,255,.12); }
.chat-chan.active { background: var(--gold); color: #1a1205; border-color: var(--gold); }
.cc-badge { margin-right: 4px; font-style: normal; }
.chat-invite {
  margin-left: auto; background: #15602f; border: 1px solid #1c7d3e; color: #eafff0;
  border-radius: 14px; padding: 4px 10px; font-size: 11px; font-weight: 800; cursor: pointer;
}
.chat-invite:hover { background: #1c7d3e; }
.chat-invite:active { transform: translateY(1px); }

/* ---------- Install banner (in normal flow, above the controls) ---------- */
.install-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 0 12px 6px;
  background: #1b2b22; border: 1px solid var(--gold); border-radius: 12px;
  padding: 8px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
.install-banner[hidden] { display: none; }
.install-banner .ib-text { flex: 1; font-size: 13px; }
.ib-action { background: var(--gold); color: #222; border: none; border-radius: 8px; padding: 8px 14px; font-weight: 800; cursor: pointer; }
.ib-close { background: transparent; color: var(--ink); border: none; font-size: 16px; cursor: pointer; }

/* ---------- Portrait ---------- */
@media (orientation: portrait) {
  .table-area { flex-direction: column; }
  .wheel-pane { flex: 0 0 auto; }
  #wheel { max-width: 220px; }
}

/* ---------- Short viewports (landscape phones, e.g. iPhone in landscape) ----------
   The full board (3 number rows + dozens + outside) plus HUD, history and controls
   must all fit with no vertical overflow/overlap. Compress chrome and shrink the
   felt so every band keeps its own row. */
/* Responsive media hacks removed: the #stage fixed-canvas (1280x576) is now
   the single source of layout and scales uniformly to every viewport, so
   per-viewport compression is no longer needed (and would distort the stage). */

/* ===================================================================== */
/* ====================  Boot flow + parity screens  =================== */
/* ===================================================================== */

.screen { position: fixed; inset: 0; }
.screen[hidden] { display: none; }

#app { position: relative; }
#app[hidden] { display: none; }

/* keep timer/leave on the HUD */
.leave-btn {
  margin-left: 0; background: transparent; border: 2px solid #ffc85c;
  color: var(--gold); border-radius: 8px; font-size: 13px; font-weight: 800;
  width: 34px; height: 34px; cursor: pointer;
}
.leave-exit { display: none; }
.leave-btn:active { filter: brightness(1.3); }
.timer.urgent { background: var(--red); color: #fff; animation: pulse .6s infinite alternate; }
@keyframes pulse { from { box-shadow: 0 0 6px rgba(212,38,47,.6); } to { box-shadow: 0 0 20px rgba(212,38,47,1); transform: scale(1.08); } }

/* ---------- Fullscreen video helper ---------- */
.fullscreen-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000;
}
.video-screen { background: #000; }
.skip-btn {
  position: absolute; right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom));
  background: rgba(0,0,0,.55); color: #fff; border: 1px solid rgba(255,255,255,.4);
  border-radius: 999px; padding: 8px 18px; font-weight: 700; font-size: 14px; cursor: pointer; z-index: 2;
}

/* ---------- Auth gate ---------- */
.auth-screen {
  display: grid; place-items: center; z-index: 100;
  background: linear-gradient(180deg, #0a0f1e, #15213b);
  padding: env(safe-area-inset-top) 18px env(safe-area-inset-bottom);
}
.auth-card {
  width: min(420px, 94vw); text-align: center;
  background: transparent; border: 0;
  border-radius: 18px; padding: 26px 22px 22px; box-shadow: 0 16px 50px rgba(0,0,0,.6);
}
.auth-brand { font-size: 34px; font-weight: 900; letter-spacing: 4px; color: var(--gold); }
.auth-tagline { font-size: 15px; color: #b9c4da; opacity: 1; margin-bottom: 18px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tab {
  flex: 1; padding: 9px 0; cursor: pointer; font-weight: 700; font-size: 13px;
  border-radius: 8px; border: 1px solid rgba(231,193,76,.4);
  background: transparent; color: var(--ink); font-family: inherit;
}
.auth-tab.active { background: var(--gold); color: #222; border-color: var(--gold); }
.auth-input {
  width: 100%; padding: 12px 14px; font-size: 16px; margin-bottom: 10px;
  border-radius: 10px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.06); color: var(--ink); font-family: inherit;
}
.auth-msg { min-height: 18px; font-size: 12.5px; font-weight: 600; color: #ffd6d6; margin-bottom: 8px; }
.auth-btn {
  width: 100%; height: 52px; padding: 0; cursor: pointer; font-weight: 900; font-size: 16px;
  border: none; border-radius: 14px; color: #1a1a1a; font-family: inherit;
  background: #f2c14e; box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.auth-btn:active { transform: translateY(1px); }
.auth-btn:disabled { opacity: .6; }
.auth-hint { font-size: 11px; opacity: .65; margin-top: 12px; }
.auth-link { background: none; border: none; color: var(--gold); font-size: 13px; cursor: pointer; margin-top: 14px; font-family: inherit; text-decoration: underline; }

/* PIN */
.pin-who { font-size: 15px; margin-bottom: 14px; }
.pin-who span { color: var(--gold); font-weight: 700; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin-bottom: 10px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(231,193,76,.7); }
.pin-dots i.on { background: var(--gold); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px auto 4px; max-width: 280px; }
.pin-key {
  height: 56px; border-radius: 12px; font-size: 22px; font-weight: 700; cursor: pointer;
  border: 1px solid rgba(231,193,76,.35); background: rgba(255,255,255,.05); color: var(--ink); font-family: inherit;
}
.pin-key:active { background: rgba(231,193,76,.25); }
.pin-key.pin-bio { color: var(--gold); font-size: 26px; }

/* ---------- Lobby ---------- */
.lobby-screen { background: #000; z-index: 90; }
.lobby-bg { filter: brightness(1.12) saturate(1.12); }
.lobby-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: env(safe-area-inset-top) 18px env(safe-area-inset-bottom);
  background: linear-gradient(90deg, rgba(5,8,18,.18), rgba(255,95,90,.30) 88%, rgba(255,120,108,.45));
}
.lobby-brand { font-size: 34px; font-weight: 900; letter-spacing: 5px; color: var(--gold); text-shadow: 0 4px 24px rgba(0,0,0,.7); }
.lobby-royale { font-size: 15px; font-weight: 800; letter-spacing: 10px; color: #ffe68d; opacity: .95; margin: 8px 0 34px; padding-left: 10px; }
.lobby-sub { font-size: 14px; opacity: .9; margin: 6px 0 34px; letter-spacing: 1px; }
.play-now {
  width: 360px; height: 82px; padding: 0; font-size: 28px; font-weight: 900; letter-spacing: 1px; cursor: pointer;
  border: none; border-radius: 999px; color: #fff; font-family: inherit;
  background: linear-gradient(180deg, #36b252, #2e9e47);
  box-shadow: 0 8px 30px rgba(46,158,71,.5); animation: glow 1.6s infinite alternate;
}
@keyframes glow { from { box-shadow: 0 8px 24px rgba(46,158,71,.35); } to { box-shadow: 0 8px 40px rgba(46,158,71,.7); } }
.play-now:active { transform: translateY(2px); }

/* Lobby top bar (parity with Android balance pill + Friends/Support) */
.lobby-topbar { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; align-items: flex-start; gap: 10px; padding: 0 14px; }
.lobby-topspacer { flex: 1; }
.lobby-balance { background: rgba(14,32,56,.92); border-radius: 16px; padding: 18px 32px 18px 22px; display: flex; flex-direction: column; line-height: 1.1; }
.lobby-balance .lbl { font-size: 12px; font-weight: 900; color: #9cb3d0; letter-spacing: 1px; }
.lobby-balance .val { font-size: 30px; font-weight: 900; color: #ffd35f; }
.lobby-icon { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
  background: rgba(20,30,48,.7); border: none; border-radius: 12px; padding: 8px 10px; color: var(--ink); font-family: inherit; }
.lobby-icon .li-glyph { font-size: 20px; line-height: 1; }
.lobby-icon .li-label { font-size: 10px; opacity: .9; }
.lobby-foot { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.lobby-who { font-size: 12px; opacity: .8; }

/* Lobby bottom rail (parity with Android RailAction row) — kept in normal flow
   so it always sits BELOW Play Now, even on short (landscape) viewports where an
   absolutely-bottom-pinned rail would overlap the vertically-centred button. */
.lobby-rail { margin-top: 20px; display: flex; gap: 22px; justify-content: center; }
.rail-action {
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
  background: transparent; border: none; color: var(--ink); font-family: inherit; padding: 4px 8px;
}
.rail-glyph { font-size: 26px; line-height: 1; }
.rail-label { font-size: 11px; font-weight: 600; opacity: .92; }
.rail-action:active { transform: translateY(1px); }

/* How to Play sheet */
.howto-card { width: min(560px, 94vw); }
.howto-body { max-height: 60vh; overflow-y: auto; margin: 4px 0 12px; -webkit-overflow-scrolling: touch; }
.howto-h { margin: 10px 0 2px; color: var(--gold); font-size: 14px; font-weight: 900; }
.howto-p { margin: 0; font-size: 13px; line-height: 1.46; color: #d7e2f2; }

/* ---------- Rotate-to-landscape gate ---------- */
.rotate-gate {
  display: none; position: fixed; inset: 0; z-index: 9999;
  flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 18px; padding: 24px;
  background: linear-gradient(180deg, #0a0f1e, #15213b); color: #fff;
}
.rotate-title { font-size: 22px; font-weight: 900; color: var(--gold); letter-spacing: .5px; }
.rotate-sub { font-size: 14px; line-height: 1.5; color: #b9c4da; }
.rotate-anim { width: 96px; height: 96px; display: grid; place-items: center; }
.rotate-phone {
  width: 46px; height: 78px; border: 3px solid var(--gold); border-radius: 12px;
  position: relative; background: rgba(231,193,76,.08);
  animation: rotateHint 2.2s ease-in-out infinite;
}
.rotate-phone::before { /* speaker notch */
  content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 14px; height: 3px; border-radius: 2px; background: var(--gold);
}
.rotate-phone::after { /* home indicator */
  content: ""; position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  width: 16px; height: 3px; border-radius: 2px; background: rgba(231,193,76,.7);
}
@keyframes rotateHint {
  0%, 30% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(-90deg); }
}
/* Phones in portrait (incl. Chrome/Safari on iPhone): force landscape. */
@media screen and (orientation: portrait) and (max-width: 900px) {
  .rotate-gate { display: flex; }
}

/* ---------- NO MORE BETS banner ---------- */
.no-more-bets {
  position: absolute; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(0,0,0,.45); pointer-events: none;
  animation: fadeIn .18s ease both;
}
.no-more-bets[hidden] { display: none; }
.nmb-inner {
  font-size: 34px; font-weight: 900; letter-spacing: 2px; color: #ffe36a;
  padding: 22px 44px; border: 2px solid #ff5252; border-radius: 16px;
  background: rgba(26,14,14,.95); text-shadow: 0 3px 16px rgba(0,0,0,.8);
  animation: nmbpop .35s ease-out;
}
@keyframes nmbpop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Pre-bet table standings (mirrors Android PreBetStandingsOverlay) ---------- */
.prebet-overlay {
  position: absolute; inset: 0; z-index: 58; display: grid; place-items: center;
  background: rgba(5,7,13,.80); pointer-events: none; padding: 16px;
}
.prebet-overlay[hidden] { display: none; }
.prebet-card {
  width: min(360px, 90%); background: rgba(13,26,46,.95); border: 2px solid var(--gold);
  border-radius: 16px; padding: 16px 22px; animation: nmbpop .3s ease-out;
}
.prebet-title { color: var(--gold); font-weight: 900; font-size: 16px; text-align: center; letter-spacing: 1px; }
.prebet-rows { margin: 10px 0 14px; }
.prebet-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.pb-rank { color: #9ca3af; font-weight: 700; font-size: 13px; min-width: 14px; }
.pb-dot { width: 18px; height: 18px; border-radius: 50%; flex: 0 0 auto; }
.pb-name { flex: 1; color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prebet-row.me .pb-name { color: var(--gold); font-weight: 900; }
.pb-chips { color: #bbd7ff; font-size: 13px; }
.prebet-cta { color: #fff; font-weight: 600; font-size: 14px; text-align: center; }

/* ---------- Refer & Earn + My Account modals (parity with Android dialogs) ---------- */
.refer-code-box { background: #0c1a30; border-radius: 12px; padding: 14px; margin: 10px 0; }
.refer-code-lbl { color: #8fa6c4; font-size: 10px; font-weight: 700; letter-spacing: .5px; }
.refer-code-val { color: #fff; font-size: 22px; font-weight: 900; margin-top: 4px; word-break: break-all; }
.refer-stats { display: flex; gap: 10px; margin: 10px 0; }
.refer-stat { flex: 1; background: #0c1a30; border-radius: 12px; padding: 14px; display: flex; flex-direction: column; align-items: center; }
.refer-stat-val { color: var(--gold); font-size: 20px; font-weight: 900; }
.refer-stat-lbl { color: #8fa6c4; font-size: 10px; font-weight: 700; margin-top: 2px; }
.refer-link { background: #0c1a30; border-radius: 8px; padding: 10px; color: #b9cbe6; font-size: 11px; word-break: break-all; }
.account-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.account-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--gold); color: #12233f; display: grid; place-items: center; font-size: 22px; font-weight: 900; }
.account-user { color: #fff; font-size: 18px; font-weight: 900; }
.account-signed { color: #4ade80; font-size: 11px; font-weight: 700; }
.account-rows { display: flex; flex-direction: column; gap: 8px; }
.account-row { display: flex; align-items: center; background: #0c1a30; border-radius: 10px; padding: 12px 14px; }
.account-row-lbl { flex: 1; color: #8fa6c4; font-size: 12px; font-weight: 700; }
.account-row-val { color: #fff; font-size: 14px; font-weight: 900; }
.act.account-logout { background: #b71c1c; color: #fff; }

/* ---------- Cinematic spin overlay ---------- */
.cinematic { position: fixed; inset: 0; z-index: 70; background: #000; }
.cinematic[hidden] { display: none; }
.win-screen {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.86) 0%, rgba(0,0,0,.64) 62%, rgba(0,0,0,.5) 100%);
}
.win-screen[hidden] { display: none; }
.win-label { font-size: clamp(15px, 3.4vw, 19px); font-weight: 900; letter-spacing: 3px; color: var(--gold); margin-bottom: clamp(14px, 3vw, 22px); text-shadow: 0 2px 12px rgba(0,0,0,.95), 0 0 18px rgba(231,193,76,.55); }
.win-badge {
  position: relative;
  width: clamp(120px, 26vw, 168px); height: clamp(120px, 26vw, 168px); border-radius: 50%;
  display: grid; place-items: center; font-size: clamp(54px, 12vw, 78px); font-weight: 900; color: #fff;
  border: 5px solid rgba(255,255,255,1);
  box-shadow: 0 0 0 6px rgba(231,193,76,.55), 0 0 70px rgba(231,193,76,.95), 0 8px 30px rgba(0,0,0,.8), inset 0 0 26px rgba(0,0,0,.55);
  text-shadow: 0 3px 10px rgba(0,0,0,.95);
  animation: winpop .5s ease-out;
}
/* Pulsing gold ring to draw the eye to the winning number over the video frame. */
.win-badge::after {
  content: ""; position: absolute; inset: -14px; border-radius: 50%;
  border: 3px solid rgba(231,193,76,.85); pointer-events: none;
  animation: winring 1.4s ease-out infinite;
}
@keyframes winpop { from { transform: scale(.4) rotate(-12deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes winring { 0% { transform: scale(1); opacity: .9; } 70% { transform: scale(1.35); opacity: 0; } 100% { transform: scale(1.35); opacity: 0; } }
.win-badge[data-color="red"] { background: var(--red); }
.win-badge[data-color="black"] { background: var(--black); }
.win-badge[data-color="green"] { background: var(--green); }
.win-delta { margin-top: 18px; font-size: clamp(22px, 6vw, 36px); font-weight: 900; text-shadow: 0 3px 12px rgba(0,0,0,.9); }
.win-delta[data-kind="win"] { color: #44e08a; }
.win-delta[data-kind="lose"] { color: #ff7676; }
.win-delta[data-kind="even"] { color: #ffe36a; }
.win-calc { margin-top: 12px; font-size: clamp(13px, 3.6vw, 17px); font-weight: 700; color: #f2edd8; letter-spacing: 0.3px; text-shadow: 0 2px 9px rgba(0,0,0,.92); background: rgba(0,0,0,.34); padding: 6px 14px; border-radius: 999px; }
.win-calc[data-kind="win"] { color: #9be9bf; }
.win-calc[data-kind="lose"] { color: #ffc0c0; }
.win-calc[data-kind="even"] { color: #f0e6b8; }

/* ---------- Result table reveal (live table dwell) ---------- */
.result-reveal {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 40;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none; width: max-content; max-width: 92%;
}
.result-reveal[hidden] { display: none; }
.rr-card {
  text-align: center; background: rgba(18,24,36,.96); border: 2px solid #e7c14c;
  border-radius: 16px; padding: 10px 22px;
  box-shadow: 0 10px 30px rgba(0,0,0,.55), 0 0 22px rgba(231,193,76,.35);
  animation: winpop .45s ease-out;
}
.rr-wlabel { font-size: 11px; letter-spacing: 3px; font-weight: 800; color: #e7c14c; opacity: .9; }
.rr-wnum {
  font-size: clamp(34px, 9vw, 52px); font-weight: 900; line-height: 1.05; margin: 2px 0 4px;
  color: #fff; width: 1.6em; height: 1.6em; margin-inline: auto;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.9); box-shadow: inset 0 0 16px rgba(0,0,0,.5);
}
.rr-wnum[data-color="red"] { background: var(--red); }
.rr-wnum[data-color="black"] { background: var(--black); }
.rr-wnum[data-color="green"] { background: var(--green); }
.rr-delta { font-size: 18px; font-weight: 900; margin-top: 4px; }
.rr-delta[data-kind="win"] { color: #44e08a; }
.rr-delta[data-kind="lose"] { color: #ff7676; }
.rr-delta[data-kind="even"] { color: #ffe36a; }
.rr-opponents {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px;
  background: rgba(18,24,36,.9); border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px; padding: 7px 12px; animation: nmbpop .3s ease-out;
}
.rr-opponents[hidden] { display: none; }
.rr-opp { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.rr-opp-dot {
  width: 20px; height: 20px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: #fff;
}
.rr-opp-name { color: #d7def0; }
.rr-opp-pl { font-weight: 900; }
.rr-opp.win .rr-opp-pl { color: #44e08a; }
.rr-opp.lose .rr-opp-pl { color: #ff7676; }

@media (max-width: 640px) {
  .pin-pad { gap: 8px; max-width: 240px; }
  .pin-key { height: 48px; font-size: 19px; }
}

/* =====================================================================
   Motion & transitions — crossfades between boot screens, button/cell
   feedback, chip & history reveals. Mirrors the Android client's animated
   phase changes so the web version doesn't feel like a hard slideshow.
   ===================================================================== */

/* --- Boot-screen crossfade (auth / intro / lobby / game) --- */
.screen, #app { will-change: opacity; }
.screen:not([hidden]):not(.leaving),
#app:not([hidden]):not(.leaving) { animation: screenIn .45s ease both; }
.screen.leaving, #app.leaving {
  animation: screenOut .42s ease both; pointer-events: none;
}
@keyframes screenIn  { from { opacity: 0; transform: scale(1.015); } to { opacity: 1; transform: none; } }
@keyframes screenOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(.992); } }

/* The game HUD/board children stagger in for a livelier table entrance. */
#app:not([hidden]):not(.leaving) .hud { animation: slideDown .5s ease both; }
#app:not([hidden]):not(.leaving) .table-area { animation: riseIn .55s ease both .06s; }
#app:not([hidden]):not(.leaving) .controls { animation: riseIn .55s ease both .12s; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes riseIn    { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* --- Lobby / auth card entrance --- */
.auth-card, .lobby-overlay { animation: popCard .5s cubic-bezier(.2,.8,.25,1) both; }
@keyframes popCard { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }

/* --- Cinematic overlay fades in over the table --- */
.cinematic:not([hidden]) { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- Number cells: smooth hover lift + press, hotspot feedback --- */
.cell { transition: filter .12s ease, transform .12s ease, box-shadow .15s ease; }
@media (hover: hover) {
  .cell:hover { filter: brightness(1.18); transform: translateY(-1px); z-index: 3;
    box-shadow: 0 4px 12px rgba(0,0,0,.45); }
}
.cell:active { transform: scale(.96); }
.hot { transition: background .15s ease, box-shadow .15s ease, transform .1s ease; }
.hot:active { transform: translate(-50%, -50%) scale(.85); }

/* --- Chip placement pop (placed chips drop onto the felt) --- */
.placed-chip { animation: chipDrop .28s cubic-bezier(.2,.9,.3,1.3) both; }
@keyframes chipDrop { from { transform: translate(-50%, -120%) scale(.4); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

/* --- History badges slide in as new results land --- */
.hist { animation: histIn .35s ease both; }
@keyframes histIn { from { opacity: 0; transform: translateX(-10px) scale(.8); } to { opacity: 1; transform: none; } }

/* --- Chip-rail selection & control buttons --- */
@media (hover: hover) { .chip:hover { transform: translateY(-3px); } }
.act { transition: transform .1s ease, filter .12s ease, background .15s ease; }
@media (hover: hover) { .act:hover { filter: brightness(1.15); } }
.act:active { transform: scale(.95); }

/* --- Modals fade/scale in --- */
.modal:not([hidden]) { animation: fadeIn .2s ease both; }
.modal:not([hidden]) .modal-card { animation: popCard .28s cubic-bezier(.2,.8,.25,1) both; }

/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; }
}

/* ====================================================================
   Multiplayer lobby — running-tables browser (PLAY NOW target)
   Mirrors the Android TournamentScreen: tier sections of live room cards.
   ==================================================================== */
.tables-screen {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 0 calc(env(safe-area-inset-bottom) + 0px);
  background: #09182e;
  color: var(--ink); overflow: hidden;
}
.tables-top {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; flex-wrap: nowrap;
  background: #0a1b33;
}
.tables-title { font-size: 16px; font-weight: 900; letter-spacing: .8px; color: #45c6f0; }
.tables-bal { display: flex; flex-direction: column; line-height: 1.1; margin-left: 4px; }
.tables-bal .lbl { font-size: 9px; opacity: .65; letter-spacing: .5px; }
.tables-bal .val { font-size: 15px; font-weight: 700; color: var(--gold); }
.tables-spacer { flex: 1 1 auto; }

.tables-search {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: #06122a;
}
.tsearch-in {
  flex: 1 1 0; min-width: 0; height: 48px; padding: 10px 16px; border-radius: 4px;
  border: 2px solid rgba(255,255,255,.55); background: #07122a;
  color: #fff; font-size: 13px;
}
.tables-searchmsg {
  margin: 6px 4px 0; padding: 7px 11px; border-radius: 9px;
  background: rgba(231,193,76,.14); border: 1px solid rgba(231,193,76,.35);
  font-size: 13px; color: var(--gold);
}
.tables-tabs {
  display: flex; gap: 8px; padding: 8px 12px 4px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; background: #06122a;
}
.tier-tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid rgba(255,255,255,.14);
  background: #0e2140; color: #cfe0f5; font-size: 13px; font-weight: 800;
  letter-spacing: .3px; white-space: nowrap; transition: background .15s, border-color .15s;
}
.tier-tab:hover { border-color: rgba(69,198,240,.5); }
.tier-tab.is-active {
  background: linear-gradient(180deg, #f4d15b, #e0b53f);
  border-color: #f4d15b; color: #0a1b33;
}
.tier-tab-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 18px;
  padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 900;
  background: rgba(0,0,0,.22); color: inherit;
}
.tier-tab.is-active .tier-tab-count { background: rgba(10,27,51,.18); }
.tables-list { flex: 1 1 auto; overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
.tables-loading { padding: 40px 12px; text-align: center; opacity: .7; font-size: 14px; }
.tables-loading.err { color: #ff9a8a; }

.tier { margin-bottom: 18px; }
.tier-head { display: flex; align-items: baseline; gap: 10px; padding: 0 4px 8px; flex-wrap: wrap; }
.tier-name { font-size: 15px; font-weight: 900; color: var(--gold); }
.tier-meta { font-size: 11px; color: #9cb3d0; opacity: 1; }
.tier-rooms {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px; padding: 2px 0 10px;
}
.room-card {
  flex: 0 0 auto; width: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px; border-radius: 12px;
  background: #13294a;
  border: 0;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
  animation: popCard .4s cubic-bezier(.2,.8,.25,1) both;
}
.room-card.is-full { opacity: .62; }
.room-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.room-name { font-size: 13px; font-weight: 800; color: #fff; }
.room-seats { font-size: 12px; font-weight: 900; color: #45c6f0; white-space: nowrap; }
.room-avatars { display: flex; gap: -6px; min-height: 24px; }
.adot {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; margin-right: -6px; border-radius: 50%;
  font-size: 11px; font-weight: 700; color: #fff;
  border: 2px solid rgba(8,19,29,.9);
}
.room-reward { font-size: 11px; font-weight: 800; color: #2ccb74; }
.room-bets { font-size: 10px; color: #9cb3d0; opacity: 1; }
.room-actions { display: flex; gap: 8px; margin-top: 2px; }
.room-join { flex: 1 1 auto; }

/* Lobby buttons (shared) */
.tbtn {
  appearance: none; border: 0; cursor: pointer;
  padding: 8px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 900; letter-spacing: .2px; color: #07121b;
  transition: transform .1s ease, filter .12s ease;
}
.tbtn-green { background: linear-gradient(180deg, #2fd06f, #119b48); color: #04210f; }
.tbtn-grey  { background: rgba(255,255,255,.16); color: var(--ink); }
.tbtn-gold  { background: linear-gradient(180deg, #f3d063, #d4a72b); }
.tbtn-blue  { background: linear-gradient(180deg, #4aa6f0, #2a72c4); color: #03162a; flex: 0 0 auto; padding: 9px 12px; }
.tbtn:disabled { cursor: default; filter: grayscale(.5) brightness(.85); }
@media (hover: hover) { .tbtn:not(:disabled):hover { filter: brightness(1.1); } }
.tbtn:not(:disabled):active { transform: scale(.95); }

/* Joined-dialog avatar row */
.joined-players { display: flex; gap: 0; margin: 4px 0 8px; min-height: 26px; }
.joined-players .adot { width: 26px; height: 26px; }

.tables-screen:not([hidden]):not(.leaving) .tables-top { animation: slideDown .45s ease both; }
.tables-screen:not([hidden]):not(.leaving) .tables-search { animation: slideDown .5s ease both .05s; }


/* ===== Platform gate (Android install wall / iOS add-to-home) ===== */
body.gate-locked { overflow: hidden; }
.platform-gate {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 18%, #14573f, #05241a 80%);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.platform-gate .pg-card {
  width: min(440px, 92vw);
  text-align: center;
  background: rgba(7, 36, 26, 0.86);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px 24px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}
.pg-brand { font-weight: 800; letter-spacing: 4px; color: var(--gold); font-size: 26px; }
.pg-tag { color: var(--ink); opacity: 0.7; font-size: 13px; margin-bottom: 14px; }
.pg-icon { font-size: 52px; margin: 8px 0; }
.pg-title { font-size: 20px; font-weight: 700; color: var(--ink); margin: 6px 0 8px; }
.pg-text { font-size: 14px; line-height: 1.5; color: var(--ink); opacity: 0.9; margin-bottom: 18px; }
.pg-text b { color: var(--gold); }
.pg-share { display: inline-block; transform: translateY(2px); }
.pg-btn {
  display: inline-block; cursor: pointer;
  background: linear-gradient(180deg, var(--gold), #c79a2e);
  color: #2a1d00; font-weight: 800; font-size: 16px;
  border: none; border-radius: 12px;
  padding: 14px 22px; text-decoration: none;
  box-shadow: 0 8px 22px rgba(231, 193, 76, 0.35);
}
.pg-btn:active { transform: translateY(1px); }
/* Stack the Android choice buttons with spacing; the web option is secondary. */
#androidGate .pg-btn { display: block; width: 100%; margin: 8px 0 0; box-sizing: border-box; }
.pg-btn-web {
  background: transparent; color: var(--gold);
  border: 1.5px solid var(--gold); box-shadow: none;
}
.pg-note { font-size: 12px; color: var(--ink); opacity: 0.65; margin-top: 14px; line-height: 1.45; }
.pg-note b { color: var(--gold); }

/* ===== Rotate-to-landscape overlay (mobile) ===== */
.rotate-overlay {
  position: fixed; inset: 0; z-index: 9500;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, #0c4a35, #04201730 80%), #04130d;
  text-align: center; padding: 24px;
}
.rotate-overlay[hidden] { display: none; }
.rotate-overlay .ro-phone { font-size: 64px; animation: roSpin 1.8s ease-in-out infinite; }
.rotate-overlay .ro-title { font-size: 20px; font-weight: 700; color: var(--gold); margin: 12px 0 6px; }
.rotate-overlay .ro-text { font-size: 14px; color: var(--ink); opacity: 0.9; max-width: 320px; }
@keyframes roSpin {
  0%, 40% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(-90deg); }
}
