:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --ink: #171b1a;
  --muted: #68706d;
  --line: #d9ded4;
  --panel: #ffffff;
  --green: #176b4d;
  --green-2: #0e4f39;
  --red: #b93d31;
  --amber: #b78016;
  --blue: #276a9f;
  --shadow: 0 12px 28px rgba(20, 27, 24, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-weight: 750;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

button.secondary,
.subtle button,
.action-grid button:nth-child(odd) {
  background: #e7ece4;
  color: var(--ink);
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(2.1rem, 8vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
  letter-spacing: 0;
}

.screen {
  width: min(1040px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: 18px;
}

#home {
  display: grid;
  align-content: center;
  gap: 16px;
}

.brand {
  padding: 26px 0 12px;
}

.eyebrow {
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel,
.join-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  box-shadow: var(--shadow);
}

.subtle {
  box-shadow: none;
}

.danger {
  border-color: #edc4bf;
}

.topbar {
  position: sticky;
  z-index: 4;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: -18px -18px 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 242, 0.92);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  font-size: 1.35rem;
  line-height: 1.1;
}

.icon-button {
  width: 44px;
  padding: 0;
  background: var(--ink);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--muted);
  padding: 0 10px;
  font-size: 0.76rem;
  font-weight: 850;
  white-space: nowrap;
}

.sync-status.is-live {
  border-color: #b8dbc5;
  background: #edf8f0;
  color: var(--green-2);
}

.link-button {
  min-height: 0;
  padding: 0;
  background: transparent;
  color: var(--green);
  font: inherit;
  text-decoration: underline;
}

.tabs {
  position: sticky;
  z-index: 3;
  top: 72px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1ea;
}

.tab {
  min-height: 38px;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 4px 10px rgba(20, 27, 24, 0.08);
}

.tab-panel {
  display: grid;
  gap: 12px;
}

.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfcf8, #eef2ea);
  padding: 10px;
  box-shadow: var(--shadow);
}

.poker-table {
  position: relative;
  min-height: 430px;
}

.table-felt {
  position: absolute;
  inset: 20% 14%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 10px solid #8b6d3b;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.12), transparent 58%),
    #236846;
  color: white;
  text-align: center;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.15), 0 14px 24px rgba(20, 27, 24, 0.14);
}

.table-felt .eyebrow {
  color: #d9f1df;
}

.table-felt strong {
  font-size: clamp(2rem, 9vw, 4rem);
  line-height: 1;
}

.table-felt span {
  max-width: 180px;
  color: #e8f4ec;
  font-size: 0.86rem;
  font-weight: 800;
}

.table-seats {
  position: absolute;
  inset: 0;
}

.seat-card {
  position: absolute;
  left: var(--seat-x);
  top: var(--seat-y);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: clamp(134px, 34vw, 188px);
  min-height: 82px;
  gap: 8px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 9px 10px;
  box-shadow: 0 10px 22px rgba(20, 27, 24, 0.12);
  transform: translate(-50%, -50%);
}

.seat-card.is-turn {
  border-color: var(--amber);
  box-shadow: 0 0 0 4px rgba(183, 128, 22, 0.16), 0 12px 26px rgba(20, 27, 24, 0.16);
}

.seat-card.is-folded,
.seat-card.is-inactive {
  opacity: 0.58;
}

.player-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 850;
}

.seat-num,
.dealer-chip {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-size: 0.72rem;
  font-weight: 900;
  flex: 0 0 auto;
}

.dealer-chip {
  background: var(--blue);
}

.badge {
  border-radius: 999px;
  background: #e7ece4;
  color: var(--muted);
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 850;
  white-space: nowrap;
}

.stack {
  color: var(--green-2);
  font-size: 1.1rem;
  font-weight: 900;
  text-align: right;
}

.meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.last-action {
  margin-top: 2px;
  color: var(--amber);
  font-size: 0.75rem;
  font-weight: 850;
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.inline-fields.three {
  grid-template-columns: 1.2fr 1fr 1fr;
}

.hand-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.hand-head button {
  min-width: 110px;
  background: var(--blue);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.bet-row {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 8px;
  align-items: end;
}

.rename-row {
  display: grid;
  grid-template-columns: 1fr 108px;
  gap: 8px;
  align-items: end;
}

.pots {
  display: grid;
  gap: 10px;
}

.pot-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 14px;
}

.pot-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.pot-amount {
  color: var(--green-2);
  font-size: 1.4rem;
  font-weight: 950;
}

.winner-grid {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.quick-winners {
  display: grid;
  gap: 8px;
}

.quick-winner-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-winner-buttons button {
  min-height: 38px;
  border: 1px solid #b8dbc5;
  background: #edf8f0;
  color: var(--green-2);
  padding: 0 12px;
}

.winner-grid label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
}

.winner-grid input {
  width: 20px;
  min-height: 20px;
}

.ledger {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
}

.totals {
  display: grid;
  gap: 8px;
}

.total-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.total-row div {
  display: grid;
  gap: 2px;
}

.total-row div:last-child {
  text-align: right;
}

.total-row span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

summary {
  cursor: pointer;
  font-weight: 850;
}

.ledger-item {
  display: grid;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

.ledger-item:last-child {
  border-bottom: 0;
}

.ledger-item p {
  font-weight: 760;
}

.ledger-item time {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 10;
  max-width: 520px;
  margin: 0 auto;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 13px 14px;
  box-shadow: var(--shadow);
  font-weight: 750;
}

.hidden {
  display: none !important;
}

@media (min-width: 760px) {
  #home {
    grid-template-columns: 1.4fr 0.8fr;
  }

  #joinByCodeForm {
    grid-column: 2;
  }

  .brand {
    grid-row: span 2;
    align-self: center;
  }

  .tab-panel {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  #tab-play {
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  }

  #tab-play .table-panel {
    grid-row: span 3;
  }

  #tab-ledger,
  #tab-fix {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .screen {
    padding: 12px;
  }

  .topbar {
    margin: -12px -12px 10px;
    padding: 12px;
  }

  .tabs {
    top: 67px;
  }

  .inline-fields,
  .inline-fields.three,
  .rename-row {
    grid-template-columns: 1fr;
  }

  .poker-table {
    min-height: 390px;
  }

  .table-felt {
    inset: 25% 12%;
    border-width: 8px;
  }

  .seat-card {
    width: 138px;
    min-height: 78px;
    padding: 8px;
  }

  .player-name {
    gap: 5px;
  }

  .badge,
  .dealer-chip,
  .seat-num {
    transform: scale(0.88);
    transform-origin: center;
  }
}
