:root {
  color-scheme: dark;
  --bg: #07110f;
  --panel: #10231f;
  --felt: #126044;
  --felt-dark: #08362b;
  --rail: #432817;
  --line: rgba(255, 255, 255, 0.14);
  --text: #f7f2e8;
  --muted: #b9c8c0;
  --gold: #efc75e;
  --purple: #b78cff;
  --coral: #ff7b6b;
  --red: #d84c4c;
  --black: #15191a;
  --danger: #e76060;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -8rem, rgba(239, 199, 94, 0.18), transparent 20rem),
    linear-gradient(150deg, #06100e, #112720 58%, #07110f);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  padding: 0 12px;
  background: #f4f0e8;
  color: #10231f;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
  transition: opacity 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.04);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

button.primary,
#newHand:not(:disabled) {
  background: linear-gradient(145deg, #f7d76d, #d59b32);
  color: #241703;
}

#checkCall:not(:disabled) {
  background: linear-gradient(145deg, #77e0a0, #27985d);
  color: #041b10;
}

#raise:not(:disabled) {
  background: linear-gradient(145deg, #ffca72, #e07d2f);
  color: #261000;
}

#allIn:not(:disabled) {
  background: linear-gradient(145deg, #d7b3ff, #7e45c6);
  color: #180829;
}

#fold {
  background: #2b1718;
  color: #ffd8d8;
}

#fold:not(:disabled):hover {
  background: var(--danger);
  color: #1b0c0c;
}

.app-shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

.table-area {
  display: block;
}

.seat-name,
.seat-meta,
.message,
h2,
p {
  margin: 0;
}

.status-strip span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.setup-panel {
  display: grid;
  grid-template-columns: auto minmax(96px, 1fr);
  gap: 8px;
  align-items: end;
}

.setup-panel label {
  display: grid;
  gap: 5px;
  align-self: center;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.setup-panel button {
  grid-column: 1 / -1;
}

select {
  min-height: 48px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: #0c1c19;
  color: var(--text);
}

.felt {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  gap: 10px;
  min-height: calc(100vh - 16px);
  overflow: hidden;
  border: 5px solid var(--rail);
  border-radius: 22px;
  padding: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 78%);
  background-size: 24px 24px, 24px 24px, auto;
  box-shadow: inset 0 0 0 3px rgba(239, 199, 94, 0.22), 0 20px 54px rgba(0, 0, 0, 0.36);
}

.table-hud {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  position: relative;
  z-index: 3;
}

.game-name {
  align-self: stretch;
  display: grid;
  place-items: center start;
  min-width: 126px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(7, 16, 15, 0.58);
  padding: 9px 10px;
  color: var(--gold);
  font-weight: 950;
  letter-spacing: 0;
  backdrop-filter: blur(12px);
}

.setup-panel {
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(7, 16, 15, 0.58);
  padding: 9px 10px;
  backdrop-filter: blur(12px);
}

.setup-panel {
  grid-column: auto;
}

.action-ticker {
  position: relative;
  top: auto;
  left: auto;
  z-index: 2;
  width: 100%;
  transform: none;
  border: 1px solid rgba(239, 199, 94, 0.3);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(7, 16, 15, 0.7);
  color: #fff7d8;
  font-size: 0.83rem;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  animation: floatIn 240ms ease both;
}

.cpu-seats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.seat,
.player-zone,
.status-strip {
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(7, 16, 15, 0.56);
  backdrop-filter: blur(12px);
}

.seat {
  position: relative;
  display: grid;
  gap: 6px;
  min-height: 112px;
  overflow: hidden;
  padding: 8px;
  transition: opacity 160ms ease, border-color 160ms ease;
}

.seat::before {
  content: "";
  position: absolute;
  inset: 0;
  border-left: 4px solid transparent;
  pointer-events: none;
}

.seat.dealer::before {
  border-left-color: var(--gold);
}

.seat.in-hand {
  border-color: rgba(98, 211, 145, 0.28);
}

.seat.in-hand::before {
  border-left-color: #62d391;
}

.seat.folded {
  opacity: 0.46;
}

.seat.busted {
  opacity: 0.32;
}

.seat-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.seat-name {
  font-weight: 950;
}

.seat-meta {
  color: var(--muted);
  font-size: 0.76rem;
}

.player-balance {
  display: block;
  margin-top: 4px;
  color: var(--gold);
  font-size: 1.3rem;
  line-height: 1;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 3px;
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 25px;
  height: 25px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  padding: 0 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.62rem;
  font-weight: 950;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.16), 0 4px 10px rgba(0, 0, 0, 0.2);
}

.badge.gold {
  border-color: #ffe08a;
  background: linear-gradient(145deg, #f7d76d, #b98422);
  color: #241703;
}

.badge.purple {
  border-color: #eadcff;
  background: linear-gradient(145deg, #b78cff, #6035a0);
  color: #180829;
}

.badge.coral {
  border-color: #ffd1c9;
  background: linear-gradient(145deg, #ff9b88, #bd3428);
  color: #270706;
}

.board-zone {
  align-self: center;
  display: grid;
  justify-items: center;
  gap: 10px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  padding: 8px;
  text-align: center;
}

.status-strip strong {
  display: block;
  margin-top: 2px;
  font-size: 1rem;
}

.cards {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-height: 55px;
}

.seat .cards {
  min-height: 54px;
}

.community {
  justify-content: center;
  min-height: 68px;
}

.card {
  display: grid;
  place-items: center;
  width: clamp(40px, 12.4vw, 54px);
  height: clamp(56px, 17.4vw, 76px);
  border: 1px solid rgba(0, 0, 0, 0.22);
  border-radius: 7px;
  background: #fffaf0;
  color: var(--black);
  font-size: 0.86rem;
  font-weight: 950;
  box-shadow: 0 7px 15px rgba(0, 0, 0, 0.22);
  transition: box-shadow 140ms ease, filter 140ms ease;
}

.card:not(.empty):hover {
  filter: brightness(1.03);
  box-shadow: 0 11px 21px rgba(0, 0, 0, 0.28);
}

.card.red {
  color: var(--red);
}

.card.back,
.card.empty {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12) 25%, transparent 25%) 0 0 / 12px 12px,
    linear-gradient(225deg, rgba(255, 255, 255, 0.12) 25%, transparent 25%) 0 0 / 12px 12px,
    #1b3e65;
  color: rgba(255, 255, 255, 0.85);
}

.card.empty {
  opacity: 0.34;
}

.table-readout {
  display: grid;
  gap: 4px;
  width: 100%;
}

.message,
.hand-strength {
  text-align: center;
  font-weight: 850;
}

.message {
  min-height: 1.25rem;
  color: #fff7d8;
}

.hand-strength {
  color: var(--muted);
  font-size: 0.88rem;
}

.player-zone {
  display: grid;
  grid-template-columns: minmax(96px, 1fr) auto;
  gap: 10px;
  align-items: center;
  justify-self: center;
  width: min(100%, 360px);
  padding: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}

.player-zone .cards {
  justify-content: flex-end;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  padding: 8px;
}

.table-actions {
  align-self: end;
  justify-self: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  background: rgba(7, 16, 15, 0.74);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.3);
}

.table-actions button {
  min-width: 0;
}

#checkCall:not(:disabled),
#raise:not(:disabled),
#allIn:not(:disabled) {
  animation: softPulse 1.8s ease-in-out infinite;
}

.hidden {
  visibility: hidden;
  pointer-events: none;
}

@media (max-width: 380px) {
  .app-shell {
    padding: 6px;
  }

  .table-hud {
    grid-template-columns: 1fr;
  }

  .game-name {
    min-width: 0;
  }

  .player-zone {
    grid-template-columns: 1fr;
    width: min(100%, 280px);
  }

  .player-zone .cards {
    justify-content: flex-start;
  }

  .felt {
    min-height: calc(100vh - 12px);
  }
}

@media (min-width: 640px) {
  .app-shell {
    width: min(1180px, calc(100% - 24px));
    padding: 14px 0;
  }

  .table-hud {
    grid-template-columns: auto minmax(360px, auto);
    justify-content: space-between;
  }

  .setup-panel {
    grid-column: auto;
    grid-template-columns: auto minmax(112px, 1fr) auto;
    min-width: 360px;
  }

  .setup-panel button {
    grid-column: auto;
  }

  .felt {
    min-height: calc(100vh - 28px);
    border-width: 8px;
    border-radius: 36px;
    padding: 16px;
  }

  .cpu-seats {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
  }

  .controls {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    width: min(760px, 100%);
    border-radius: 999px;
  }

  .player-zone {
    width: min(420px, 100%);
  }

  .status-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .app-shell {
    padding: 24px 0;
  }

  .felt {
    min-height: 720px;
    border-width: 10px;
    border-radius: 50px;
    padding: 64px 22px 22px;
  }

  .action-ticker {
    width: min(520px, calc(100% - 36px));
    justify-self: center;
    font-size: 0.9rem;
  }

  .cpu-seats {
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  }

  .seat {
    min-height: 132px;
  }

  .status-strip {
    width: min(620px, 100%);
    padding: 12px;
  }

  .status-strip strong {
    font-size: 1.25rem;
  }

  .card {
    width: 58px;
    height: 82px;
    font-size: 1.02rem;
  }

  .community {
    min-height: 108px;
  }
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes softPulse {
  0%,
  100% {
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(239, 199, 94, 0.18), 0 12px 24px rgba(0, 0, 0, 0.28);
  }
}

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