:root {
  color-scheme: dark;
  --bg: #131a18;
  --panel: #202b26;
  --border: #4c6255;
  --text: #f5efe2;
  --muted: #b7c8be;
  --gold: #e6c78b;
  --felt: #163e31;
  font-family: "Malgun Gothic", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button, input, select {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
button {
  background: #2e4237;
  color: var(--text);
  padding: 8px 14px;
  cursor: pointer;
}
button:hover { background: #3b5446; }
button:disabled { opacity: .45; cursor: default; }
button.primary { color: #211a10; background: var(--gold); border-color: var(--gold); font-weight: 700; }
button.primary:hover { background: #f4d9a2; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
input, select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  background: #15211b;
  color: var(--text);
}
h1, h2, p, ol, dl { margin: 0; }
h2 { font-size: 1.06rem; }
form, label { display: block; }
form > label { margin: 12px 0; color: var(--muted); font-size: .86rem; }
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px max(20px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid var(--border);
}
.brand { text-decoration: none; color: var(--gold); font-weight: 750; font-size: 1.15rem; }
.masthead-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#theme { width: auto; margin: 0; }
main { width: min(1120px, calc(100% - 36px)); margin: 38px auto; }
.welcome {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.intro {
  padding: clamp(26px, 6vw, 72px);
  background: radial-gradient(ellipse at 20% 20%, #285a44, var(--felt) 70%);
}
.intro h1 { margin-top: 26px; font-size: clamp(2rem, 6vw, 3.6rem); letter-spacing: -.07em; }
.intro p { color: #d2e1d7; margin: 12px 0 30px; line-height: 1.55; }
.intro dl { display: flex; flex-wrap: wrap; gap: 18px; }
.intro dt { color: #c5d5ca; font-size: .78rem; }
.intro dd { margin: 5px 0 0; color: var(--gold); font-weight: 700; }
.table-art { display: flex; margin-left: 4px; }
.table-art span, .card {
  display: grid;
  place-items: center;
  border-radius: 7px;
  aspect-ratio: 5 / 7;
  background: #f1e9d9;
  border: 1px solid #e5d1ad;
  color: #203b31;
  font: 700 clamp(1.3rem, 3.4vw, 2.4rem) Georgia, serif;
}
.table-art span { width: clamp(48px, 8vw, 84px); transform: rotate(-9deg); box-shadow: 1px 5px 14px #0006; }
.table-art span + span { margin-left: -12px; transform: rotate(0deg); }
.table-art span:last-child { transform: rotate(9deg); }
.entry { display: grid; gap: 20px; align-content: center; padding: 26px clamp(22px, 4vw, 48px); background: var(--panel); }
.entry button { width: 100%; margin-top: 4px; }
.entry > :not([hidden]) ~ :not([hidden]) { border-top: 1px solid var(--border); padding-top: 18px; }
#resume-button { margin-top: 10px; }
#invite-note { margin-top: 8px; color: var(--muted); }
#other-room { color: var(--gold); }
.seat-recovery summary { cursor: pointer; }
#seat-backup p { margin-top: 14px; }
#status:not(:empty), #connection:not(:empty) { margin: 14px 0; padding: 10px 12px; color: var(--gold); border-left: 2px solid var(--gold); }
.room-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.room-bar h1 { font-size: 1.25rem; }
.room-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.share-link { flex-basis: 100%; color: var(--muted); }
.seats { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.seat {
  display: grid;
  gap: 5px;
  align-content: start;
  flex: 1 1 120px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow-wrap: anywhere;
}
.seat.current, .seat.winner { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.seat small, .seat.empty, .seat p { color: var(--muted); font-size: .78rem; }
.seat-heading, .seat-balance { display: flex; align-items: center; gap: 7px; min-width: 0; }
.seat-balance { flex-wrap: wrap; }
.avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  aspect-ratio: 1;
  border: 1px solid #ffffff38;
  border-radius: 50%;
  background: var(--avatar, #597a65);
  color: #fff;
  font-weight: 750;
}
.seat-2 { --avatar: #566aa0; }
.seat-3 { --avatar: #9b5b52; }
.seat-4 { --avatar: #765b89; }
.seat-5 { --avatar: #8a6937; }
.seat-wager strong { color: var(--gold); }
.seat-snipe strong { color: var(--text); }
.seat-reveal { display: grid; gap: 4px; }
.stack { font-size: 1.2rem; font-weight: 700; color: var(--gold); }
.table-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(250px, 1fr); gap: 12px; align-items: start; }
.table-grid.waiting-room { grid-template-columns: minmax(0, 480px); }
[data-theme="table"] .poker-table {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
[data-theme="table"] .poker-table::before {
  content: "";
  position: absolute;
  inset: 38px 1% 38px;
  z-index: -1;
  border: 5px solid #634d35;
  border-radius: 48% / 43%;
  background: radial-gradient(ellipse at 45% 30%, #286149, #14392d 82%);
  box-shadow: inset 0 0 0 1px #73886b, inset 0 0 0 7px #1a382a, 0 6px 18px #0005;
  pointer-events: none;
}
[data-theme="table"] .poker-table .seats { display: contents; }
[data-theme="table"] .poker-table .seat { z-index: 1; align-self: start; }
[data-theme="table"] .poker-table :is(.seat-1, .seat-4, .seat-5) { grid-column: 1; }
[data-theme="table"] .poker-table .seat-2 { grid-area: 1 / 3; }
[data-theme="table"] .poker-table .seat-3 { grid-area: 3 / 3; }
[data-theme="table"] .poker-table .seat-1 { grid-row: 1; }
[data-theme="table"] .poker-table :is(.seat-4, .seat-5) { grid-row: 3; }
[data-theme="table"] .seats-3 .seat-1, [data-theme="table"] .seats-5 .seat-4 { grid-column: 2; }
[data-theme="table"] .seats-3 .seat-2 { grid-area: 3 / 3; }
[data-theme="table"] .seats-3 .seat-3 { grid-area: 3 / 1; }
[data-theme="table"] .poker-table .felt {
  grid-area: 2 / 1 / 3 / -1;
  background: transparent;
  border: 0;
  width: min(100%, 480px);
  margin-inline: auto;
}
[data-theme="table"] .wager-change .avatar { animation: chip-nod 380ms ease-out; }
[data-theme="table"] .snipe-change .avatar { animation: declare-ring 500ms ease-out; }
@keyframes chip-nod { 35% { transform: translateY(-4px); box-shadow: 0 0 0 3px #e6c78b90; } }
@keyframes declare-ring { 30% { box-shadow: 0 0 0 3px #fff4cb; } 100% { box-shadow: 0 0 0 8px #fff4cb00; } }
@media (prefers-reduced-motion: reduce) {
  [data-theme="table"] :is(.wager-change, .snipe-change) .avatar { animation: none; }
}
.felt {
  text-align: center;
  padding: clamp(16px, 3vw, 34px);
  background: radial-gradient(ellipse at 50% 25%, #275a44, var(--felt) 85%);
  border: 1px solid #72886a;
  border-radius: 20px;
}
.table-overview { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
[data-theme="table"] .table-overview { display: grid; grid-template-columns: 1fr auto 1fr; gap: 4px; }
.felt h2 { font-size: .82rem; color: #d2e1d7; }
.round { color: var(--gold); font-weight: 700; }
.pot { display: flex; align-items: end; gap: 8px; white-space: nowrap; }
.pot-count { display: flex; align-items: baseline; gap: 6px; }
.pot-chips { display: flex; align-items: end; justify-content: center; width: 90px; height: 42px; padding-bottom: 2px; }
.pot-stack { display: flex; flex-direction: column-reverse; }
.pot-stack img, .flying-chip { display: block; width: 33px; height: 22px; object-fit: contain; }
.pot-stack img + img { margin-bottom: -18px; }
.pot-stack + .pot-stack { margin-left: -6px; }
.pot-stack:nth-child(2) { margin-bottom: 2px; }
.flying-chip { position: fixed; z-index: 5; pointer-events: none; top: 0; left: 0; }
.pot strong { font: 700 1.75rem Georgia, serif; }
.pot small { font: 600 .75rem "Malgun Gothic", sans-serif; margin-inline-start: 3px; }
.card-groups { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: clamp(10px, 2vw, 24px); margin-top: 24px; }
.card-groups section { min-width: 0; }
.cards, .revealed { display: flex; gap: 5px; justify-content: center; margin: 8px 0 0; }
.cards .card { flex: 0 1 74px; min-width: 0; }
.card.unknown { color: #bbccbf; background: #204a3b; border: 1px dashed #779384; }
.revealed { justify-content: flex-start; margin: 0; }
.revealed .card { width: 24px; font-size: 1rem; }
.side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.panel p { margin: 10px 0; color: var(--muted); line-height: 1.55; }
.panel h3 { margin: 14px 0 6px; font-size: .92rem; }
.play-controls.acting { border-color: var(--gold); }
.play-controls .turn-status { margin-bottom: 7px; }
.play-controls.acting .turn-status { color: var(--gold); font-weight: 700; }
.play-controls .wager-status { margin: 6px 0 8px; font-size: .85rem; }
.play-controls .wager-status strong { color: var(--text); }
.final-stacks { list-style: none; margin: 0; padding: 0; }
.final-stacks li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.final-stacks li span { overflow-wrap: anywhere; }
.final-stacks strong { color: var(--gold); white-space: nowrap; }
.play-controls > button { margin-top: 8px; }
:is(.match-history, .previous-result) summary { cursor: pointer; font-weight: 700; }
.match-history section { margin-top: 12px; }
.match-history h2 { margin-bottom: 6px; }
.prior-hands { list-style: none; padding: 0; margin: 12px 0 0; }
.prior-hands li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 8px; padding: 8px 0; border-top: 1px solid var(--border); font-size: .85rem; }
.prior-hands li strong { overflow-wrap: anywhere; }
.prior-hands li p { grid-column: 1 / -1; margin: 0; }
.actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin: 10px 0; }
.paired { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.paired.raise { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.paired label { margin: 10px 0 0; }
.paired .action-hint { grid-column: 1 / -1; margin: 0; font-size: .8rem; }
.history ol { padding-left: 20px; margin-top: 8px; max-height: 186px; overflow-y: auto; color: var(--muted); }
.history li { margin-top: 6px; font-size: .85rem; }
dialog {
  width: min(540px, calc(100% - 28px));
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
dialog::backdrop { background: #06100cd0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
dialog ol { padding-left: 20px; margin: 14px 0; }
dialog li, dialog p { line-height: 1.6; margin-bottom: 8px; }
[hidden] { display: none !important; }
.office-label, [data-theme="office"] .table-label { display: none; }
[data-theme="office"] .office-label { display: inline; }

:root[data-theme="office"] {
  color-scheme: light;
  --bg: #f3f4f6;
  --panel: #fff;
  --border: #c7cdd5;
  --text: #242b34;
  --muted: #505d6c;
  --gold: #35597b;
}
[data-theme="office"] .masthead { background: var(--panel); }
[data-theme="office"] button,
[data-theme="office"] input,
[data-theme="office"] select {
  color: var(--text);
  background: #f8f9fb;
  border-radius: 3px;
}
[data-theme="office"] button:hover { background: #edf0f4; }
[data-theme="office"] button.primary { background: #e1eaf3; border-color: #9aafc3; }
[data-theme="office"] button.primary:hover { background: #d3e2ef; }
[data-theme="office"] :is(.welcome, .felt, .seat, .panel, dialog) { border-radius: 4px; }
[data-theme="office"] :is(.intro, .felt) { background: var(--panel); }
[data-theme="office"] .table-art { display: none; }
[data-theme="office"] .intro { padding: clamp(20px, 4vw, 40px); border-inline-end: 1px solid var(--border); }
[data-theme="office"] .intro h1 { margin: 0; font-size: 1.65rem; letter-spacing: -.035em; }
[data-theme="office"] :is(.intro p, .intro dt, .felt h2) { color: var(--muted); }
[data-theme="office"] .intro dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
[data-theme="office"] .intro dl > div { padding: 8px; border-block: 1px solid var(--border); background: #f7f8fa; }
[data-theme="office"] .seats { display: grid; gap: 0; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
[data-theme="office"] .seat {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 0;
  padding: 7px 10px;
}
[data-theme="office"] .avatar { display: none; }
[data-theme="office"] .seat-reveal { grid-column: 1 / -1; }
[data-theme="office"] .seat + .seat { border-top: 1px solid var(--border); }
[data-theme="office"] :is(.seat.current, .seat.winner) { box-shadow: inset 3px 0 var(--gold); background: #edf3f8; }
[data-theme="office"] .seat .stack { justify-self: end; color: var(--text); font-size: .96rem; font-variant-numeric: tabular-nums; }
[data-theme="office"] .seat p { grid-column: 2 / -1; }
[data-theme="office"] .felt { text-align: start; min-height: 0; border-color: var(--border); padding: 16px; }
[data-theme="office"] .pot,
[data-theme="office"] .cards { justify-content: flex-start; }
[data-theme="office"] .pot strong { font: inherit; font-weight: 700; }
[data-theme="office"] :is(.pot-chips, .flying-chip) { display: none; }
[data-theme="office"] .cards { gap: 0; }
[data-theme="office"] .cards .card { flex-basis: 44px; height: 36px; }
[data-theme="office"] .cards .card + .card { border-inline-start: 0; }
[data-theme="office"] .card {
  color: var(--text);
  background: #fff;
  border-color: var(--border);
  border-radius: 0;
  font: inherit;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
[data-theme="office"] .card.unknown { color: var(--muted); background: #f5f6f8; }
[data-theme="office"] dialog::backdrop { background: #23314566; }

@media (max-width: 680px) {
  main { margin: 18px auto; width: calc(100% - 24px); }
  .welcome, .table-grid { grid-template-columns: minmax(0, 1fr); }
  .seat { flex-basis: 84px; padding: 7px; gap: 4px; }
  .avatar { width: 23px; font-size: .75rem; }
  .seat-heading { gap: 4px; font-size: .85rem; }
  .felt { padding: 12px; border-radius: 12px; }
  .card-groups { margin-top: 13px; }
  .cards .card { flex-basis: 50px; }
  .panel { padding: 12px; }
  [data-theme="office"] .intro { border-inline-end: 0; border-bottom: 1px solid var(--border); }
}
