:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #fff;
  background: #171717;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, select { font: inherit; }
button { cursor: pointer; }

body[data-theme="kitchen"] {
  --room-bg: radial-gradient(circle at 50% 0%, #6b4a31 0%, #2d2119 48%, #16110d 100%);
  --table-bg: radial-gradient(circle at 50% 40%, #7a5537 0%, #5f4029 68%, #3f2b1d 100%);
  --table-edge: #281a12;
  --accent: #f0c27b;
  --accent-soft: rgba(240, 194, 123, .25);
}

body[data-theme="pub"] {
  --room-bg: radial-gradient(circle at 50% 0%, #4d2a20 0%, #241412 52%, #100a09 100%);
  --table-bg: radial-gradient(circle at 50% 40%, #4b2f23 0%, #352117 70%, #1f140f 100%);
  --table-edge: #160d0a;
  --accent: #e8a24b;
  --accent-soft: rgba(232, 162, 75, .24);
}

body[data-theme="casino"] {
  --room-bg: radial-gradient(circle at 50% 0%, #152a24 0%, #091713 55%, #050b09 100%);
  --table-bg: radial-gradient(circle at 50% 40%, #245a46 0%, #173f31 72%, #0e2b21 100%);
  --table-edge: #081a14;
  --accent: #e0c06b;
  --accent-soft: rgba(224, 192, 107, .22);
}

body {
  background: var(--room-bg);
  transition: background .25s ease;
}

.game-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 32px) 24px;
}

.topbar,
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  line-height: 1;
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.controls label {
  display: grid;
  gap: 4px;
  color: rgba(255,255,255,.68);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

select,
.statusbar button {
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  background: rgba(0,0,0,.28);
  color: #fff;
  padding: 9px 11px;
}

.room-stage {
  position: relative;
  overflow: hidden;
  margin-top: 18px;
  border-radius: 30px;
  min-height: 720px;
  background: rgba(0,0,0,.18);
  box-shadow: inset 0 0 70px rgba(0,0,0,.4), 0 24px 60px rgba(0,0,0,.3);
}

.ambient {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  filter: blur(4px);
  opacity: .24;
  pointer-events: none;
}

.ambient-left { left: 2%; top: 2%; background: var(--accent); }
.ambient-right { right: 2%; top: 4%; background: var(--accent); }

.table {
  position: absolute;
  inset: 7% 5% 4%;
  border: 18px solid var(--table-edge);
  border-radius: 46% 46% 38% 38% / 38% 38% 28% 28%;
  background: var(--table-bg);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.05), inset 0 0 70px rgba(0,0,0,.28), 0 18px 30px rgba(0,0,0,.42);
}

.seat {
  position: absolute;
  min-width: 0;
  text-align: center;
}

.seat-left { top: 5%; left: 7%; transform: rotate(7deg); }
.seat-right { top: 5%; right: 7%; transform: rotate(-7deg); }
.seat-player {
  left: 50%;
  bottom: 1%;
  width: min(820px, 94%);
  transform: translateX(-50%);
  z-index: 5;
}

.nameplate {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  border-radius: 999px;
  background: rgba(0,0,0,.35);
  padding: 6px 10px;
  font-weight: 800;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}

.self-nameplate { margin-top: 2px; }

.active .nameplate {
  box-shadow: 0 0 0 2px var(--accent), 0 0 24px var(--accent-soft);
}

.turn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.card-row,
.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(4px, .7vw, 9px);
}

.opponent-hand { margin-bottom: 8px; }
.face-row { position: relative; }
.face-stack { position: relative; width: 52px; height: 72px; }
.face-stack .card { position: absolute; inset: 0; }
.face-stack .card:first-child { transform: translate(4px, 4px); }

.card {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(46px, 6vw, 70px);
  aspect-ratio: 0.71;
  border: 1px solid rgba(0,0,0,.25);
  border-radius: 8px;
  background: #f7f4ed;
  color: #111;
  font-weight: 900;
  font-size: clamp(1rem, 2.2vw, 1.6rem);
  box-shadow: 0 3px 8px rgba(0,0,0,.28);
  user-select: none;
}

.card.red { color: #c51f2d; }
.card.small { width: 46px; font-size: 1rem; }
.card-back {
  background:
    linear-gradient(45deg, rgba(255,255,255,.08) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.08) 75%),
    linear-gradient(45deg, rgba(255,255,255,.08) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.08) 75%),
    #242b4c;
  background-size: 12px 12px;
  background-position: 0 0, 6px 6px;
  border: 4px solid #e8e5dc;
}

.self-table-zone {
  display: grid;
  justify-items: center;
  gap: 7px;
  margin-bottom: 6px;
}

.self-face-row {
  min-height: 92px;
}

.self-face-row .face-stack {
  width: 66px;
  height: 92px;
}

.self-face-row .card {
  width: 66px;
}

.hand {
  position: relative;
  min-height: 132px;
  padding: 18px 18px 0;
  gap: 0;
  overflow: visible;
}

.hand button.card {
  appearance: none;
  width: clamp(68px, 7vw, 86px);
  flex: 0 0 clamp(68px, 7vw, 86px);
  margin-left: -8px;
  padding: 0;
  font-size: clamp(1.25rem, 2.4vw, 1.75rem);
  transform-origin: 50% 115%;
  transform: rotate(calc((var(--card-index) - var(--card-mid)) * 2deg));
  transition: transform .14s ease, box-shadow .14s ease, filter .14s ease;
  z-index: calc(20 + var(--card-index));
}

.hand button.card:first-child { margin-left: 0; }

.hand button.card:hover,
.hand button.card:focus-visible {
  transform: translateY(-14px) rotate(0deg) scale(1.04);
  outline: none;
  box-shadow: 0 16px 28px rgba(0,0,0,.38), 0 0 0 3px var(--accent);
  z-index: 60;
}

.hand button.card.selected {
  transform: translateY(-22px) rotate(0deg) scale(1.05);
  box-shadow: 0 16px 28px rgba(0,0,0,.42), 0 0 0 4px var(--accent);
  z-index: 70;
}

.player-label {
  margin: 0;
  color: rgba(255,255,255,.62);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .14em;
}

.play-actions {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
}

.play-actions.visible {
  opacity: 1;
  pointer-events: auto;
}

.play-selected {
  min-width: 86px;
  min-height: 42px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 999px;
  background: rgba(0,0,0,.68);
  color: #fff;
  padding: 9px 18px;
  font-weight: 900;
  letter-spacing: .08em;
  box-shadow: 0 8px 20px rgba(0,0,0,.28);
}

.play-selected:hover,
.play-selected:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(0,0,0,.34), 0 0 0 3px var(--accent-soft);
}

.selection-hint {
  color: rgba(255,255,255,.68);
  font-size: .76rem;
}

.centre-zone {
  position: absolute;
  left: 50%;
  top: 40%;
  display: flex;
  gap: 52px;
  align-items: center;
  transform: translate(-50%, -50%);
  z-index: 3;
}

.centre-zone::before {
  content: "";
  position: absolute;
  inset: -28px -38px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  background: rgba(0,0,0,.08);
  z-index: -1;
}

.pile {
  position: relative;
  width: 76px;
  min-height: 108px;
  border: 0;
  background: transparent;
  padding: 0;
}

.pile .card { width: 76px; }
.pile-draw .stacked::before,
.pile-draw .stacked::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  border: inherit;
  z-index: -1;
}
.pile-draw .stacked::before { transform: translate(-4px, 3px); }
.pile-draw .stacked::after { transform: translate(-8px, 6px); }

.empty-pile {
  opacity: .16;
  border: 2px dashed rgba(255,255,255,.4);
  background: transparent;
  box-shadow: none;
}

.pile-count {
  position: absolute;
  right: -10px;
  bottom: -8px;
  min-width: 28px;
  border-radius: 999px;
  background: rgba(0,0,0,.75);
  color: #fff;
  padding: 4px 7px;
  font-size: .72rem;
  font-weight: 800;
}

.pile-wrap { display: grid; justify-items: center; gap: 6px; }
.pile-label { color: rgba(255,255,255,.65); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }

.statusbar {
  margin-top: 14px;
  min-height: 44px;
  color: rgba(255,255,255,.8);
}
.statusbar p { margin: 0; }
.statusbar button { border-color: var(--accent); }

@media (max-width: 700px) {
  .game-shell { padding-inline: 8px; }
  .topbar { align-items: flex-start; }
  .controls { gap: 6px; }
  .controls label { font-size: .62rem; }
  select { max-width: 128px; padding: 7px 8px; }
  .room-stage { min-height: 650px; border-radius: 18px; }
  .table { inset: 5% 2.5% 2%; border-width: 11px; border-radius: 44% 44% 28% 28% / 26% 26% 20% 20%; }
  .seat-left { left: 2%; top: 5%; }
  .seat-right { right: 2%; top: 5%; }
  .seat-opponent .card-row { gap: 2px; }
  .seat-opponent .card { width: 39px; border-radius: 6px; font-size: .9rem; }
  .seat-opponent .face-stack { width: 39px; height: 58px; }
  .seat-player { width: 98%; bottom: 0; }
  .centre-zone { top: 36%; gap: 28px; }
  .centre-zone::before { inset: -20px -24px; }
  .pile, .pile .card { width: 58px; min-height: 83px; }
  .self-table-zone { margin-bottom: 0; }
  .self-face-row { min-height: 76px; }
  .self-face-row .face-stack { width: 54px; height: 76px; }
  .self-face-row .card { width: 54px; }
  .hand {
    min-height: 118px;
    overflow-x: auto;
    overflow-y: visible;
    justify-content: flex-start;
    padding: 24px 18px 0;
    scroll-snap-type: x proximity;
  }
  .hand button.card {
    flex: 0 0 68px;
    width: 68px;
    margin-left: -10px;
    scroll-snap-align: center;
    transform: none;
  }
  .hand button.card:first-child { margin-left: 0; }
  .hand button.card.selected { transform: translateY(-16px) scale(1.03); }
  .player-label { margin-top: 0; }
  .play-actions { min-height: 42px; }
  .selection-hint { display: none; }
  .statusbar { padding-inline: 4px; font-size: .86rem; }
}
