:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #647067;
  --paper: #f4f1e8;
  --felt: #0f6c50;
  --felt-dark: #0b4235;
  --felt-mid: #13785a;
  --line: rgba(23, 32, 27, 0.14);
  --gold: #d8ad50;
  --gold-soft: rgba(216, 173, 80, 0.18);
  --red: #bd3d37;
  --blue: #2f5f9f;
  --blue-soft: rgba(47, 95, 159, 0.18);
  --white: #fffdf7;
  --shadow: 0 18px 50px rgba(18, 28, 23, 0.18);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--white);
  background: #171816;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

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

.app-shell {
  width: min(680px, calc(100vw - 18px));
  margin: 0 auto;
  padding: 10px 0 14px;
}

.topbar,
.match-strip,
.player-row,
.market-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 8px;
  opacity: 0.92;
}

.eyebrow,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.15rem, 3vw, 1.7rem);
  line-height: 1;
}

h2 {
  font-size: 1.02rem;
  line-height: 1.15;
}

.room-panel,
.match-strip,
.action-panel,
.log-panel {
  background: rgba(255, 253, 247, 0.08);
  border: 1px solid rgba(255, 253, 247, 0.14);
  box-shadow: none;
}

.room-panel {
  display: grid;
  grid-template-columns: 40px minmax(72px, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-width: 300px;
  padding: 6px;
  border-radius: 8px;
}

.learn-mode .room-panel {
  grid-template-columns: 40px minmax(72px, 1fr) auto;
}

.learn-mode #copyInviteButton {
  display: none;
}

.learn-mode #learnModeButton {
  display: none;
}

.icon-button,
.primary-button,
.secondary-button {
  min-height: 34px;
  border-radius: 8px;
  font-weight: 800;
}

.icon-button {
  width: 34px;
  background: var(--ink);
  color: var(--white);
  font-size: 1.5rem;
}

.primary-button {
  padding: 0 16px;
  color: var(--ink);
  background: var(--gold);
}

.primary-button:hover,
.icon-button:hover {
  filter: brightness(1.04);
}

.secondary-button {
  padding: 0 14px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.secondary-button:disabled {
  opacity: 0.45;
}

.match-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 12px 16px;
  border-radius: 8px 8px 0 0;
  margin-bottom: 0;
  background: #242622;
  border-color: rgba(255, 253, 247, 0.16);
}

.match-strip div {
  min-width: 0;
}

.match-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 0.98rem;
  line-height: 1.18;
  color: rgba(255, 253, 247, 0.86);
}

#turnLabel {
  display: inline-flex;
  width: fit-content;
  min-height: 30px;
  align-items: center;
  padding: 4px 13px;
  border-radius: 999px;
  color: var(--white);
  background: var(--blue);
}

.table-scene {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 253, 247, 0.16);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: #282925;
}

.player-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  min-height: 96px;
  padding: 16px 28px;
  border: 0;
  border-bottom: 1px solid rgba(255, 253, 247, 0.13);
  border-radius: 0;
  background: #2b2c29;
  transition: border-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.player-row.current-turn {
  background: #2d302d;
  box-shadow: inset 5px 0 0 var(--blue);
}

.player-row.current-turn::before {
  content: none;
}

.winner-row {
  border-color: rgba(216, 173, 80, 0.95);
  box-shadow: 0 0 0 3px rgba(216, 173, 80, 0.28), var(--shadow);
  background: rgba(255, 253, 247, 0.96);
}

.you-row {
  background: #2e302c;
  box-shadow: inset 5px 0 0 var(--gold);
}

.player-row.self {
  display: block;
  border-bottom: 0;
}

.seat-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.loser-row {
  opacity: 0.68;
}

.split-row {
  border-color: rgba(47, 95, 159, 0.72);
  box-shadow: 0 0 0 3px rgba(47, 95, 159, 0.18), var(--shadow);
}

.player-outcome {
  display: inline-flex;
  width: max-content;
  margin-top: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--gold);
  font-size: 0.72rem;
  font-weight: 950;
  line-height: 1.2;
  text-transform: uppercase;
}

.loser-row .player-outcome {
  color: var(--white);
  background: var(--red);
}

.player-outcome[hidden] {
  display: none;
}

.seat-summary {
  min-width: 0;
}

.seat-summary h2 {
  color: var(--white);
  font-size: 1.18rem;
  line-height: 1.1;
}

.seat-summary p {
  margin: 4px 0 0;
  color: rgba(255, 253, 247, 0.76);
  font-size: 0.88rem;
  font-weight: 750;
  line-height: 1.3;
}

.felt {
  min-height: 250px;
  padding: 24px 28px 22px;
  border-radius: 0;
  color: var(--white);
  background:
    radial-gradient(circle at 50% 52%, rgba(255, 253, 247, 0.11), transparent 48%),
    linear-gradient(145deg, var(--felt-mid), var(--felt-dark));
  box-shadow: inset 0 0 0 1px rgba(255, 253, 247, 0.08);
}

.market-header h2 {
  color: rgba(255, 253, 247, 0.86);
  font-size: 0.98rem;
  font-weight: 800;
}

.card-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.market {
  justify-content: center;
  margin: 20px auto 4px;
}

.compact {
  justify-content: flex-end;
  min-width: 220px;
}

.compact .card {
  width: 54px;
  padding: 6px;
}

.compact .rank {
  font-size: 0.95rem;
}

.compact .pip {
  font-size: 1.26rem;
}

.compact .suit {
  font-size: 0.9rem;
}

.card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 66px;
  aspect-ratio: 5 / 7;
  padding: 8px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid rgba(23, 32, 27, 0.22);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
  transition: box-shadow 150ms ease, transform 150ms ease, outline-color 150ms ease;
  user-select: none;
}

.market .card:not(:disabled):hover {
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.26);
  transform: translateY(-4px);
}

.market .card {
  width: 92px;
  padding: 12px;
}

.market .rank {
  font-size: 1.55rem;
}

.market .pip {
  font-size: 2.08rem;
}

.market .suit {
  font-size: 1.2rem;
}

.card.back {
  background:
    radial-gradient(circle, rgba(255, 253, 247, 0.16) 1px, transparent 1.5px),
    #163f75;
  background-size: 10px 10px;
  color: #8ebdff;
}

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

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

.card.suit-C {
  color: var(--ink);
}

.card.suit-S {
  color: var(--ink);
}

.card.selected {
  outline: 4px solid var(--blue);
  transform: translateY(-8px);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.3);
}

.rank {
  font-size: 1.12rem;
  font-weight: 900;
}

.suit {
  align-self: end;
  justify-self: end;
  font-weight: 900;
}

.pip {
  align-self: center;
  justify-self: center;
  font-size: 1.48rem;
  font-weight: 900;
}

.action-panel,
.log-panel {
  border-radius: 8px;
  padding: 9px;
}

.action-panel {
  padding: 14px 0 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.decision-readout {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
}

.decision-readout span {
  color: rgba(255, 253, 247, 0.72);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.25;
}

.decision-readout strong {
  color: var(--white);
  font-size: 1.05rem;
  line-height: 1.25;
}

.action-panel.ready {
  box-shadow: none;
}

.action-panel.waiting {
  background: transparent;
  box-shadow: none;
}

.action-panel.complete {
  border-color: rgba(47, 95, 159, 0.55);
}

.log-panel {
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.log-panel summary {
  display: flex;
  min-height: 30px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: rgba(255, 253, 247, 0.78);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.log-panel summary::-webkit-details-marker {
  display: none;
}

.moves-open {
  display: none;
}

.log-panel[open] .moves-open {
  display: inline;
}

.log-panel[open] .moves-closed {
  display: none;
}

.log-panel li {
  color: rgba(255, 253, 247, 0.72);
}

.log-panel ol {
  max-height: 70px;
  overflow: auto;
}

.action-button {
  width: 100%;
  min-height: 74px;
  margin-top: 14px;
  padding: 12px 16px;
  text-align: center;
  color: var(--white);
  border: 0;
  border-radius: 8px;
  background: #2f7edb;
}

.action-panel.ready .action-button {
  background: #2f7edb;
}

.winner-banner {
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--gold);
  font-size: 1.05rem;
  font-weight: 950;
  line-height: 1.2;
  text-align: center;
}

.winner-banner.split {
  color: var(--white);
  background: var(--blue);
}

.winner-banner[hidden] {
  display: none;
}

.trainer-scene {
  overflow: hidden;
  border: 1px solid rgba(255, 253, 247, 0.16);
  border-radius: 8px;
  background: #282925;
}

.trainer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: #242622;
  border-bottom: 1px solid rgba(255, 253, 247, 0.14);
}

.trainer-head h2 {
  margin-top: 4px;
  color: var(--white);
}

.trainer-board {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.trainer-copy {
  display: grid;
  gap: 8px;
}

.trainer-copy p,
.trainer-copy strong {
  margin: 0;
  line-height: 1.35;
}

.trainer-copy p {
  color: rgba(255, 253, 247, 0.78);
  font-size: 0.95rem;
}

.trainer-copy strong {
  color: var(--white);
  font-size: 1rem;
}

.trainer-hand {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(170px, auto);
  gap: 14px;
  align-items: end;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.08);
}

.trainer-readout {
  color: var(--white);
  font-size: 1rem;
  font-weight: 850;
  text-align: right;
}

.trainer-table {
  display: grid;
  gap: 12px;
  padding: 18px 14px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 253, 247, 0.1), transparent 50%),
    linear-gradient(145deg, var(--felt-mid), var(--felt-dark));
}

.trainer-table .muted {
  color: rgba(255, 253, 247, 0.76);
}

.trainer-feedback {
  display: grid;
  gap: 5px;
  padding: 13px 14px;
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.1);
  border-left: 5px solid var(--blue);
}

.trainer-feedback.correct {
  border-left-color: var(--gold);
}

.trainer-feedback.miss {
  border-left-color: var(--red);
}

.trainer-feedback strong,
.trainer-feedback span,
.trainer-feedback small {
  display: block;
  line-height: 1.3;
}

.trainer-feedback strong {
  color: var(--white);
  font-size: 1.05rem;
}

.trainer-feedback span {
  color: rgba(255, 253, 247, 0.86);
  font-weight: 800;
}

.trainer-feedback small {
  color: rgba(255, 253, 247, 0.68);
  font-size: 0.82rem;
}

.trainer-actions .action-button {
  margin-top: 0;
}

.trainer-actions .action-button:disabled {
  color: rgba(255, 253, 247, 0.72);
  background: rgba(255, 253, 247, 0.14);
}

.action-button span,
.action-button small {
  display: block;
}

.action-button span {
  font-size: 1.18rem;
  font-weight: 950;
  margin-bottom: 4px;
  line-height: 1.15;
}

.action-button small {
  color: rgba(255, 253, 247, 0.82);
  font-size: 0.82rem;
  line-height: 1.35;
}

ol {
  margin: 6px 0 0;
  padding-left: 20px;
}

li {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 820px) {
  .app-shell {
    width: calc(100vw - 12px);
    padding: 3px 0;
  }

  .topbar,
  .market-header {
    align-items: center;
    flex-direction: row;
    gap: 8px;
  }

  .topbar {
    margin-bottom: 4px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: 1.18rem;
  }

  h2 {
    font-size: 0.9rem;
  }

  .room-panel {
    grid-template-columns: 30px minmax(48px, 1fr) auto auto;
    gap: 5px;
    min-width: 0;
    width: min(310px, 58vw);
    padding: 4px;
  }

  .learn-mode .room-panel {
    grid-template-columns: 30px minmax(48px, 1fr) auto;
  }

  .icon-button {
    width: 30px;
    min-height: 30px;
  }

  .primary-button,
  .secondary-button {
    min-height: 30px;
    padding: 0 9px;
    font-size: 0.82rem;
  }

  .match-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 6px 8px;
    margin-bottom: 4px;
  }

  .match-strip strong {
    font-size: 0.82rem;
  }

  .muted {
    font-size: 0.68rem;
  }

  .primary-button {
    grid-column: auto;
  }

  .table-scene {
    gap: 6px;
  }

  .player-row {
    grid-template-columns: minmax(88px, 1fr) auto;
    min-height: 58px;
    padding: 6px 8px;
  }

  .player-row.self {
    padding: 10px 12px;
  }

  .seat-topline {
    gap: 10px;
  }

  .seat-summary h2 {
    font-size: 1rem;
  }

  .seat-summary p {
    font-size: 0.76rem;
    line-height: 1.2;
  }

  .player-outcome {
    margin-top: 2px;
    padding: 1px 5px;
    font-size: 0.58rem;
  }

  .compact {
    justify-content: flex-end;
    min-width: 110px;
    gap: 6px;
  }

  .compact .card {
    width: 44px;
    padding: 5px;
  }

  .felt {
    padding: 12px 10px 10px;
    min-height: auto;
  }

  .market-header h2 {
    font-size: 0.86rem;
  }

  .market {
    gap: 6px;
    margin: 12px auto 8px;
  }

  .card {
    width: clamp(42px, 8.5vw, 50px);
    padding: 5px;
  }

  .market .card {
    width: clamp(66px, 14vw, 78px);
    padding: 8px;
  }

  .market .rank {
    font-size: 1.18rem;
  }

  .market .pip {
    font-size: 1.58rem;
  }

  .market .suit {
    font-size: 0.98rem;
  }

  .rank {
    font-size: 0.92rem;
  }

  .pip {
    font-size: 1.16rem;
  }

  .suit {
    font-size: 0.82rem;
  }

  .action-panel,
  .log-panel {
    padding: 0;
  }

  .action-button {
    min-height: 58px;
    margin-top: 8px;
    padding: 9px;
  }

  .winner-banner {
    margin-top: 4px;
    padding: 7px 8px;
    font-size: 0.86rem;
  }

  .action-button span {
    margin-bottom: 2px;
    font-size: 1.08rem;
  }

  .action-button small,
  li {
    font-size: 0.72rem;
  }

  .trainer-head {
    padding: 10px 12px;
  }

  .trainer-board {
    gap: 10px;
    padding: 12px;
  }

  .trainer-copy p {
    font-size: 0.84rem;
  }

  .trainer-copy strong,
  .trainer-readout {
    font-size: 0.9rem;
  }

  .trainer-hand {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .trainer-readout {
    text-align: left;
  }

  .trainer-table {
    gap: 8px;
    padding: 12px 10px;
  }

  .trainer-feedback {
    padding: 10px 11px;
  }

}

@media (max-width: 560px) {
  .room-panel {
    width: min(300px, 62vw);
  }

  .match-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
