:root {
  color-scheme: dark;
  --bg: #101410;
  --ink: #f3efe4;
  --muted: #c5cfc4;
  --felt: #15724a;
  --felt-deep: #0c4a30;
  --rail: #6b3f22;
  --gold: #e6c27a;
  --card: #f7f3ea;
  --danger: #9d3b32;
  --call: #1f7a45;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 50% -10%, #243328, transparent),
    var(--bg);
  color: var(--ink);
}

header, main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 28px 0 18px;
}

h1, h2, p { margin: 0; }

h1 {
  font-size: 2rem;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.eyebrow {
  color: var(--gold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  margin-bottom: 4px;
}

.sub, .fine, .loading {
  color: var(--muted);
  line-height: 1.45;
}

.session {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

#results-toggle {
  background: transparent;
  color: var(--gold);
  border: 1px solid #3c4a40;
  padding: 6px 12px;
}

.score {
  text-align: right;
  min-width: 160px;
}

.score strong {
  display: block;
  font-size: 1.6rem;
}

main {
  padding-bottom: 48px;
}

#table-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
}

#table-view[hidden],
#results-view[hidden] {
  display: none;
}

.felt-wrap {
  position: relative;
  height: 600px;
}

.felt {
  position: absolute;
  inset: 48px 24px 72px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 45%, var(--felt), var(--felt-deep));
  box-shadow:
    0 0 0 14px var(--rail),
    0 0 0 18px #3e2414,
    inset 0 0 80px rgba(0, 0, 0, 0.25);
}

.center {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  z-index: 2;
}

.pot {
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 8px;
}

.boards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

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

.hole-cards poker-card + poker-card {
  margin-left: -14px;
}

.seat {
  position: absolute;
  width: 132px;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 3;
}

.seat.hero { width: 188px; }

.seat.folded { opacity: 0.45; }

.seat.to-act .seat-card {
  outline: 2px solid var(--gold);
}

.seat-card {
  background: rgba(8, 20, 14, 0.78);
  border-radius: 12px;
  padding: 8px 8px 10px;
}

.seat.hero .seat-card {
  background: rgba(12, 28, 20, 0.92);
}

.name {
  font-weight: 650;
}

.meta, .bet, .holding {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.holding { white-space: normal; }

.bet { color: var(--gold); min-height: 1em; }

.dealer {
  position: absolute;
  z-index: 4;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--ink);
  color: #111;
  font-size: 0.78rem;
  line-height: 26px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

poker-card {
  display: inline-flex;
  flex-direction: column;
  justify-content: space-between;
  width: 34px;
  height: 48px;
  padding: 3px 4px;
  border-radius: 6px;
  background: var(--card);
  color: #1b1b1b;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
  font-family: Georgia, "Iowan Old Style", serif;
}

.center poker-card { width: 40px; height: 56px; }

.seat.hero poker-card { width: 46px; height: 64px; }

poker-card.back {
  background:
    repeating-linear-gradient(45deg, #1d4f8a 0 6px, #173f6e 6px 12px);
  border: 2px solid #f3efe4;
  box-shadow: none;
}

.rank { font-size: 0.95rem; font-weight: 700; line-height: 1; }
.suit { font-size: 1.45rem; align-self: center; line-height: 0.8; }
.center .suit { font-size: 1.7rem; }
.seat.hero .suit { font-size: 1.9rem; }

poker-card.spade { color: #1c1c1c; }
poker-card.heart { color: #d01212; }
poker-card.diamond { color: #1a6fd0; }
poker-card.club { color: #178a45; }

poker-card.dealing { animation: deal-in 0.35s ease; }
poker-card.flipping { animation: flip-card 0.4s ease; }

.wager {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.wager.arriving {
  animation: chip-in 0.28s ease;
}

.center .wager {
  position: static;
  transform: none;
  margin-top: 8px;
}

.center .wager.arriving {
  animation: pot-in 0.28s ease;
}

.center .wager.clearing {
  animation: pot-out 0.35s ease forwards;
}

.wager.awarding {
  z-index: 6;
  animation: award-chips 0.9s cubic-bezier(0.22, 0.7, 0.2, 1) forwards;
}

.wager.gathering {
  z-index: 6;
  animation: gather-chips 0.7s ease-in forwards;
}

.board-row.scoop {
  padding: 4px;
  border-radius: 12px;
  box-shadow:
    0 0 0 2px rgba(228, 179, 64, 0.95),
    0 0 22px rgba(228, 179, 64, 0.55);
}

.seat.scoop { z-index: 5; }

.seat.scoop poker-card {
  animation: win-glow 1.1s ease-in-out infinite;
}

.seat.showdown { width: 156px; z-index: 6; }
.seat.showdown.hero { width: 220px; }
.seat.showdown .hole-cards { gap: 3px; }
.seat.showdown .hole-cards poker-card { width: 32px; height: 44px; }
.seat.showdown.hero .hole-cards poker-card { width: 42px; height: 58px; }
.seat.showdown .hole-cards poker-card + poker-card { margin-left: 0; }
.seat.showdown .suit { font-size: 1.15rem; }
.seat.showdown.hero .suit { font-size: 1.5rem; }

.seat.quiet { opacity: 0.42; }

.scoop-label {
  margin-top: 3px;
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: normal;
}

.piles { display: flex; gap: 4px; align-items: end; }

.pile { position: relative; width: 26px; }

.chip {
  position: absolute;
  left: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-size: 8px;
  font-weight: 700;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.9),
    inset 0 0 0 4px rgba(0, 0, 0, 0.18),
    0 1px 2px rgba(0, 0, 0, 0.45);
}

.chip.red { background: radial-gradient(circle at 50% 40%, #ef6a5c, #b42318); }
.chip.green { background: radial-gradient(circle at 50% 40%, #46c56e, #157a38); }
.chip.black {
  background: radial-gradient(circle at 50% 40%, #6a6a6a, #141414);
  font-size: 7px;
}
.chip.plaque {
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, #5c2d91 0 3px, #e4b340 3px 6px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.8),
    0 1px 2px rgba(0, 0, 0, 0.45);
  font-size: 7px;
  letter-spacing: -0.04em;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.85);
}

.wager-amount {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 650;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 999px;
  padding: 1px 6px;
}

.seat.pulse .seat-card { animation: seat-pulse 0.45s ease; }
.seat.folded { transition: opacity 0.3s ease; }

@keyframes seat-pulse {
  40% { transform: translateY(-6px); }
}

@keyframes deal-in {
  from { transform: translateY(-14px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes flip-card {
  from { transform: rotateY(90deg); }
  to { transform: rotateY(0); }
}

@keyframes chip-in {
  from { transform: translate(-50%, -30%); opacity: 0; }
  to { transform: translate(-50%, -50%); opacity: 1; }
}

@keyframes pot-in {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes pot-out {
  to { opacity: 0; transform: scale(0.92); }
}

.wager.returning {
  z-index: 6;
  animation: return-chips 0.7s ease-in forwards;
}

@keyframes return-chips {
  to { left: var(--end-x); top: var(--end-y); }
}

@keyframes award-chips {
  from { left: 50%; top: 44%; }
  to { left: var(--end-x); top: var(--end-y); }
}

@keyframes gather-chips {
  to { left: 50%; top: 44%; }
}

@keyframes win-glow {
  0%, 100% {
    box-shadow: 0 0 0 2px #e4b340, 0 0 8px rgba(228, 179, 64, 0.45);
  }
  50% {
    box-shadow: 0 0 0 3px #ffe7a3, 0 0 18px rgba(228, 179, 64, 0.95);
  }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  min-height: 64px;
}

.action-copy { flex: 1 1 220px; }

button, .actions button {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  font: inherit;
  color: white;
  background: #314238;
  cursor: pointer;
}

button:disabled { opacity: 0.55; cursor: wait; }

button.primary { background: var(--call); }
button.raise { background: #8a6230; }
button.all-in { background: var(--danger); }
button.fold { background: #4d564f; }

#restart {
  margin-top: 16px;
  background: transparent;
  color: var(--muted);
  border: 1px solid #3c4a40;
}

.hand-name {
  display: flex;
  align-items: center;
  gap: 6px;
}

button.copy-hand {
  width: auto;
  margin: 0;
  padding: 2px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  line-height: 0;
}

button.copy-hand:hover,
button.copy-hand.copied {
  background: transparent;
  color: var(--gold);
}

.board { list-style: none; padding: 0; margin: 0; }

.board li, .log li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.92rem;
}

.board li.you { color: var(--gold); }

.log {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  max-height: 180px;
  overflow: auto;
}

.log li { color: var(--muted); justify-content: flex-start; }

.fine { margin-top: 12px; font-size: 0.8rem; }

.history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
  margin-bottom: 22px;
}

.hand-box {
  background: rgba(8, 20, 14, 0.78);
  border-radius: 12px;
  padding: 8px 10px 10px;
}

.hand-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-size: 0.82rem;
}

.hand-head strong.up { color: #46c56e; }
.hand-head strong.down { color: #ef6a5c; }

.hand-cards {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  margin: 6px 0 4px;
}

.hand-boards {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hand-board { display: flex; gap: 3px; }

.tabled {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tabled > span {
  color: var(--muted);
  font-size: 0.72rem;
}

.hand-box poker-card {
  width: 26px;
  height: 36px;
  padding: 2px 3px;
}

.hand-box .rank { font-size: 0.68rem; }
.hand-box .suit { font-size: 1.15rem; }
.hand-box .meta { white-space: normal; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.stat-card {
  display: block;
  width: 100%;
  text-align: left;
  border-radius: 12px;
  background: rgba(8, 20, 14, 0.78);
  color: inherit;
  padding: 12px 14px;
}

.stat-card:disabled {
  opacity: 1;
  cursor: default;
}

.stat-card .eyebrow { margin-bottom: 6px; }

.stat-card strong {
  display: block;
  font-size: 1.35rem;
}

.results-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.day-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 70vh;
  overflow: auto;
}

.day-list button {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  padding: 8px 10px;
  text-align: left;
}

.day-list button.selected {
  background: rgba(230, 194, 122, 0.12);
  box-shadow: inset 0 0 0 1px var(--gold);
}

.day-list .date { display: block; }

.day-list .fine { display: block; font-size: 0.75rem; }

.profit.up { color: #46c56e; }
.profit.down { color: #ef6a5c; }

.day-title {
  font-size: 1.25rem;
  font-weight: 650;
}

.day-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 8px;
}

.day-heading strong {
  font-size: 1.6rem;
}

.day-nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0;
}

.day-nav .day-newer { margin-left: auto; }

#day-detail .history { max-height: none; }

@media (max-width: 800px) {
  header, main { width: min(100% - 16px, 1120px); }
  header { flex-direction: column; align-items: start; }
  .session { align-items: flex-start; }
  .score { text-align: left; }
  #table-view { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .results-layout { grid-template-columns: 1fr; }
  .day-list { max-height: 220px; }
  .felt-wrap { height: 470px; }
  .felt { inset: 36px 4px 56px; }
  .seat { width: 96px; }
  .seat.hero { width: 132px; }
  .seat.showdown { width: 112px; }
  .seat.showdown.hero { width: 148px; }
  .seat.showdown .hole-cards poker-card { width: 24px; height: 34px; }
  .seat.showdown.hero .hole-cards poker-card { width: 30px; height: 42px; }
  .seat.showdown .suit { font-size: 0.95rem; }
  .seat.showdown.hero .suit { font-size: 1.15rem; }
  .hole-cards poker-card + poker-card { margin-left: -16px; }
  .center poker-card { width: 28px; height: 40px; }
  .center .suit { font-size: 1rem; }
  .name { font-size: 0.78rem; }
  .meta, .bet, .holding { font-size: 0.68rem; }
  poker-card { width: 28px; height: 40px; padding: 2px 3px; }
  .seat.hero poker-card { width: 36px; height: 50px; }
  .rank { font-size: 0.85rem; }
  .suit { font-size: 1.1rem; }
  .seat.hero .suit { font-size: 1.45rem; }
  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .action-copy { grid-column: 1 / -1; }
  .actions button { padding: 12px 8px; }
}
