:root {
  color-scheme: dark;
  --ink: #f8f3e7;
  --muted: #aab9b2;
  --night: #071713;
  --panel: #10241f;
  --panel-soft: #17342c;
  --felt: #14634f;
  --felt-dark: #0b4436;
  --mint: #7ce0b2;
  --gold: #f0c879;
  --coral: #ff786c;
  --line: rgba(255, 255, 255, .13);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--night); }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(42, 151, 115, .2), transparent 34rem),
    radial-gradient(circle at 100% 90%, rgba(240, 200, 121, .12), transparent 36rem),
    var(--night);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; }
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #1a3931;
  cursor: pointer;
  font-weight: 760;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
button:hover:not(:disabled) { transform: translateY(-1px); border-color: rgba(124, 224, 178, .55); }
button:disabled { cursor: not-allowed; opacity: .38; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.app {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) clamp(14px, 2.2vw, 34px) max(22px, env(safe-area-inset-bottom));
}

.topbar, .room-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar { min-height: 54px; margin-bottom: 18px; }
.back {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, .05);
  text-decoration: none;
  font-weight: 750;
}
.brand { text-align: center; line-height: 1; }
.brand small {
  display: block;
  margin-bottom: 5px;
  color: var(--mint);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .22em;
}
.brand strong { font-family: Georgia, "Songti SC", serif; font-size: clamp(20px, 2.5vw, 30px); }
.sound-button { min-height: 38px; padding: 0 12px; font-size: 12px; }

.lobby {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, .9fr) minmax(380px, 1.1fr);
  min-height: min(750px, calc(100vh - 100px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: linear-gradient(135deg, #123f34, #0d211c 62%);
  box-shadow: 0 32px 90px rgba(0, 0, 0, .36);
}
.lobby-art {
  position: relative;
  min-height: 460px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at center, rgba(25, 126, 95, .85), rgba(4, 25, 20, .36) 68%),
    repeating-linear-gradient(30deg, transparent 0 28px, rgba(255, 255, 255, .025) 28px 29px);
}
.lobby-art::before {
  content: "";
  position: absolute;
  width: 72%;
  aspect-ratio: 1.65;
  left: 14%;
  top: 26%;
  border: 12px solid rgba(240, 200, 121, .22);
  border-radius: 50%;
  background: #126049;
  box-shadow: 0 22px 70px rgba(0, 0, 0, .4), inset 0 0 0 2px rgba(255, 255, 255, .08);
  transform: rotate(-7deg);
}
.art-card {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: clamp(104px, 13vw, 170px);
  aspect-ratio: .7;
  padding: 13px;
  border: 2px solid #dbd7cb;
  border-radius: 17px;
  color: #161916;
  background: #fbf8ed;
  box-shadow: 0 20px 35px rgba(0, 0, 0, .38);
  font: 800 clamp(27px, 4vw, 54px)/.85 Georgia, serif;
}
.art-card i { margin: auto; font-size: 1.3em; font-style: normal; }
.art-card.red { color: #d83d3d; }
.card-one { top: 31%; left: 24%; transform: rotate(-17deg); }
.card-two { top: 28%; left: 49%; transform: rotate(10deg); }
.art-chip {
  position: absolute;
  z-index: 3;
  width: clamp(44px, 5vw, 68px);
  aspect-ratio: 1;
  border: 7px dashed rgba(255, 255, 255, .85);
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 8px 15px rgba(0, 0, 0, .35);
}
.chip-one { top: 65%; left: 27%; }
.chip-two { top: 69%; left: 39%; background: #293fca; }
.chip-three { top: 61%; left: 57%; background: #e9b54e; }

.lobby-panel {
  align-self: center;
  width: min(600px, 100%);
  padding: clamp(28px, 5vw, 74px);
}
.eyebrow {
  margin: 0 0 12px;
  color: var(--mint);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .2em;
}
.lobby h1 {
  max-width: 520px;
  margin: 0;
  font: 700 clamp(38px, 5.4vw, 76px)/.98 Georgia, "Songti SC", serif;
  letter-spacing: -.045em;
}
.intro { max-width: 540px; margin: 20px 0 28px; color: var(--muted); line-height: 1.75; }
.field { display: grid; gap: 8px; color: #dfe9e5; font-size: 12px; font-weight: 720; }
.field input, .field select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(3, 19, 15, .56);
}
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin: 22px 0 16px;
  padding: 5px;
  border-radius: 15px;
  background: rgba(2, 16, 13, .54);
}
.tabs button { border: 0; background: transparent; }
.tabs button.active { color: #092119; background: var(--mint); }
.option-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pane .primary { width: 100%; margin-top: 16px; }
.primary {
  min-height: 48px;
  border-color: transparent;
  color: #0a241b;
  background: var(--mint);
}
.secondary { background: rgba(124, 224, 178, .13); }
.room-code-input { text-transform: uppercase; letter-spacing: .18em; font-weight: 850; }
.form-error { min-height: 20px; margin: 12px 0 0; color: #ff9b91; font-size: 13px; }
.rules-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.rules-strip span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
}

.table-screen { min-height: calc(100vh - 92px); }
.room-bar {
  min-height: 58px;
  margin-bottom: 14px;
  padding: 9px 12px 9px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(16, 36, 31, .88);
}
.room-bar > div:first-child { display: grid; grid-template-columns: auto auto; align-items: center; gap: 0 9px; }
.room-bar small { grid-column: 2; color: var(--muted); font-size: 10px; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: #68756f; box-shadow: 0 0 0 4px rgba(104, 117, 111, .15); }
.online-dot.online { background: var(--mint); box-shadow: 0 0 0 4px rgba(124, 224, 178, .13), 0 0 15px var(--mint); }
.room-actions { display: flex; gap: 8px; }
.room-actions button { min-height: 36px; padding: 0 12px; font-size: 12px; }

.table-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; }
.poker-stage {
  min-width: 0;
  padding: clamp(12px, 1.5vw, 22px);
  border: 1px solid var(--line);
  border-radius: 26px;
  background: #0d201b;
}
.felt {
  position: relative;
  min-height: clamp(500px, 68vh, 780px);
  overflow: hidden;
  border: clamp(10px, 1.5vw, 20px) solid #3a2418;
  border-radius: 42% / 48%;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(38, 150, 111, .5), transparent 58%),
    repeating-radial-gradient(ellipse at center, rgba(255, 255, 255, .013) 0 2px, transparent 2px 5px),
    var(--felt-dark);
  box-shadow: inset 0 0 0 4px #8a5c39, inset 0 0 80px rgba(0, 0, 0, .42), 0 20px 46px rgba(0, 0, 0, .36);
}
.felt-mark {
  position: absolute;
  left: 50%;
  top: 31%;
  opacity: .16;
  text-align: center;
  transform: translate(-50%, -50%);
}
.felt-mark span { display: block; font-size: 12px; letter-spacing: .25em; }
.felt-mark strong { font: 700 clamp(24px, 4vw, 55px)/1 Georgia, serif; }
.community {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 43%;
  display: flex;
  gap: clamp(5px, .7vw, 10px);
  transform: translate(-50%, -50%);
}
.playing-card {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(48px, 5.2vw, 76px);
  aspect-ratio: .7;
  border: 2px solid #e6e0d3;
  border-radius: clamp(7px, .8vw, 12px);
  color: #171a18;
  background: #fdf9ef;
  box-shadow: 0 7px 15px rgba(0, 0, 0, .32);
  font: 800 clamp(18px, 2.2vw, 30px)/1 Georgia, serif;
}
.playing-card.red { color: #d64343; }
.playing-card em { display: block; font-size: .8em; font-style: normal; }
.playing-card.back {
  border: 4px solid #f4eddb;
  background:
    repeating-linear-gradient(45deg, transparent 0 4px, rgba(255, 255, 255, .22) 4px 6px),
    #254a8e;
}
.playing-card.empty { border: 1px dashed rgba(255, 255, 255, .18); background: rgba(0, 0, 0, .12); box-shadow: none; }
.pot {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 58%;
  min-width: 105px;
  padding: 8px 13px;
  border: 1px solid rgba(240, 200, 121, .45);
  border-radius: 999px;
  background: rgba(5, 28, 22, .85);
  text-align: center;
  transform: translateX(-50%);
}
.pot span { color: var(--muted); font-size: 10px; }
.pot strong { margin-left: 6px; color: var(--gold); }
.seats { position: absolute; inset: 0; }
.seat {
  position: absolute;
  z-index: 3;
  width: clamp(125px, 15vw, 190px);
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 15px;
  background: rgba(5, 25, 20, .91);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .3);
  transform: translate(-50%, -50%);
  transition: border-color 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}
.seat[data-seat="0"] { left: 50%; top: 85%; }
.seat[data-seat="1"] { left: 17%; top: 69%; }
.seat[data-seat="2"] { left: 18%; top: 23%; }
.seat[data-seat="3"] { left: 50%; top: 12%; }
.seat[data-seat="4"] { left: 82%; top: 23%; }
.seat[data-seat="5"] { left: 83%; top: 69%; }
.seat.active { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(240, 200, 121, .15), 0 8px 20px rgba(0, 0, 0, .3); }
.seat.folded { opacity: .52; }
.seat-head { display: flex; align-items: center; gap: 7px; }
.avatar {
  display: grid;
  flex: 0 0 29px;
  height: 29px;
  place-items: center;
  border-radius: 50%;
  color: #0b271e;
  background: var(--mint);
  font-size: 12px;
  font-weight: 900;
}
.seat-name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 750; }
.seat-stack { color: var(--gold); font-size: 11px; }
.seat-cards { display: flex; justify-content: center; gap: 4px; margin-top: 6px; }
.seat-cards .playing-card { width: clamp(32px, 3vw, 44px); border-width: 1px; border-radius: 6px; font-size: 15px; }
.seat-meta { display: flex; justify-content: space-between; gap: 5px; margin-top: 5px; color: var(--muted); font-size: 9px; }
.badge {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  margin-left: 3px;
  place-items: center;
  border-radius: 50%;
  color: #172019;
  background: var(--gold);
  font-size: 9px;
  font-weight: 900;
}

.action-panel {
  display: grid;
  grid-template-columns: minmax(160px, .75fr) minmax(180px, .75fr) minmax(400px, 1.5fr);
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #122a23;
}
.turn-copy span, .turn-copy small { display: block; color: var(--muted); font-size: 10px; }
.turn-copy strong { display: block; margin: 4px 0; font-size: 15px; }
.bet-control { display: grid; gap: 5px; }
.bet-control label { color: var(--muted); font-size: 10px; }
.bet-control input { width: 100%; accent-color: var(--gold); }
.action-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.action-buttons button { min-width: 0; padding: 0 6px; font-size: 12px; }
.action-buttons .danger { color: #ffb8b1; background: rgba(255, 120, 108, .13); }
.action-buttons .accent { color: #0b271e; background: var(--gold); }
.action-buttons .all-in { color: #fff; background: #b43b52; }

.side-panel { display: grid; align-content: start; gap: 12px; }
.room-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(16, 36, 31, .92);
}
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-heading small { color: var(--mint); font-size: 8px; font-weight: 850; letter-spacing: .18em; }
.section-heading h2 { margin: 2px 0 0; font-size: 16px; }
.section-heading > span { color: var(--muted); font-size: 11px; }
.player-list { display: grid; gap: 6px; }
.player-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 5px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .04);
}
.player-row.me { outline: 1px solid rgba(124, 224, 178, .34); }
.player-row .avatar { width: 25px; height: 25px; }
.player-row small { color: var(--muted); font-size: 9px; }
.player-row .ready { color: var(--mint); }
.lobby-actions { display: grid; gap: 7px; margin-top: 12px; }
.lobby-actions button { width: 100%; }
.game-log { display: grid; gap: 7px; max-height: 220px; margin: 0; padding: 0; overflow: auto; list-style: none; }
.game-log li { padding-left: 10px; border-left: 2px solid rgba(124, 224, 178, .35); color: var(--muted); font-size: 11px; line-height: 1.45; }
.winner {
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid rgba(240, 200, 121, .24);
  border-radius: 11px;
  background: rgba(240, 200, 121, .08);
}
.winner strong, .winner span { display: block; }
.winner span { margin-top: 3px; color: var(--gold); font-size: 11px; }
.hand-result button { width: 100%; margin-top: 8px; }
.rules summary { cursor: pointer; font-size: 12px; font-weight: 750; }
.rules p { margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  max-width: calc(100vw - 28px);
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  opacity: 0;
  background: #203e36;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1080px) {
  .table-layout { grid-template-columns: 1fr; }
  .side-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side-panel .rules { grid-column: 1 / -1; }
  .action-panel { grid-template-columns: 1fr 1fr; }
  .action-buttons { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .app { padding-inline: 9px; }
  .topbar { margin-bottom: 10px; }
  .brand small { display: none; }
  .sound-button { font-size: 0; width: 42px; padding: 0; }
  .sound-button::after { content: "♪"; font-size: 17px; }
  .lobby { display: block; min-height: auto; border-radius: 23px; }
  .lobby-art { min-height: 230px; }
  .lobby-art::before { top: 12%; width: 62%; left: 19%; }
  .art-card { width: 78px; padding: 8px; border-radius: 10px; font-size: 25px; }
  .card-one { top: 16%; left: 33%; }
  .card-two { top: 13%; left: 52%; }
  .art-chip { width: 38px; border-width: 4px; }
  .chip-one { top: 68%; left: 31%; }
  .chip-two { top: 72%; left: 46%; }
  .chip-three { top: 63%; left: 62%; }
  .lobby-panel { padding: 25px 18px 28px; }
  .lobby h1 { font-size: 39px; }
  .option-grid { grid-template-columns: 1fr; }
  .room-bar { align-items: flex-start; }
  .room-actions button { width: 40px; padding: 0; overflow: hidden; font-size: 0; }
  #copyInviteButton::after { content: "⧉"; font-size: 17px; }
  #leaveButton::after { content: "↩"; font-size: 17px; }
  .poker-stage { padding: 7px; border-radius: 18px; }
  .felt { min-height: 550px; border-width: 8px; border-radius: 25% / 20%; }
  .seat { width: 115px; padding: 6px; }
  .seat[data-seat="0"] { left: 50%; top: 87%; }
  .seat[data-seat="1"] { left: 19%; top: 70%; }
  .seat[data-seat="2"] { left: 20%; top: 20%; }
  .seat[data-seat="3"] { left: 50%; top: 11%; }
  .seat[data-seat="4"] { left: 80%; top: 20%; }
  .seat[data-seat="5"] { left: 81%; top: 70%; }
  .seat-head { gap: 4px; }
  .seat-name { font-size: 10px; }
  .seat-stack { font-size: 9px; }
  .avatar { display: none; }
  .seat-meta { font-size: 8px; }
  .community { top: 43%; }
  .pot { top: 57%; }
  .action-panel { grid-template-columns: 1fr; gap: 10px; }
  .action-buttons { grid-column: auto; grid-template-columns: repeat(3, 1fr); }
  .action-buttons .all-in, .action-buttons .accent { grid-column: auto; }
  .side-panel { grid-template-columns: 1fr; }
  .side-panel .rules { grid-column: auto; }
}

@media (max-width: 430px) {
  .back { padding: 0 10px; font-size: 12px; }
  .felt { min-height: 520px; }
  .seat { width: 101px; }
  .seat[data-seat="1"] { left: 18%; }
  .seat[data-seat="2"] { left: 18%; }
  .seat[data-seat="4"] { left: 82%; }
  .seat[data-seat="5"] { left: 82%; }
  .seat-cards .playing-card { width: 29px; font-size: 12px; }
  .playing-card { width: 43px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
