:root {
  --felt: #1b5a43;
  --felt-dark: #0c241c;
  --ink: #f6f1e3;
  --muted: #c9d5cc;
  --gold: #e4c56a;
  --gold-dark: #8a6a1f;
  --card: #fffcf6;
  --red: #c0122e;
  --black: #17201c;
  --danger: #ffb4b4;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1f6a4e 0%, transparent 55%),
    var(--felt-dark);
  color: var(--ink);
  font-family: "Source Sans 3", sans-serif;
}

h1, h2, h3 {
  font-family: Fraunces, Georgia, serif;
  margin: 0;
  font-weight: 700;
}

#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 16px calc(120px + env(safe-area-inset-bottom, 0px));
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.site-header-copy {
  min-width: 0;
}

#open-help {
  flex: 0 0 auto;
  margin-top: 4px;
}

body.at-table .site-header {
  display: none;
}

body.at-table #app {
  padding-top: 12px;
}

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

.table-rule {
  margin: 6px 0 0;
  color: var(--gold);
  font-size: 0.95rem;
}

.table-chrome {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.table-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(8, 28, 22, 0.72);
  border: 1px solid rgba(228, 197, 106, 0.18);
  border-radius: 16px;
}

.table-toolbar-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.table-status-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}

.table-toolbar.is-playing .table-toolbar-copy {
  min-height: 0;
}

.table-identity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.table-identity-copy {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  min-width: 0;
}

.table-identity-copy .eyebrow {
  margin: 0;
}

.table-identity-copy h2 {
  margin: 0;
  letter-spacing: 0.06em;
}

.table-identity-row > button,
.table-identity-actions > button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.table-identity-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.table-rules {
  margin: 0;
}

.table-rules summary {
  cursor: pointer;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  list-style: none;
}

.table-rules summary::-webkit-details-marker {
  display: none;
}

.table-rules summary::before {
  content: "▸ ";
}

.table-rules[open] summary::before {
  content: "▾ ";
}

.table-rules .table-rule {
  margin: 8px 0 0;
}

.variant-badge {
  display: inline-block;
  margin: 0;
  padding: 3px 10px;
  border: 1px solid rgba(228, 197, 106, 0.45);
  border-radius: 999px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tagline {
  color: var(--muted);
  margin: 8px 0 0;
}

.panel {
  background: rgba(8, 28, 22, 0.72);
  border: 1px solid rgba(228, 197, 106, 0.18);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel > summary {
  cursor: pointer;
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-size: 1.35rem;
}

.panel-head,
.row,
.table-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.table-actions:not(:has(:not([hidden]))) {
  display: none;
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  margin: 16px 0;
}

label, .hint, .hand-hint, .trick-note {
  color: var(--muted);
}

input[type="text"],
input:not([type="checkbox"]) {
  background: #10281f;
  border: 1px solid rgba(246, 241, 227, 0.16);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  min-width: 0;
  flex: 1;
}

select {
  appearance: none;
  -webkit-appearance: none;
  color-scheme: dark;
  background-color: #10281f;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23e4c56a' d='M1.5 1.8L6 6.3 10.5 1.8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  border: 1px solid rgba(246, 241, 227, 0.16);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 36px 10px 12px;
  font: inherit;
  cursor: pointer;
  min-width: 0;
}

select:focus {
  outline: none;
  border-color: rgba(228, 197, 106, 0.55);
}

select option {
  background: #10281f;
  color: var(--ink);
}

button {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  background: #234e3d;
  color: var(--ink);
}

button.primary {
  background: var(--gold);
  color: var(--felt-dark);
}

button.ghost {
  background: transparent;
  border: 1px solid rgba(246, 241, 227, 0.25);
}

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

.check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 12px 0;
}

.table-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.table-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid rgba(246, 241, 227, 0.08);
}

.table-list-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.table-list .empty {
  color: var(--muted);
  border: 0;
}

.join-form {
  margin-top: 18px;
}

.game-metrics {
  margin: 0 0 16px;
}

.game-metrics > .eyebrow {
  margin-top: 14px;
}

.metrics-tabs {
  display: flex;
  align-items: stretch;
  gap: 6px;
  margin: 14px 0 0;
  padding: 0 2px;
}

button.metrics-tab {
  position: relative;
  z-index: 0;
  flex: 1 1 0;
  max-width: 220px;
  margin: 0;
  background: rgba(8, 28, 22, 0.55);
  border: 1px solid rgba(246, 241, 227, 0.2);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  color: var(--muted);
  padding: 11px 18px 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: none;
}

button.metrics-tab:hover {
  color: var(--ink);
  background: rgba(16, 40, 31, 0.9);
}

button.metrics-tab.is-active {
  z-index: 1;
  background: var(--gold);
  border-color: var(--gold);
  color: var(--felt-dark);
}

button.metrics-tab.is-active:hover {
  background: var(--gold);
  color: var(--felt-dark);
}

.metrics-panels {
  position: relative;
  z-index: 1;
  margin-top: -1px;
  border: 1px solid rgba(228, 197, 106, 0.35);
  border-radius: 0 14px 14px 14px;
  background: rgba(8, 28, 22, 0.42);
  padding: 18px 16px 16px;
}

.metrics-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.metrics-block h3,
.hof-variant h3 {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hof-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
  margin: 0;
}

.hof-list div {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(228, 197, 106, 0.16);
  border-radius: 12px;
  background: rgba(16, 40, 31, 0.55);
}

.hof-list dt {
  color: var(--gold);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 6px;
}

.hof-list dd {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: baseline;
}

.hof-list .hof-name {
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-size: 1.15rem;
}

.hof-list .hof-stat {
  font-weight: 700;
  color: var(--gold);
}

.hof-list .hof-date,
.hof-list .hof-empty,
.hof-empty-block {
  color: var(--muted);
  font-size: 0.92rem;
}

.hof-empty-block {
  margin: 0;
}

.hof-recent {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(480px, 55vh);
  overflow-y: auto;
}

.hof-recent > li {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(228, 197, 106, 0.16);
  border-radius: 12px;
  background: rgba(16, 40, 31, 0.55);
}

.hof-recent-meta {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.hof-recent-players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.hof-recent-players li {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.hof-recent-players .hof-name {
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-size: 1rem;
}

.hof-recent-players .hof-stat {
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.hof-recent-players li.winner .hof-name {
  color: var(--gold);
}

.rules ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

button.text-link {
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: var(--gold);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.help-dialog {
  width: min(34rem, calc(100vw - 32px));
  max-height: min(90vh, 40rem);
  overflow: hidden;
  margin: auto;
  padding: 24px 22px 16px;
  border: 1px solid rgba(228, 197, 106, 0.28);
  border-radius: 16px;
  background: #10281f;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.help-dialog[open] {
  display: flex;
  flex-direction: column;
}

.help-dialog::backdrop {
  background: rgba(6, 18, 14, 0.72);
}

.help-dialog h2,
.help-lead,
.help-dialog .hint,
.help-dialog-actions {
  flex-shrink: 0;
}

.help-lead {
  margin: 8px 0 0;
  color: var(--muted);
}

.help-steps {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: help-step;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.help-steps > li {
  counter-increment: help-step;
  position: relative;
  padding: 14px 0 14px 44px;
  border-top: 1px solid rgba(246, 241, 227, 0.08);
  color: var(--muted);
}

.help-steps > li::before {
  content: counter(help-step);
  position: absolute;
  left: 0;
  top: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--felt-dark);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 28px;
  text-align: center;
}

.help-steps h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  color: var(--ink);
}

.help-steps p,
.help-steps ul {
  margin: 0;
}

.help-steps ul {
  margin-top: 6px;
  padding-left: 18px;
}

.help-steps strong {
  color: var(--ink);
}

.help-dialog .hint {
  margin: 8px 0 0;
  flex: 0 0 auto;
}

.help-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 12px;
  flex: 0 0 auto;
  background: #10281f;
}

.table-top {
  display: grid;
  grid-template-columns: 1fr 260px;
  grid-template-areas:
    "meta meta"
    "play side"
    "celebrate celebrate";
  gap: 16px;
  align-items: stretch;
}

body.game-over .table-top {
  grid-template-areas:
    "meta meta"
    "celebrate celebrate"
    "play side";
}

.table-meta {
  grid-area: meta;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.table-identity {
  min-width: 0;
}

.table-play {
  grid-area: play;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.felt {
  width: 100%;
  background:
    radial-gradient(circle at 50% 30%, #2a7a58 0%, var(--felt) 62%, #123628 100%);
  border: 10px solid #6d5420;
  border-radius: 999px;
  min-height: 220px;
  aspect-ratio: 2.4 / 1;
  max-height: 300px;
  padding: 16px 36px;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.28), var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.felt.game-over {
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.28), 0 0 36px rgba(228, 197, 106, 0.35), var(--shadow);
}

.variant-options {
  border: 1px solid rgba(228, 197, 106, 0.18);
  border-radius: 12px;
  margin: 12px 0;
  padding: 4px 12px 8px;
  min-inline-size: 0;
}

.variant-options legend {
  color: var(--gold);
  font-size: 0.85rem;
  padding: 0 6px;
  float: left;
  width: 100%;
}

.variant-choices {
  clear: both;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding-top: 4px;
}

.variant-options .check {
  margin: 0;
}

.variant-options .check input {
  flex: 0 0 auto;
  margin: 0.2em 0 0;
}

.player-count,
.turn-timeout {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
}

.create-actions {
  justify-content: flex-start;
  margin: 4px 0 8px;
}

.create-actions button {
  flex: 1 1 140px;
}

.table-actions .variant-select {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  flex: 1 1 100%;
  color: var(--muted);
}

.table-actions .variant-select span {
  flex: 0 0 auto;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.table-actions .variant-select select {
  flex: 1;
}

.stock-pile {
  position: absolute;
  left: 18px;
  bottom: 20px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.stock-meta {
  margin: 0;
  color: var(--gold);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  max-width: 90px;
  line-height: 1.3;
}

.scoreboard {
  background: rgba(8, 28, 22, 0.72);
  border-radius: 16px;
  padding: 14px;
  border: 1px solid rgba(228, 197, 106, 0.18);
}

.table-side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.table-sheet-head {
  display: none;
  align-items: center;
  gap: 8px;
}

.table-sheet-head button:last-child {
  margin-left: auto;
}

.table-sheet-toggle {
  display: none;
}

.table-sheet-head button.is-active {
  background: var(--gold);
  color: var(--felt-dark);
}

.table-sheet-toggle.has-unread::after,
.table-sheet-head button.has-unread::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--gold);
  vertical-align: middle;
}

.sheet-scrim {
  display: none;
}

body.table-playing .opponents {
  flex-wrap: nowrap;
  overflow-x: auto;
  justify-content: flex-start;
  align-items: stretch;
  gap: 8px;
  margin: 0;
  padding: 6px 4px 8px;
  scroll-padding-inline: 8px;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  flex: 0 0 auto;
}

body.table-playing .opponent {
  flex: 0 0 auto;
  min-width: 84px;
  max-width: 148px;
  padding: 6px 8px;
  margin: 0;
  border: 3px solid transparent;
  outline: none;
  box-shadow: none;
}

body.table-playing .seat-head {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  line-height: 1.15;
}

body.table-playing .opponent strong {
  display: inline;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

body.table-playing .seat-score {
  display: inline;
  flex: 0 0 auto;
  font-size: 0.95rem;
  margin-top: 0;
  line-height: 1.15;
}

body.table-playing .seat-state {
  font-size: 0.72rem;
  margin-top: 2px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.table-playing .opponent.bot {
  border-style: dashed;
  border-color: rgba(228, 197, 106, 0.45);
}

body.table-playing .opponent.you {
  border-style: solid;
  border-color: rgba(228, 197, 106, 0.4);
}

body.table-playing .opponent.turn {
  border-style: solid;
  border-color: var(--gold);
  box-shadow: inset 0 0 10px rgba(228, 197, 106, 0.28);
}

body.table-playing .opponent.you.turn {
  transform: none;
  border-width: 3px;
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(228, 197, 106, 0.32) 0%, rgba(8, 28, 22, 0.7) 100%);
  box-shadow: inset 0 0 14px rgba(228, 197, 106, 0.45);
  animation: turn-pulse-inset 1.4s ease-in-out infinite;
}

.table-chat {
  background: rgba(8, 28, 22, 0.72);
  border-radius: 16px;
  padding: 14px;
  border: 1px solid rgba(228, 197, 106, 0.18);
  display: flex;
  flex-direction: column;
  min-height: 180px;
  max-height: 260px;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  margin: 8px 0;
  padding-right: 4px;
  min-height: 80px;
}

.chat-line {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.35;
  word-wrap: break-word;
}

.chat-line strong {
  color: var(--gold);
  font-weight: 700;
  margin-right: 6px;
}

.chat-line.you strong {
  color: #f3e2a4;
}

.chat-line.spectator strong {
  color: var(--muted);
  font-weight: 600;
}

.watchers {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.chat-empty {
  color: var(--muted);
  margin: 0;
  font-size: 0.9rem;
}

.chat-form .row {
  margin: 0;
  flex-wrap: nowrap;
}

.chat-form input {
  flex: 1;
  min-width: 0;
}

.table-chat h3 {
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.opponents {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 0;
  width: 100%;
}

.opponent {
  background: rgba(8, 28, 22, 0.55);
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 110px;
  text-align: center;
  position: relative;
  border: 3px solid transparent;
  box-sizing: border-box;
}

.seat-score {
  display: block;
  margin-top: 4px;
  color: var(--gold);
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  line-height: 1.1;
}

.seat-head {
  display: block;
}

.opponent.bot {
  border-style: dashed;
  border-color: rgba(228, 197, 106, 0.45);
  outline: none;
}

.opponent.you {
  border-style: solid;
  border-color: rgba(228, 197, 106, 0.4);
  outline: none;
}

.opponent.turn {
  border-style: solid;
  border-color: var(--gold);
  outline: none;
  box-shadow: inset 0 0 10px rgba(228, 197, 106, 0.28);
}

.opponent.you.turn {
  border-style: solid;
  border-color: var(--gold);
  outline: none;
  background: linear-gradient(180deg, rgba(228, 197, 106, 0.32) 0%, rgba(8, 28, 22, 0.7) 100%);
  box-shadow: inset 0 0 14px rgba(228, 197, 106, 0.45);
  transform: none;
  z-index: 1;
  animation: turn-pulse-inset 1.4s ease-in-out infinite;
}

.opponent.you.turn .seat-state,
.opponent.turn .turn-countdown {
  color: var(--gold);
}

.remove-bot {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  padding: 0;
  line-height: 1;
  background: #3a1b1b;
}

.bot-wrap {
  width: 100%;
}

.table-quick-play {
  justify-content: flex-start;
  margin: 0 0 12px;
}

.table-quick-play label {
  flex: 0 0 auto;
}

.table-quick-play select {
  width: 5.5rem;
  flex: 0 0 auto;
}

.bot-wrap input,
.bot-wrap select {
  min-width: 0;
}

.bot-wrap input {
  flex: 1;
}

.opponent.winner {
  border-style: solid;
  border-color: var(--gold);
  outline: none;
  background: linear-gradient(180deg, rgba(228, 197, 106, 0.42) 0%, rgba(8, 28, 22, 0.7) 100%);
  box-shadow: inset 0 0 14px rgba(228, 197, 106, 0.45);
  transform: none;
  z-index: 1;
  animation: turn-pulse-inset 1.5s ease-in-out infinite;
}

.opponent.winner .seat-state,
.opponent.winner .winner-label {
  color: var(--gold);
}

.winner-label {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.final-score {
  grid-area: celebrate;
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 28px 28px 24px;
  border-radius: 22px;
  color: #fff8e4;
  background:
    radial-gradient(circle at 18% 0%, #ffe9a8 0%, transparent 42%),
    radial-gradient(circle at 88% 12%, rgba(255, 214, 120, 0.45) 0%, transparent 38%),
    linear-gradient(165deg, #9a7424 0%, #1f6a4e 42%, #10281f 100%);
  border: 3px solid var(--gold);
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.35),
    0 0 40px rgba(228, 197, 106, 0.45),
    inset 0 0 28px rgba(255, 232, 160, 0.18);
  animation: fanfare-in 0.7s ease-out, banner-glow 2.4s ease-in-out infinite 0.7s;
}

.final-score[hidden] {
  display: none;
}

.final-score .eyebrow,
.final-score h2,
.final-score-sub,
.final-score ol,
.final-score-actions {
  position: relative;
  z-index: 1;
}

.final-score .eyebrow {
  margin-bottom: 8px;
}

.final-score h2 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.15;
  color: #fff6d4;
  text-shadow: 0 2px 0 #6d5420, 0 0 22px rgba(255, 230, 140, 0.75);
}

.final-score h2 .winner-name {
  color: var(--gold);
}

.final-score-sub {
  margin: 10px 0 16px;
  color: #f6f1e3;
}

.final-score ol {
  display: inline-block;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
  min-width: min(100%, 280px);
}

.final-score li {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
}

.final-score li.winner {
  background: rgba(228, 197, 106, 0.28);
  color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(228, 197, 106, 0.45);
}

.final-score-actions {
  margin-top: 18px;
}

.final-score-actions button {
  background: #fff6d4;
  color: #10281f;
}

.final-score-actions .hint {
  margin: 8px 0 0;
  color: #f6f1e3;
}

.final-score-burst {
  pointer-events: none;
  position: absolute;
  inset: -20%;
  background-image:
    radial-gradient(circle, #ffe9a8 1.5px, transparent 2px),
    radial-gradient(circle, #c0122e 1.5px, transparent 2px),
    radial-gradient(circle, #f6f1e3 1.2px, transparent 2px),
    radial-gradient(circle, var(--gold) 1.6px, transparent 2.2px);
  background-size: 72px 72px, 54px 54px, 90px 90px, 40px 40px;
  background-position: 8% 12%, 70% 30%, 40% 80%, 88% 70%;
  opacity: 0.55;
  animation: burst-drift 6s linear infinite;
}

@keyframes fanfare-in {
  from {
    transform: scale(0.84) translateY(16px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@keyframes banner-glow {
  0%, 100% { box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35), 0 0 28px rgba(228, 197, 106, 0.35); }
  50% { box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35), 0 0 56px rgba(255, 230, 140, 0.7); }
}

@keyframes winner-glow {
  0%, 100% { box-shadow: 0 0 14px rgba(228, 197, 106, 0.45); }
  50% { box-shadow: 0 0 28px rgba(255, 230, 140, 0.95); }
}

@keyframes turn-pulse-inset {
  0%, 100% { box-shadow: inset 0 0 10px rgba(228, 197, 106, 0.28); }
  50% { box-shadow: inset 0 0 18px rgba(255, 230, 140, 0.55); }
}

@keyframes turn-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(228, 197, 106, 0.4); }
  50% { box-shadow: 0 0 26px rgba(255, 230, 140, 0.9); }
}

@keyframes burst-drift {
  from { transform: rotate(0deg); }
  to { transform: rotate(18deg); }
}

.opponent.offline {
  opacity: 0.55;
}

.opponent.vacated {
  border-style: dashed;
  border-color: rgba(246, 241, 227, 0.35);
  outline: none;
}

.opponent.vacated strong {
  color: var(--ink);
}

.seat-state {
  display: block;
  margin-top: 2px;
  color: var(--gold);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
}

.trick-scroller {
  position: relative;
  width: 100%;
  min-width: 0;
}

.trick-scroller.showing-nets {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.trick-scroller.is-overflow::before,
.trick-scroller.is-overflow::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 8px;
  width: 28px;
  pointer-events: none;
  z-index: 1;
}

.trick-scroller.is-overflow::before {
  left: 0;
  background: linear-gradient(90deg, rgba(18, 54, 40, 0.92), transparent);
}

.trick-scroller.is-overflow::after {
  right: 0;
  background: linear-gradient(270deg, rgba(18, 54, 40, 0.92), transparent);
}

.trick {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 10px;
  min-height: 118px;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.trick > * {
  flex: 0 0 auto;
}

.trick.round-nets {
  flex-direction: column;
  flex-wrap: nowrap;
  overflow-x: visible;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
  width: min(100%, 300px);
  min-width: 0;
  max-width: 300px;
  margin: 0 auto;
}

.trick.round-nets > * {
  flex: 0 0 auto;
  width: 100%;
}

.round-net {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  background: rgba(8, 28, 22, 0.62);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--ink);
  font-weight: 600;
}

.round-net-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.round-net-scores {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.round-net-total {
  color: var(--gold);
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
}

.trick-note {
  text-align: center;
  min-height: 1.4em;
}

.draw-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  margin: 0;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(8, 28, 22, 0.94);
  border: 1px solid rgba(228, 197, 106, 0.55);
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 24px);
}

.draw-banner[hidden] {
  display: none !important;
}

.draw-banner-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.draw-banner .card.tiny,
.draw-banner .card.draw-card {
  width: 56px;
  height: 80px;
  font-size: 0.85rem;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.28);
}

.felt.is-drawing .trick,
.felt.is-drawing .trick-note {
  opacity: 0.45;
}

.status-line {
  margin: 0;
  padding: 0;
  text-align: left;
  line-height: 1.35;
  min-height: 0;
  max-height: none;
  overflow: hidden;
  flex: 1 1 auto;
  min-width: 0;
}

#play-again {
  align-self: flex-start;
  margin-top: 8px;
}

#play-again[hidden] {
  display: none;
}

.table-toolbar.is-playing .turn-timer[hidden] {
  display: block !important;
  visibility: hidden;
}

.table-actions .check {
  margin: 0;
  flex: 1 1 100%;
}

.table-toolbar .watchers {
  margin: 4px 0 0;
}

.turn-timer {
  margin: 0;
  text-align: left;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  min-height: 1.35em;
}

.turn-countdown {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.scoreboard ol {
  margin: 8px 0 0;
  padding-left: 18px;
}

.scoreboard li.winner {
  color: var(--gold);
  font-weight: 700;
}

.score-delta {
  color: var(--gold);
  font-weight: 600;
}

.score-delta.up {
  color: var(--gold);
}

.score-delta.down {
  color: var(--danger);
}

.hand-dock {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: sticky;
  bottom: 0;
  z-index: 25;
  background: linear-gradient(transparent, var(--felt-dark) 24%);
  padding-top: 12px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.hand-dock.your-turn {
  animation: dock-pulse 1.4s ease-in-out infinite;
}

.hand-dock.your-turn .hand-hint {
  color: var(--gold);
  font-weight: 700;
}

.hand-hint {
  text-align: center;
  margin: 0 0 8px;
}

@keyframes dock-pulse {
  0%, 100% { box-shadow: 0 -6px 16px rgba(228, 197, 106, 0.08); }
  50% { box-shadow: 0 -14px 32px rgba(228, 197, 106, 0.42); }
}

.hand {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.hand.cards {
  flex-wrap: nowrap;
  gap: 0;
  overflow-x: auto;
  overflow-y: visible;
  padding: 18px 12px 8px;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.hand.cards > .card {
  flex: 0 0 auto;
  margin-left: -22px;
  position: relative;
  isolation: isolate;
  touch-action: manipulation;
  z-index: var(--hand-z, 1);
}

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

.hand.cards > .card.legal {
  transform: translateY(-14px);
}

.hand.cards > .card:disabled,
.hand.cards > .card.illegal {
  opacity: 1;
  filter: none;
  pointer-events: none;
  cursor: default;
}

.hand.cards > .card.illegal::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(12, 36, 28, 0.55);
  pointer-events: none;
}

.hand.cards > .card:hover,
.hand.cards > .card:focus-visible {
  z-index: 80;
}

.spectator-hand {
  min-width: 110px;
  background: rgba(8, 28, 22, 0.55);
  border: 1px solid rgba(228, 197, 106, 0.22);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spectator-hand.turn {
  outline: 2px solid var(--gold);
}

.spectator-hand .cards-left {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.card {
  width: 86px;
  height: 122px;
  border-radius: 10px;
  background: var(--card);
  color: var(--black);
  border: 1px solid #d7d0c3;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 10px;
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  line-height: 1;
  cursor: default;
}

button.card {
  padding: 8px 10px;
  appearance: none;
  -webkit-appearance: none;
}

.card .suit {
  font-size: 1.6rem;
  text-align: center;
}

.card.joker {
  letter-spacing: 0.02em;
}

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

.card.legal {
  cursor: pointer;
  transform: translateY(-8px);
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.32);
  min-width: 44px;
  min-height: 44px;
}

.card.tiny {
  width: 64px;
  height: 92px;
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: #3a1b1b;
  color: var(--danger);
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.identity .row {
  margin-top: 8px;
}

@media (max-width: 800px) {
  .help-dialog {
    width: calc(100vw - 24px);
    max-height: min(88vh, 40rem);
    padding: 18px 16px 12px;
  }

  .lobby-grid,
  .table-top {
    grid-template-columns: 1fr;
    grid-template-areas:
      "meta"
      "play"
      "side"
      "celebrate";
  }

  body.game-over .table-top {
    grid-template-areas:
      "meta"
      "celebrate"
      "play"
      "side";
  }

  body.table-playing .table-top {
    grid-template-areas:
      "meta"
      "play"
      "celebrate";
  }

  body.at-table #app {
    padding-top: 8px;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }

  .table-chrome {
    position: sticky;
    top: 0;
    z-index: 40;
    margin: -8px -4px 0;
    padding: max(8px, env(safe-area-inset-top, 0px)) 4px 8px;
    background: var(--felt-dark);
    box-shadow: 0 12px 18px var(--felt-dark);
  }

  body.table-playing .table-chrome {
    gap: 8px;
  }

  body.table-playing .table-toolbar {
    display: flex;
    flex: 0 0 auto;
    padding: 8px 12px;
    border-radius: 12px;
  }

  .table-toolbar {
    padding: 8px 12px;
    border-radius: 12px;
  }

  .table-status-row {
    gap: 2px;
  }

  .status-line {
    display: block;
    color: var(--ink);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
    min-height: 1.35em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .turn-timer {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.table-playing .table-toolbar .watchers {
    margin-top: 2px;
    font-size: 0.8rem;
  }

  .table-identity-copy .eyebrow {
    display: none;
  }

  .table-identity-copy h2 {
    font-size: 1.15rem;
  }

  .table-identity-row {
    flex-wrap: wrap;
  }

  .table-identity-row > button,
  .table-identity-actions > button {
    padding: 8px 10px;
  }

  body.table-playing .table-sheet-toggle {
    display: inline-flex;
    align-items: center;
  }

  body.table-playing .table-sheet-head {
    display: flex;
  }

  body.table-playing .sheet-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(0, 0, 0, 0.45);
  }

  body.table-playing .sheet-scrim[hidden] {
    display: none !important;
  }

  body.table-playing .table-side {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    max-height: min(72vh, 540px);
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--felt-dark);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(110%);
    transition: transform 0.2s ease;
  }

  body.table-playing.sheet-open .table-side {
    transform: translateY(0);
  }

  body.table-playing.sheet-scores .table-chat,
  body.table-playing.sheet-chat .scoreboard {
    display: none;
  }

  body.table-playing.sheet-open .table-chat {
    max-height: none;
    flex: 1 1 auto;
    min-height: 160px;
  }

  body.table-playing .table-chat h3 {
    display: none;
  }

  body.table-playing.sheet-open .scoreboard {
    overflow-y: auto;
    max-height: none;
    flex: 1 1 auto;
  }

  .hof-list {
    grid-template-columns: 1fr;
  }

  .felt {
    border-radius: 40px;
    min-height: 220px;
    aspect-ratio: auto;
    max-height: none;
    padding: 16px;
  }

  body.table-playing .felt {
    min-height: 220px;
    height: 220px;
    max-height: 220px;
    overflow: hidden;
    justify-content: center;
    padding: 12px 16px;
  }

  body.table-playing .opponents {
    margin-bottom: 0;
    padding: 4px 2px 6px;
  }

  body.table-playing .seat-head {
    display: flex;
  }

  body.table-playing .opponent strong {
    display: inline;
  }

  body.table-playing .seat-score {
    display: inline;
    margin-top: 0;
  }

  .card {
    width: 70px;
    height: 102px;
  }

  .hand.cards {
    padding: 22px 8px 6px;
  }

  .hand.cards > .card {
    margin-left: -28px;
  }

  .hand.cards > .card.legal {
    transform: translateY(-18px) scale(1.06);
    transform-origin: bottom center;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  body.table-playing .table-top {
    grid-template-columns: 1fr;
    grid-template-areas:
      "meta"
      "play"
      "celebrate";
  }

  body.table-playing .table-identity-copy,
  body.table-playing .table-rules {
    display: none;
  }

  body.table-playing .table-identity-row {
    justify-content: flex-end;
  }

  body.table-playing .table-sheet-toggle {
    display: inline-flex;
    align-items: center;
  }

  body.table-playing .table-sheet-head {
    display: flex;
  }

  body.table-playing .sheet-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(0, 0, 0, 0.45);
  }

  body.table-playing .sheet-scrim[hidden] {
    display: none !important;
  }

  body.table-playing .table-side {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    max-height: min(86vh, 420px);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--felt-dark);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(110%);
    transition: transform 0.2s ease;
  }

  body.table-playing.sheet-open .table-side {
    transform: translateY(0);
  }

  body.table-playing.sheet-scores .table-chat,
  body.table-playing.sheet-chat .scoreboard {
    display: none;
  }

  body.table-playing.sheet-open .table-chat {
    max-height: none;
    flex: 1 1 auto;
    min-height: 120px;
  }

  body.table-playing .table-chrome {
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-bottom: 4px;
    gap: 6px;
  }

  body.table-playing .table-toolbar {
    display: flex;
    padding: 6px 10px;
  }

  body.table-playing .status-line {
    font-size: 0.9rem;
  }

  body.table-playing .felt {
    min-height: 100px;
    height: 34vh;
    max-height: 40vh;
    border-width: 5px;
    padding: 6px 10px;
    border-radius: 28px;
    overflow: hidden;
    justify-content: center;
  }

  body.table-playing .opponents {
    margin-bottom: 0;
    padding: 4px 2px 6px;
    scroll-padding-inline: 6px;
  }

  body.table-playing .opponent {
    min-width: 76px;
    max-width: 128px;
    padding: 4px 6px;
    border-width: 2px;
  }

  body.table-playing .seat-head {
    display: flex;
    gap: 4px;
  }

  body.table-playing .seat-score {
    display: inline;
    font-size: 0.9rem;
    margin-top: 0;
  }

  body.table-playing .seat-state {
    display: none;
  }

  body.table-playing .card.tiny {
    width: 48px;
    height: 68px;
  }

  body.table-playing .draw-banner {
    padding: 6px 10px;
    gap: 4px;
  }

  body.table-playing .draw-banner .card.tiny,
  body.table-playing .draw-banner .card.draw-card {
    width: 44px;
    height: 64px;
  }

  body.table-playing .trick {
    min-height: 84px;
  }

  body.table-playing .trick-note {
    min-height: 0;
  }

  body.table-playing .hand-hint {
    margin-bottom: 2px;
    font-size: 0.85rem;
  }

  body.table-playing .hand.cards {
    padding: 10px 8px 4px;
  }

  body.table-playing .card {
    width: 56px;
    height: 80px;
  }

  body.table-playing .hand-dock {
    padding-top: 4px;
  }

  body.table-playing .table-sheet-toggle {
    display: inline-flex;
    align-items: center;
  }
}
