/* Layout concept: one green-baize table shared by everyone. Wheel and round clock on the left,
   betting board and chips in the middle, players in a side column. Stacked on phones. */
:root {
  --felt: #0d3b2d;
  --felt-deep: #082a20;
  --felt-line: #2c6a56;
  --ink: #f0ebd8;
  --muted: #9fb5a9;
  --red: #b3261e;
  --black: #14181a;
  --zero: #1b7a4d;
  --gold: #d8a640;
  --gold-ink: #2b1f05;
  --good: #8de0a4;
  --danger: #ff9a8f;
  --wood: #2a1c10;
  --track: #0b1f18;
  --chip-100: #e9e6da;
  --chip-1k: #2f6db5;
  --chip-10k: #7a4fb0;
  --chip-50k: #d8a640;
  --f-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--felt-deep); }
body {
  margin: 0;
  background: var(--felt-deep);
  color: var(--ink);
  font: 15px/1.45 var(--f-body);
  padding-block: 20px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.wrap { max-width: 1080px; margin: 0 auto; }

/* Header */
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 16px; }
h1 { font: 700 clamp(30px, 6vw, 44px)/1 var(--f-display); letter-spacing: .04em; text-transform: uppercase; margin: 0; text-wrap: balance; }
.sub { color: var(--muted); margin: 6px 0 0; font-size: 13px; }
.me { display: flex; align-items: center; justify-content: flex-end; gap: 4px 20px; flex-wrap: wrap; min-width: 0; }
.who { min-width: 0; text-align: right; }
.who .name { font-weight: 600; overflow-wrap: anywhere; }
.bal { text-align: right; }
.bal .label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.bal .amt { font: 700 clamp(28px, 6vw, 38px)/1 var(--f-display); font-variant-numeric: tabular-nums; color: var(--gold); }
.bal .staked { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1.2em; }

/* Panels */
.panel { background: var(--felt); border: 1px solid var(--felt-line); border-radius: 10px; padding: 16px; min-width: 0; margin-bottom: 16px; }
.panel h2 { font: 600 13px var(--f-body); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.note { margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--gold); border-radius: 8px; color: var(--ink); background: var(--felt); font-size: 14px; }
.conn { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); margin: 0; padding: 8px 14px; border-radius: 999px; background: var(--gold); color: var(--gold-ink); font-weight: 600; font-size: 13px; z-index: 20; }

/* Wheel, board, players. Stacked on phones; wheel and players share a left column from 900px;
   players move to their own right-hand column from 1200px. */
.layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "wheel" "board" "seats"; margin-bottom: 16px; }
.layout > .panel { margin-bottom: 0; }
.wheel-panel { grid-area: wheel; }
.board-panel { grid-area: board; }
.seats-panel { grid-area: seats; }
@media (min-width: 900px) { .layout { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); grid-template-areas: "wheel board" "seats board"; align-items: start; } }
@media (min-width: 1200px) {
  .wrap { max-width: 1320px; }
  .layout { grid-template-columns: minmax(0, 320px) minmax(0, 1fr) minmax(0, 250px); grid-template-areas: "wheel board seats"; }
}

/* Buttons and inputs */
.btn { font: 600 14px var(--f-body); padding: 10px 14px; border-radius: 8px; border: 1px solid var(--felt-line); background: var(--felt-deep); color: var(--ink); cursor: pointer; min-height: 44px; }
.btn:hover:not(:disabled) { border-color: var(--gold); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.btn.link { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 4px 6px; min-height: 0; font-size: 13px; }
input[type=text], input[type=password] { font: 500 16px var(--f-body); padding: 10px 12px; border-radius: 8px; border: 1px solid var(--felt-line); background: var(--felt-deep); color: var(--ink); min-height: 44px; min-width: 0; width: 100%; max-width: 320px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Join and account */
.join form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.join .field { flex: 1 1 220px; min-width: 0; }
.join .field.small { flex: 0 1 200px; }
.join p { margin: 0 0 14px; max-width: 64ch; }
.join p.hintline { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.err { color: var(--danger); margin: 8px 0 0; min-height: 1.2em; font-size: 13px; }
.acct-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: 8px; }
.small-note { margin: 8px 0 0; font-size: 12px; color: var(--muted); max-width: 52ch; }

/* Round clock */
.wheel-panel { display: grid; gap: 14px; justify-items: center; }
.clock { display: grid; gap: 8px; align-self: stretch; }
.phase { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.phase .lbl { font-weight: 600; }
.phase .cd { display: flex; align-items: baseline; gap: 6px; }
.phase .cd small { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.phase .t { font: 700 30px/1 var(--f-display); color: var(--gold); font-variant-numeric: tabular-nums; min-width: 2.2ch; text-align: right; }
.bar { height: 6px; border-radius: 3px; background: var(--felt-deep); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--gold); }
.bar.closed i { background: var(--danger); }

/* Wheel */
#wheel { width: 100%; max-width: 320px; height: auto; aspect-ratio: 1; display: block; }
.last { display: flex; align-items: center; gap: 12px; align-self: stretch; justify-content: center; }
.last .label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0; }
.ball-num { font: 700 30px/1 var(--f-display); width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--gold); background: var(--felt-deep); font-variant-numeric: tabular-nums; }
.ball-num.red, .pill.red { background: var(--red); }
.ball-num.black, .pill.black { background: var(--black); }
.ball-num.green, .pill.green { background: var(--zero); }
.history { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; min-height: 24px; }
.pill { font: 600 13px/1 var(--f-display); min-width: 26px; padding: 6px 4px; text-align: center; border-radius: 4px; font-variant-numeric: tabular-nums; }

/* Betting board */
.board-scroll { overflow-x: auto; padding-bottom: 4px; }
.board { display: grid; grid-template-columns: 1.2fr repeat(12, 1fr) 1.2fr; gap: 2px; background: var(--felt-line); padding: 2px; border-radius: 6px; min-width: 520px; }
.slot { position: relative; min-width: 0; display: grid; }
.cell { border: 0; margin: 0; padding: 0; width: 100%; height: 100%; display: grid; place-items: center; background: var(--felt-deep); color: var(--ink); font: 600 clamp(12px, 2.4vw, 17px)/1 var(--f-display); letter-spacing: .02em; min-height: clamp(34px, 6.5vw, 46px); cursor: pointer; border-radius: 2px; min-width: 0; }
.cell.red { background: var(--red); }
.cell.black { background: var(--black); }
.cell.green { background: var(--zero); }
.cell:hover:not(:disabled) { filter: brightness(1.3); }
.cell:disabled { cursor: not-allowed; }
.cell:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; z-index: 2; }
.stake { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--gold); color: var(--gold-ink); font: 700 11px/1.2 var(--f-body); padding: 2px 5px; border-radius: 9px; pointer-events: none; font-variant-numeric: tabular-nums; box-shadow: 0 1px 2px rgba(0,0,0,.5); white-space: nowrap; }
.hint { display: none; margin: 8px 0 0; font-size: 12px; color: var(--muted); }
@media (max-width: 640px) { .hint { display: block; } }

/* Split and corner hit-zones sit on the lines between number cells */
.zone { position: absolute; z-index: 2; border: 0; margin: 0; padding: 0; background: transparent; overflow: visible; cursor: pointer; border-radius: 4px; }
.zone:hover:not(:disabled) { background: rgba(216,166,64,.65); }
.zone:disabled { cursor: not-allowed; }
.zone:focus-visible { outline: 2px solid var(--gold); }
.z-r { right: -9px; top: 22%; width: 16px; height: 56%; }
.z-l { left: -9px; top: 22%; width: 16px; height: 56%; }
.z-b { bottom: -9px; left: 22%; height: 16px; width: 56%; }
.z-c { right: -9px; bottom: -9px; width: 16px; height: 16px; z-index: 3; border-radius: 50%; }

/* Chips and controls */
.controls { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: center; justify-content: space-between; margin-top: 16px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { width: 56px; height: 56px; border-radius: 50%; border: 3px dashed rgba(255,255,255,.8); background: var(--c); color: var(--t, #fff); font: 700 15px var(--f-display); cursor: pointer; font-variant-numeric: tabular-nums; padding: 0; }
.chip.c100 { --c: var(--chip-100); --t: #1b1b1b; }
.chip.c1000 { --c: var(--chip-1k); --t: #fff; }
.chip.c10000 { --c: var(--chip-10k); --t: #fff; }
.chip.c50000 { --c: var(--chip-50k); --t: var(--gold-ink); }
.chip[aria-pressed=true] { box-shadow: 0 0 0 3px var(--felt), 0 0 0 6px var(--gold); transform: translateY(-2px); }
.chip:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.msg { min-height: 1.5em; margin: 14px 0 0; font-weight: 500; }
.msg[data-kind=win] { color: var(--good); }
.msg[data-kind=lose] { color: var(--danger); }
.msg[data-kind=warn] { color: var(--gold); }
.broke { margin-top: 12px; padding: 12px; border: 1px dashed var(--gold); border-radius: 8px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.legend { margin: 14px 0 0; font-size: 12px; color: var(--muted); }

/* Players at the table: name on top, then Balance and Bet in a smaller size */
.seats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.seat { display: grid; gap: 3px; padding: 10px 12px; border-radius: 8px; background: var(--felt-deep); min-width: 0; }
.seat.mine { outline: 1px solid var(--gold); }
.seat .sn { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; min-width: 0; }
.seat .sl { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.seat .sl b { font-weight: 600; color: var(--ink); }
.seat .sl.bal b { color: var(--gold); }
.seat .sbets { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; margin-top: 6px; }
.seats .none { color: var(--muted); font-size: 13px; padding: 4px 2px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--felt); border: 1px solid var(--felt-line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tag.more { color: var(--muted); }

/* Leaderboard */
.lb { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.lb li { display: grid; grid-template-columns: 3ch minmax(0, 1fr) auto; gap: 12px; padding: 8px 10px; border-radius: 6px; background: var(--felt-deep); align-items: baseline; }
.lb li.mine { outline: 1px solid var(--gold); }
.lb li.empty { display: block; color: var(--muted); }
.lb .rank { color: var(--muted); font-variant-numeric: tabular-nums; }
.lb .nm { overflow-wrap: anywhere; }
.lb .nm.off { color: var(--muted); }
.lb .bl { font: 600 18px var(--f-display); font-variant-numeric: tabular-nums; color: var(--gold); }
.loading { color: var(--muted); }

@media (prefers-reduced-motion: reduce) { .chip { transform: none !important; } }
