:root {
  color-scheme: dark;
  --felt: #17664c;
  --felt-dark: #0d3d32;
  --rail: #3d2430;
  --gold: #f2c75c;
  --cream: #fff4d6;
  --ink: #171717;
  --muted: #a8c3ba;
  --danger: #f87171;
  --panel: rgba(12, 24, 24, 0.78);
  --line: rgba(255, 255, 255, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 50% 42%, rgba(65, 173, 121, 0.35), transparent 32rem),
    linear-gradient(145deg, #121010, #182523 52%, #100d12);
  color: var(--cream);
}

.confetti-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 30;
}

.confetti-piece {
  position: absolute;
  top: -24px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  opacity: 0.95;
  animation: confetti-fall var(--fall-time, 1800ms) ease-out forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }

  100% {
    transform: translate3d(var(--drift, 0), 105vh, 0) rotate(var(--spin, 540deg));
    opacity: 0;
  }
}

button,
input,
textarea {
  font: inherit;
}

.app {
  width: min(1320px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.topbar,
.controls,
.log {
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 8px;
}

h1 {
  margin: 0;
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  font-weight: 800;
  letter-spacing: 0;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.pill {
  min-width: 96px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-align: center;
  background: rgba(255, 255, 255, 0.06);
}

.sound-toggle {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.06);
}

.game-area {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 14px;
}

.play-area {
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
}

.table-wrap {
  min-height: 520px;
  display: grid;
  place-items: center;
}

.table {
  width: min(100%, 1040px);
  min-height: min(62vh, 650px);
  position: relative;
  overflow: hidden;
  border: 18px solid var(--rail);
  border-radius: 48% / 34%;
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.08), transparent 58%),
    repeating-radial-gradient(ellipse at center, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 8px),
    linear-gradient(135deg, var(--felt), var(--felt-dark));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4), inset 0 0 0 10px rgba(255, 255, 255, 0.06);
}

.seat {
  position: absolute;
  width: min(270px, 34vw);
  min-width: 210px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(7, 20, 20, 0.72);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
}

.dealer {
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
}

.player {
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
}

.seat-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 800;
}

.status {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.86rem;
}

.cards,
.board {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.card {
  width: clamp(48px, 7vw, 72px);
  aspect-ratio: 0.72;
  display: grid;
  align-content: space-between;
  padding: 7px;
  border-radius: 7px;
  background: #fffdf8;
  color: var(--ink);
  font-weight: 900;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.32);
  user-select: none;
}

.card.red {
  color: #b91c1c;
}

.card.back {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent),
    repeating-linear-gradient(45deg, #224c90 0 7px, #18356d 7px 14px);
  color: transparent;
  border: 3px solid #f7f1df;
}

.rank {
  font-size: clamp(1rem, 2vw, 1.45rem);
  line-height: 1;
}

.suit {
  justify-self: end;
  font-size: clamp(1.2rem, 2.4vw, 1.7rem);
  line-height: 1;
}

.center {
  position: absolute;
  inset: 40% 10% auto;
  display: grid;
  gap: 14px;
  justify-items: center;
  transform: translateY(-50%);
}

.shuffle-layer {
  position: absolute;
  inset: -24px 0 auto;
  height: 118px;
  display: none;
  place-items: center;
  pointer-events: none;
  z-index: 4;
}

.shuffle-layer.active {
  display: grid;
}

.shuffle-deck {
  position: relative;
  width: 88px;
  height: 86px;
}

.shuffle-deck span {
  position: absolute;
  left: 18px;
  top: 7px;
  width: 52px;
  aspect-ratio: 0.72;
  border: 3px solid #f7f1df;
  border-radius: 7px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent),
    repeating-linear-gradient(45deg, #224c90 0 7px, #18356d 7px 14px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.34);
  animation: shuffle-card 900ms ease-in-out both;
}

.shuffle-deck span:nth-child(1) {
  animation-delay: 0ms;
}

.shuffle-deck span:nth-child(2) {
  animation-delay: 70ms;
}

.shuffle-deck span:nth-child(3) {
  animation-delay: 140ms;
}

.shuffle-deck span:nth-child(4) {
  animation-delay: 210ms;
}

.shuffle-deck span:nth-child(5) {
  animation-delay: 280ms;
}

@keyframes shuffle-card {
  0% {
    opacity: 0;
    transform: translateX(0) rotate(0deg);
  }

  18% {
    opacity: 1;
  }

  38% {
    transform: translateX(-34px) rotate(-18deg);
  }

  64% {
    transform: translateX(34px) rotate(18deg);
  }

  100% {
    opacity: 0;
    transform: translateX(0) rotate(0deg);
  }
}

.pot {
  display: grid;
  gap: 4px;
  place-items: center;
  padding: 12px 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(11, 23, 22, 0.78);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.pot strong {
  color: var(--gold);
  font-size: 1.25rem;
}

.board {
  min-height: 96px;
  align-items: center;
}

.result-banner {
  min-height: 64px;
  min-width: min(420px, 92vw);
  display: none;
  place-items: center;
  gap: 3px;
  padding: 10px 16px;
  border: 1px solid rgba(242, 199, 92, 0.5);
  border-radius: 8px;
  text-align: center;
  background: rgba(12, 24, 24, 0.88);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}

.result-banner.active {
  display: grid;
}

.result-banner strong {
  color: var(--gold);
  font-size: clamp(1.2rem, 3vw, 2rem);
  line-height: 1.05;
}

.result-banner span {
  color: var(--cream);
  font-weight: 800;
  font-size: 0.95rem;
}

.empty-slot {
  width: clamp(48px, 7vw, 72px);
  aspect-ratio: 0.72;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.12);
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
}

.message {
  min-height: 42px;
  display: flex;
  align-items: center;
  color: var(--cream);
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.bet-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

input {
  width: 92px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--cream);
  background: rgba(0, 0, 0, 0.26);
}

button {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.1);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.34);
}

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

.primary {
  color: #1b1708;
  background: var(--gold);
  border-color: transparent;
  font-weight: 900;
}

.danger {
  color: #2a0c0c;
  background: var(--danger);
  border-color: transparent;
  font-weight: 900;
}

.log {
  min-height: 0;
  max-height: calc(100vh - 110px);
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(190px, 1fr) auto;
  padding: 0;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.log-section,
.comments-section {
  padding: 12px;
  overflow: auto;
}

.comments-section {
  max-height: 380px;
  border-top: 1px solid var(--line);
}

.log h2 {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: -12px -12px 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 24, 24, 0.96);
  color: var(--cream);
  font-size: 0.95rem;
  letter-spacing: 0;
}

.log p {
  margin: 0 0 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  line-height: 1.35;
}

.comment-form {
  display: grid;
  gap: 8px;
}

.comment-form input,
.comment-form textarea {
  width: 100%;
}

.comment-form textarea {
  min-height: 76px;
  resize: vertical;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--cream);
  background: rgba(0, 0, 0, 0.26);
}

.comments-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.comment {
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.comment strong {
  display: block;
  color: var(--cream);
  font-size: 0.86rem;
}

.comment span {
  display: block;
  margin-top: 2px;
  color: rgba(168, 195, 186, 0.85);
  font-size: 0.78rem;
}

.comment p {
  margin: 7px 0 0;
  padding: 0;
  border: 0;
  color: var(--muted);
}

@media (max-width: 760px) {
  .app {
    padding: 10px;
  }

  .game-area {
    grid-template-columns: 1fr;
  }

  .play-area {
    order: 1;
  }

  .log {
    order: 2;
    max-height: 420px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats,
  .actions {
    justify-content: flex-start;
  }

  .table-wrap {
    min-height: 560px;
  }

  .table {
    min-height: 520px;
    border-width: 12px;
    border-radius: 34px;
  }

  .seat {
    width: calc(100% - 34px);
    min-width: 0;
  }

  .center {
    inset: 42% 5% auto;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .bet-box {
    width: 100%;
  }

  input {
    flex: 1;
    min-width: 0;
  }
}
