:root {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color-scheme: dark;
  color: #f3f1e4;
  background: #09231d;
  font-synthesis: none;
  --gold: #f4cc77;
  --muted: #b3c9b8;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-inline-size: 0;
  background: radial-gradient(ellipse at 50% 0%, #1a4536, #09231d 68%);
}

[hidden] { display: none !important; }
h1, h2, p, ol { margin: 0; }
ol { padding: 0; list-style: none; }

.game {
  width: min(100% - 2rem, 62rem);
  min-height: 100vh;
  margin-inline: auto;
  padding-block: 1.25rem;
  display: grid;
  align-content: start;
  gap: .8rem;
}

.masthead,
.player-heading,
.player-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.masthead h1 {
  font-family: "Songti SC", "Noto Serif CJK SC", Georgia, serif;
  font-size: clamp(1.5rem, 4vw, 2.6rem);
  letter-spacing: .12em;
}

.masthead p, .player-heading span { color: var(--muted); font-size: .875rem; }

.table {
  display: grid;
  align-content: start;
  gap: clamp(.6rem, 2.5vh, 1.75rem);
  padding: clamp(.65rem, 2vw, 1.5rem);
  border: 1px solid #527c61;
  border-radius: clamp(1rem, 3vw, 2rem);
  background: radial-gradient(ellipse, #224f3b, #123629 83%);
  box-shadow: inset 0 0 0 4px #0f3024, 0 .4rem 1.4rem #061c166e;
}

.opponents {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(.3rem, 1.5vw, .8rem);
}

.seat {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: .15rem .5rem;
  padding: .4rem .25rem;
  border: 1px solid #50735e;
  border-radius: .6rem;
  background: #102d24;
  font-size: .875rem;
  text-align: center;
}

.seat.acting { border-color: var(--gold); }
.seat-count { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.seat-status { color: var(--gold); font-weight: 700; }
.seat-status:empty { display: none; }

.center { text-align: center; display: grid; justify-items: center; gap: .35rem; }
.turn { display: flex; align-items: center; justify-content: center; gap: .6rem; min-height: 1.8rem; }
.turn strong { color: var(--gold); font-size: clamp(1rem, 3vw, 1.35rem); }
.countdown {
  padding: .12rem .45rem;
  border: 1px solid #8a7851;
  border-radius: .4rem;
  white-space: nowrap;
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
}

.public-title { font-size: .9rem; }
.activity { color: var(--muted); min-height: 1.2em; font-size: .82rem; }
.public-cards {
  --public-height: clamp(2.75rem, 11vh, 4.5rem);
  display: flex;
  justify-content: center;
  gap: .32rem;
  min-height: var(--public-height);
}
.public-cards .card { width: calc(var(--public-height) * .72); height: var(--public-height); }

.player {
  display: grid;
  gap: .55rem;
  padding: .75rem;
  border: 1px solid #365a48;
  border-radius: 1rem;
  background: #102e25;
}

.player-heading h2 { font-size: .95rem; }
.player-heading h2 span { margin-inline-start: .3rem; font-weight: 400; }
.hand {
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  justify-content: center;
  gap: clamp(.14rem, .8vw, .48rem);
  min-height: 3.2rem;
  padding-top: .48rem;
}

button {
  min-height: 2.75rem;
  border: 1px solid #678473;
  border-radius: .5rem;
  padding: .45rem clamp(.6rem, 1.8vw, 1.1rem);
  background: #173d30;
  color: #f3f1e4;
  font: inherit;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled { cursor: default; }
.controls button:disabled { opacity: .55; }
button:focus-visible { outline: 2px solid #fff2b9; outline-offset: 2px; }
button.primary { border-color: var(--gold); background: var(--gold); color: #241e12; }

.card {
  display: block;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  border-radius: .32rem;
  background: transparent;
  color: #18251e;
  font-size: clamp(.82rem, 2.8vw, 1.65rem);
  font-weight: 750;
  text-align: center;
  user-select: none;
}

.hand .card { height: clamp(2.75rem, 13vh, 6.2rem); }
.card.red { color: #a02231; }
.card-face {
  display: grid;
  height: 100%;
  place-content: center;
  border: 1px solid #d8d2bc;
  border-radius: inherit;
  background: #fcf7e9;
  box-shadow: 0 .16rem .2rem #041d1680;
  line-height: 1;
  pointer-events: none;
  transition: transform 120ms ease;
}

.card .suit { font-size: 1.06em; }
.card[aria-pressed="true"] .card-face {
  transform: translateY(-.45rem);
  background: #fff0c3;
  border-color: #ce921d;
  outline: 1px solid #ce921d;
}

.player-footer { min-height: 2.75rem; }
.feedback { color: var(--gold); font-size: .88rem; min-height: 1.2em; }
.controls { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .4rem; margin-inline-start: auto; }
.result {
  display: grid;
  justify-items: center;
  gap: .65rem;
  padding: 1rem;
  border: 1px solid #ae8f50;
  border-radius: 1rem;
  background: #102e25;
}

.result h2 { color: var(--gold); }
.result ol { display: flex; justify-content: center; flex-wrap: wrap; gap: .35rem 1.2rem; color: var(--muted); }

@media (max-width: 38rem) and (orientation: portrait) {
  .game { width: calc(100% - 1rem); }
  .hand { grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: .55rem; }
  .hand .card { height: clamp(3.25rem, 13vw, 4.75rem); }
  .player-footer { flex-direction: column; align-items: stretch; gap: .25rem; }
  .controls { margin-inline-start: 0; }
}

@media (max-height: 32rem) and (orientation: landscape) {
  .game { padding-block: .25rem; gap: .3rem; width: min(100% - 1rem, 62rem); }
  .masthead h1 { font-size: 1.25rem; }
  .table, .player { padding: .45rem; gap: .3rem; }
  .center { gap: .15rem; }
  .public-cards { --public-height: clamp(2.25rem, 10vh, 3rem); }
  .hand { min-height: 0; }
  .hand .card { height: 2.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  .card-face { transition: none; }
}
