:root {
  --ink: #14120f;
  --felt: #157a52;
  --felt-dark: #0c4a34;
  --ivory: #f3eee3;
  --red: #d42b2b;
  --gold: #e3c36f;
  --line: rgba(243, 238, 227, 0.18);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  color: var(--ivory);
  background:
    radial-gradient(1200px 700px at 50% -10%, #2a241c 0%, var(--ink) 55%);
  letter-spacing: 0;
}

button, input {
  font: inherit;
  letter-spacing: 0;
}
button {
  border: 0;
  background: var(--gold);
  color: #22190b;
  padding: 10px 16px;
  min-height: 42px;
  cursor: pointer;
}
button.ghost {
  background: transparent;
  color: var(--ivory);
  border: 1px solid var(--line);
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
input {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: #1c1915;
  color: var(--ivory);
  border: 1px solid var(--line);
}

.hidden { display: none !important; }
.lobby {
  min-height: 100%;
  display: grid;
  place-content: center;
  gap: 28px;
  padding: 32px 16px 80px;
}
.kicker { margin: 0; color: var(--gold); font-size: 14px; }
.lobby h1 { margin: 6px 0 0; font-size: 72px; line-height: 0.9; }
.sub { margin: 10px 0 0; color: rgba(243, 238, 227, 0.72); }
.entry {
  width: min(420px, 92vw);
  display: grid;
  gap: 14px;
}
.entry-actions { display: flex; gap: 10px; }
.error { min-height: 1.2em; color: #ff8d73; margin: 0; }

.table {
  height: 100%;
  display: grid;
  grid-template-rows: 64px 1fr 168px;
  position: relative;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.room {
  font-size: 20px;
  margin-right: 12px;
  color: var(--gold);
}
.top-actions { display: flex; gap: 8px; }

.felt {
  position: relative;
  margin: 12px 16px;
  background:
    radial-gradient(ellipse at center, #1d9464 0%, var(--felt) 42%, var(--felt-dark) 100%);
  box-shadow: var(--shadow), inset 0 0 80px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
.seat {
  position: absolute;
  min-width: 160px;
  padding: 10px 12px;
  background: rgba(12, 20, 16, 0.28);
}
.seat.turn { outline: 2px solid var(--gold); }
.seat-top { top: 16px; left: 50%; transform: translateX(-50%); text-align: center; }
.seat-bottom { bottom: 16px; left: 50%; transform: translateX(-50%); text-align: center; }
.seat-left { left: 16px; top: 50%; transform: translateY(-50%); }
.seat-right { right: 16px; top: 50%; transform: translateY(-50%); text-align: right; }
.seat b { display: block; font-size: 18px; }
.seat span { color: rgba(243, 238, 227, 0.76); font-size: 13px; }
.mini-cards { display: flex; gap: 4px; margin-top: 8px; justify-content: inherit; }

.center {
  position: absolute;
  inset: 90px 180px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
}
.trick { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; min-height: 110px; }
.banner { margin: 0; font-size: 20px; text-shadow: 0 2px 12px #000; }

.dock {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 8px 16px 16px;
}
.hand {
  display: flex;
  justify-content: center;
  min-height: 132px;
  overflow: hidden;
}
.play-actions {
  display: flex;
  gap: 8px;
  padding-bottom: 18px;
}

.card {
  width: 72px;
  height: 108px;
  border: 1px solid #2a2318;
  background: linear-gradient(#fffaf1, #efe6d4);
  color: #1a1510;
  position: relative;
  flex: 0 0 72px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.28);
  user-select: none;
}
.card.red { color: var(--red); }
.card.joker { background: linear-gradient(#f7e7a6, #e7c35a); color: #231b0b; }
.card.wild { outline: 2px solid #1f8a5a; }
.card small, .card strong {
  position: absolute;
  left: 8px;
  font-style: normal;
}
.card small { top: 8px; font-size: 13px; }
.card strong { bottom: 8px; right: 8px; left: auto; font-size: 22px; }
.card.back {
  background:
    repeating-linear-gradient(45deg, #7b1e24, #7b1e24 8px, #5e151a 8px, #5e151a 16px);
  color: transparent;
}
.hand .card {
  margin-left: -18px;
  cursor: pointer;
  transition: transform 80ms ease;
}
.hand .card:first-child { margin-left: 0; }
.hand .card.up { transform: translateY(-18px); }
.trick .card { width: 64px; height: 96px; flex-basis: 64px; }

.log {
  position: absolute;
  right: 24px;
  bottom: 188px;
  width: min(240px, 30vw);
  max-height: 180px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(243, 238, 227, 0.82);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 188px;
  transform: translateX(-50%);
  background: #1b1611;
  color: var(--ivory);
  padding: 10px 16px;
  border: 1px solid var(--gold);
}

@media (max-width: 800px) {
  .lobby h1 { font-size: 54px; }
  .center { inset: 96px 12px; }
  .seat-left, .seat-right { top: 88px; transform: none; }
  .log { display: none; }
  .dock { grid-template-columns: 1fr; }
  .play-actions { justify-content: center; }
  .card, .hand .card { width: 54px; height: 84px; flex-basis: 54px; }
}
