:root {
  color-scheme: dark;
  --space-xs: clamp(4px, 0.8vh, 10px);
  --space-sm: clamp(6px, 1.1vh, 14px);
  --space-md: clamp(9px, 1.8vh, 22px);
  --tile-pad: clamp(6px, 1.35vh, 14px);
  --control-h: clamp(30px, 5vh, 48px);
  --chip-h: clamp(28px, 4.9vh, 44px);
  --stat-h: clamp(40px, 7.4vh, 72px);
  --record-h: clamp(44px, 7.8vh, 82px);
  --dial-w: clamp(96px, 19vh, 170px);
  --dial-h: clamp(54px, 10.8vh, 96px);
  --bg: #171818;
  --panel: #242726;
  --panel-2: #303531;
  --felt: #225f46;
  --felt-dark: #174532;
  --gold: #f0be54;
  --mint: #9de7c1;
  --ink: #f6f3eb;
  --muted: #b6b2a8;
  --danger: #e36f63;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(240, 190, 84, 0.18), transparent 32rem),
    linear-gradient(135deg, #101211, #232522 55%, #171818);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: clamp(12px, 1.6vw, 20px);
  width: min(1200px, calc(100% - 32px));
  height: calc(100vh - 32px);
  margin: 16px auto;
}

.table-area,
.control-panel {
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(36, 39, 38, 0.88);
  box-shadow: var(--shadow);
}

.table-area {
  display: grid;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
  border-radius: 8px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: var(--space-md) 24px;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: clamp(1.15rem, 2.6vh, 1.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: var(--space-xs);
  font-size: clamp(0.88rem, 1.4vh, 0.95rem);
  color: var(--mint);
}

.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font-size: 1.35rem;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: rgba(255, 255, 255, 0.1);
}

.status-strip div {
  padding: var(--space-sm) 20px;
  background: rgba(15, 17, 16, 0.45);
}

.label,
dt {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: clamp(0.68rem, 1.2vh, 0.78rem);
  font-weight: 700;
  text-transform: uppercase;
}

.status-strip strong,
dd {
  font-size: clamp(1rem, 2.2vh, 1.25rem);
  font-weight: 800;
}

.felt {
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  gap: var(--space-sm);
  min-height: 0;
  padding: var(--space-md) 24px;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.03) 0 2px, transparent 2px 18px),
    radial-gradient(circle at center, var(--felt), var(--felt-dark));
}

.hand-zone {
  min-height: clamp(135px, 21vh, 190px);
}

.hand-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 800;
}

.hand-heading strong {
  color: var(--gold);
  font-size: 1.3rem;
}

.cards {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  min-height: clamp(100px, 15vh, 132px);
}

.card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  width: clamp(62px, 8vw, 104px);
  aspect-ratio: 0.72;
  padding: 10px;
  border-radius: 8px;
  background: #faf6eb;
  color: #1d1d1b;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.25);
  transform: translateY(0);
  animation: dealIn 180ms ease-out both;
}

.card.red {
  color: #bd2d2d;
}

.card.back {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent),
    repeating-linear-gradient(45deg, #2c5f80 0 8px, #20455f 8px 16px);
  color: transparent;
}

.card-rank {
  font-size: 1.35rem;
  font-weight: 800;
}

.card-suit {
  display: grid;
  place-items: center;
  font-size: clamp(2.35rem, 4.4vh, 3rem);
}

.message-panel {
  display: grid;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: clamp(54px, 8.2vh, 70px);
  padding: var(--space-xs) 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  text-align: center;
}

.message-panel p {
  margin: 0;
  color: #fff7d8;
  font-size: clamp(0.92rem, 1.8vh, 1.08rem);
  font-weight: 800;
}

.message-panel .suggestion {
  color: var(--mint);
  font-size: 0.95rem;
}

.control-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel), #181a19);
}

.panel-section {
  padding: var(--space-xs) 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.bet-section,
.actions-section,
.statistics-section,
.records-section {
  display: flex;
  flex-direction: column;
}

.bet-section {
  flex: 0.7 1 11%;
  justify-content: center;
}

.actions-section {
  flex: 1.4 1 27%;
  justify-content: center;
}

.statistics-section {
  flex: 1.4 1 35%;
  justify-content: center;
}

.records-section {
  flex: 1.4 1 27%;
  justify-content: center;
  border-bottom: 0;
}

.bet-control {
  display: grid;
  gap: clamp(8px, 1.8vh, 16px);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.bet-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.chip {
  min-height: var(--chip-h);
  border: 2px dashed rgba(255, 255, 255, 0.32);
  border-radius: 50%;
  background: #a8323a;
  color: white;
  font-weight: 800;
}

.chip:disabled {
  cursor: not-allowed;
  filter: grayscale(0.6);
  opacity: 0.48;
}

.chip:nth-child(2) {
  background: #315eac;
}

.chip:nth-child(3) {
  background: #2d805f;
}

.chip:nth-child(4) {
  background: #33302c;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(8px, 1.5vh, 12px);
}

.action-grid button {
  min-height: var(--control-h);
  border-radius: 8px;
  background: var(--gold);
  color: #251d0e;
  font-weight: 900;
}

.action-grid button:disabled {
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.38);
}

.assist-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: var(--control-h);
  margin-top: clamp(8px, 1.5vh, 14px);
  padding: 0 14px;
  border-radius: 8px;
  background: rgba(157, 231, 193, 0.14);
  color: var(--ink);
  font-weight: 800;
}

.assist-toggle strong {
  color: var(--mint);
}

.assist-toggle[aria-pressed="false"] {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.assist-toggle[aria-pressed="false"] strong {
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(8px, 1.3vh, 12px);
  margin: clamp(8px, 1.3vh, 12px) 0 0;
}

.stats-grid-three {
  grid-template-columns: repeat(3, 1fr);
}

.stats-grid div,
.record-grid div,
.ratio-dial-card {
  padding: var(--tile-pad);
  border-radius: 8px;
  background: var(--panel-2);
}

.stats-grid div {
  display: grid;
  place-items: center;
  min-height: var(--stat-h);
  text-align: center;
}

dd {
  margin: 0;
}

.ratio-dial-card {
  display: grid;
  place-items: center;
  gap: clamp(6px, 1.2vh, 10px);
}

.ratio-dial {
  position: relative;
  display: grid;
  place-items: end center;
  width: var(--dial-w);
  height: var(--dial-h);
  overflow: hidden;
}

.ratio-dial::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  width: var(--dial-w);
  aspect-ratio: 2 / 1;
  border-radius: var(--dial-w) var(--dial-w) 0 0;
  background: conic-gradient(from 270deg at 50% 100%, var(--mint) var(--dial-fill, 0deg), rgba(227, 111, 99, 0.38) 0deg 180deg, transparent 180deg);
}

.ratio-dial::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 3px;
  height: calc(var(--dial-h) * 0.76);
  border-radius: 999px;
  background: var(--gold);
  transform: translateX(-50%) rotate(var(--dial-angle, -90deg));
  transform-origin: 50% 100%;
  box-shadow: 0 0 12px rgba(240, 190, 84, 0.5);
}

.ratio-dial div {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: calc(var(--dial-w) * 0.58);
  min-height: calc(var(--dial-h) * 0.68);
  padding-top: var(--space-xs);
  border-radius: calc(var(--dial-w) * 0.29) calc(var(--dial-w) * 0.29) 0 0;
  background: var(--panel-2);
}

.ratio-dial span,
.ratio-dial-card p,
.record-grid dt {
  color: var(--muted);
  font-size: clamp(0.72rem, 1.2vh, 0.82rem);
  font-weight: 700;
  text-transform: uppercase;
}

.ratio-dial strong {
  color: var(--mint);
  font-size: clamp(1.15rem, 2.4vh, 1.6rem);
  font-weight: 900;
}

.ratio-dial-card p {
  margin: 0;
  text-transform: none;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(8px, 1.3vh, 12px);
  margin: 0;
}

.record-grid div {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: var(--record-h);
  text-align: center;
}

.record-grid dd {
  color: var(--mint);
}

@keyframes dealIn {
  from {
    opacity: 0;
    transform: translateY(12px) rotate(2deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0);
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .game-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 32px);
  }

  .control-panel {
    overflow: visible;
  }
}

@media (max-width: 620px) {
  .game-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
  }

  .table-area,
  .control-panel {
    border-radius: 0;
  }

  .top-bar,
  .felt,
  .panel-section {
    padding: 16px;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .felt {
    min-height: 500px;
  }

  .card {
    width: 68px;
  }

  .bet-row {
    grid-template-columns: repeat(2, 1fr);
  }
}
