:root {
  --page: #050908;
  --page-2: #0a1410;
  --felt: #0d5f3f;
  --felt-deep: #073925;
  --felt-light: #16815a;
  --rail: #21170f;
  --rail-light: #624322;
  --gold: #e8c45c;
  --gold-bright: #ffe69a;
  --text: #f8fafc;
  --muted: #b8c4be;
  --panel: #101b18;
  --panel-2: #172620;
  --white: #fff;
  --black: #101318;
  --red: #c93c3c;
  --red-dark: #7d2020;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --header-height: 4rem;
  --radius-sm: .55rem;
  --radius-md: .9rem;
  --radius-lg: 1.5rem;
  --shadow: 0 1.2rem 3rem rgba(0,0,0,.45);
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; }
body, h1, h2, h3, p, ul { margin: 0; }
button, input, select { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .38; filter: saturate(.55); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: .18rem solid var(--gold-bright);
  outline-offset: .18rem;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -20%, rgba(24,129,90,.22), transparent 48%),
    linear-gradient(180deg, var(--page-2), var(--page));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.35;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 999;
  padding: .65rem .9rem;
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--black);
}
.skip-link:focus { top: .75rem; }

/* Header */
.casino-header {
  position: relative;
  z-index: 20;
  min-height: var(--header-height);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: .5rem clamp(.75rem,2vw,1.5rem);
  border-bottom: 1px solid rgba(255,255,255,.09);
  background: rgba(4,10,8,.94);
  box-shadow: 0 .45rem 1.5rem rgba(0,0,0,.25);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  width: max-content;
  color: var(--gold-bright);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 900;
  font-size: clamp(1rem,2vw,1.35rem);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  aspect-ratio: 1;
  border: 1px solid rgba(232,196,92,.55);
  border-radius: 50%;
  background: rgba(232,196,92,.1);
}

.header-bankroll {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .35rem 1rem;
  border: 1px solid rgba(232,196,92,.26);
  border-radius: 999px;
  background: rgba(255,255,255,.035);
}
.bankroll-item { display: grid; text-align: center; min-width: 6.8rem; }
.bankroll-label { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; }
.bankroll-item strong { color: var(--gold-bright); font-size: .95rem; }
.bankroll-divider { width: 1px; height: 1.8rem; background: rgba(255,255,255,.14); }

.utility-nav { display: flex; justify-content: flex-end; gap: .4rem; }
.utility-button {
  min-width: 2.5rem;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .45rem .65rem;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: .7rem;
  background: rgba(255,255,255,.045);
  color: var(--text);
}
.utility-button:hover { background: rgba(255,255,255,.1); }
.utility-label { font-size: .78rem; }

/* Full-screen table */
.casino-stage {
  height: calc(100dvh - var(--header-height));
  min-height: 35rem;
  padding: clamp(.45rem,1.2vw,.8rem);
}

.casino-table {
  position: relative;
  isolation: isolate;
  height: 100%;
  max-width: 92rem;
  margin-inline: auto;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(9rem,1fr) auto minmax(9rem,1.05fr) auto;
  gap: clamp(.25rem,.7vh,.6rem);
  padding: clamp(.65rem,1.4vw,1.15rem) clamp(.7rem,2vw,1.5rem);
  border: clamp(.35rem,.7vw,.65rem) solid var(--rail);
  border-radius: clamp(1.5rem,3vw,3rem);
  background:
    radial-gradient(ellipse at 50% 48%, rgba(35,159,108,.75) 0%, var(--felt) 36%, var(--felt-deep) 100%);
  box-shadow:
    inset 0 0 0 .14rem var(--rail-light),
    inset 0 0 4rem rgba(0,0,0,.4),
    var(--shadow);
}
.casino-table::before {
  content: "";
  position: absolute;
  inset: .7rem;
  z-index: -1;
  border: 1px solid rgba(232,196,92,.28);
  border-radius: calc(clamp(1.5rem,3vw,3rem) - .55rem);
  pointer-events: none;
}
.casino-table::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  opacity: .18;
  background-image: repeating-radial-gradient(circle at 40% 40%, rgba(255,255,255,.08) 0 1px, transparent 1px 4px);
  pointer-events: none;
}

.table-branding {
  position: absolute;
  left: 50%;
  top: 45%;
  z-index: -1;
  transform: translate(-50%,-50%);
  text-align: center;
  text-transform: uppercase;
  color: rgba(255,255,255,.11);
  pointer-events: none;
}
.table-branding span { display: block; font-weight: 900; font-size: clamp(2rem,6vw,6rem); letter-spacing: .09em; }
.table-branding small { font-size: clamp(.55rem,1vw,.78rem); letter-spacing: .14em; }

.table-zone {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
}
.zone-heading {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .7rem;
  min-height: 1.75rem;
}
.zone-heading h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.score-badge {
  padding: .16rem .55rem;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  background: rgba(0,0,0,.22);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
}
.score-badge span { display: inline-block; min-width: 1.2rem; color: var(--white); text-align: center; }
.score-pop { animation: score-pop 300ms ease; }
@keyframes score-pop { 50% { transform: scale(1.35); color: var(--gold-bright); } }

.card-row {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .1rem .5rem;
}
.playing-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  flex: 0 0 clamp(4.7rem,7.3vh,6rem);
  width: clamp(4.7rem,7.3vh,6rem);
  height: clamp(6.75rem,10.4vh,8.5rem);
  padding: clamp(.36rem,.7vh,.52rem);
  border: .12rem solid #e5e7eb;
  border-radius: clamp(.45rem,.7vh,.65rem);
  background: var(--white);
  color: var(--black);
  box-shadow: 0 .45rem .9rem rgba(0,0,0,.32);
  transform-style: preserve-3d;
}
.playing-card + .playing-card { margin-left: clamp(-2rem,-2.5vw,-1.2rem); }
.playing-card.red { color: var(--red); }
.card-corner { font-size: clamp(.74rem,1.25vh,.95rem); font-weight: 900; line-height: .9; }
.card-corner:last-child { align-self: end; justify-self: end; transform: rotate(180deg); }
.card-suit { display: grid; place-items: center; font-size: clamp(1.7rem,3.2vh,2.5rem); }
.playing-card.card-back {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(45deg, transparent 42%, rgba(255,255,255,.15) 42% 58%, transparent 58%),
    repeating-linear-gradient(45deg,var(--red-dark) 0,var(--red-dark) .42rem,var(--red) .42rem,var(--red) .84rem);
}
.playing-card.card-back::after { content: ""; position: absolute; inset: .38rem; border: .13rem solid rgba(255,255,255,.9); border-radius: .32rem; }
.playing-card.is-dealing { opacity: 0; transform: translate(5rem,-3rem) rotate(9deg) scale(.9); animation: deal-card 350ms ease-out forwards; pointer-events: none; }
@keyframes deal-card { to { opacity: 1; transform: translate(0) rotate(0) scale(1); } }
.playing-card.is-flipping { animation: flip-card 520ms ease; }
@keyframes flip-card { 50% { transform: rotateY(90deg); } 100% { transform: rotateY(0); } }

.player-hands {
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: clamp(.35rem,1vw,.85rem);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.player-hand {
  min-width: min(100%,22rem);
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  padding: .28rem .55rem .1rem;
  border: 1px solid transparent;
  border-radius: .9rem;
  background: rgba(0,0,0,.08);
}
.player-hand.is-active { border-color: rgba(232,196,92,.72); background: rgba(232,196,92,.075); box-shadow: 0 0 0 .12rem rgba(232,196,92,.12); }
.player-hand-heading { display: flex; justify-content: center; align-items: center; gap: .5rem; font-size: .72rem; }
.player-hand-heading h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.hand-result { color: var(--muted); text-transform: capitalize; }
.player-hand .card-row { height: 100%; }

.game-status {
  justify-self: center;
  width: min(92%,42rem);
  min-height: 2.35rem;
  display: grid;
  place-items: center;
  padding: .35rem .8rem;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  background: rgba(1,15,9,.72);
  box-shadow: 0 .3rem 1rem rgba(0,0,0,.16);
  text-align: center;
  font-size: clamp(.78rem,1.4vw,.95rem);
  font-weight: 750;
}
.game-status.is-success { border-color: rgba(34,197,94,.55); background: rgba(17,94,50,.76); }
.game-status.is-error { border-color: rgba(239,68,68,.55); background: rgba(127,29,29,.78); }
.game-status.is-warning { border-color: rgba(245,158,11,.55); background: rgba(113,63,18,.78); }
.game-status.result-win { animation: result-pulse 650ms ease; }
.game-status.result-blackjack { animation: blackjack-burst 900ms ease; }
.game-status.result-lose { animation: result-shake 450ms ease; }
.game-status.result-push { animation: result-pulse 500ms ease; }
@keyframes result-pulse { 50% { transform: scale(1.035); } }
@keyframes blackjack-burst { 35% { transform: scale(1.08); box-shadow: 0 0 2rem rgba(232,196,92,.65); } }
@keyframes result-shake { 25%,75% { transform: translateX(-.35rem); } 50% { transform: translateX(.35rem); } }

/* Bottom console */
.table-console {
  min-height: 4.65rem;
  display: grid;
  grid-template-columns: minmax(20rem,.85fr) minmax(28rem,1.45fr);
  gap: clamp(.5rem,1.2vw,1rem);
  padding: .5rem .65rem;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 1.15rem;
  background: rgba(4,15,11,.84);
  box-shadow: 0 -.4rem 1.5rem rgba(0,0,0,.16);
  backdrop-filter: blur(10px);
}
.bet-console { display: flex; align-items: center; justify-content: center; gap: clamp(.45rem,1vw,.85rem); min-width: 0; }
.bet-spot {
  position: relative;
  flex: 0 0 4rem;
  height: 3.2rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(232,196,92,.5);
  border-radius: 50%;
  color: rgba(232,196,92,.8);
}
.bet-spot-label { position: absolute; font-size: .6rem; text-transform: uppercase; letter-spacing: .1em; }
.visual-chip-stack { min-height: 1.8rem; display: flex; justify-content: center; align-items: flex-end; }
.mini-chip { width: 1.65rem; height: .45rem; border-radius: 50%; border: 2px dashed rgba(255,255,255,.8); margin-left: -1rem; box-shadow: 0 .15rem .25rem rgba(0,0,0,.35); }
.mini-chip:first-child { margin-left: 0; }

.chip-controls { display: flex; align-items: center; justify-content: center; gap: clamp(.25rem,.65vw,.5rem); }
.chip-button {
  width: clamp(2.65rem,4vw,3.25rem);
  height: clamp(2.65rem,4vw,3.25rem);
  border: .24rem dashed rgba(255,255,255,.82);
  border-radius: 50%;
  color: var(--white);
  font-size: clamp(.7rem,1vw,.82rem);
  font-weight: 900;
  box-shadow: inset 0 0 0 .16rem rgba(0,0,0,.2), 0 .25rem .55rem rgba(0,0,0,.28);
  transition: transform 150ms ease, filter 150ms ease;
}
.chip-button:hover:not(:disabled) { transform: translateY(-.18rem); filter: brightness(1.15); }
.chip-5 { background: #c93c3c; }
.chip-10 { background: #2563eb; }
.chip-25 { background: #15803d; }
.chip-50 { background: #7e22ce; }
.chip-100 { background: #111827; }
.text-action { padding: .35rem; background: transparent; color: var(--muted); font-size: .72rem; text-decoration: underline; text-underline-offset: .18rem; }

.game-controls { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); align-items: center; gap: clamp(.28rem,.6vw,.5rem); }
.action-button {
  min-height: 2.75rem;
  padding: .48rem .65rem;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: .72rem;
  color: var(--white);
  font-size: clamp(.72rem,1.1vw,.86rem);
  font-weight: 850;
  white-space: nowrap;
  transition: transform 140ms ease, filter 140ms ease, background 140ms ease;
}
.action-button:hover:not(:disabled) { transform: translateY(-.1rem); filter: brightness(1.08); }
.action-primary { background: #19623f; }
.action-secondary { background: #263d34; }
.action-muted { background: #3b4650; }
.action-deal { background: linear-gradient(180deg,var(--gold-bright),var(--gold)); color: #182019; border-color: rgba(255,255,255,.35); }

.decision-panel {
  position: absolute;
  left: 50%;
  bottom: 5.8rem;
  z-index: 15;
  width: min(92%,38rem);
  transform: translateX(-50%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1rem;
  border: 1px solid rgba(232,196,92,.6);
  border-radius: 1rem;
  background: rgba(9,20,16,.97);
  box-shadow: var(--shadow);
}
.decision-panel[hidden] { display: none; }
.decision-panel h2 { color: var(--gold-bright); font-size: 1rem; }
.decision-panel p { color: var(--muted); font-size: .78rem; }
.decision-actions { display: flex; gap: .5rem; }

/* Dialogs */
.app-dialog {
  width: min(100% - 1.5rem,32rem);
  max-height: min(84dvh,46rem);
  overflow: auto;
  padding: 1.2rem;
  border: 1px solid rgba(232,196,92,.22);
  border-radius: 1.25rem;
  background: linear-gradient(180deg,#14231d,#0c1512);
  color: var(--text);
  box-shadow: var(--shadow);
}
.app-dialog::backdrop { background: rgba(0,0,0,.76); backdrop-filter: blur(5px); }
.app-dialog-wide { width: min(100% - 1.5rem,52rem); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.dialog-heading h2 { color: var(--gold-bright); }
.dialog-eyebrow { margin-bottom: .15rem; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .13em; }
.dialog-close { width: 2.35rem; height: 2.35rem; border-radius: 50%; background: rgba(255,255,255,.09); color: var(--white); font-size: 1.35rem; }
.field-label { display: block; margin-bottom: .35rem; font-weight: 750; }
select { width: 100%; padding: .7rem; margin-bottom: 1rem; border: 1px solid rgba(255,255,255,.18); border-radius: .65rem; background: #09120f; color: var(--white); }
.check-row { display: flex; align-items: center; gap: .65rem; margin-block: .75rem; }
.check-row input { width: 1.1rem; height: 1.1rem; accent-color: var(--gold); }
.dialog-note, .shortcut-note { margin-top: 1rem; color: var(--muted); font-size: .85rem; }
.rules-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .65rem; }
.rules-grid article, .stat-card { padding: .8rem; border: 1px solid rgba(255,255,255,.1); border-radius: .8rem; background: rgba(255,255,255,.035); }
.rules-grid strong { display: block; margin-bottom: .25rem; color: var(--gold-bright); }
.rules-grid p { color: var(--muted); font-size: .82rem; }
.statistics-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(8.5rem,1fr)); gap: .65rem; margin-bottom: 1rem; }
.stat-card span { display: block; color: var(--muted); font-size: .76rem; }
.stat-card strong { font-size: 1.25rem; color: var(--gold-bright); }

/* Short desktop screens */
@media (max-height: 760px) and (min-width: 760px) {
  :root { --header-height: 3.5rem; }
  .casino-header { padding-block: .3rem; }
  .brand-mark { width: 1.75rem; }
  .casino-table { grid-template-rows: minmax(7.2rem,1fr) auto minmax(7.2rem,1fr) auto; }
  .playing-card { flex-basis: clamp(4.15rem,7vh,5.2rem); width: clamp(4.15rem,7vh,5.2rem); height: clamp(5.95rem,10vh,7.35rem); }
  .table-console { min-height: 4rem; padding-block: .35rem; }
  .action-button { min-height: 2.35rem; }
  .chip-button { width: 2.65rem; height: 2.65rem; }
}

/* Tablet / narrow desktop */
@media (max-width: 900px) {
  .casino-header { grid-template-columns: 1fr auto; }
  .header-bankroll { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; justify-content: center; padding-block: .25rem; }
  :root { --header-height: 6.5rem; }
  .utility-label { display: none; }
  .casino-table { grid-template-rows: minmax(7.8rem,1fr) auto minmax(7.8rem,1fr) auto; }
  .table-console { grid-template-columns: 1fr; min-height: 7.8rem; gap: .35rem; }
  .bet-console { order: 2; }
  .game-controls { order: 1; }
}

/* Mobile */
@media (max-width: 620px) {
  :root { --header-height: 5.5rem; }
  body { overflow-y: auto; }
  .casino-header { grid-template-columns: 1fr auto; gap: .4rem; padding: .4rem .55rem; }
  .brand { font-size: .95rem; }
  .brand-mark { width: 1.7rem; }
  .header-bankroll { gap: .55rem; padding: .2rem .7rem; }
  .bankroll-item { min-width: 5.2rem; }
  .bankroll-label { font-size: .58rem; }
  .bankroll-item strong { font-size: .78rem; }
  .utility-button { min-width: 2.2rem; min-height: 2.2rem; padding: .35rem; }

  .casino-stage { height: auto; min-height: calc(100dvh - var(--header-height)); padding: .35rem; }
  .casino-table {
    min-height: calc(100dvh - var(--header-height) - .7rem);
    grid-template-rows: minmax(7rem,1fr) auto minmax(7rem,1fr) auto;
    padding: .55rem;
    border-width: .3rem;
    border-radius: 1.35rem;
  }
  .casino-table::before { inset: .42rem; border-radius: 1rem; }
  .table-branding { display: none; }
  .zone-heading { min-height: 1.4rem; }
  .zone-heading h2 { font-size: .65rem; }
  .score-badge { font-size: .62rem; }
  .playing-card { flex-basis: 4rem; width: 4rem; height: 5.75rem; padding: .3rem; }
  .playing-card + .playing-card { margin-left: -1.45rem; }
  .card-suit { font-size: 1.55rem; }
  .card-corner { font-size: .67rem; }
  .player-hand { min-width: 16rem; padding-inline: .3rem; }
  .game-status { width: 96%; min-height: 2rem; padding: .25rem .55rem; font-size: .72rem; }

  .table-console { min-height: 8.2rem; padding: .4rem; border-radius: .9rem; }
  .game-controls { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .action-button { min-height: 2.3rem; padding: .35rem .25rem; font-size: .68rem; }
  .bet-console { gap: .35rem; }
  .bet-spot { display: none; }
  .chip-controls { gap: .22rem; }
  .chip-button { width: 2.45rem; height: 2.45rem; border-width: .18rem; font-size: .66rem; }
  .text-action { font-size: .66rem; }
  .decision-panel { bottom: 8.8rem; width: calc(100% - 1rem); flex-direction: column; text-align: center; gap: .55rem; }
  .rules-grid { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .game-controls { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .table-console { min-height: 10.4rem; }
  .decision-panel { bottom: 10.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* =========================================================
   VERSION 3 SOUND CONTROLS
   ========================================================= */

.mute-button {
  border-color: rgba(232,196,92,.28);
  color: var(--gold-bright);
}

.mute-button.is-muted {
  border-color: rgba(239,68,68,.36);
  background: rgba(127,29,29,.28);
  color: #fecaca;
}

.volume-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: .95rem;
}

.volume-label output {
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
}

.volume-control {
  width: 100%;
  margin: .2rem 0 .8rem;
  accent-color: var(--gold);
}

.settings-preview {
  width: 100%;
  margin-bottom: .85rem;
}

@media (max-width: 620px) {
  .utility-nav { gap: .22rem; }
  .mute-button .utility-label { display: none; }
}
