:root {
  --bg-canvas: #0b0f17;
  --bg-surface: #121824;
  --bg-surface-elevated: #171f2e;
  --bg-well: #0e141e;
  --text-primary: #f1f3f5;
  --text-secondary: #8b96a8;
  --text-muted: #5d6a7e;
  --border-hairline: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --accent-gold: #d4af63;
  --accent-gold-hover: #e2c17b;
  --accent-gold-dim: rgba(212, 175, 99, 0.14);
  --font-display: "Playfair Display", "Noto Serif SC", Georgia, serif;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-canvas);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(20, 107, 70, 0.12), transparent 65%),
    radial-gradient(ellipse 60% 45% at 85% 20%, rgba(212, 175, 99, 0.06), transparent 60%),
    var(--bg-canvas);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

button, input, select { font: inherit; }

button {
  cursor: pointer;
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 500;
  transition: background-color .18s cubic-bezier(.22, 1, .36, 1),
              border-color .18s cubic-bezier(.22, 1, .36, 1),
              transform .12s cubic-bezier(.22, 1, .36, 1),
              opacity .18s ease;
}

button:hover:enabled {
  background: #1d2739;
  border-color: var(--border-strong);
}

button:active:enabled { transform: translateY(1px); }
button:disabled { opacity: .35; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 15;
  height: 76px;
  padding: 0 4%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(11, 15, 23, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-hairline);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  text-decoration: none;
  color: var(--accent-gold);
}

.brand-crest {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(145deg, #1b2333, #101622);
  border: 1px solid rgba(212, 175, 99, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 12px rgba(0, 0, 0, 0.35);
  font-size: 20px;
  color: var(--accent-gold);
}

.brand span:not(.brand-crest) {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-primary);
  line-height: 1.1;
}

.brand b {
  font-weight: 600;
  color: var(--accent-gold);
}

.brand small {
  display: block;
  font-family: var(--font-sans);
  letter-spacing: 0.22em;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 4px;
}

.top {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
}

#connection {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-hairline);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #8ad8b4;
}

.top button {
  padding: 8px 14px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-hairline);
}

.top #accountBtn {
  border-color: rgba(212, 175, 99, 0.32);
  color: #f3dfb0;
}

/* Lobby */
#lobby {
  max-width: 1180px;
  margin: clamp(32px, 6vh, 72px) auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  gap: 72px;
  padding: 24px;
  align-items: center;
}

.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: var(--accent-gold);
}

.intro h1 {
  font-size: clamp(2.5rem, 4.5vw, 3.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 18px 0 16px;
  color: var(--text-primary);
}

.intro p {
  color: var(--text-secondary);
  font-size: 15px;
  margin: 0;
}

.intro > small {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  border-top: 1px solid var(--border-hairline);
  padding-top: 16px;
}

.mini-cards {
  display: flex;
  margin: 36px 0 28px;
  padding: 4px 12px;
}

.mini-cards i {
  position: relative;
  font-style: normal;
  font-family: var(--font-display);
  background: linear-gradient(160deg, #fafaf7 0%, #e9e7df 100%);
  color: #161c24;
  width: 84px;
  height: 118px;
  font-size: 28px;
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55);
  transform: rotate(-10deg);
  transition: transform .3s cubic-bezier(.22, 1, .36, 1);
}

.mini-cards i + i {
  transform: rotate(8deg) translateY(-4px);
  margin-left: -14px;
}

.mini-cards:hover i { transform: rotate(-13deg) translateY(-3px); }
.mini-cards:hover i + i { transform: rotate(11deg) translateY(-7px); }

.mini-cards span { display: block; font-size: 22px; line-height: 1; }
.mini-cards .card-mark {
  position: absolute;
  bottom: 12px;
  right: 12px;
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: #b48c3c;
}

/* Welcome Card */
.welcome {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-hairline);
  margin-bottom: 24px;
  gap: 4px;
}

.tabs button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  flex: 1;
  padding: 12px 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.tabs button:hover:enabled {
  background: none;
  color: var(--text-primary);
}

.tabs .selected {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
}

label {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  margin: 16px 0;
}

input, select {
  display: block;
  width: 100%;
  background: var(--bg-well);
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  color: var(--text-primary);
  padding: 12px 14px;
  margin-top: 7px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}

input:focus, select:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px var(--accent-gold-dim);
}

input[type="number"] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

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

.primary {
  background: linear-gradient(180deg, #dfc07c 0%, #c89f4e 100%);
  border: 1px solid #e6cb8f;
  color: #0b0f17;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 6px 20px rgba(0, 0, 0, 0.35);
}

.primary:hover:enabled {
  background: linear-gradient(180deg, #e9cd8e 0%, #d3ab59 100%);
  border-color: #f0d8a3;
}

.wide { width: 100%; margin-top: 12px; padding: 13px 18px; font-size: 14px; }
.muted { color: var(--text-muted); font-size: 12px; text-align: center; margin-top: 14px; }

/* Saved Rooms Strip */
.saved-rooms {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border-hairline);
  padding-top: 24px;
  margin-top: 8px;
}

.saved-rooms h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

.saved-rooms button {
  margin: 0 8px 8px 0;
  font-size: 13px;
  padding: 10px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
}

.saved-rooms button:hover:enabled {
  border-color: rgba(212, 175, 99, 0.45);
  background: var(--bg-surface-elevated);
}

#clearSavedRecords {
  background: transparent;
  color: var(--text-muted);
  border-style: dashed;
}

/* Game View */
#game {
  max-width: 1380px;
  margin: 0 auto;
  padding: 16px 32px 24px;
}

.roomline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--text-secondary);
  font-size: 13px;
  padding-bottom: 12px;
}

.room-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.roomline strong {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
}

#roomCode {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  color: var(--accent-gold);
  letter-spacing: 0.06em;
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #55d7a1;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(85, 215, 161, 0.16);
}

.room-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.room-actions #handInfo {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
}

.room-actions #switchRoom {
  min-height: 38px;
  white-space: nowrap;
  padding: 0 14px;
  font-size: 13px;
  background: var(--bg-surface);
}

/* Poker Table Stage */
.stage {
  height: 600px;
  position: relative;
  max-width: 1030px;
  margin: 16px auto 0;
}

.table {
  position: absolute;
  inset: 72px 52px 58px;
  border-radius: 240px;
  background: linear-gradient(165deg, #27221d 0%, #161a23 55%, #0d121a 100%);
  padding: 16px;
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 0 0 1px rgba(212, 175, 99, 0.22),
    inset 0 0 0 9px rgba(11, 15, 23, 0.72);
}

[data-table-theme="green"] { --felt-center: #146b46; --felt-edge: #083d28; --felt-shadow: #022015; --felt-ring: rgba(212, 175, 99, 0.22); }
[data-table-theme="blue"] { --felt-center: #1d5472; --felt-edge: #0f2f44; --felt-shadow: #071b2a; --felt-ring: rgba(154, 210, 236, 0.24); }
[data-table-theme="wine"] { --felt-center: #6d2b3d; --felt-edge: #3e1725; --felt-shadow: #220b14; --felt-ring: rgba(212, 175, 99, 0.22); }
[data-table-theme="purple"] { --felt-center: #533d75; --felt-edge: #2e2046; --felt-shadow: #1a1129; --felt-ring: rgba(208, 187, 238, 0.22); }
[data-table-theme="graphite"] { --felt-center: #424e59; --felt-edge: #222e38; --felt-shadow: #101920; --felt-ring: rgba(255, 255, 255, 0.18); }

.felt {
  height: 100%;
  border-radius: 220px;
  background: radial-gradient(ellipse at 50% 45%, var(--felt-center, #146b46), var(--felt-edge, #083d28));
  box-shadow:
    inset 0 0 70px var(--felt-shadow, #022015),
    inset 0 0 0 2px var(--felt-ring, rgba(212, 175, 99, 0.22));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.felt:after {
  content: '';
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 204px;
  pointer-events: none;
}

.table-brand {
  font-family: var(--font-display);
  font-size: 24px;
  font-style: italic;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.12);
  position: absolute;
  top: 24px;
  text-align: center;
  pointer-events: none;
}

.table-brand span { font-weight: 400; }
.table-brand small {
  display: block;
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 8px;
  letter-spacing: 0.3em;
  margin-top: 3px;
}

/* Pot & Turn Status */
.pot-area { position: relative; margin-top: 10px; }

.pot-status {
  position: absolute;
  z-index: 3;
  bottom: calc(100% + 6px);
  left: 50%;
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: max-content;
  max-width: min(300px, 75vw);
  text-align: center;
}

.pot-status #squidStatus { margin: 0; font-size: 11px; color: #f0cf8c; }
.pot-status #squidStatus:empty { display: none; }

#pot {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 18px;
  border-radius: 999px;
  background: rgba(11, 15, 23, 0.62);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(212, 175, 99, 0.28);
  color: var(--accent-gold);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 700;
  margin-top: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

#pot small {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.24em;
  margin-bottom: 2px;
}

.pot-value { display: flex; align-items: center; justify-content: center; gap: 8px; }
.chip-stack { position: relative; display: inline-block; flex: none; width: 24px; height: 24px; }
.pot-chips {
  position: absolute;
  left: 0;
  bottom: calc(var(--chip-layer) * 3px);
  width: 24px;
  height: 14px;
  border: 2px dashed #ffe5a6;
  border-radius: 50%;
  background: radial-gradient(ellipse, #cb7740 0 36%, #8e3029 38% 68%, #bf6841 70%);
  box-shadow: 0 2px 0 #6d2d29, 0 3px 3px rgba(0, 0, 0, 0.45);
}

#turnText {
  max-width: 100%;
  min-height: 1.4em;
  text-align: center;
  overflow-wrap: anywhere;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(11, 15, 23, 0.45);
  font-size: clamp(13px, 1.4vw, 15px);
  font-weight: 600;
  line-height: 1.4;
  color: #dbe3ec;
}
#turnText[data-state="waiting"] { color: #c7d2df; }
#turnText[data-state="your-turn"] { color: var(--accent-gold); border: 1px solid rgba(212, 175, 99, 0.35); }
#actionCountdown { white-space: nowrap; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

#payoutBanner {
  width: max-content;
  max-width: min(290px, 74vw);
  padding: 10px 16px;
  border: 1px solid var(--accent-gold);
  border-radius: 12px;
  background: rgba(18, 24, 36, 0.94);
  backdrop-filter: blur(10px);
  color: var(--text-primary);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  animation: payout-banner-in .28s cubic-bezier(.22, 1, .36, 1);
}
#payoutBanner div { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: clamp(.85rem, 3.2vw, 1rem); }
#payoutBanner div + div { margin-top: 4px; }
#payoutBanner span { overflow-wrap: anywhere; }
#payoutBanner strong { color: var(--accent-gold); font-family: var(--font-mono); white-space: nowrap; }
#payoutBanner:not([hidden]) + #turnText { display: none; }

@keyframes payout-banner-in {
  from { opacity: 0; transform: translateY(4px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Cards */
#board { display: flex; gap: 8px; margin: 16px 0 8px; }

.card {
  width: 54px;
  height: 76px;
  background: #f5f4ee;
  color: #1c2836;
  border-radius: 6px;
  display: inline-flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px;
  font-size: 21px;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
  line-height: 1;
}
.card em { font-style: normal; align-self: flex-end; font-size: 20px; }
.card.red { color: #c93d41; }
.card.empty {
  background: rgba(11, 15, 23, 0.28);
  border: 1px dashed rgba(255, 255, 255, 0.16);
  box-shadow: none;
}
.card.image-card {
  padding: 0;
  background: transparent;
  object-fit: contain;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.42);
  border: 0;
  display: inline-block;
}

#tableHint {
  font-size: 11px;
  color: rgba(241, 243, 245, 0.65);
  max-width: 70%;
  text-align: center;
}

/* Seats */
.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 142px;
  text-align: center;
  z-index: 2;
}
.seat.s0 { left: 50%; top: 95%; }
.seat.s1 { left: 21%; top: 85%; }
.seat.s2 { left: 9%; top: 57%; }
.seat.s3 { left: 14%; top: 28%; }
.seat.s4 { left: 34%; top: 9%; }
.seat.s5 { left: 66%; top: 9%; }
.seat.s6 { left: 86%; top: 28%; }
.seat.s7 { left: 91%; top: 57%; }
.seat.s8 { left: 79%; top: 85%; }

.seat-body {
  display: flex;
  background: rgba(18, 24, 36, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  align-items: center;
  padding: 8px 10px;
  gap: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  text-align: left;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--avatar);
  font-size: 15px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

.seat-body > div:nth-child(2) { min-width: 0; }
.seat-body .seat-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
}

.chips {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-top: 2px;
}

.seat.turn .seat-body {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 99, 0.2), 0 10px 24px rgba(0, 0, 0, 0.5);
}

.seat.folded { opacity: .45; }

.hole {
  height: 51px;
  margin-bottom: -3px;
  display: flex;
  justify-content: center;
  gap: 3px;
}
.hole .card { width: 36px; height: 51px; font-size: 17px; padding: 4px; }
.hole .card em { font-size: 15px; }
.hole .image-card { padding: 0; }

.own-seat .hole { position: relative; align-items: flex-end; --own-card-height: 98px; }
.own-seat .hole .card { width: 70px; height: var(--own-card-height); flex-shrink: 0; }

.seat-label {
  font-size: 10px;
  color: #e6d5a8;
  margin-top: 5px;
  min-height: 14px;
}

.dealer {
  position: absolute;
  right: -8px;
  top: 58px;
  border-radius: 50%;
  background: linear-gradient(145deg, #e7ca88, #c59b45);
  color: #0b0f17;
  width: 21px;
  height: 21px;
  line-height: 21px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}

.vacant .seat-body {
  background: rgba(18, 24, 36, 0.45);
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  justify-content: center;
  font-size: 11px;
  height: 54px;
  box-shadow: none;
}

.seat.turn .hole { position: relative; --action-card-width: 36px; --action-card-height: 51px; }
.own-seat.turn .hole { --action-card-width: 70px; --action-card-height: var(--own-card-height); }
.action-badge {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  left: calc(50% + var(--action-card-width) + 6px);
  bottom: calc(var(--action-card-height) / 2);
  transform: translateY(50%);
  display: inline-flex;
  align-items: center;
  padding: 4px 7px;
  border: 1px solid #f5dfa6;
  border-radius: 6px;
  background: var(--accent-gold);
  color: #0b0f17;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.06em;
}
.seat:is(.s6, .s7, .s8) .action-badge {
  left: auto;
  right: calc(50% + var(--action-card-width) + 6px);
}

/* Controls Cockpit */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
  min-height: 175px;
}

.action-row { display: flex; gap: 8px; width: 100%; }
.action-row button {
  min-width: 0;
  flex: 1;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 10px;
}
.action-row small {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  opacity: .65;
  margin-top: 3px;
  letter-spacing: 0.14em;
}
.fold { background: #28384a; }
.fold:hover:enabled { background: #32465c; }
.call { background: #2e6b4e; }
.call:hover:enabled { background: #377f5d; }
.raise { background: #a63a3e; }
.raise:hover:enabled { background: #bc4549; }
.allin { background: #6b2432; border-color: rgba(212, 175, 99, 0.4) !important; }
.allin:hover:enabled { background: #812c3d; }

.raise-controls { display: flex; width: min(100%, 650px); flex-direction: column; gap: 10px; align-items: center; }

.raise-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.raise-controls .raise-presets button {
  min-height: 40px;
  padding: 0 6px;
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  background: var(--bg-well);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
}
.raise-controls .raise-presets button:hover:enabled {
  background: var(--bg-surface-elevated);
  border-color: var(--accent-gold);
}
.raise-controls .raise-presets :is([data-size="2bb"], [data-size="3bb"]) {
  background: rgba(212, 175, 99, 0.12);
  border-color: rgba(212, 175, 99, 0.28);
  color: #f3dfb0;
}

.raise-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.raise-custom label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  margin: 0;
}
.raise-controls #amountSlider {
  flex: 1;
  min-width: 0;
  padding: 0;
  margin: 0;
  accent-color: var(--accent-gold);
  background: transparent;
  border: 0;
  box-shadow: none;
}
.raise-number { display: flex; align-items: stretch; gap: 3px; }
.raise-controls #amount {
  width: 76px;
  margin: 0;
  padding: 8px 10px;
  appearance: textfield;
  text-align: center;
}
.raise-controls #amount::-webkit-inner-spin-button { appearance: none; }
.raise-stepper { display: grid; gap: 2px; }
.raise-controls .raise-stepper button { padding: 0 8px; min-height: 19px; font-size: 9px; line-height: 1; border-radius: 5px; }
.raise-custom #raise {
  flex-shrink: 0;
  min-height: 40px;
  padding: 0 16px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

#result { font-size: 13px; color: var(--accent-gold); }

/* Room Chat */
.room-chat {
  width: 100%;
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  background: var(--bg-surface);
  overflow: hidden;
}
.room-chat summary {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
#chatUnread { margin-left: 8px; color: var(--accent-gold); font-family: var(--font-mono); font-weight: 700; }
#chatMessages {
  max-height: 140px;
  min-height: 44px;
  padding: 8px 14px;
  overflow: auto;
  border-top: 1px solid var(--border-hairline);
  background: var(--bg-well);
  color: var(--text-secondary);
  font-size: 13px;
}
#chatMessages div { display: flex; align-items: baseline; gap: 8px; margin: 4px 0; }
#chatMessages b { flex: none; max-width: 38%; overflow: hidden; text-overflow: ellipsis; color: var(--accent-gold); font-weight: 600; }
#chatMessages div span { min-width: 0; overflow-wrap: anywhere; color: var(--text-primary); }
#chatForm { display: flex; gap: 6px; padding: 8px; background: var(--bg-surface); border-top: 1px solid var(--border-hairline); }
#chatForm input { flex: 1; min-width: 0; margin: 0; padding: 8px 10px; font-size: 14px; }
#chatForm button { flex: none; padding: 8px 12px; font-size: 13px; }
#chatError { margin: 0 10px 8px; }

/* Footer */
footer {
  border-top: 1px solid var(--border-hairline);
  margin-top: 16px;
  padding: 14px 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--text-muted);
  font-size: 12px;
}
footer > span { margin-right: auto; }
footer button {
  border: 1px solid transparent;
  background: none;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 8px;
}
footer button:hover:enabled {
  background: var(--bg-surface);
  border-color: var(--border-hairline);
  color: var(--text-primary);
}

/* Dialogs & Modals */
dialog {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  width: min(640px, 92vw);
  max-height: 85vh;
  padding: 24px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.65);
}
dialog::backdrop { background: rgba(5, 8, 14, 0.78); backdrop-filter: blur(6px); }
.wide-panel { width: min(1000px, 94vw); }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
#panel > .panel-head {
  position: sticky;
  top: -24px;
  background: var(--bg-surface);
  z-index: 5;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-hairline);
}
h2 { font-size: 18px; margin: 0; font-weight: 700; }

/* Misc Components */
.record { padding: 16px 0; border-bottom: 1px solid var(--border-hairline); font-size: 13px; line-height: 1.8; }
.record summary { cursor: pointer; color: var(--text-primary); font-weight: 500; }
.record p { color: var(--text-secondary); }
.record .card { width: 32px; height: 43px; font-size: 14px; margin: 2px; padding: 3px; }
.record .card em { font-size: 13px; }
.record .image-card { padding: 0; }

#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--accent-gold);
  color: var(--text-primary);
  padding: 12px 22px;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  z-index: 20;
  display: none;
  font-size: 13px;
  max-width: 90vw;
}

.network { display: block; padding: 10px; color: var(--accent-gold); font-family: var(--font-mono); word-break: break-all; }
[hidden] { display: none !important; }

/* Settings, Stats, Rules, Avatars, Themes */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.settings-grid label { margin: 10px 0; }
.check-label { display: flex; align-items: center; gap: 9px; }
.check-label input { width: 18px; margin: 0; accent-color: var(--accent-gold); }
.rules-note { font-size: 12px; line-height: 1.7; color: var(--text-secondary); }
.create-settings summary, details > summary { font-size: 12px; color: var(--accent-gold); cursor: pointer; padding: 10px 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled { opacity: .7; }
.blind-presets { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 14px 0 6px; }
.blind-presets span { font-size: 11px; color: var(--text-secondary); margin-right: 4px; }
.blind-presets button { font-family: var(--font-mono); font-size: 11px; padding: 6px 11px; }

.stats-scroll { overflow-x: auto; }
.stats-table { border-collapse: collapse; min-width: 790px; width: 100%; font-size: 12px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.stats-table th, .stats-table td { border-bottom: 1px solid var(--border-hairline); padding: 12px 10px; text-align: right; white-space: nowrap; }
.stats-table th:first-child, .stats-table td:first-child { text-align: left; font-family: var(--font-sans); }
.stats-table th { color: var(--accent-gold); font-weight: 600; font-family: var(--font-sans); }
.stats-table small { display: block; font-size: 10px; color: var(--text-muted); margin-top: 4px; }

.session-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.session-totals div { background: var(--bg-well); border: 1px solid var(--border-hairline); padding: 14px; border-radius: 12px; }
.session-totals strong { font-family: var(--font-mono); font-size: 22px; color: var(--accent-gold); display: block; }
.session-totals small { font-size: 11px; color: var(--text-secondary); }

.panel-tools { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin: 14px 0; }
.panel-tools span { font-size: 12px; color: var(--text-secondary); }
.buyin-request { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--border-hairline); }
.buyin-request span { font-size: 13px; flex: 1; }
.buyin-request input { width: 96px; margin: 0; padding: 8px 10px; }
.buyin-request button { font-size: 12px; padding: 8px 12px; }

.help-links { padding: 12px 0; margin-bottom: 14px; border-top: 1px solid var(--border-hairline); border-bottom: 1px solid var(--border-hairline); }
.help-links button { width: 100%; text-align: left; color: var(--accent-gold); }
.rules-help { font-size: 13px; line-height: 1.85; color: var(--text-secondary); }
.rules-help section { margin: 24px 0; scroll-margin-top: 15px; }
.rules-help h3 { font-size: 16px; color: var(--text-primary); }
.rules-help b, .rules-help dt { color: #e6d5a8; }
.rules-help li { padding: 4px 0; }
.rules-help ol, .rules-help ul { padding-left: 22px; }
.rules-help dl { margin: 16px 0; }
.rules-help dt { font-weight: 600; margin-top: 14px; }
.rules-help dd { margin: 4px 0 14px; }
.rules-help .rules-example {
  display: block;
  background: var(--bg-well);
  border-left: 2px solid var(--accent-gold);
  padding: 10px 14px;
  margin: 12px 0;
  color: var(--text-primary);
  font-size: 12px;
  border-radius: 0 8px 8px 0;
}
.rules-nav { display: flex; gap: 7px; flex-wrap: wrap; }
.rules-nav a {
  color: var(--accent-gold);
  text-decoration: none;
  background: var(--bg-well);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
}
.rules-current { font-size: 12px; color: var(--text-secondary); }
.rank-list span { display: block; color: var(--text-muted); font-size: 12px; }
.rank-list li { margin-bottom: 6px; }

#game .squid-token {
  display: block;
  width: max-content;
  margin-top: 3px;
  padding: 2px 6px;
  color: #f0cf8c;
  background: var(--bg-well);
  border: 1px solid rgba(212, 175, 99, 0.45);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}
.squid-token .squid-icon { display: inline-block; }
.squid-token.squid-waiting .squid-icon { filter: grayscale(1) brightness(0); }

.account-name { display: flex; align-items: center; gap: 10px; }
.account-rooms { display: grid; gap: 6px; }
.avatar-gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 10px 0 16px; }
.avatar-gallery button { display: grid; justify-items: center; gap: 5px; padding: 8px 4px; font-size: 11px; }
.avatar-gallery button[aria-pressed="true"] { border-color: var(--accent-gold); background: var(--accent-gold-dim); }
.avatar-category h3 { margin: 10px 0 0; color: var(--text-primary); font-size: 13px; }
.avatar-category .avatar-gallery { margin: 6px 0 12px; }
.cartoon-face { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--cartoon-bg); font: 21px/1 system-ui; }
.avatar .cartoon-face { width: 100%; height: 100%; border-radius: inherit; font-size: inherit; }

.profit-legend { display: flex; gap: 18px; margin: 12px 0; font-size: 13px; }
.profit-legend span::before { content: ''; display: inline-block; width: 19px; margin-right: 6px; vertical-align: middle; border-top: 3px solid; }
.profit-legend .actual-line::before { color: #55d7a1; }
.profit-legend .ev-line::before { color: #ff777a; border-top-style: dashed; }
#profitCanvas { display: block; width: 100%; height: clamp(180px, 42vh, 280px); background: var(--bg-well); border: 1px solid var(--border-hairline); border-radius: 10px; }
#profitPoint { display: block; padding-top: 8px; color: var(--text-primary); font-family: var(--font-mono); font-size: 13px; }

.flying-chips { position: absolute; z-index: 7; pointer-events: none; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.flying-chip-amount {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--accent-gold);
  border: 1px solid var(--accent-gold);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
}

.danger-action { border-color: #a63a3e; color: #ffd4d4; background: #491f24; }
.danger-action:hover:enabled { background: #63272e; }
.form-error { color: #ff9c9e; font-weight: 600; font-size: 13px; }
.record-checklist { display: grid; gap: 6px; max-height: 45vh; overflow: auto; margin: 10px 0 16px; }
.record-checklist .check-label { padding: 10px; border: 1px solid var(--border-hairline); border-radius: 8px; background: var(--bg-well); }
.account-rooms + #clearAccountRecords { margin-top: 10px; }
.signup-avatar { margin: 12px 0; padding: 10px; border: 1px solid var(--border-hairline); border-radius: 10px; background: var(--bg-well); }
.signup-avatar summary { cursor: pointer; color: var(--text-primary); }
.signup-avatar-preview { display: flex; align-items: center; justify-content: center; min-height: 48px; margin-top: 8px; color: var(--text-secondary); }
.account-avatar-image { width: 42px; height: 42px; object-fit: cover; border-radius: 10px; }
.account-required, .entry-login-notice {
  margin: 12px 0 14px;
  padding: 10px 14px;
  border: 1px solid rgba(212, 175, 99, 0.35);
  border-radius: 10px;
  background: rgba(212, 175, 99, 0.08);
  color: #f3dfb0;
  font-size: 13px;
  font-weight: 600;
}
.account-auth-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.account-auth-actions button { min-height: 44px; font-size: 14px; }

/* Table Theme Picker */
.table-themes { margin: 10px 0; padding: 6px 0; border: 0; }
.table-themes legend { color: var(--text-secondary); font-size: 12px; font-weight: 500; margin-bottom: 8px; }
.table-theme-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(91px, 1fr)); gap: 6px; }
.table-theme-options label { display: flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap; cursor: pointer; }
.table-theme-options input { width: auto; margin: 0; accent-color: var(--accent-gold); }
.table-swatch { width: 14px; height: 14px; flex: none; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 50%; background: var(--felt-center); }
#newTableThemes .table-theme-options { gap: 8px; }
#newTableThemes .table-theme-options label {
  position: relative;
  justify-content: center;
  min-height: 40px;
  padding: 6px 8px;
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  background: var(--bg-well);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
}
#newTableThemes .table-theme-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
#newTableThemes .table-theme-options label:hover { border-color: var(--border-strong); color: var(--text-primary); }
#newTableThemes .table-theme-options label:has(input:checked) {
  border-color: var(--accent-gold);
  background: var(--accent-gold-dim);
  color: var(--text-primary);
}
#newTableThemes .table-swatch { border-radius: 50%; }
#tableThemeFeedback { margin: 6px 0; color: var(--accent-gold); font-size: 13px; }

/* Desktop Cockpit */
@media (min-width: 701px) {
  body:has(#game:not([hidden])) header { height: 64px; }
  #game { padding: 12px 28px; }
  #game .stage { height: clamp(360px, calc(100dvh - 320px), 510px); margin: 8px auto 0; }
  #game .table { inset: 48px 46px 38px; }
  #game .table-brand { top: 18px; }
  #game .controls { margin-top: 28px; min-height: 0; gap: 10px; }
  #game footer { padding: 8px 0; margin-top: 10px; gap: 4px; }
  #board { margin: 12px 0 6px; }
  #board .card { width: clamp(56px, 8dvh, 64px); height: clamp(79px, 11.25dvh, 90px); flex: none; }
}

@media (min-width: 1050px) {
  #game:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(290px, 340px);
    gap: 8px 24px;
    align-items: start;
  }
  #game .roomline, #game footer { grid-column: 1 / -1; }
  #game .stage { width: 100%; height: clamp(460px, calc(100dvh - 180px), 570px); margin: 0; }
  #game .controls {
    align-self: center;
    margin: 0;
    min-width: 0;
    padding: 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border-hairline);
    border-radius: 18px;
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.42);
  }
  #game .raise-custom { flex-wrap: wrap; }
  #game .raise-custom label { flex-basis: 100%; }
  #game footer { margin-top: 16px; }
}

/* Mobile Responsive */
@media (max-width: 700px) {
  header { height: 66px; padding: 0 16px; }
  .brand-crest { width: 32px; height: 32px; font-size: 16px; }
  .brand span:not(.brand-crest) { font-size: 15px; }
  .brand small { font-size: 8px; }
  .top { gap: 6px; }
  .top > span { display: none; }
  .top button { padding: 8px 10px; font-size: 12px; }

  #lobby { margin: 20px auto; display: block; padding: 16px; }
  .intro { margin-bottom: 24px; }
  .intro h1 { font-size: 36px; }
  .intro p { font-size: 13px; }
  .mini-cards, .intro > small { display: none; }
  .welcome { padding: 22px 18px; border-radius: 16px; }
  .fields { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

  #game { padding: 12px; }
  .roomline { font-size: 11px; }
  .roomline strong { font-size: 14px; }
  .stage { height: 610px; margin: 12px 0 0; }
  .table { inset: 54px 26px 62px; border-radius: 160px; padding: 10px; }
  .felt { border-radius: 150px; }
  .felt:after { border-radius: 150px; inset: 9px; }
  .table-brand { top: 88px; font-size: 17px; }
  .table-brand small { font-size: 6px; }
  #board { gap: 4px; }
  .card { width: 36px; height: 52px; font-size: 16px; padding: 4px; }
  .card em { font-size: 15px; }
  #pot { margin-top: 14px; font-size: 16px; padding: 5px 14px; }

  .seat { width: 96px; }
  .seat.s0 { left: 50%; top: 96%; }
  .seat.s1 { left: 17%; top: 84%; }
  .seat.s2 { left: 14%; top: 62%; }
  .seat.s3 { left: 14%; top: 39%; }
  .seat.s4 { left: 29%; top: 12%; }
  .seat.s5 { left: 71%; top: 12%; }
  .seat.s6 { left: 86%; top: 39%; }
  .seat.s7 { left: 86%; top: 62%; }
  .seat.s8 { left: 83%; top: 84%; }
  .seat-body { padding: 6px; gap: 5px; border-radius: 9px; }
  .avatar { width: 22px; height: 22px; font-size: 11px; }
  .seat-body .seat-name { max-width: 58px; font-size: 10px; }
  .chips { font-size: 12px; }
  .hole { height: 36px; }
  .hole .card { width: 26px; height: 36px; font-size: 12px; }
  .own-seat .hole { --own-card-height: 72px; }
  .own-seat .hole .card { width: 52px; }
  .seat.turn .hole { --action-card-width: 26px; --action-card-height: 36px; }
  .own-seat.turn .hole { --action-card-width: 52px; --action-card-height: var(--own-card-height); }
  .action-badge { font-size: 9px; padding: 3px 5px; }
  .seat-label { font-size: 9px; }
  .dealer { top: 44px; width: 18px; height: 18px; line-height: 18px; font-size: 10px; }
  .vacant .seat-body { height: 44px; }

  .controls { margin-top: 28px; gap: 10px; }
  .action-row button { font-size: 13px; padding: 13px 8px; }
  .raise-controls button { padding: 8px 6px; }
  footer { justify-content: center; gap: 4px; }
  footer > span { width: 100%; text-align: center; margin: 0 0 6px; }
  .settings-grid { gap: 0 10px; }
  .session-totals strong { font-size: 18px; }
}

@media (max-width: 480px) {
  header .top { gap: 4px; }
  header .top #accountBtn { white-space: nowrap; padding: 7px 10px; font-size: 11px; }
  header .top #connection { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #payoutBanner, .mini-cards i, button { animation: none; transition: none; }
}
