/* ============================================
   Texas Hold — bright practice UI
   ============================================ */
:root {
  --bg-primary: #F7F9FC;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #E8EEF5;
  --bg-ink-soft: #EEF3F8;
  --text-primary: #15202B;
  --text-secondary: #3D4F5F;
  --text-muted: #7A8B9A;

  --felt: #0D7A5F;
  --felt-deep: #0A5C47;
  --felt-light: #14906F;
  --rail: #2A4A3A;
  --rail-light: #3D6B54;

  --accent: #0D7A5F;
  --accent-hover: #0B6A52;
  --accent-gold: #C9780A;
  --accent-gold-light: #E0922A;
  --accent-red: #C23B3B;
  --accent-green: #0D7A5F;
  --accent-blue: #2F6FED;

  --card-bg: #FFFFFF;
  --card-red: #E03131;
  --card-black: #1F1F1F;
  --card-back: #1E4A7A;
  --card-back-pattern: #2A5F96;
  --card-border: rgba(15, 23, 42, 0.06);
  --card-radius: 6px;

  --shadow-sm: 0 1px 2px rgba(21, 32, 43, 0.06);
  --shadow-md: 0 8px 24px rgba(21, 32, 43, 0.08);
  --shadow-lg: 0 16px 40px rgba(21, 32, 43, 0.1);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.06), 0 3px 8px rgba(15, 23, 42, 0.12);

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 420ms cubic-bezier(0.22, 1, 0.36, 1);

  --font-display: "Outfit", "Noto Sans SC", sans-serif;
  --font-body: "Noto Sans SC", "Outfit", sans-serif;

  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-primary);
}

.dark {
  --bg-primary: #0F1419;
  --bg-secondary: #1A222C;
  --bg-tertiary: #2A3542;
  --bg-ink-soft: #151C24;
  --text-primary: #E8EEF4;
  --text-secondary: #A8B6C4;
  --text-muted: #6E7F8F;
  --rail: #1E3A30;
  --rail-light: #2A5042;
  --felt: #0F6B54;
  --felt-deep: #0A4A3A;
  --felt-light: #128066;
  /* Face cards stay white like the rules chart, even in dark mode */
  --card-bg: #FFFFFF;
  --card-red: #E03131;
  --card-black: #1F1F1F;
  --card-border: rgba(15, 23, 42, 0.08);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(ellipse 90% 60% at 10% -10%, rgba(13, 122, 95, 0.1), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 0%, rgba(201, 120, 10, 0.07), transparent 50%),
    linear-gradient(rgba(21, 32, 43, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 32, 43, 0.03) 1px, transparent 1px);
  background-size: auto, auto, 28px 28px, 28px 28px;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

body.nav-open {
  overflow: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover { color: var(--accent-hover); }

/* ============================================
   Topbar
   ============================================ */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  padding: 0.65rem clamp(1rem, 3vw, 1.75rem);
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--bg-tertiary);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  animation: barIn 0.5s var(--transition-slow) both;
}

.dark .topbar {
  background: rgba(26, 34, 44, 0.9);
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  animation: brandIn 0.55s var(--transition-slow) both;
}

.site-brand:hover { color: var(--accent); }

.site-brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  font-family: var(--font-display);
}

.site-brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-links a i {
  font-size: 1.05rem;
  line-height: 1;
}

.nav-links a:hover {
  color: var(--text-primary);
  background: var(--bg-ink-soft);
}

.nav-links a.is-active {
  color: var(--accent);
  background: rgba(13, 122, 95, 0.1);
  font-weight: 600;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}

.nav-toggle {
  display: none;
  background: var(--bg-ink-soft);
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 1.25rem;
  line-height: 1;
  align-items: center;
  justify-content: center;
}

.nav-toggle:hover {
  color: var(--text-primary);
  border-color: var(--bg-tertiary);
}

.theme-toggle {
  background: var(--bg-ink-soft);
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  color: var(--text-primary);
  border-color: var(--bg-tertiary);
}

.sfx-toggle {
  background: var(--bg-ink-soft);
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.sfx-toggle:hover {
  color: var(--text-primary);
  border-color: var(--bg-tertiary);
}

.sfx-toggle[aria-pressed="true"] {
  color: var(--text-muted);
}

@keyframes barIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

@keyframes brandIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: none; }
}

/* ============================================
   Page shells
   ============================================ */
.page {
  flex: 1 0 auto;
  width: 100%;
  padding: clamp(1.25rem, 3vw, 2rem);
  max-width: 1120px;
  margin: 0 auto;
}

body.page-play .page {
  max-width: 1280px;
}

body.page-home .page {
  max-width: 820px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.btn-lg {
  padding: 0.85rem 1.5rem;
  font-size: 1.05rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px rgba(13, 122, 95, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  color: #fff;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--bg-tertiary);
}

.btn-ghost:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-secondary {
  background: var(--bg-ink-soft);
  color: var(--text-primary);
  border-color: var(--bg-tertiary);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
}

.btn-danger {
  background: var(--accent-red);
  color: #fff;
}

.btn-danger:hover { filter: brightness(1.05); }

/* ============================================
   Home hero
   ============================================ */
.hero {
  padding: clamp(2.5rem, 8vh, 5rem) 0 3rem;
  text-align: left;
  animation: heroIn 0.6s var(--transition-slow) both;
}

.hero-kicker {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-brand {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: clamp(3rem, 10vw, 5.25rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.95;
  color: var(--text-primary);
}

.hero-lead {
  margin: 0 0 1.5rem;
  max-width: 34rem;
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.engine-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  box-shadow: var(--shadow-sm);
}

.engine-status.is-online { color: var(--accent-green); }
.engine-status.is-offline { color: var(--accent-red); }

.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--bg-tertiary);
  font-size: 0.88rem;
  color: var(--text-muted);
}

.hero-meta .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.5;
}

@keyframes heroIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ============================================
   Start / setup
   ============================================ */
.setup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
  padding: 1rem 0 2rem;
}

.setup-kicker {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.setup-title {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 4vw, 2.4rem);
  font-weight: 750;
  letter-spacing: -0.03em;
}

.setup-hint {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 28rem;
}

.setup-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

.error-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: rgba(194, 59, 59, 0.08);
  border: 1px solid rgba(194, 59, 59, 0.25);
  border-radius: var(--radius-md);
  color: var(--accent-red);
  font-size: 0.92rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  font: inherit;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 122, 95, 0.15);
}

.form-help {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ============================================
   Playing cards — match rules chart style
   ============================================ */
.card {
  width: 48px;
  height: 68px;
  border-radius: var(--card-radius);
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0.28em 0.12em 0.2em;
  gap: 0.08em;
  font-family: "Outfit", "Noto Sans SC", system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--card-border);
  position: relative;
  color: var(--card-black);
  user-select: none;
}

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

.card-rank {
  font-size: 1.05rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.card-suit {
  font-size: 1.12rem;
  line-height: 1;
  font-weight: 600;
}

.card-back {
  background: linear-gradient(145deg, var(--card-back), var(--card-back-pattern));
  color: transparent;
  border: none;
  box-shadow: var(--shadow-card);
  padding: 0;
  justify-content: center;
  gap: 0;
}

.card-back::before {
  content: "♠";
  color: rgba(255, 255, 255, 0.35);
  font-size: 1.4rem;
}

.card.dealing {
  animation: dealCard 0.4s var(--transition-slow) forwards;
}

@keyframes dealCard {
  from { opacity: 0; transform: translateY(-24px) scale(0.85); }
  to { opacity: 1; transform: none; }
}

/* ============================================
   Table / felt
   ============================================ */
.table-wrap { color: var(--text-primary); }

.play-stage {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.play-table-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  gap: 0.5rem;
}

.play-control-rail {
  min-width: 0;
}

.action-dock {
  min-width: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.action-context {
  flex-shrink: 0;
}

.action-context-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.action-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.45rem 0.35rem;
  border-radius: var(--radius-md);
  background: var(--bg-ink-soft);
  border: 1px solid var(--bg-tertiary);
}

.action-stat.is-highlight {
  border-color: var(--accent-gold);
  background: rgba(201, 120, 10, 0.08);
}

.action-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.action-stat-value {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  line-height: 1;
}

.action-context-waiting {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.55rem;
  margin-bottom: 0.35rem;
  border-radius: var(--radius-md);
  background: rgba(13, 122, 95, 0.08);
  border: 1px solid rgba(13, 122, 95, 0.15);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.action-context-waiting i {
  font-size: 1.1rem;
  color: var(--accent);
  flex-shrink: 0;
}

.action-dock-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.hud-hole-block {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  background: rgba(13, 122, 95, 0.06);
  border: 1px solid rgba(13, 122, 95, 0.12);
  border-radius: var(--radius-md);
  min-width: 0;
}

.hud-hole-block .hud-label {
  margin: 0;
  flex-shrink: 0;
}

.dark .hud-hole-block {
  background: rgba(13, 122, 95, 0.12);
  border-color: rgba(255, 255, 255, 0.08);
}

body.page-play #hole,
body.page-play .hole-cards {
  min-height: 0;
  margin-bottom: 0;
  justify-content: flex-start;
}

body.page-play #hole .card,
body.page-play .hole-cards .card {
  width: 44px;
  height: 62px;
}

.action-waiting {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.felt-pane {
  min-width: 0;
  width: 100%;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.status-primary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.65rem 1rem;
  min-width: 0;
}

.status-street {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
}

.status-msg {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
}

.hud-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.action-timer {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 7rem;
}

.action-timer-track {
  flex: 1;
  height: 0.35rem;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
}

.action-timer-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.15s linear;
}

.action-timer.is-urgent .action-timer-fill {
  background: #e05a4f;
}

.action-timer-label {
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  min-width: 2.2rem;
  text-align: right;
}

.action-timer.is-urgent .action-timer-label {
  color: #e05a4f;
}

.ws-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
}

.ws-status.connected {
  background: rgba(13, 122, 95, 0.12);
  color: var(--accent);
}

.ws-status.disconnected {
  background: rgba(201, 120, 10, 0.12);
  color: var(--accent-gold);
}

.felt {
  position: relative;
  height: min(64vh, 600px);
  min-height: 460px;
  border-radius: 50% / 46%;
  background:
    radial-gradient(ellipse at 35% 25%, rgba(255, 255, 255, 0.14), transparent 45%),
    radial-gradient(ellipse at center, var(--felt-light) 0%, var(--felt) 52%, var(--felt-deep) 100%);
  border: 12px solid var(--rail);
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.22),
    0 12px 36px rgba(13, 122, 95, 0.18);
  /* Seats sit on the rail; allow name/stack to render fully. */
  overflow: visible;
  margin-bottom: 0.75rem;
}

.center {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  z-index: 30;
  pointer-events: none;
}

.board {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 0.15rem var(--space-sm) 0;
  order: 2;
}

.board .card {
  width: 46px;
  height: 64px;
  border-radius: var(--card-radius);
}

.board .card-rank { font-size: 1rem; }
.board .card-suit { font-size: 1.05rem; }

.board .card.is-new {
  animation: flopReveal 0.35s var(--transition-slow) both;
}

@keyframes flopReveal {
  from { opacity: 0; transform: translateY(-8px) scale(0.92); }
  to { opacity: 1; transform: none; }
}

.pot {
  order: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 0 0 0.45rem;
  min-width: 8.5rem;
  padding: 0.35rem 1.1rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #E0922A 0%, #C9780A 100%);
  border: 1px solid rgba(255, 224, 138, 0.38);
  box-shadow:
    0 0 14px rgba(224, 146, 42, 0.48),
    0 2px 8px rgba(0, 0, 0, 0.3);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  line-height: 1.2;
}

.pot-icon {
  font-size: 1.05rem;
  line-height: 1;
  opacity: 0.95;
}

.pot-label {
  font-size: 0.88em;
  font-weight: 600;
  opacity: 0.92;
}

.pot-amount {
  font-weight: 800;
  letter-spacing: 0.01em;
}

.pot::before {
  content: none;
}

/* Seats */
.seats {
  position: absolute;
  inset: 0;
  margin: 0.55rem 0.45rem 0.75rem;
  pointer-events: none;
}

.seat {
  position: absolute;
  width: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 20;
  pointer-events: auto;
}

.seat.turn {
  z-index: 28;
}

.seat.turn .seat-info {
  box-shadow: 0 0 0 3px #FFE08A, 0 0 20px rgba(255, 224, 138, 0.65);
  animation: turnPulse 1.6s ease-in-out infinite;
}

.seat.folded { opacity: 0.45; }

.seat.eliminated {
  opacity: 0.32;
  filter: grayscale(0.85);
  pointer-events: none;
}

.seat.eliminated .seat-stack .num {
  text-decoration: line-through;
}

.badge-out {
  background: rgba(80, 80, 80, 0.9);
  color: #ddd;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
}

.tourney-result {
  width: 100%;
  text-align: center;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text, #e8f0ea);
}

.seat-info {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(15, 30, 24, 0.88);
  padding: 0.22rem 0.5rem 0.22rem 0.22rem;
  border-radius: var(--radius-full);
  max-width: 100%;
  order: 1;
}

.seat-avatar {
  position: relative;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: visible;
}

.seat-avatar-img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55);
  background: #E8F5F0;
}

.seat-avatar.is-ai .seat-avatar-img {
  box-shadow: 0 0 0 2px rgba(13, 122, 95, 0.85);
}

.seat-avatar.is-human .seat-avatar-img {
  box-shadow: 0 0 0 2px #FFE08A;
}

.seat-avatar-tag {
  position: absolute;
  right: -3px;
  bottom: -3px;
  min-width: 16px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 14px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.seat-name {
  font-size: 0.74rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 108px;
}

.seat-hero .seat-name {
  color: #FFE08A;
}

.seat-hero .seat-cards .card {
  width: 36px;
  height: 50px;
  box-shadow:
    0 0 0 2px rgba(255, 224, 138, 0.55),
    0 4px 12px rgba(0, 0, 0, 0.22);
}

.seat-hero.turn .seat-cards .card {
  box-shadow:
    0 0 0 3px rgba(255, 224, 138, 0.8),
    0 0 14px rgba(255, 224, 138, 0.45);
}

.seat-cards {
  display: flex;
  gap: 4px;
  justify-content: center;
  order: 2;
}

.seat-cards .card {
  width: 32px;
  height: 46px;
  border-radius: 5px;
  padding: 0.22em 0.08em 0.12em;
}

.seat-cards .card-rank { font-size: 0.72rem; }
.seat-cards .card-suit { font-size: 0.78rem; }

.seat-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  order: 3;
  min-height: 1.35em;
}

.chip-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  padding: 0.14rem 0.42rem;
  border-radius: var(--radius-full);
  line-height: 1.2;
  white-space: nowrap;
}

.chip-pill .chip-icon {
  font-size: 0.82rem;
  line-height: 1;
  flex-shrink: 0;
}

.chip-pill .num {
  font-variant-numeric: tabular-nums;
}

.seat-stack.chip-pill,
.chip-pill.chip-stack {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: #FFD966;
  background: rgba(8, 24, 18, 0.78);
  border: 1px solid rgba(184, 134, 11, 0.5);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
  min-width: 2.4rem;
}

.seat-stack.chip-pill .chip-icon,
.chip-pill.chip-stack .chip-icon {
  color: #E0922A;
}

.seat-bet.chip-pill,
.chip-pill.chip-bet {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: #FFF8E7;
  background: rgba(201, 120, 10, 0.42);
  border: 1px solid rgba(224, 146, 42, 0.72);
  box-shadow: 0 0 8px rgba(224, 146, 42, 0.28);
  min-width: 1.8rem;
  min-height: 1.35em;
}

.seat-bet.chip-pill .chip-icon,
.chip-pill.chip-bet .chip-icon {
  color: #FFE08A;
}

.chip-pill.chip-bet.is-empty {
  visibility: hidden;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  min-width: 0;
  width: 0;
  overflow: hidden;
}

/* Face cards/info toward the board to reduce overlap */
/* South: keep cards toward the rail (below), not floating into the pot. */
.seat-south .seat-info { order: 1; }
.seat-south .seat-meta { order: 2; }
.seat-south .seat-cards { order: 3; }

.seat-north .seat-info { order: 1; }
.seat-north .seat-cards { order: 2; }
.seat-north .seat-meta { order: 3; }

.seat-west,
.seat-east,
.seat-north-west,
.seat-north-east {
  width: 148px;
}

.seat-west,
.seat-north-west {
  align-items: flex-start;
}

.seat-east,
.seat-north-east {
  align-items: flex-end;
}

.seat-west .seat-info,
.seat-east .seat-info,
.seat-north-west .seat-info,
.seat-north-east .seat-info {
  margin-inline: 0;
}

.seat-west .seat-cards,
.seat-north-west .seat-cards {
  justify-content: flex-start;
  padding-left: 0.15rem;
}

.seat-east .seat-cards,
.seat-north-east .seat-cards {
  justify-content: flex-end;
  padding-right: 0.15rem;
}

.seat-west .seat-meta,
.seat-north-west .seat-meta {
  justify-content: flex-start;
}

.seat-east .seat-meta,
.seat-north-east .seat-meta {
  justify-content: flex-end;
}

/* Keep north seats above the pot/board stack */
.seat-north { z-index: 22; }
.seat-north-west,
.seat-north-east { z-index: 21; }
.seat-south { z-index: 24; }

@keyframes turnPulse {
  0%, 100% { box-shadow: 0 0 0 3px #FFE08A, 0 0 10px rgba(255, 224, 138, 0.4); }
  50% { box-shadow: 0 0 0 4px #FFE08A, 0 0 22px rgba(255, 224, 138, 0.7); }
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
}

.badge-dealer {
  background: var(--accent-gold);
  color: #15202B;
}

.badge-allin {
  background: var(--accent-red);
  color: #fff;
}

/* ============================================
   HUD + coach
   ============================================ */
.hud {
  margin-top: 1.25rem;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(260px, 1.15fr);
  gap: 1.25rem;
  align-items: stretch;
}

.hud-main {
  min-width: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-md);
}

.hud-label {
  margin: 0 0 0.45rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hud-hand-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.35rem;
}

.hud-actions-block {
  margin-top: 0.25rem;
}

.coach-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.55rem;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.coach-toggle .coach-header {
  margin-bottom: 0;
}

.coach-caret {
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.coach:not(.is-collapsed-mobile) .coach-caret {
  transform: rotate(180deg);
}

.coach-body {
  display: block;
}

.hole-cards,
#hole {
  display: flex;
  gap: 6px;
  min-height: 84px;
  align-items: center;
  margin-bottom: 1rem;
}

#hole .card,
.hole-cards .card {
  width: 58px;
  height: 84px;
  border-radius: 8px;
  padding: 0.32em 0.14em 0.22em;
}

#hole .card-rank,
.hole-cards .card-rank { font-size: 1.35rem; }

#hole .card-suit,
.hole-cards .card-suit { font-size: 1.45rem; }

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  align-items: stretch;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  align-items: stretch;
}

.action-btn.action-raise,
.action-btn.action-all_in {
  min-height: 48px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.45rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 0;
  width: 100%;
  justify-content: center;
  overflow: hidden;
  transition: transform var(--transition-fast), filter var(--transition-fast), box-shadow var(--transition-fast);
}

.action-btn:active { transform: scale(0.97); }

.action-btn .action-icon {
  font-size: 1rem;
  line-height: 1;
  flex: 0 0 auto;
  width: 1em;
  text-align: center;
  opacity: 0.95;
  overflow: hidden;
}

.action-btn .action-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
  gap: 0.08rem;
  min-width: 0;
  overflow: hidden;
}

.action-btn .action-zh {
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.action-btn .action-en {
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.72;
  white-space: nowrap;
}

.action-btn .action-amount {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  margin-left: 0.05rem;
  padding-left: 0.3rem;
  border-left: 1px solid rgba(21, 32, 43, 0.12);
  line-height: 1;
  text-align: right;
  flex: 0 0 auto;
}

.action-btn.btn-danger .action-amount,
.action-btn.btn-primary .action-amount {
  border-left-color: rgba(255, 255, 255, 0.28);
}

.action-fold .action-icon,
.action-all_in .action-icon,
.action-call .action-icon,
.action-raise .action-icon,
.action-check .action-icon { font-size: 1rem; }

.raise-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius-md);
  background: var(--bg-ink-soft);
  border: 1px solid var(--bg-tertiary);
}

.raise-bar-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
}

.raise-tools {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
  flex: 1 1 auto;
}

.raise-chip {
  border: 1px solid var(--bg-tertiary);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.32rem 0.5rem;
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
}

.raise-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.raise-chip.is-active {
  background: rgba(13, 122, 95, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.raise-input {
  width: 4.5rem;
  min-width: 4.5rem;
  margin-left: auto;
  padding: 0.32rem 0.4rem;
  border: 1px solid var(--bg-tertiary);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

.raise-input::-webkit-outer-spin-button,
.raise-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.raise-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13, 122, 95, 0.18);
}

.waiting-text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.showdown {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--bg-tertiary);
}

.showdown-result {
  display: inline-block;
  padding: 0.25rem 0.55rem;
  margin: 0.15rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.coach {
  min-height: 100%;
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, rgba(201, 120, 10, 0.1), rgba(13, 122, 95, 0.06));
  border: 1px solid rgba(201, 120, 10, 0.22);
  border-left: 4px solid var(--accent-gold);
  box-shadow: var(--shadow-md);
  animation: coachIn 0.35s var(--transition-slow) both;
}

.coach[data-level="good"] {
  border-left-color: var(--accent);
  background: linear-gradient(160deg, rgba(13, 122, 95, 0.12), transparent);
}

.coach[data-level="ok"] { border-left-color: var(--accent-gold); }

.coach[data-level="warn"] {
  border-left-color: #C9842A;
  background: linear-gradient(160deg, rgba(201, 132, 42, 0.12), transparent);
}

.coach[data-level="bad"] {
  border-left-color: var(--accent-red);
  background: linear-gradient(160deg, rgba(194, 59, 59, 0.1), transparent);
}

.coach.is-updating {
  animation: coachIn 0.3s var(--transition-slow) both;
}

.coach-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.coach-header i {
  color: var(--accent-gold);
  font-size: 1.1rem;
}

.coach-title {
  margin-bottom: 0.45rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

.coach-suggest {
  display: inline-flex;
  align-items: center;
  margin: 0 0 0.65rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-full);
  background: rgba(13, 122, 95, 0.14);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.coach[data-level="bad"] .coach-suggest {
  background: rgba(194, 59, 59, 0.12);
  color: var(--accent-red);
}

.coach[data-level="warn"] .coach-suggest {
  background: rgba(201, 132, 42, 0.14);
  color: #A66B1A;
}

.coach-advice {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.coach-details {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem 0.55rem 1.25rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.86rem;
  line-height: 1.55;
}

.coach-details li {
  margin: 0.2rem 0;
}

.coach-details[hidden] {
  display: none;
}

.coach-rule {
  margin: 0;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--bg-tertiary);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-muted);
}

@keyframes coachIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.toast-error {
  display: none;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(194, 59, 59, 0.1);
  border: 1px solid rgba(194, 59, 59, 0.3);
  border-radius: var(--radius-md);
  color: var(--accent-red);
}

.toast-error[style*="block"],
.toast-error:not([hidden]) {
  display: block;
}

/* Legacy panel / hero leftovers used elsewhere */
.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

/* ============================================
   Responsive — tablet & phone
   ============================================ */
@media (max-width: 860px) {
  .setup {
    grid-template-columns: 1fr;
  }

  .hud {
    grid-template-columns: 1fr;
  }

  .felt {
    min-height: 380px;
    height: min(52vh, 480px);
    border-width: 10px;
  }

  .seats {
    margin: 0.85rem 0.55rem 1.1rem;
  }

  .nav-links a { padding: 0.35rem 0.5rem; font-size: 0.82rem; }

  .history-head {
    flex-direction: column;
    align-items: stretch;
  }

  .history-item {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 760px) {
  .page {
    padding: 0.85rem 0.75rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
  }

  body.page-play .page {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  }

  body.page-play .play-stage {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
  }

  body.page-play .felt-pane {
    flex: 0 0 auto;
  }

  body.page-play .felt-pane .felt,
  body.page-play .felt {
    width: 100%;
    max-width: none;
    height: min(52vh, 420px);
    min-height: 240px;
    margin-bottom: 0;
    border-width: 8px;
  }

  body.page-play .play-control-rail {
    display: flex;
    flex-direction: column;
    max-height: none;
    width: 100%;
    grid-template-columns: none;
  }

  body.page-play .action-dock,
  body.page-play .coach {
    grid-column: auto;
    grid-row: auto;
    height: auto;
  }

  body.page-play .play-table-column {
    flex: 0 0 auto;
    padding-right: 0;
  }

  body.page-play .action-dock {
    order: 2;
    position: sticky;
    bottom: 0;
    z-index: 50;
    padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -8px 24px rgba(21, 32, 43, 0.12);
  }

  body.page-play .coach {
    order: 1;
  }

  body.page-play .action-row {
    grid-template-columns: 1fr 1fr;
  }

  body.page-play .raise-bar {
    flex-direction: row;
    flex-wrap: wrap;
  }

  body.page-play .raise-chip {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.35rem 0.5rem;
    padding: 0.55rem 0.75rem;
    padding-top: calc(0.55rem + env(safe-area-inset-top, 0px));
  }

  .nav-toggle {
    display: inline-flex;
    order: 2;
  }

  .topbar-tools {
    order: 3;
    margin-left: 0;
  }

  .site-brand {
    order: 1;
  }

  .nav-links {
    display: none;
    order: 4;
    grid-column: 1 / -1;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    padding: 0.35rem 0 0.15rem;
    border-top: 1px solid var(--bg-tertiary);
  }

  body.nav-open .nav-links {
    display: flex;
  }

  .nav-links a {
    padding: 0.7rem 0.85rem;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
  }

  .status-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: 0.65rem 0.75rem;
  }

  .status-primary {
    gap: 0.35rem;
  }

  .status-street {
    font-size: 0.95rem;
  }

  .status-msg {
    font-size: 0.84rem;
    line-height: 1.4;
  }

  .ws-status {
    align-self: flex-start;
  }

  .felt {
    height: min(46vh, 380px);
    min-height: 300px;
    border-width: 8px;
    margin-bottom: 0.55rem;
  }

  .center {
    top: 36%;
  }

  .pot {
    font-size: 0.92rem;
    min-width: 0;
    padding: 0.18rem 0.65rem;
  }

  .board {
    gap: 0.3rem;
    padding: 0.1rem 0.2rem 0;
  }

  .board .card {
    width: 38px;
    height: 54px;
  }

  .board .card-rank { font-size: 0.85rem; }
  .board .card-suit { font-size: 0.9rem; }

  .seat {
    width: 108px;
  }

  .seat-info {
    padding: 0.2rem 0.4rem 0.2rem 0.2rem;
    gap: 0.25rem;
  }

  .seat-avatar,
  .seat-avatar-img {
    width: 28px;
    height: 28px;
  }

  .seat-name {
    font-size: 0.68rem;
    max-width: 68px;
  }

  .seat-cards .card {
    width: 26px;
    height: 38px;
  }

  .seat-cards .card-suit { font-size: 0.72rem; }
  .seat-stack,
  .seat-bet {
    font-size: 0.7rem;
    min-width: 2.4rem;
  }

  .hud,
  .play-control-rail {
    margin-top: 0.65rem;
    gap: 0.65rem;
  }

  .hud-main {
    order: 1;
    position: sticky;
    bottom: 0;
    z-index: 50;
    padding: 0.75rem 0.85rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -8px 28px rgba(21, 32, 43, 0.12);
  }

  .dark .hud-main {
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.35);
  }

  .coach {
    order: 2;
    padding: 0.85rem 0.95rem;
  }

  .coach.is-collapsed-mobile .coach-body {
    display: none;
  }

  .coach.is-collapsed-mobile {
    padding-bottom: 0.75rem;
  }

  .hud-hand-row {
    margin-bottom: 0.15rem;
  }

  #hole,
  .hole-cards {
    min-height: 64px;
    margin-bottom: 0.55rem;
  }

  #hole .card,
  .hole-cards .card {
    width: 44px;
    height: 64px;
    font-size: 1.05rem;
  }

  #hole .card-suit,
  .hole-cards .card-suit {
    font-size: 1.2rem;
  }

  .actions {
    gap: 0.4rem;
  }

  .action-row {
    gap: 0.4rem;
  }

  .action-btn {
    min-height: 48px;
    padding: 0.5rem 0.45rem;
    font-size: 0.88rem;
    touch-action: manipulation;
  }

  .action-btn .action-en {
    display: none;
  }

  .raise-bar {
    padding: 0.45rem 0.5rem;
  }

  .raise-chip {
    padding: 0.35rem 0.45rem;
    font-size: 0.7rem;
    min-height: 32px;
  }

  .raise-input {
    width: 4.25rem;
    min-width: 4.25rem;
    min-height: 36px;
  }

  .hero {
    padding-top: 1.75rem;
    padding-bottom: 2rem;
  }

  .hero-brand { font-size: clamp(2.1rem, 10vw, 2.75rem); }

  .hero-lead {
    font-size: 1rem;
    max-width: none;
  }

  .cta {
    flex-direction: column;
    align-items: stretch;
  }

  .cta .btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }

  .hero-meta {
    flex-wrap: wrap;
    gap: 0.35rem 0.65rem;
    font-size: 0.82rem;
  }

  .form-row { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { width: 100%; justify-content: center; min-height: 48px; }

  .history-title { font-size: 1rem; }
  .replay-controls {
    flex-wrap: wrap;
    justify-content: center;
  }

  .rules {
    padding-bottom: 1.5rem;
  }

  .rules-section {
    padding: 1rem 1rem;
  }
}

@media (min-width: 761px) {
  .coach-caret { display: none; }
  .coach-toggle { cursor: default; }
  .coach-body { display: block !important; }

  /* Play page: fit table + HUD in one viewport (no page scroll). */
  body.page-play {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  /* Live table: top nav becomes left sidebar */
  body.page-play:not(.page-replay) {
    display: grid;
    grid-template-columns: 5.75rem minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }

  body.page-play:not(.page-replay) .topbar {
    grid-column: 1;
    grid-row: 1 / -1;
    display: flex;
    position: relative;
    top: auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 0.45rem;
    padding-top: calc(0.85rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
    border-bottom: none;
    border-right: 1px solid var(--bg-tertiary);
    backdrop-filter: blur(14px);
  }

  body.page-play:not(.page-replay) .site-brand {
    flex-direction: column;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.15rem 0 0.35rem;
  }

  body.page-play:not(.page-replay) .site-brand-name {
    display: none;
  }

  body.page-play:not(.page-replay) .nav-toggle {
    display: none;
  }

  body.page-play:not(.page-replay) .nav-links {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    flex: 1;
    min-height: 0;
    overflow: auto;
  }

  body.page-play:not(.page-replay) .nav-links a {
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.55rem 0.25rem;
    font-size: 0.72rem;
    text-align: center;
    border-radius: var(--radius-md);
  }

  body.page-play:not(.page-replay) .nav-links a i {
    font-size: 1.25rem;
  }

  body.page-play:not(.page-replay) .topbar-tools {
    margin-left: 0;
    margin-top: auto;
    flex-direction: column;
    width: 100%;
    gap: 0.35rem;
  }

  body.page-play:not(.page-replay) .sfx-toggle,
  body.page-play:not(.page-replay) .theme-toggle {
    width: 100%;
    justify-content: center;
    padding: 0.55rem 0.35rem;
  }

  body.page-play:not(.page-replay) .site-footer {
    grid-column: 2;
    grid-row: 2;
  }

  body.page-play.page-replay .topbar {
    flex-shrink: 0;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  body.page-play .page {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 1280px;
    display: flex;
    flex-direction: column;
    padding: 0.55rem 1.1rem 0.65rem;
  }

  body.page-play:not(.page-replay) .page {
    grid-column: 2;
    grid-row: 1;
    max-width: none;
    width: auto;
    min-width: 0;
    padding: 0.45rem 0.55rem 0.5rem;
  }

  body.page-play .table-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    width: 100%;
  }

  body.page-play .action-dock {
    flex: 1 1 auto;
    min-width: 0;
    max-height: none;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.65rem 0.8rem;
    position: static;
  }

  body.page-play .action-dock-body {
    margin-top: 0;
  }

  body.page-play .action-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.page-play .raise-bar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.3rem 0.45rem;
  }

  body.page-play .raise-input {
    margin-left: auto;
    width: 4.5rem;
  }

  body.page-play:not(.page-replay) .hand-review {
    max-height: 22vh;
    overflow: auto;
    margin: 0;
  }

  body.page-play .status-bar {
    margin-bottom: 0;
    padding: 0.45rem 0.85rem;
    flex-shrink: 0;
  }

  body.page-play .status-street {
    font-size: 0.95rem;
  }

  body.page-play .status-msg {
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: min(48vw, 520px);
  }

  body.page-play .hud-label {
    margin-bottom: 0.15rem;
    font-size: 0.7rem;
  }

  body.page-play .action-stat-value {
    font-size: 1rem;
  }

  body.page-play #hole .card,
  body.page-play .hole-cards .card {
    width: 40px;
    height: 56px;
  }

  body.page-play .actions {
    gap: 0.35rem;
  }

  body.page-play .action-btn {
    padding: 0.4rem 0.35rem;
    min-width: 0;
    font-size: 0.84rem;
  }

  body.page-play .action-btn .action-en {
    display: none;
  }

  body.page-play .action-btn .action-zh {
    font-size: 0.86rem;
  }

  body.page-play .seats {
    margin: 0.55rem 0.65rem 0.85rem;
  }

  body.page-play .coach-advice {
    margin: 0.35rem 0 0.45rem;
    font-size: 0.88rem;
    line-height: 1.5;
  }

  body.page-play .coach-details {
    font-size: 0.82rem;
    line-height: 1.45;
  }

  body.page-play .coach-title {
    font-size: 0.95rem;
  }
}

/* Tablet / small desktop: table stacked above controls (761–1023px only) */
@media (min-width: 761px) and (max-width: 1023px) {
  body.page-play .play-stage {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  body.page-play .play-table-column {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    overflow-x: visible;
  }

  body.page-play .felt-pane {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: stretch;
    padding: 0;
    overflow-x: visible;
    overflow-y: auto;
  }

  body.page-play .felt-pane .felt {
    --felt-ar: 2.05;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 2.05 / 1;
    height: auto;
    min-height: unset;
    margin: 0;
    border-width: 10px;
    flex: 0 0 auto;
    align-self: stretch;
  }

  body.page-play .play-control-rail {
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
    margin-top: 0;
    max-height: min(42vh, 360px);
    height: auto;
    align-self: stretch;
    min-height: 0;
    display: flex;
    flex-direction: row;
    gap: 0.65rem;
    grid-template-columns: none;
  }

  body.page-play .action-dock {
    flex: 1 1 62%;
    min-width: 0;
    min-height: 0;
    max-height: inherit;
    overflow: auto;
  }

  body.page-play #table-app[data-hide-coach="1"] .play-control-rail {
    flex-direction: column;
    max-height: min(38vh, 320px);
  }

  body.page-play #table-app[data-hide-coach="1"] .action-dock {
    flex: 1 1 auto;
  }

  body.page-play .coach {
    flex: 0 0 min(38%, 280px);
    min-width: 0;
    min-height: 0;
    max-height: inherit;
    overflow: auto;
    font-size: clamp(0.78rem, 0.9vw, 0.88rem);
  }

  body.page-play #table-app[data-hide-coach="1"] .coach {
    display: none !important;
  }
}

/* PC wide: table left | gutter | actions + coach (side by side) */
@media (min-width: 1024px) {
  body.page-play:not(.page-replay) .play-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(520px, min(580px, 34vw));
    gap: 1rem;
    align-items: stretch;
    height: 100%;
    flex: 1;
    min-height: 0;
  }

  body.page-play #table-app[data-hide-coach="1"] .play-stage {
    grid-template-columns: minmax(0, 1fr) minmax(280px, min(320px, 22vw));
  }

  body.page-play:not(.page-replay) .play-table-column {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    gap: 0.35rem;
    position: relative;
    padding: 0;
    overflow-x: visible;
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  /* Status above felt — in document flow, never overlays seats */
  body.page-play:not(.page-replay) .play-table-column .status-bar {
    position: static;
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    z-index: auto;
    margin: 0;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    box-shadow: var(--shadow-sm);
    backdrop-filter: none;
  }

  html.dark body.page-play:not(.page-replay) .play-table-column .status-bar {
    background: var(--bg-secondary);
  }

  body.page-play:not(.page-replay) .felt-pane {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    width: 100%;
    padding: 0;
    overflow-x: visible;
    overflow-y: auto;
    display: flex;
    align-items: center;
    justify-content: stretch;
  }

  body.page-play:not(.page-replay) .felt-pane .felt {
    --felt-ar: 2.05;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 2.05 / 1;
    height: auto;
    min-height: unset;
    margin: 0;
    border-width: 10px;
    flex: 0 0 auto;
    align-self: stretch;
  }

  body.page-play:not(.page-replay) .seats {
    margin: 0.5rem 0.1rem 0.65rem;
  }

  /* Action dock left, AI coach right */
  body.page-play:not(.page-replay) .play-control-rail {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(220px, 0.95fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0.75rem;
    align-items: stretch;
    max-height: none;
    height: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    margin-top: 0;
    margin-left: 0;
    padding-left: 0;
    border-left: none;
  }

  body.page-play #table-app[data-hide-coach="1"] .play-control-rail {
    grid-template-columns: minmax(0, 1fr);
    max-height: none;
  }

  body.page-play #table-app[data-hide-coach="1"] .coach {
    display: none !important;
  }

  body.page-play .action-dock {
    grid-column: 1;
    grid-row: 1;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: 0.65rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  body.page-play #table-app[data-hide-coach="1"] .action-dock {
    grid-column: 1;
    flex: none;
  }

  body.page-play .showdown {
    flex: 0 0 auto;
    margin-top: 0;
    padding: 0.45rem 0.55rem;
    border-top: none;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    font-size: 0.82rem;
  }

  body.page-play .showdown:not(:empty) {
    display: block;
  }

  body.page-play .action-dock-body {
    flex: 0 0 auto;
    margin-top: 0;
  }

  body.page-play .hud-label-row {
    margin-bottom: 0.25rem;
  }

  body.page-play .action-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
  }

  body.page-play .action-btn {
    min-height: 46px;
    padding: 0.4rem 0.45rem;
    font-size: 0.86rem;
  }

  body.page-play .action-btn .action-en {
    display: block;
    font-size: 0.68rem;
    opacity: 0.72;
    margin-top: 0.05rem;
  }

  body.page-play .raise-bar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.45rem;
    padding: 0.4rem 0.55rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
  }

  body.page-play .raise-bar-label {
    font-size: 0.72rem;
    width: 100%;
    margin-bottom: 0.05rem;
  }

  body.page-play .raise-tools {
    justify-content: flex-start;
    flex: 1 1 auto;
    width: auto;
  }

  body.page-play .raise-input {
    margin-left: auto;
    width: 4.25rem;
    max-width: 5rem;
    flex-shrink: 0;
  }

  body.page-play .coach {
    grid-column: 2;
    grid-row: 1;
    height: 100%;
    min-width: 0;
    min-height: 0;
    max-height: none;
    overflow: auto;
    margin-top: 0;
    padding: 0.65rem 0.75rem;
    font-size: clamp(0.78rem, 0.9vw, 0.88rem);
  }

  body.page-play .center {
    top: 38%;
  }

  body.page-play .seat {
    gap: 0.2rem;
    width: min(142px, 24%);
  }

  body.page-play .seat-west,
  body.page-play .seat-east {
    width: min(146px, 26%);
  }

  body.page-play .seat-west {
    flex-direction: column;
    align-items: flex-start;
  }

  body.page-play .seat-east {
    flex-direction: column;
    align-items: flex-end;
  }

  body.page-play .seat-west .seat-info {
    order: 1;
  }

  body.page-play .seat-west .seat-cards {
    order: 2;
    margin-left: 0.5rem;
  }

  body.page-play .seat-west .seat-meta {
    order: 3;
  }

  body.page-play .seat-east .seat-info {
    order: 1;
  }

  body.page-play .seat-east .seat-cards {
    order: 2;
    margin-right: 0.5rem;
  }

  body.page-play .seat-east .seat-meta {
    order: 3;
  }

  body.page-play .action-timer {
    min-width: 7.5rem;
    flex: 1 1 auto;
  }

  body.page-play .status-msg {
    max-width: min(32vw, 560px);
  }
}

@media (min-width: 1440px) {
  body.page-play:not(.page-replay) .play-stage {
    grid-template-columns: minmax(0, 1fr) minmax(540px, min(620px, 32vw));
    gap: 1.25rem;
  }

  body.page-play:not(.page-replay) .page {
    padding: 0.5rem 0.75rem 0.55rem;
  }

  body.page-play .play-control-rail {
    grid-template-columns: minmax(0, 1.15fr) minmax(240px, 1fr);
  }

  body.page-play #table-app[data-hide-coach="1"] .play-stage {
    grid-template-columns: minmax(0, 1fr) minmax(280px, min(300px, 18vw));
  }

  body.page-play .seat {
    width: min(148px, 22%);
  }

  body.page-play .seat-west,
  body.page-play .seat-east {
    width: min(152px, 24%);
  }
}

@media (max-width: 560px) {
  .topbar { padding-left: 0.65rem; padding-right: 0.65rem; }
  .site-brand-name { font-size: 1rem; }

  .felt {
    height: min(42vh, 320px);
    min-height: 260px;
  }

  .seat { width: 96px; }
  .seat-name { max-width: 56px; }

  .rules-dl > div {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }
  .rules-ranks li {
    grid-template-columns: 1.4rem 1fr;
  }
  .rules-ex {
    grid-column: 2;
    justify-content: flex-start;
  }
  .rules-ex .card {
    width: 30px;
    height: 42px;
  }
}

@media (max-width: 380px) {
  .action-row {
    grid-template-columns: 1fr 1fr;
  }
  .board .card {
    width: 32px;
    height: 46px;
  }
}



/* ============================================
   Site footer
   ============================================ */
.site-footer {
  flex-shrink: 0;
  margin-top: auto;
  border-top: 1px solid var(--bg-tertiary);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
  padding: 1.25rem clamp(1rem, 3vw, 1.75rem);
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

.dark .site-footer {
  background: rgba(26, 34, 44, 0.88);
}

.site-footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: start;
}

.site-footer-brand {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.site-footer-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.site-footer-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.site-footer-copy strong {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.site-footer-copy span {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.site-footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  justify-content: flex-end;
}

.site-footer-nav a {
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
}

.site-footer-nav a:hover {
  color: var(--accent);
}

.site-footer-meta {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 0.35rem;
  border-top: 1px solid var(--bg-tertiary);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.site-footer-sep {
  opacity: 0.55;
}

/* Play page: compact one-line footer (keeps build visible, saves vertical space) */
body.page-play .site-footer {
  display: block;
  padding: 0.35rem clamp(0.75rem, 2vw, 1.25rem);
  padding-bottom: calc(0.35rem + env(safe-area-inset-bottom, 0px));
}

body.page-play .site-footer-brand,
body.page-play .site-footer-nav {
  display: none;
}

body.page-play .site-footer-inner {
  display: block;
}

body.page-play .site-footer-meta {
  border-top: none;
  padding-top: 0;
  justify-content: center;
  font-size: 0.72rem;
}

@media (max-width: 760px) {
  .site-footer-inner {
    grid-template-columns: 1fr;
  }

  .site-footer-nav {
    justify-content: flex-start;
  }
}

/* ============================================
   History & Replay
   ============================================ */
.history-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.15rem;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.history-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.history-winners {
  margin-top: 0.35rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.history-empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: var(--bg-secondary);
  border: 1px dashed var(--bg-tertiary);
  border-radius: var(--radius-lg);
}

.history-empty p {
  margin: 0 0 1rem;
  color: var(--text-secondary);
}

.replay-head {
  margin-bottom: 1rem;
}

.replay-back {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.replay-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 750;
}

.replay-sub {
  margin: 0.35rem 0 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.replay-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(240px, 0.85fr);
  gap: 1rem;
  align-items: stretch;
}

.replay-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.replay-main .felt {
  margin-bottom: 0;
  /* Restore oval table sizing — live play uses height:100% which collapses here. */
  height: min(56vh, 560px);
  min-height: 420px;
}

.replay-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin: 0;
  padding: 0.85rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.replay-speed {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.replay-speed select {
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg-tertiary);
  background: var(--bg-primary);
  color: var(--text-primary);
  font: inherit;
}

.replay-log {
  margin-top: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 640px);
}

.replay-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.replay-timeline-item {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
}

.replay-timeline-item:hover {
  background: var(--bg-ink-soft);
}

.replay-timeline-item.is-active {
  background: rgba(13, 122, 95, 0.12);
  outline: 1px solid rgba(13, 122, 95, 0.25);
}

.replay-timeline-item.is-done .tl-msg {
  color: var(--text-muted);
}

.tl-type {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.page-replay .hud {
  display: none;
}

/* Replay page should scroll normally; don't lock to one viewport like live play. */
body.page-replay {
  height: auto !important;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: auto !important;
}

body.page-replay .page {
  height: auto !important;
  overflow: visible !important;
  display: block !important;
  flex: none !important;
}

body.page-replay .table-wrap.replay-layout {
  display: grid !important;
  grid-template-rows: none !important;
  flex: none !important;
  min-height: 0;
}

body.page-replay .felt {
  height: min(56vh, 560px);
  min-height: 420px;
  max-height: none;
  width: min(100%, 1200px);
  margin-left: auto;
  margin-right: auto;
}

body.page-replay .site-footer {
  display: block;
}

body.page-replay .site-footer-brand,
body.page-replay .site-footer-nav {
  display: flex;
}

@media (min-width: 961px) {
  body.page-replay .replay-log {
    position: sticky;
    top: 4.5rem;
  }
}

@media (max-width: 960px) {
  .replay-layout {
    grid-template-columns: 1fr;
  }

  .replay-log {
    max-height: 280px;
  }
}

@media (max-width: 860px) {
  .history-item {
    flex-direction: column;
    align-items: stretch;
  }
  .replay-speed { margin-left: 0; }
}

/* ============================================
   Rules page
   ============================================ */
.rules {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 2.5rem;
}

.rules-hero {
  margin-bottom: 2rem;
}

.rules-hero .btn {
  margin-top: 1.25rem;
}

.rules-section {
  margin-bottom: 1.75rem;
  padding: 1.25rem 1.35rem;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.rules-section h2 {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.rules-steps {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.rules-steps li {
  margin-bottom: 0.65rem;
}

.rules-steps strong {
  color: var(--text-primary);
}

.rules-dl {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rules-dl > div {
  display: grid;
  grid-template-columns: minmax(7rem, 9rem) 1fr;
  gap: 0.75rem;
  align-items: baseline;
}

.rules-dl dt {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.rules-dl dt .ph {
  font-size: 1.1rem;
  line-height: 1;
}

.rules-dl dd {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

.rules-ranks {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rank;
}

.rules-ranks li {
  counter-increment: rank;
  display: grid;
  grid-template-columns: 1.6rem minmax(7.5rem, 11rem) 1fr;
  gap: 0.75rem 0.85rem;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.rules-ranks li:last-child {
  border-bottom: none;
}

.rules-ranks li::before {
  content: counter(rank);
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
  align-self: start;
  padding-top: 0.15rem;
}

.rules-rank-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.rules-rank-name {
  font-weight: 700;
  color: var(--text-primary);
}

.rules-rank-desc {
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--text-secondary);
}

.rules-ex {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.rules-ex .card {
  width: 36px;
  height: 50px;
  border-radius: 5px;
  padding: 0.24em 0.08em 0.14em;
}

.rules-ex .card-rank {
  font-size: 0.8rem;
}

.rules-ex .card-suit {
  font-size: 0.86rem;
}

.rules-bullets {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.rules-bullets li {
  margin-bottom: 0.45rem;
}

/* ============================================
   Coach equity + post-hand review + stats
   ============================================ */
.coach-equity {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  margin: 0.35rem 0 0.5rem;
  padding: 0.4rem 0.55rem;
  font-size: 0.86rem;
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: var(--radius-sm, 6px);
}

.coach-equity[data-tone="warn"] {
  background: color-mix(in srgb, var(--accent-red, #c23b3b) 12%, transparent);
}

.coach-equity-pct {
  font-family: var(--font-display);
  font-weight: 750;
  font-size: 1.15rem;
  color: var(--text-primary);
}

.hand-review {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.hand-review-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.92rem;
}

.hand-review-close {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
}

.hand-review-lead {
  margin: 0.4rem 0 0.55rem;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.hand-review-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.hand-review-item-title {
  font-size: 0.88rem;
  font-weight: 650;
}

.hand-review-item-note {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.replay-review {
  margin: 0 0 1rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.stats-card {
  padding: 0.9rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.stats-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stats-value {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 750;
  margin-top: 0.2rem;
}

.stats-sub {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stats-section-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.history-head-actions,
.stats-head-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.is-pos { color: var(--accent); }
.is-neg { color: var(--accent-red, #c23b3b); }

@media (max-width: 760px) {
  .hand-review {
    margin-top: 0.5rem;
    padding: 0.7rem 0.8rem;
  }
  .stats-value { font-size: 1.25rem; }
}

/* ——— Auth / PvP lobby (PowerETF-inspired card) ——— */
.auth-shell {
  min-height: min(70vh, 720px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 2.5rem;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(13, 122, 95, 0.12), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(13, 122, 95, 0.08), transparent 45%);
}

.auth-card {
  width: min(100%, 420px);
  padding: 1.75rem 1.5rem 1.5rem;
  border-radius: var(--radius-lg, 16px);
  background: var(--bg-primary);
  border: 1px solid color-mix(in srgb, var(--bg-tertiary) 80%, transparent);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.auth-card.pvp-card {
  width: min(100%, 720px);
}

.auth-brand {
  text-align: center;
  margin-bottom: 1.25rem;
}

.auth-brand h1 {
  margin: 0.35rem 0 0.4rem;
  font-size: 1.55rem;
}

.auth-brand p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.auth-form input,
.auth-form select {
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  font: inherit;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.auth-submit {
  width: 100%;
  margin-top: 0.35rem;
}

.auth-error {
  color: var(--accent-red);
  background: rgba(194, 59, 59, 0.08);
  border: 1px solid rgba(194, 59, 59, 0.22);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
}

.auth-flash {
  color: var(--accent);
  font-size: 0.9rem;
  text-align: center;
}

.auth-foot {
  margin: 1.1rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-resend {
  text-align: center;
  margin-bottom: 0.75rem;
}

.pvp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 1rem;
}

@media (max-width: 700px) {
  .pvp-grid { grid-template-columns: 1fr; }
}

.pvp-check {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
  font-weight: 500 !important;
}

.pvp-seats {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}

.pvp-seat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  border: 1px dashed var(--bg-tertiary);
  background: var(--bg-secondary, transparent);
}

.pvp-seat.is-human { border-style: solid; border-color: var(--accent); }
.pvp-seat.is-ai { border-style: solid; opacity: 0.85; }
.pvp-seat.is-me { box-shadow: 0 0 0 2px rgba(13, 122, 95, 0.25); }
.pvp-seat-no { font-size: 0.75rem; color: var(--text-muted); }
.pvp-seat-name { font-weight: 600; }
.pvp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.5rem;
}
.pvp-active {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}
.topbar-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(13, 122, 95, 0.22);
  background: var(--bg-ink-soft);
}

.topbar-user-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

body.page-play:not(.page-replay) .topbar-user-avatar {
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: 0.15rem;
}

.topbar-logout { display: inline; margin: 0; }
.topbar-auth-btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
}
