/* CopperWind — interface "Copper Night" (Opus 5.5, 2026-10-09)
   One stylesheet replaces copperwind-runtime.css + copperwind-layout.css + copperwind-portrait.css.
   The game canvas is untouched; everything here is the shell around it.
   Rules: the page never scrolls, nothing essential is ever cut, no backdrop blur, no animated shadows. */

:root {
  /* Ink (near black, slightly blue) */
  --ink-0: #030409;
  --ink-1: #080b12;
  --ink-2: #0f141d;
  --ink-3: #18202c;
  --ink-4: #232e3d;
  --steel-hi: #3a4658;
  --text: #f6eedb;
  --text-dim: #a9b2c2;
  --text-mute: #6f7a8c;

  /* Copper / brass / patina — taken from the logo */
  --copper: #e57a32;
  --copper-hi: #ffb36b;
  --copper-lo: #6e2f0c;
  --brass: #f7c653;
  --brass-hi: #ffe7a1;
  --brass-lo: #8f5f10;
  --teal: #27d6c6;
  --teal-hi: #8ff5ea;
  --teal-lo: #0a6b66;

  /* Action colours: frank and different from each other */
  --go-hi: #7dffb0;
  --go: #22c96a;
  --go-lo: #0b6a33;
  --cash-hi: #ffe27a;
  --cash: #ff9d1c;
  --cash-lo: #a14300;
  --stop-hi: #ff9aa4;
  --stop: #f0384f;
  --stop-lo: #7c0c1e;
  --violet: #b072ff;

  /* Shadows: present, nearly sharp, tinted — never flat grey blur */
  --sh-color: 222 60% 2%;
  --sh-panel: 0 4px 0 hsl(var(--sh-color) / .75), 0 12px 22px -8px hsl(var(--sh-color) / .8);
  --sh-btn: 0 4px 0 hsl(var(--sh-color) / .8), 0 8px 12px -6px hsl(var(--sh-color) / .7);
  --bevel: inset 0 1px 0 rgb(255 255 255 / .14), inset 0 -2px 0 rgb(0 0 0 / .45);
  --rim: linear-gradient(160deg, #ffc485 0%, #b4581c 22%, #5a2408 46%, #e9893f 70%, #4a1d06 100%);
  --rim-teal: linear-gradient(160deg, #bafff7 0%, #1aa79b 30%, #064541 55%, #33d8c8 80%, #053532 100%);

  --pad: 8px;
  --gap: 8px;
  --radius: 14px;
  --side-w: clamp(280px, 24vw, 400px);
  --canvas-w: 100%;
  --canvas-x: 0%;
  --hud-x: 0%;
  --f-ui: "Rajdhani", "Segoe UI", system-ui, sans-serif;
  --f-title: "Cinzel", "Georgia", serif;
}

/* ───────────────────────── Page lock ───────────────────────── */
html,
body.cw-runtime-body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body.cw-runtime-body {
  position: fixed;
  inset: 0;
  color: var(--text);
  font-family: var(--f-ui);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  background:
    radial-gradient(70vmax 50vmax at 78% 18%, rgb(39 214 198 / .13), transparent 62%),
    radial-gradient(60vmax 45vmax at 6% 96%, rgb(229 122 50 / .17), transparent 62%),
    radial-gradient(50vmax 40vmax at 100% 100%, rgb(176 114 255 / .10), transparent 60%),
    repeating-linear-gradient(135deg, rgb(255 255 255 / .012) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, #070a11 0%, #030409 100%);
}
input, textarea { user-select: text; -webkit-user-select: text; }
button { font-family: inherit; }
button:focus-visible, input:focus-visible, label:focus-within { outline: 2px solid var(--brass-hi); outline-offset: 2px; }
svg { display: block; fill: currentColor; }
[hidden] { display: none !important; }

/* ───────────────────────── Shell grid ───────────────────────── */
.cwx,
.cwx * { box-sizing: border-box; }

.cwx {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  gap: var(--gap);
  padding:
    max(var(--pad), env(safe-area-inset-top))
    max(var(--pad), env(safe-area-inset-right))
    max(var(--pad), env(safe-area-inset-bottom))
    max(var(--pad), env(safe-area-inset-left));
  /* Desktop / tablet landscape */
  /* Desktop / tablet landscape: brand, balance, ticket(s) and community in the left column,
     the game takes the full height on the right. */
  grid-template-columns: var(--side-w) minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  grid-template-areas:
    "brand   history controls"
    "balance stage   stage"
    "dock    stage   stage"
    "side    stage   stage";
}

.cwx-history, .cwx-controls { align-self: center; }
.cwx-brand { grid-area: brand; }
.cwx-controls { grid-area: controls; }
.cwx-balance { grid-area: balance; }
.cwx-history { grid-area: history; }
.cwx-stage { grid-area: stage; }
.cw-bet-dock { grid-area: dock; }
.cwx-side { grid-area: side; }

/* ───────────────────────── Brand ───────────────────────── */
.cwx-brand {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 4px 10px 4px 6px;
  border-radius: var(--radius);
  background:
    radial-gradient(80% 120% at 30% 50%, rgb(229 122 50 / .16), transparent 70%),
    linear-gradient(180deg, #05070b, #010203);
  box-shadow: inset 0 0 0 1px rgb(255 179 107 / .10), var(--sh-panel);
}
.cwx-logo {
  display: block;
  width: 100%;
  max-width: 330px;
  height: auto;
  max-height: 96px;
  object-fit: contain;
  object-position: left center;
  filter: drop-shadow(0 3px 0 rgb(0 0 0 / .85)) drop-shadow(0 0 10px rgb(255 160 80 / .22));
  pointer-events: none;
}

/* ───────────────────────── Buttons: icon + quit ───────────────────────── */
.cwx-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.cwx-icon,
.cwx-quit {
  appearance: none;
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 13px;
  color: var(--brass-hi);
  cursor: pointer;
  background:
    linear-gradient(180deg, #2b3546 0%, #161d28 55%, #0c1118 100%) padding-box,
    var(--rim) border-box;
  box-shadow: var(--bevel), var(--sh-btn);
  transition: transform 80ms ease, filter 120ms ease;
}
.cwx-icon svg { width: 24px; height: 24px; filter: drop-shadow(0 1px 0 rgb(0 0 0 / .8)); }
.cwx-icon:hover, .cwx-quit:hover { filter: brightness(1.15); }
.cwx-icon:active, .cwx-quit:active { transform: translateY(3px); box-shadow: inset 0 2px 4px rgb(0 0 0 / .6), 0 1px 0 hsl(var(--sh-color) / .8); }
.cw-sound-toggle .cwx-ico-off { display: none; }
.cw-sound-toggle.is-muted { color: #fff; background: linear-gradient(180deg, #d6324a, #84101f) padding-box, var(--rim) border-box; }
.cw-sound-toggle.is-muted .cwx-ico-on { display: none; }
.cw-sound-toggle.is-muted .cwx-ico-off { display: block; }

.cwx-quit {
  width: auto;
  grid-auto-flow: column;
  gap: 6px;
  padding: 0 14px 0 11px;
  color: #fff;
  background:
    linear-gradient(180deg, #ff6b78 0%, #e0283f 48%, #9a0d22 100%) padding-box,
    linear-gradient(160deg, #ffd1d6, #7c0c1e 50%, #ff8a96 75%, #4a0510) border-box;
}
.cwx-quit svg { width: 22px; height: 22px; filter: drop-shadow(0 1px 0 rgb(80 0 10 / .9)); }
.cwx-quit__label {
  font: 800 17px/1 var(--f-ui);
  letter-spacing: .08em;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgb(90 0 15 / .8);
}
.cwx-quit.is-armed { animation: cwx-shake 360ms ease 2; }
@keyframes cwx-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* ───────────────────────── Panels (copper rim) ───────────────────────── */
.cwx-balance,
.cwx-history,
.cwx-side > section,
.cwx-ticket,
.cw-settings-panel {
  border: 2px solid transparent;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, var(--ink-3) 0%, var(--ink-2) 60%, #0b1017 100%) padding-box,
    var(--rim) border-box;
  box-shadow: var(--bevel), var(--sh-panel);
}

/* ───────────────────────── Balance ───────────────────────── */
.cwx-balance {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  padding: 8px 12px 10px;
  min-width: 0;
}
.cwx-balance__label {
  color: var(--teal);
  font: 800 13px/1 var(--f-ui);
  letter-spacing: .2em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 #000;
}
.cw-player-name {
  justify-self: end;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-mute);
  font: 700 12px/1 var(--f-ui);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.cw-balance-value {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
  padding: 6px 12px 5px;
  border-radius: 10px;
  background: linear-gradient(180deg, #020305, #0a0e15);
  box-shadow: inset 0 2px 5px rgb(0 0 0 / .9), inset 0 -1px 0 rgb(255 255 255 / .07);
  min-width: 0;
}
.cwx-amount {
  color: var(--brass);
  font: 700 clamp(26px, 2.4vw, 36px)/1 var(--f-ui);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  background: linear-gradient(180deg, var(--brass-hi) 10%, var(--brass) 55%, #d98d1f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 0 rgb(0 0 0 / .9));
  white-space: nowrap;
}
.cwx-currency { color: var(--copper-hi); font: 800 13px/1 var(--f-ui); letter-spacing: .12em; }
.cw-balance-value.is-up .cwx-amount { animation: cwx-pop 600ms cubic-bezier(.2, 1.6, .4, 1); }
.cw-balance-value.is-up { animation: cwx-flash-up 900ms ease-out; }
.cw-balance-value.is-down { animation: cwx-flash-down 700ms ease-out; }
@keyframes cwx-pop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes cwx-flash-up { 0% { background: linear-gradient(180deg, #0c5a35, #06301c); } 100% { background: linear-gradient(180deg, #020305, #0a0e15); } }
@keyframes cwx-flash-down { 0% { background: linear-gradient(180deg, #5a0c18, #2a050b); } 100% { background: linear-gradient(180deg, #020305, #0a0e15); } }

/* ───────────────────────── History chips ───────────────────────── */
.cwx-history {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 8px;
  overflow: hidden;
  background:
    linear-gradient(180deg, #0b0f16, #06080d) padding-box,
    var(--rim) border-box;
}
.cwx-history::after {
  /* fade the oldest chips into the rail instead of a hard cut */
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 42px;
  border-radius: 0 12px 12px 0;
  background: linear-gradient(90deg, transparent, #070a0f 85%);
  pointer-events: none;
}
.cw-results-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  padding: 7px 0 9px;
}
.cw-result-slip {
  flex: 0 0 auto;
  min-width: 52px;
  padding: 5px 9px 4px;
  border-radius: 999px;
  text-align: center;
  color: #fff;
  font: 800 15px/1 var(--f-ui);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgb(0 0 0 / .55);
  background: linear-gradient(180deg, #4ff0df, #12a395 55%, #0a6b63);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .45), inset 0 -2px 0 rgb(0 0 0 / .3), 0 3px 0 rgb(0 0 0 / .7);
}
.cw-result-slip[data-tier="red"] { background: linear-gradient(180deg, #ff7f8c, #e0283f 55%, #8c0c20); }
.cw-result-slip[data-tier="high"] { background: linear-gradient(180deg, #d4a8ff, #9a52f2 55%, #5a1fa6); }
.cw-result-slip[data-tier="warm"] { background: linear-gradient(180deg, #ffc56b, #ff8a1c 55%, #a84500); }
.cw-result-slip[data-tier="gold"] { color: #3b2400; text-shadow: 0 1px 0 rgb(255 255 255 / .5); background: linear-gradient(180deg, #fff3b8, #ffcc33 50%, #c98a00); }
.cw-result-slip.is-latest { outline: 2px solid var(--brass-hi); outline-offset: 2px; }

/* ───────────────────────── Stage (the star) ───────────────────────── */
.cwx-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  container-type: size;
  display: grid;
  place-items: center;
}
.cwx-stage-fit {
  position: relative;
  width: min(100cqw, 100cqh * 16 / 9);
  height: min(100cqh, 100cqw * 9 / 16);
  container-type: size;
  border-radius: 16px;
  padding: 3px;
  background: var(--rim);
  box-shadow: 0 6px 0 hsl(var(--sh-color) / .8), 0 18px 34px -10px hsl(var(--sh-color) / .9);
}
.cw-stage-frame {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 13px;
  background: #000;
  isolation: isolate;
}
.cw-stage-frame canvas#c,
.cw-stage-frame canvas.cw-sky-layer {
  position: absolute;
  top: 0;
  left: var(--canvas-x);
  width: var(--canvas-w);
  height: 100%;
  display: block;
}
.cw-stage-frame canvas#c { z-index: 1; touch-action: none; user-select: none; background: transparent; }
.cw-stage-frame canvas.cw-sky-layer { z-index: 0; display: none; pointer-events: none; }
.cw-stage-frame[data-layered-sky="1"] canvas.cw-sky-layer { display: block; }
.cw-stage-frame[data-compose-sky-main="1"] canvas.cw-sky-layer { display: none; }
.cw-stage-frame canvas.cw-run-hud {
  position: absolute;
  top: 0;
  left: var(--hud-x);
  width: var(--canvas-w);
  height: auto;
  z-index: 2;
  pointer-events: none;
}

/* Betting countdown (DOM sprites over the stage), sized from the canvas width */
.cw-stage-countdown { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.cw-stage-countdown__stack {
  --u: calc(var(--canvas-w-cq, 100cqw) / 1280);
  position: absolute;
  left: 50%;
  top: 74%;
  width: calc(var(--u) * 173);
  height: calc(var(--u) * 167);
  transform: translate(-50%, -50%);
}
.cw-stage-countdown__play,
.cw-stage-countdown__bg { position: absolute; inset: 0; background: center / contain no-repeat; }
.cw-stage-countdown__play { z-index: 1; }
.cw-stage-countdown__bg { z-index: 2; }
.cw-stage-countdown__value {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  align-items: center;
  transform: translateY(-4%);
  color: #fff3d4;
  font: 800 calc(var(--u) * 82) / .9 var(--f-ui);
  text-shadow: 0 3px 0 rgb(0 0 0 / .7), 0 0 12px rgb(255 212 126 / .35);
}
.cw-cd-digit { display: inline-block; width: .6em; text-align: center; }

/* ───────────────────────── Bet dock ───────────────────────── */
.cw-bet-dock {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
}
.cwx-dock-bar { display: none; }
.cwx-chat-peek { display: none; }
.cw-bet-card { min-width: 0; min-height: 0; container-type: inline-size; position: relative; }

.cwx-ticket {
  height: 100%;
  display: grid;
  gap: 8px;
  padding: 9px 12px 12px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}
.cwx-ticket__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.cwx-ticket__name {
  font: 900 18px/1 var(--f-title);
  letter-spacing: .04em;
  color: var(--brass);
  text-shadow: 0 2px 0 #000;
}
.cwx-ticket__status {
  padding: 4px 9px 3px;
  border-radius: 999px;
  font: 800 12px/1 var(--f-ui);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--teal-hi);
  background: #062a29;
  box-shadow: inset 0 0 0 1px rgb(39 214 198 / .45);
}
.cwx-ticket__status[data-status="live"] { color: #fff; background: linear-gradient(180deg, #ff9d1c, #b24c00); box-shadow: none; }
.cwx-ticket__status[data-status="bet"] { color: #062b16; background: linear-gradient(180deg, #7dffb0, #22c96a); box-shadow: none; }
.cwx-ticket__status[data-status="done"] { color: #3b2400; background: linear-gradient(180deg, #fff3b8, #ffcc33); box-shadow: none; }
.cwx-ticket__status[data-status="lost"] { color: #fff; background: linear-gradient(180deg, #ff6b78, #9a0d22); box-shadow: none; }

/* Fields */
.cwx-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  align-content: start;
}
.cwx-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 7px 8px 8px;
  border-radius: 12px;
  background: linear-gradient(180deg, #0a0e15, #0d121a);
  box-shadow: inset 0 2px 4px rgb(0 0 0 / .7), inset 0 -1px 0 rgb(255 255 255 / .05);
}
.cwx-field__top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  color: var(--text-dim);
  font: 800 13px/1 var(--f-ui);
  letter-spacing: .14em;
  text-transform: uppercase;
}
.cwx-field__top em { margin-left: auto; font-style: normal; color: var(--copper-hi); }
.cwx-field__top .cw-field-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cwx-field--auto .cw-field-label { color: var(--text-dim); }
.cwx-field--auto.is-off .cw-stepper { filter: saturate(.2) brightness(.7); }

.cw-stepper {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 6px;
  align-items: stretch;
  height: 46px;
}
.cw-stepper-btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
  color: var(--brass-hi);
  font: 700 28px/1 var(--f-ui);
  background: linear-gradient(180deg, #3a4658 0%, #222b39 50%, #151b25 100%);
  box-shadow: var(--bevel), 0 3px 0 #000;
  transition: transform 70ms ease;
}
.cw-stepper-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 2px 4px rgb(0 0 0 / .7); }
.cw-stepper-btn:disabled { color: #566070; cursor: default; background: linear-gradient(180deg, #232b37, #161c25); }
.cw-bet-input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 4px;
  border: 0;
  border-radius: 10px;
  text-align: center;
  color: var(--text);
  font: 700 26px/1 var(--f-ui);
  font-variant-numeric: tabular-nums;
  background: #020305;
  box-shadow: inset 0 2px 6px rgb(0 0 0 / .9), inset 0 0 0 1px rgb(255 179 107 / .16);
  -moz-appearance: textfield;
}
.cw-bet-input::-webkit-outer-spin-button,
.cw-bet-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cw-bet-input:focus { outline: none; box-shadow: inset 0 2px 6px rgb(0 0 0 / .9), 0 0 0 2px var(--brass); }
.cw-bet-input:disabled { color: #8a93a2; }

.cw-preset-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}
.cw-preset {
  appearance: none;
  border: 0;
  height: 32px;
  min-width: 0;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font: 800 15px/1 var(--f-ui);
  background: linear-gradient(180deg, #2c3646, #19202b);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .12), 0 2px 0 #000;
}
.cw-preset:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 2px 3px rgb(0 0 0 / .6); }
.cw-preset.is-active { color: #04201d; background: linear-gradient(180deg, var(--teal-hi), var(--teal) 60%, #15a497); box-shadow: inset 0 1px 0 rgb(255 255 255 / .6), 0 2px 0 var(--teal-lo); }
.cwx-field--auto .cw-preset.is-active { color: #2a1200; background: linear-gradient(180deg, var(--copper-hi), var(--copper) 60%, #b4581c); box-shadow: inset 0 1px 0 rgb(255 255 255 / .55), 0 2px 0 var(--copper-lo); }
.cw-preset:disabled { color: #5f6878; cursor: default; background: linear-gradient(180deg, #1e252f, #151a22); }

/* Auto switch */
.cwx-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-dim);
}
.cwx-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.cwx-switch__track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #05070b;
  box-shadow: inset 0 2px 4px rgb(0 0 0 / .9), inset 0 0 0 1px rgb(255 255 255 / .1);
  transition: background 140ms ease;
}
.cwx-switch__knob {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #d9dee6, #8b95a5);
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 rgb(0 0 0 / .7);
  transition: transform 140ms cubic-bezier(.3, 1.4, .5, 1);
}
.cwx-switch.is-on .cwx-switch__track { background: linear-gradient(180deg, #0a8f84, var(--teal)); }
.cwx-switch.is-on .cwx-switch__knob { transform: translateX(18px); background: linear-gradient(180deg, #fff, #d2fff9); }
.cwx-switch.is-disabled { cursor: default; filter: saturate(.3) brightness(.75); }
.cwx-switch__text { display: none; font: 800 13px/1 var(--f-ui); letter-spacing: .12em; text-transform: uppercase; }
.cwx-switch--compact .cwx-switch__text { display: inline; }

/* The big action button */
.cwx-action {
  appearance: none;
  position: relative;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 3px;
  width: 100%;
  min-height: 64px;
  padding: 6px 12px 8px;
  border: 2px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  color: #fff;
  isolation: isolate;
  transition: transform 80ms ease, filter 120ms ease;
  background:
    linear-gradient(180deg, var(--go-hi) 0%, var(--go) 42%, #13994d 72%, var(--go-lo) 100%) padding-box,
    linear-gradient(170deg, #c9ffe0, #0b6a33 45%, #5dfb98 75%, #04331a) border-box;
  box-shadow: inset 0 2px 0 rgb(255 255 255 / .5), inset 0 -3px 0 rgb(0 0 0 / .28), 0 5px 0 #03210f, 0 12px 18px -8px rgb(0 0 0 / .85);
}
.cwx-action__label {
  font: 900 clamp(22px, 2vw, 28px)/1 var(--f-ui);
  letter-spacing: .08em;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgb(0 0 0 / .45);
}
.cwx-action__sub {
  font: 700 15px/1 var(--f-ui);
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgb(0 0 0 / .5);
  opacity: 1;
}
.cwx-action:hover:not(:disabled) { filter: brightness(1.08) saturate(1.1); }
.cwx-action:active:not(:disabled) { transform: translateY(4px); box-shadow: inset 0 2px 0 rgb(255 255 255 / .35), inset 0 -2px 0 rgb(0 0 0 / .25), 0 1px 0 #03210f; }

.cwx-action--cash {
  color: #2b1200;
  background:
    linear-gradient(180deg, var(--cash-hi) 0%, #ffbd3b 30%, var(--cash) 62%, #d76300 100%) padding-box,
    linear-gradient(170deg, #fff6c9, #a14300 45%, #ffd36b 75%, #4d1c00) border-box;
  box-shadow: inset 0 2px 0 rgb(255 255 255 / .65), inset 0 -3px 0 rgb(120 40 0 / .35), 0 5px 0 #4a1c00, 0 12px 18px -8px rgb(0 0 0 / .85);
}
.cwx-action--cash .cwx-action__label { text-shadow: 0 1px 0 rgb(255 255 255 / .45); }
.cwx-action--cash .cwx-action__sub { font-size: 19px; font-weight: 800; text-shadow: 0 1px 0 rgb(255 255 255 / .4); }
.cwx-action--cash::after {
  /* breathing halo: transform + opacity only (compositor), no animated shadow */
  content: "";
  position: absolute;
  inset: -6px;
  z-index: -1;
  border-radius: 20px;
  background: radial-gradient(closest-side, rgb(255 190 60 / .55), transparent);
  animation: cwx-breathe 1.1s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes cwx-breathe { from { opacity: .35; transform: scale(.97); } to { opacity: 1; transform: scale(1.03); } }

.cwx-action--cancel {
  background:
    linear-gradient(180deg, var(--stop-hi) 0%, #ff5466 35%, var(--stop) 65%, #a5122a 100%) padding-box,
    linear-gradient(170deg, #ffd1d6, #7c0c1e 45%, #ff8a96 75%, #3d0410) border-box;
  box-shadow: inset 0 2px 0 rgb(255 255 255 / .45), inset 0 -3px 0 rgb(0 0 0 / .28), 0 5px 0 #3d0410, 0 12px 18px -8px rgb(0 0 0 / .85);
}
.cwx-action--won {
  color: #3b2400;
  background:
    linear-gradient(180deg, #fff6c4, #ffd34d 45%, #e2a114 100%) padding-box,
    linear-gradient(170deg, #fffbe6, #8f5f10 45%, #ffe7a1 75%, #4a2f00) border-box;
}
.cwx-action--won .cwx-action__label, .cwx-action--won .cwx-action__sub { text-shadow: 0 1px 0 rgb(255 255 255 / .5); }
.cwx-action--lost {
  background:
    linear-gradient(180deg, #5b2430, #3a121b 60%, #250a10) padding-box,
    linear-gradient(170deg, #ff8a96, #3d0410 50%, #a5122a) border-box;
  color: #ffc2c9;
}
.cwx-action--wait,
.cwx-action--closed,
.cwx-action:disabled:not(.cwx-action--won):not(.cwx-action--lost):not(.cwx-action--cash) {
  cursor: default;
  color: #9aa4b4;
  background:
    linear-gradient(180deg, #333e4f 0%, #222a37 55%, #171d27 100%) padding-box,
    linear-gradient(170deg, #6b7a90, #1a212c 50%, #3a4658) border-box;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .12), inset 0 -2px 0 rgb(0 0 0 / .35), 0 4px 0 #05070b;
}
.cwx-action--cash:disabled { filter: saturate(.6) brightness(.85); }
.cwx-action--cash:disabled::after { display: none; }

/* Summary (bet placed / in play / settled) */
.cwx-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 10px;
  border-radius: 12px;
  background: linear-gradient(180deg, #0a0e15, #0d121a);
  box-shadow: inset 0 2px 4px rgb(0 0 0 / .7);
}
.cwx-summary__cell { display: grid; gap: 2px; min-width: 0; }
.cwx-summary__cell span { color: var(--text-mute); font: 800 11px/1 var(--f-ui); letter-spacing: .16em; text-transform: uppercase; }
.cwx-summary__cell b { color: var(--text); font: 700 22px/1 var(--f-ui); font-variant-numeric: tabular-nums; }
.cwx-summary .cwx-switch { margin-left: auto; }

/* Live: progress towards the auto cash-out target (transform only) */
.cwx-target {
  position: relative;
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  background: #05070b;
  box-shadow: inset 0 2px 3px rgb(0 0 0 / .9), inset 0 0 0 1px rgb(255 255 255 / .08);
}
.cwx-target__fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, #0a8f84, var(--teal) 60%, var(--teal-hi));
  transition: transform 220ms ease-out;
}
.cwx-target span {
  position: relative;
  display: block;
  padding-right: 10px;
  text-align: right;
  color: #fff;
  font: 800 12px/18px var(--f-ui);
  letter-spacing: .12em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 #000, 0 0 4px #000;
}

/* Ticket inner layouts by available width (container queries) */
@container (min-width: 600px) {
  .cwx-ticket {
    grid-template-columns: minmax(0, 1fr) clamp(180px, 30%, 240px);
    grid-template-rows: auto 1fr;
    grid-template-areas: "head head" "body action";
    align-items: stretch;
  }
  .cwx-ticket__head { grid-area: head; }
  .cwx-fields, .cwx-summary { grid-area: body; }
  .cwx-ticket .cwx-action { grid-area: action; height: 100%; }
  .cwx-ticket .cwx-target { grid-area: body; align-self: end; margin: 0 10px 10px; }
  .cwx-summary { gap: 28px; padding: 10px 18px 34px; }
  .cwx-summary__cell span { font-size: 13px; }
  .cwx-summary__cell b { font-size: 34px; }
}
@container (max-width: 359px) {
  .cwx-fields { grid-template-columns: minmax(0, 1fr); }
}

/* ───────────────────────── Community side (players + chat) ───────────────────────── */
.cwx-side {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--gap);
}
.cw-players-panel {
  min-height: 0;
  max-height: 24vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}
.cw-pl-header {
  padding: 9px 12px 7px;
  color: var(--teal);
  font: 800 12px/1 var(--f-ui);
  letter-spacing: .2em;
  text-transform: uppercase;
  border-bottom: 1px solid rgb(255 255 255 / .07);
}
.cw-players-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #3a4658 transparent; }
.cw-pl-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 5px 12px;
  border-bottom: 1px solid rgb(255 255 255 / .04);
}
.cw-pl-row.cw-pl-self { background: rgb(39 214 198 / .10); }
.cw-pl-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); font: 700 13px/1.2 var(--f-ui); }
.cw-pl-stake { color: var(--text-mute); font: 700 12px/1 var(--f-ui); font-variant-numeric: tabular-nums; }
.cw-pl-status { font: 800 12px/1 var(--f-ui); text-transform: uppercase; letter-spacing: .06em; }
.cw-pl-playing { color: var(--go-hi); }
.cw-pl-cashout { color: var(--brass); }
.cw-pl-crash { color: var(--stop-hi); }
.cw-pl-empty { padding: 8px 12px; color: var(--text-mute); font-size: 13px; text-align: center; }

.cw-chat-shell {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}
.cw-chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 8px 12px;
  border-bottom: 1px solid rgb(255 255 255 / .07);
}
.cw-chat-header h2 {
  margin: 0 auto 0 0;
  color: var(--brass);
  font: 900 20px/1 var(--f-title);
  letter-spacing: .04em;
  text-shadow: 0 2px 0 #000;
}
.cw-chat-clear,
.cw-portrait-chat-close {
  appearance: none;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-dim);
  font: 800 12px/1 var(--f-ui);
  letter-spacing: .12em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #2c3646, #19202b);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .12), 0 2px 0 #000;
}
.cw-portrait-chat-close { display: none; width: 38px; height: 38px; padding: 0; place-items: center; color: var(--text); }
.cw-portrait-chat-close svg { width: 22px; height: 22px; }

.cw-chat-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 8px 8px 10px;
  scrollbar-width: thin;
  scrollbar-color: #3a4658 transparent;
  -webkit-overflow-scrolling: touch;
}
.cw-chat-item {
  padding: 6px 9px 7px;
  border-radius: 10px;
  background: #0b1018;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .05);
  user-select: text;
}
.cw-chat-item strong {
  display: inline;
  margin-right: 6px;
  color: var(--teal);
  font: 800 14px/1.25 var(--f-ui);
}
.cw-chat-item span { color: var(--text); font: 600 15px/1.25 var(--f-ui); overflow-wrap: anywhere; }
.cw-chat-item[data-kind="player"] strong { color: var(--brass); }
/* Game/system lines: smaller, quieter, so real conversation stands out */
.cw-chat-item[data-kind="system"],
.cw-chat-item[data-kind="step"] { padding: 3px 9px; background: transparent; box-shadow: none; }
.cw-chat-item[data-kind="system"] strong,
.cw-chat-item[data-kind="step"] strong { color: var(--text-mute); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.cw-chat-item[data-kind="system"] span { color: var(--text-mute); font-size: 13px; }
.cw-chat-item[data-kind="step"] span { color: var(--copper-hi); font-size: 13px; }
.cw-chat-item[data-kind="alert"] { background: #2a0a10; box-shadow: inset 0 0 0 1px rgb(240 56 79 / .35); }
.cw-chat-item[data-kind="alert"] strong { color: var(--stop-hi); }

.cw-chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid rgb(255 255 255 / .07);
}
.cw-chat-input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  font: 600 16px/1 var(--f-ui);
  background: #020305;
  box-shadow: inset 0 2px 5px rgb(0 0 0 / .9), inset 0 0 0 1px rgb(255 255 255 / .08);
}
.cw-chat-input::placeholder { color: var(--text-mute); }
.cw-chat-input:focus { outline: none; box-shadow: inset 0 2px 5px rgb(0 0 0 / .9), 0 0 0 2px var(--teal); }
.cw-chat-send {
  appearance: none;
  height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  color: #032521;
  font: 900 15px/1 var(--f-ui);
  letter-spacing: .1em;
  text-transform: uppercase;
  background: linear-gradient(180deg, var(--teal-hi), var(--teal) 55%, #12a093);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .6), 0 3px 0 var(--teal-lo);
}
.cw-chat-send:active { transform: translateY(2px); box-shadow: inset 0 2px 3px rgb(0 0 0 / .4); }

.cw-portrait-chat-scrim { display: none; }

/* ───────────────────────── Toast ───────────────────────── */
.cwx-toast {
  position: fixed;
  left: 50%;
  top: max(14px, env(safe-area-inset-top));
  z-index: 400;
  max-width: min(92vw, 460px);
  padding: 12px 18px;
  border-radius: 12px;
  color: #fff;
  font: 700 16px/1.25 var(--f-ui);
  text-align: center;
  background: linear-gradient(180deg, #e0283f, #8c0c20);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .35), 0 4px 0 #3d0410, 0 12px 20px -8px #000;
  transform: translateX(-50%);
}
.cwx-toast.is-in { animation: cwx-drop 260ms cubic-bezier(.2, 1.4, .4, 1); }
@keyframes cwx-drop { from { transform: translate(-50%, -20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ───────────────────────── Settings ───────────────────────── */
.cw-settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  background: radial-gradient(circle at 50% 40%, rgb(3 4 9 / .78), rgb(3 4 9 / .94));
}
.cw-settings-panel {
  width: min(760px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 18px 20px 16px;
}
/* Header and actions stay put; only the settings themselves scroll on short screens. */
.cw-settings-grid { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.cw-settings-header, .cw-settings-actions { flex: 0 0 auto; }
.cw-settings-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.cw-settings-kicker { display: block; color: var(--teal); font: 800 12px/1 var(--f-ui); letter-spacing: .22em; text-transform: uppercase; }
.cw-settings-header h2 { margin: 6px 0 0; color: var(--brass); font: 900 28px/1 var(--f-title); text-shadow: 0 2px 0 #000; }
.cw-settings-close {
  appearance: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 2px solid transparent;
  border-radius: 13px;
  cursor: pointer;
  color: var(--text);
  background: linear-gradient(180deg, #2b3546, #0c1118) padding-box, var(--rim) border-box;
  box-shadow: var(--bevel), var(--sh-btn);
}
.cw-settings-close svg { width: 24px; height: 24px; }
.cw-settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cw-settings-block {
  padding: 12px 14px 14px;
  border-radius: 12px;
  background: linear-gradient(180deg, #0a0e15, #0d121a);
  box-shadow: inset 0 2px 4px rgb(0 0 0 / .7), inset 0 -1px 0 rgb(255 255 255 / .05);
}
.cw-settings-block h3 { margin: 0 0 12px; color: var(--copper-hi); font: 800 15px/1 var(--f-title); letter-spacing: .06em; }
.cw-settings-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 10px; min-height: 40px; }
.cw-settings-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cw-settings-pair label { display: grid; gap: 6px; color: var(--text-dim); font: 700 13px/1.2 var(--f-ui); letter-spacing: .06em; text-transform: uppercase; }
.cw-switch { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font: 700 16px/1.2 var(--f-ui); cursor: pointer; }
.cw-switch-compact { margin-top: 10px; color: var(--text-dim); font-size: 14px; }
.cw-switch input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--teal); }
.cw-slider { width: 100%; accent-color: var(--copper); height: 28px; }
.cw-settings-number {
  width: 100%;
  height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  font: 700 20px/1 var(--f-ui);
  background: #020305;
  box-shadow: inset 0 2px 5px rgb(0 0 0 / .9), inset 0 0 0 1px rgb(255 179 107 / .16);
}
.cw-quality-group { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cw-segment,
.cwx-btn {
  appearance: none;
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  color: var(--text);
  font: 800 15px/1 var(--f-ui);
  letter-spacing: .08em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #3a4658, #1d2531 60%, #141a23);
  box-shadow: var(--bevel), 0 3px 0 #000;
}
.cw-segment:active, .cwx-btn:active { transform: translateY(2px); box-shadow: inset 0 2px 4px rgb(0 0 0 / .6); }
.cw-segment.is-active { color: #04201d; background: linear-gradient(180deg, var(--teal-hi), var(--teal) 60%, #12a093); box-shadow: inset 0 1px 0 rgb(255 255 255 / .6), 0 3px 0 var(--teal-lo); }
.cwx-btn--gold { color: #2b1700; background: linear-gradient(180deg, var(--brass-hi), var(--brass) 55%, #d4911a); box-shadow: inset 0 1px 0 rgb(255 255 255 / .6), 0 3px 0 var(--brass-lo); }
.cwx-btn--quit { color: #fff; background: linear-gradient(180deg, #ff6b78, #e0283f 50%, #9a0d22); box-shadow: inset 0 1px 0 rgb(255 255 255 / .45), 0 3px 0 #3d0410; }
.cw-settings-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.cwx-spacer { flex: 1; }

/* ───────────────────────── Entry gate & cinematic ───────────────────────── */
.cw-entry-gate { position: fixed; inset: 0; z-index: 250; background: #030409; }
.cw-entry-gate__bg,
.cw-entry-gate__cover { position: absolute; inset: 0; background: center / cover no-repeat; }
.cw-entry-gate__bg { background-image: url('../assets/load.webp'); }
.cw-entry-gate__cover { background-image: url('../assets/load2.webp'); }
.cw-entry-gate__play {
  position: absolute;
  left: 50%;
  top: 68%;
  z-index: 2;
  width: clamp(96px, 16vmin, 200px);
  height: clamp(96px, 16vmin, 200px);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transform: translate(-50%, -50%);
}
.cw-entry-gate__play-base,
.cw-entry-gate__play-light { position: absolute; inset: 0; background: center / contain no-repeat; pointer-events: none; }
.cw-entry-gate__play-light { animation: cw-play-blink 1.6s ease-in-out infinite; }
@keyframes cw-play-blink { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }
.cw-entry-gate__loading {
  position: absolute;
  left: 50%;
  top: 68%;
  z-index: 2;
  width: min(440px, calc(100vw - 48px));
  display: grid;
  gap: 12px;
  place-items: center;
  transform: translate(-50%, -50%);
}
.cw-entry-gate__loading-track {
  width: 100%;
  height: 16px;
  padding: 2px;
  border-radius: 999px;
  background: #020305;
  box-shadow: inset 0 2px 4px #000, 0 0 0 2px #6e2f0c, 0 0 0 3px #ffb36b, 0 5px 0 4px rgb(0 0 0 / .6);
  overflow: hidden;
}
.cw-entry-gate__loading-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(180deg, var(--teal-hi), var(--teal) 50%, #0a8f84);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .6);
  transition: width 120ms linear;
}
.cw-entry-gate__loading-text {
  color: var(--text);
  font: 800 18px/1 var(--f-ui);
  letter-spacing: .16em;
  text-transform: uppercase;
  text-shadow: 0 2px 0 #000, 0 0 10px #000;
}
.cw-entry-gate__tagline {
  position: absolute;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 2;
  margin: 0;
  transform: translateX(-50%);
  color: #fff;
  font: italic 700 clamp(15px, 2vw, 22px)/1 var(--f-ui);
  letter-spacing: .14em;
  text-shadow: 0 2px 0 #000, 0 0 12px #000;
  white-space: nowrap;
  pointer-events: none;
}

/* ═════════════════════════ COMPACT LAYOUTS (phones) ═════════════════════════ */
/* Chat becomes a drawer when there is no room to dock it. */
@media (orientation: portrait), (max-height: 760px) {
  .cwx-side { grid-area: auto; }
  .cwx-side {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 220;
    width: min(380px, 90vw);
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    background: linear-gradient(180deg, #0b0f16, #05070b);
    box-shadow: 6px 0 0 rgb(0 0 0 / .6), 18px 0 30px -10px #000;
    transform: translateX(-104%);
    transition: transform 220ms cubic-bezier(.2, .8, .3, 1);
    visibility: hidden;
  }
  .cwx.is-portrait-chat-open .cwx-side { transform: none; visibility: visible; }
  .cw-portrait-chat-close { display: grid; }
  .cw-players-panel { max-height: 28dvh; }
  .cw-portrait-chat-scrim {
    position: fixed;
    inset: 0;
    z-index: 210;
    border: 0;
    padding: 0;
    background: rgb(2 3 6 / .72);
  }
  .cwx.is-portrait-chat-open .cw-portrait-chat-scrim { display: block; }

}

/* Tabbed dock: one ticket at a time (+ every ticket holding a bet during the run). */
@media (orientation: portrait), (max-height: 1049px) {
  .cw-bet-dock {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .cwx-dock-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    flex: 0 0 auto;
  }
  .cw-portrait-bet-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .cw-portrait-bet-tab,
  .cw-portrait-chat-toggle {
    appearance: none;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 40px;
    padding: 0 12px;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-dim);
    font: 800 16px/1 var(--f-ui);
    letter-spacing: .1em;
    text-transform: uppercase;
    background: linear-gradient(180deg, #232c3a, #121821) padding-box, linear-gradient(170deg, #4a5568, #0b0f15) border-box;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .1), 0 3px 0 #000;
  }
  .cw-portrait-bet-tab[aria-selected="true"] {
    color: #2b1700;
    background: linear-gradient(180deg, var(--brass-hi), var(--brass) 55%, #d4911a) padding-box, var(--rim) border-box;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .6), 0 3px 0 var(--brass-lo);
  }
  .cwx-tab-dot { display: none; width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 2px rgb(0 0 0 / .55); }
  .cw-portrait-bet-tab[data-bet="placed"] .cwx-tab-dot { display: block; background: var(--go-hi); }
  .cw-portrait-bet-tab[data-bet="won"] .cwx-tab-dot { display: block; background: var(--brass-hi); }
  .cw-portrait-bet-tab[data-bet="lost"] .cwx-tab-dot { display: block; background: var(--stop); }
  .cw-portrait-chat-toggle { color: var(--teal-hi); }
  .cw-portrait-chat-toggle svg { width: 20px; height: 20px; }
  .cwx-unread {
    position: absolute;
    right: -6px;
    top: -7px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    color: #fff;
    font: 800 12px/20px var(--f-ui);
    letter-spacing: 0;
    text-align: center;
    background: var(--stop);
    box-shadow: 0 2px 0 #3d0410;
  }

  /* Which tickets: betting phase → the selected tab; run → every ticket that holds a bet. */
  .cw-bet-card { display: none; flex: 1 1 0; min-height: 0; }
  .cw-bet-dock[data-active-bet="left"] .cw-bet-card-left,
  .cw-bet-dock[data-active-bet="right"] .cw-bet-card-right { display: block; }
  .cwx.is-running .cw-bet-dock.has-any-bet .cw-bet-card { display: none; }
  .cwx.is-running .cw-bet-dock.has-any-bet .cw-bet-card.cw-bet-card--committed { display: block; }

  .cwx-ticket { display: flex; flex-direction: column; gap: 8px; }
  .cwx-ticket > .cwx-action { margin-top: auto; }
  .cwx-ticket[data-mode="edit"] .cwx-ticket__head { display: none; }
  .cwx.is-running .has-left-bet.has-right-bet .cwx-ticket { gap: 5px; padding-top: 6px; padding-bottom: 8px; }
  .cwx.is-running .has-left-bet.has-right-bet .cwx-ticket > .cwx-action { min-height: 56px; }
  .cwx.is-running .has-left-bet.has-right-bet .cwx-target { height: 12px; }
  .cwx.is-running .has-left-bet.has-right-bet .cwx-target span { display: none; }
}

/* ─── Portrait phone ─── */
@media (orientation: portrait), (max-height: 560px) {
  .cwx-history { align-self: stretch; }
}

@media (orientation: portrait) {
  .cwx {
    --pad: 6px;
    --gap: 6px;
    /* Portrait shows the left 3/4 of the 1920x1080 scene: main.js draws its round screen for
       exactly that crop (getBootVisibleWidth). The multiplier HUD layer is re-centred on it. */
    --canvas-w: 133.333%;
    --canvas-x: 0%;
    --hud-x: -16.667%;
    --canvas-w-cq: 133.333cqw;
    --stage-h: min(calc((100vw - 12px) * 3 / 4), calc(100dvh - 480px));
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(160px, var(--stage-h)) auto minmax(0, 1fr);
    grid-template-areas:
      "brand   brand   controls"
      "stage   stage   stage"
      "balance history history"
      "dock    dock    dock";
  }
  .cwx-brand { padding: 2px 6px 2px 2px; background: linear-gradient(180deg, #020306, #000); }
  .cwx-logo { width: auto; height: clamp(48px, 7.4vh, 74px); max-height: none; max-width: 100%; }
  .cwx-controls { gap: 6px; }
  .cwx-icon { width: 44px; height: 44px; }
  .cwx-quit { height: 44px; padding: 0 10px 0 8px; }
  .cwx-quit__label { font-size: 15px; }
  .cwx-stage-fit {
    width: min(100cqw, 100cqh * 4 / 3);
    height: min(100cqh, 100cqw * 3 / 4);
  }
  .cwx-balance {
    grid-template-columns: auto;
    grid-template-rows: auto auto;
    padding: 6px 10px 7px;
    row-gap: 3px;
  }
  .cw-player-name { display: none; }
  .cw-balance-value { margin-top: 0; padding: 4px 8px 3px; }
  .cwx-amount { font-size: 22px; }
  .cwx-currency { font-size: 11px; }
  .cwx-balance__label { font-size: 11px; }
  .cw-result-slip { min-width: 44px; padding: 5px 7px 4px; font-size: 14px; }

  /* Ticket: two big fields side by side, the action button grows into the thumb zone */
  .cwx-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .cwx-field { padding: 7px 7px 8px; }
  .cwx-field .cw-stepper { height: 52px; grid-template-columns: 40px minmax(0, 1fr) 40px; gap: 4px; }
  .cw-bet-input { font-size: 24px; }
  .cw-preset-row { gap: 3px; }
  .cw-preset { height: 40px; font-size: 14px; }
  .cwx-ticket > .cwx-action { flex: 1 1 auto; min-height: 72px; max-height: 116px; }
  .cwx-action__label { font-size: 28px; }
  .cwx-action__sub { font-size: 16px; }
  .cwx-action--cash .cwx-action__sub { font-size: 24px; }
  .cwx-summary__cell b { font-size: 26px; }
}
@media (orientation: portrait) and (min-height: 820px) {
  .cwx-chat-peek:not([hidden]) {
    appearance: none;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex: 0 0 auto;
    min-width: 0;
    height: 34px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    background: linear-gradient(180deg, #0a0e15, #0d121a);
    box-shadow: inset 0 2px 4px rgb(0 0 0 / .7), inset 0 0 0 1px rgb(39 214 198 / .25);
    line-height: 34px;
  }
  .cwx-chat-peek b { flex: 0 0 auto; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--teal); font: 800 14px/34px var(--f-ui); }
  .cwx-chat-peek span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font: 600 15px/34px var(--f-ui); }
}
@media (orientation: portrait) and (max-height: 700px) {
  .cwx { --stage-h: min(calc((100vw - 12px) * 3 / 4), calc(100dvh - 400px)); }
  .cwx-field .cw-stepper { height: 44px; }
  .cw-preset { height: 32px; }
  .cwx-field--auto .cw-preset-row { display: none; }
  .cwx-ticket > .cwx-action { min-height: 60px; }
}

/* ─── Landscape phone: stage left (full height), control column right ─── */
@media (orientation: landscape) and (max-height: 560px) {
  .cwx {
    --pad: 6px;
    --gap: 6px;
    --stage-w: min(calc(100vw - 300px - 3 * var(--pad)), calc((100dvh - 2 * var(--pad)) * 16 / 9));
    grid-template-columns: var(--stage-w) auto minmax(0, 1fr) auto;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "stage brand   brand   controls"
      "stage balance history history"
      "stage dock    dock    dock";
  }
  .cwx-brand { padding: 2px 4px; background: linear-gradient(180deg, #020306, #000); }
  .cwx-logo { width: auto; height: 38px; max-width: 100%; }
  .cwx-controls { gap: 5px; }
  .cwx-icon { width: 38px; height: 38px; border-radius: 11px; }
  .cwx-icon svg { width: 20px; height: 20px; }
  .cwx-quit { height: 38px; padding: 0 8px; border-radius: 11px; }
  .cwx-quit__label { display: none; }
  .cwx-balance { grid-template-columns: auto; padding: 4px 8px 5px; row-gap: 2px; }
  .cw-player-name { display: none; }
  .cwx-balance__label { font-size: 10px; letter-spacing: .16em; }
  .cw-balance-value { margin: 0; padding: 3px 7px 2px; }
  .cwx-amount { font-size: 19px; }
  .cwx-currency { font-size: 10px; }
  .cwx-history { padding: 0 5px; }
  .cw-results-strip { padding: 4px 0 6px; gap: 4px; }
  .cw-result-slip { min-width: 40px; padding: 4px 6px 3px; font-size: 13px; }
  .cwx-stage-fit { border-radius: 12px; padding: 2px; }
  .cw-stage-frame { border-radius: 10px; }

  .cw-portrait-bet-tab, .cw-portrait-chat-toggle { height: 34px; font-size: 14px; padding: 0 9px; }
  .cw-portrait-chat-toggle span { display: none; }
  .cwx-ticket { padding: 6px 8px 8px; gap: 6px; }
  .cwx-field { padding: 5px 6px 6px; gap: 4px; }
  .cwx-field__top { min-height: 20px; font-size: 11px; letter-spacing: .1em; }
  .cwx-switch__track { width: 36px; height: 20px; }
  .cwx-switch__knob { width: 14px; height: 14px; }
  .cwx-switch.is-on .cwx-switch__knob { transform: translateX(16px); }
  .cw-stepper { height: 38px; grid-template-columns: 32px minmax(0, 1fr) 32px; gap: 4px; }
  .cw-stepper-btn { font-size: 22px; border-radius: 8px; }
  .cw-bet-input { font-size: 20px; border-radius: 8px; }
  .cw-preset-row { gap: 3px; }
  .cw-preset { height: 28px; font-size: 13px; border-radius: 7px; }
  .cwx-action { min-height: 56px; border-radius: 13px; }
  .cwx-action__label { font-size: 21px; }
  .cwx-action__sub { font-size: 13px; }
  .cwx-action--cash .cwx-action__sub { font-size: 16px; }
  .cwx-summary { padding: 4px 8px; }
  .cwx-summary__cell b { font-size: 18px; }
  .cwx-ticket__name { font-size: 15px; }
  .cwx-ticket__status { font-size: 10px; }
}
/* Narrow control column: stake and auto side by side, stake chips on one full row */
@media (orientation: landscape) and (max-height: 560px) {
  .cwx-fields {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "st at" "ss as" "sp sp";
    gap: 4px 6px;
    padding: 5px 6px 6px;
    border-radius: 11px;
    background: linear-gradient(180deg, #0a0e15, #0d121a);
    box-shadow: inset 0 2px 4px rgb(0 0 0 / .7);
  }
  .cwx-field { display: contents; }
  .cwx-field--stake .cwx-field__top { grid-area: st; }
  .cwx-field--stake .cw-stepper { grid-area: ss; }
  .cwx-field--stake .cw-preset-row { grid-area: sp; }
  .cwx-field--auto .cwx-field__top { grid-area: at; }
  .cwx-field--auto .cw-stepper { grid-area: as; }
  .cwx-field--auto .cw-preset-row { display: none; }
  .cwx-field__top em { display: none; }
}


/* ─── Desktop variants ─── */
@media (orientation: landscape) and (min-height: 561px) and (max-height: 760px) {
  .cwx {
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "brand   history controls"
      "balance stage   stage"
      "dock    stage   stage";
  }
  .cwx-logo { max-height: 64px; }
  .cwx-ticket > .cwx-action { max-height: 96px; }
}
@media (orientation: landscape) and (min-height: 761px) {
  .cw-bet-card { flex: 0 0 auto; }
  .cw-portrait-chat-toggle { display: none !important; }
  .cwx-dock-bar { grid-template-columns: minmax(0, 1fr) !important; }
}
/* Narrow left column: stake and auto side by side, stake chips on one full row */
@media (orientation: landscape) {
  @container (max-width: 379px) {
    .cwx-fields {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      grid-template-areas: "st at" "ss as" "sp sp";
      gap: 4px 6px;
      padding: 6px 7px 7px;
      border-radius: 11px;
      background: linear-gradient(180deg, #0a0e15, #0d121a);
      box-shadow: inset 0 2px 4px rgb(0 0 0 / .7);
    }
    .cwx-field { display: contents; }
    .cwx-field--stake .cwx-field__top { grid-area: st; }
    .cwx-field--stake .cw-stepper { grid-area: ss; }
    .cwx-field--stake .cw-preset-row { grid-area: sp; }
    .cwx-field--auto .cwx-field__top { grid-area: at; }
    .cwx-field--auto .cw-stepper { grid-area: as; }
    .cwx-field--auto .cw-preset-row { display: none; }
    .cwx-field__top em { display: none; }
    .cw-stepper { grid-template-columns: 34px minmax(0, 1fr) 34px; gap: 4px; }
  }
}

/* ─── Large desktop: a little more air ─── */
@media (min-width: 1500px) and (min-height: 820px) {
  .cwx { --pad: 12px; --gap: 12px; }
  .cwx-action { min-height: 78px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

@media (orientation: landscape) and (max-height: 560px) {
  .cw-settings-panel { padding: 10px 14px 10px; }
  .cw-settings-header { margin-bottom: 8px; }
  .cw-settings-header h2 { font-size: 22px; margin-top: 2px; }
  .cw-settings-close { width: 40px; height: 40px; }
  .cw-settings-actions { margin-top: 8px; }
  .cw-settings-block { padding: 8px 12px 10px; }
  .cw-settings-row { min-height: 34px; }
}
@media (orientation: landscape) and (min-height: 561px) {
  .cwx-stage { place-items: start center; }
}
