/* =====================================================
   1. IMPORTS & VARIABLES
   ===================================================== */

/* 独特字体组合 - 高端感 + 清晰数字 */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=JetBrains+Mono:wght@400;500;600&family=DM+Sans:wght@400;500;600&display=swap');

:root {
  /* Professional Poker Palette */
  --felt-green: #1a472a;
  --felt-dark: #0f3018;
  --felt-highlight: #1e5c35;
  --gold-bright: #ffd700;
  --gold-soft: #d4af37;
  --chocolate: #3e2723;
  --cream: #f5f5dc;

  /* Status Colors */
  --winner-glow: #00ff88;
  --loser-dim: #ff4757;
  --action-glow: #fbbf24;
  --human-blue: #3b82f6;

  /* Card Suit Colors */
  --suit-red: #dc2626;
  --suit-black: #1f2937;

  /* Neutral Grays */
  --gray-900: #0b1520;
  --gray-800: #1c2b3a;
  --gray-700: #2f4863;
  --gray-600: #4a5568;

  /* Semantic Theme Variables */
  --bg-primary: var(--gray-900);
  --bg-secondary: var(--gray-800);
  --bg-elevated: #020617;
  --text-primary: #e6eef5;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-accent: rgba(212, 175, 55, 0.3);

  /* Typography */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* =====================================================
   2. BASE & RESET
   ===================================================== */

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

body {
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.01em;
  margin: 0;
  padding: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
}

main {
  max-width: 1000px;
  margin: 20px auto;
  padding: 0 16px;
  transition: margin-right 0.25s ease;
}

/* When drawer is open, push main content left */
body.drawer-open main {
  margin-right: 290px;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =====================================================
   3. LAYOUT COMPONENTS
   ===================================================== */

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.session-info {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.session-info span {
  background: var(--bg-secondary);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

/* Controls Bar */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Invite Code Section */
.invite-code-section {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--gray-700);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.invite-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.invite-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 2px 4px;
  outline: none;
  width: 100px;
  text-transform: uppercase;
}

.invite-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.invite-input:focus {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.invite-status {
  font-size: 0.9rem;
  min-width: 18px;
  text-align: center;
}

.invite-status[data-status="valid"]::after {
  content: "✓";
  color: #4ade80;
}

.invite-status[data-status="invalid"]::after {
  content: "✗";
  color: #f87171;
}

.invite-status[data-status="pending"]::after {
  content: "…";
  color: var(--gold-soft);
}

.model-selector {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--gray-700);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.llm-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--gray-700);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.llm-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.llm-toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.llm-toggle__track {
  position: relative;
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: background 0.15s ease, border-color 0.15s ease;
  flex: 0 0 auto;
}

.llm-toggle__thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, background 0.15s ease;
}

.llm-toggle__label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.llm-toggle input:checked + .llm-toggle__track {
  background: rgba(255, 197, 61, 0.35);
  border-color: rgba(255, 197, 61, 0.75);
  box-shadow: 0 0 0 1px rgba(255, 197, 61, 0.25);
}

.llm-toggle input:checked + .llm-toggle__track .llm-toggle__thumb {
  transform: translateX(16px);
  background: rgba(255, 255, 255, 0.92);
}

.llm-toggle input:focus-visible + .llm-toggle__track {
  outline: 2px solid var(--gold-soft);
  outline-offset: 2px;
}

.llm-toggle input:disabled + .llm-toggle__track {
  opacity: 0.6;
  cursor: not-allowed;
}

.llm-toggle input:disabled + .llm-toggle__track + .llm-toggle__label {
  opacity: 0.6;
}

.ask-llm-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.ask-llm-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 197, 61, 0.35);
}

.ask-llm-btn[data-state='loading'] {
  padding-left: 28px;
}

.ask-llm-btn[data-state='loading']::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: rgba(255, 197, 61, 0.75);
  transform: translateY(-50%);
  animation: ask-llm-spin 0.8s linear infinite;
}

.ask-llm-btn[data-state='success'] {
  border-color: rgba(80, 200, 120, 0.55);
}

.ask-llm-btn[data-state='error'] {
  border-color: rgba(255, 90, 90, 0.55);
}

.ask-llm-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

@keyframes ask-llm-spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

.model-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.model-selector select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 2px 4px;
  outline: none;
  cursor: pointer;
}

.model-selector select:focus-visible {
  outline: 2px solid var(--gold-soft);
  outline-offset: 2px;
}

/* Audio Toggle Button */
.audio-toggle {
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  font-size: 1.2rem;
  background: var(--bg-secondary);
  border: 1px solid var(--gray-700);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.audio-toggle:hover {
  background: var(--gray-700);
  border-color: var(--gold-soft);
}

/* BGM Toggle Button */
.bgm-toggle {
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  font-size: 1.2rem;
  background: var(--bg-secondary);
  border: 1px solid var(--gray-700);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bgm-toggle:hover {
  background: var(--gray-700);
  border-color: var(--gold-soft);
}

.bgm-toggle.playing {
  border-color: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.3);
}

.bgm-toggle.loading {
  opacity: 0.6;
  cursor: wait;
}

/* Speed Toggle Button */
.speed-toggle {
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  font-size: 1.2rem;
  background: var(--bg-secondary);
  border: 1px solid var(--gray-700);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.speed-toggle:hover {
  background: var(--gray-700);
  border-color: var(--gold-soft);
}

.speed-toggle[data-speed="instant"] {
  border-color: var(--gold-bright);
  box-shadow: 0 0 6px rgba(255, 215, 0, 0.3);
}

.speed-toggle[data-speed="fast"] {
  border-color: #4ade80;
}

.speed-toggle[data-speed="slow"] {
  border-color: #f97316;
}

/* Skip Queue Button */
.skip-queue {
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  font-size: 1.1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--gray-700);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.skip-queue:hover {
  background: var(--gray-700);
  border-color: var(--action-glow);
}

/* Queue Indicator */
.queue-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  height: 44px;
  padding: 8px 10px;
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1;
  color: var(--gold-bright);
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid var(--border-accent);
  border-radius: 8px;
  box-sizing: border-box;
  animation: queuePulse 1.5s ease-in-out infinite;
}

.queue-indicator .queue-count {
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

@keyframes queuePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Poker Table */
.poker-table {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 16 / 10;
  margin: 0 auto 20px;
  background: radial-gradient(ellipse 80% 60% at 50% 50%, var(--felt-highlight) 0%, var(--felt-green) 40%, var(--felt-dark) 100%);
  border: 4px solid var(--border-accent);
  border-radius: 50%;
  isolation: isolate;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -2px 6px rgba(0, 0, 0, 0.2);
}

.poker-table::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.45;
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.04) 0px,
      rgba(255, 255, 255, 0.04) 1px,
      transparent 1px,
      transparent 4px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.035) 0px,
      rgba(0, 0, 0, 0.035) 1px,
      transparent 1px,
      transparent 5px
    );
  mix-blend-mode: overlay;
  z-index: 0;
}

.poker-table::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 50% 45%, rgba(255, 255, 255, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse 85% 70% at 50% 50%, transparent 52%, rgba(0, 0, 0, 0.35) 100%);
  opacity: 0.9;
  z-index: 0;
}

.table-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 2;
}

.pot-info {
  background: rgba(0, 0, 0, 0.35);
  padding: 14px 20px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.pot-info,
.model-selector,
.llm-controls,
.drawer-section-body {
  background: rgba(2, 6, 23, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .pot-info,
  .model-selector,
  .llm-controls,
  .drawer-section-body {
    background: rgba(2, 6, 23, 0.35);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.09);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }
}

.pot-amount {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #4ade80;
  margin-bottom: 10px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.pot-amount.pot-bump {
  animation: potBump 0.3s ease-out;
}

@keyframes potBump {
  0% { transform: scale(1); filter: brightness(1); }
  45% { transform: scale(1.08); filter: brightness(1.15); }
  100% { transform: scale(1); filter: brightness(1); }
}

.board {
  display: flex;
  gap: 6px;
  justify-content: center;
}

/* Showdown summary */
.showdown-summary {
  margin-top: 12px;
  background: rgba(0, 0, 0, 0.5);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  border: 1px solid var(--border-subtle);
}

.showdown-summary .winners {
  color: var(--winner-glow);
  font-weight: 600;
}

.showdown-summary .losers {
  color: #f87171;
  margin-top: 4px;
}

/* Seats Container */
.seats-container {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.seat {
  position: absolute;
  width: 78px;
}

/* Percentage-based seat positioning for responsive layout */
.seat-1 { bottom: -2%; left: 50%; transform: translateX(-50%); }
/* Right side seats: add extra separation to avoid overlap between seat-2 (SB) and seat-3 (BB). */
.seat-2 { bottom: 4%; right: 6%; }
.seat-3 { top: 45%; right: -6%; transform: translateY(-50%); }
.seat-4 { top: -2%; right: 10%; }
.seat-5 { top: -2%; left: 10%; }
.seat-6 { top: 50%; left: -2%; transform: translateY(-50%); }

/* Game Controls */
.game-controls {
  margin-bottom: 20px;
  text-align: center;
}

.street-info {
  margin-bottom: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.street-info span {
  color: var(--text-primary);
}

.session-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

/* Primary actions row: Fold, Call/Check */
.actions-primary {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Raise section: single row with presets + slider */
.actions-raise {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  flex-wrap: wrap;
  justify-content: center;
}

/* Raise preset buttons: [2x] [3x] [Pot] [All-in] */
.raise-presets {
  display: flex;
  gap: 4px;
}

.raise-presets .raise-preset {
  padding: 6px 10px;
  font-size: 0.8rem;
  min-width: auto;
  min-height: 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--gray-700);
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.raise-presets .raise-preset:hover {
  background: var(--gray-700);
  border-color: var(--gold-soft);
}

.raise-presets .raise-preset:active {
  background: var(--gray-800);
  transform: scale(0.96);
}

/* Slider group: $min [====○========] $max */
.raise-slider-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Min/Max labels */
.raise-bound {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 32px;
}

.raise-min {
  text-align: right;
}

.raise-max {
  text-align: left;
}

/* Amount display (current slider value) */
.raise-amount-display {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gold-bright);
  min-width: 50px;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

/* Submit raise button */
.raise-submit {
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 36px;
}

/* Slider styling */
.raise-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    var(--gold-soft) 0%,
    var(--gold-soft) var(--fill-percent, 0%),
    var(--gray-700) var(--fill-percent, 0%),
    var(--gray-700) 100%
  );
  cursor: pointer;
  outline: none;
  transition: background 0.1s ease;
}

/* Slider thumb - WebKit (Chrome, Safari) */
.raise-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(145deg, #fff 0%, #e8e8e8 100%);
  border: 2px solid var(--gold-soft);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: grab;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.raise-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.raise-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.05);
}

/* Slider thumb - Firefox */
.raise-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(145deg, #fff 0%, #e8e8e8 100%);
  border: 2px solid var(--gold-soft);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: grab;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.raise-slider::-moz-range-thumb:hover {
  transform: scale(1.1);
}

/* Slider track - Firefox */
.raise-slider::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: var(--gray-700);
}

.raise-slider::-moz-range-progress {
  height: 8px;
  border-radius: 4px 0 0 4px;
  background: var(--gold-soft);
}

/* Focus state for accessibility */
.raise-slider:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 4px;
}

/* Log section (collapsible) */
.log-section {
  margin-top: 24px;
  border: 1px solid var(--gray-700);
  border-radius: 8px;
  background: var(--bg-elevated);
}

.log-section summary {
  cursor: pointer;
  padding: 10px 14px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.log-section summary:hover {
  background: rgba(255, 255, 255, 0.03);
}

.log-section summary::-webkit-details-marker {
  display: none;
}

.log-section summary::before {
  content: "▶";
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.log-section[open] summary::before {
  transform: rotate(90deg);
}

.log-section summary h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.log-section pre {
  margin: 0;
  border-top: 1px solid var(--gray-700);
  border-radius: 0 0 8px 8px;
}

pre {
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  padding: 14px;
  border: 1px solid var(--gray-700);
  border-radius: 8px;
  max-height: 180px;
  overflow-y: auto;
  font-size: 0.8rem;
  line-height: 1.5;
}

/* =====================================================
   4. UI COMPONENTS
   ===================================================== */

/* Player Info Cards */
.player-info {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 6px;
  text-align: center;
  border: 2px solid transparent;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-width: 68px;
  max-width: 82px;
  position: relative;
}

.player-name {
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 1px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 76px;
}

.player-pos {
  font-size: 0.65rem;
  color: var(--gold-soft);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.player-stack {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #4ade80;
  margin-bottom: 4px;
}

.player-cards {
  display: flex;
  gap: 2px;
  justify-content: center;
}

.player-bet {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translate(var(--bet-x, 0px), var(--bet-y, 0px));
  pointer-events: none;
  z-index: 8;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: #0b1520;
  padding: 3px 9px;
  border-radius: 999px;
  width: fit-content;
  white-space: nowrap;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(235, 245, 255, 0.88) 100%);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, transform 0.18s ease, filter 0.18s ease;
  filter: saturate(1.05);
}

.player-bet.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) translate(var(--bet-x, 0px), var(--bet-y, 0px)) translateY(0);
}

.player-bet.bet-pop {
  animation: betPop 0.26s ease-out;
}

.player-bet.bet-bump {
  animation: betBump 0.22s ease-out;
}

@keyframes betPop {
  0% { transform: translate(-50%, -50%) translate(var(--bet-x, 0px), var(--bet-y, 0px)) translateY(6px) scale(0.92); filter: brightness(1.1); }
  60% { transform: translate(-50%, -50%) translate(var(--bet-x, 0px), var(--bet-y, 0px)) translateY(0) scale(1.06); filter: brightness(1.15); }
  100% { transform: translate(-50%, -50%) translate(var(--bet-x, 0px), var(--bet-y, 0px)) translateY(0) scale(1); filter: brightness(1); }
}

@keyframes betBump {
  0% { transform: translate(-50%, -50%) translate(var(--bet-x, 0px), var(--bet-y, 0px)) scale(1); }
  50% { transform: translate(-50%, -50%) translate(var(--bet-x, 0px), var(--bet-y, 0px)) scale(1.08); }
  100% { transform: translate(-50%, -50%) translate(var(--bet-x, 0px), var(--bet-y, 0px)) scale(1); }
}

/* Bet positioning: push bet labels toward the table center to utilize the empty felt space. */
.seat {
  --bet-x: 0px;
  --bet-y: 0px;
}

/* 6-max seats: 1 bottom, 2 bottom-right, 3 right, 4 top-right, 5 top-left, 6 left */
.seat-1 { --bet-y: -58px; }
.seat-2 { --bet-x: -44px; --bet-y: -42px; }
.seat-3 { --bet-x: -64px; --bet-y: 0px; }
.seat-4 { --bet-x: -44px; --bet-y: 42px; }
.seat-5 { --bet-x: 44px; --bet-y: 42px; }
.seat-6 { --bet-x: 64px; --bet-y: 0px; }

/* Playing Cards */
.card {
  background: linear-gradient(135deg, #ffffff 0%, #f8f8f8 100%);
  border-radius: 3px;
  width: 28px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.22);
  color: var(--suit-black);
  transition: transform 0.22s ease, opacity 0.22s ease, filter 0.22s ease;
  position: relative;
  overflow: hidden;
}

.card-svg {
  width: 100%;
  height: 100%;
  display: block;
  color: inherit;
}

.card-svg .card-rank {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  fill: currentColor;
  /* Improve legibility at small sizes */
  paint-order: stroke fill;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 1.6px;
}

.card-svg .card-suit {
  color: inherit;
}

/* Keep baseline identical: do NOT change font-size for 10, only tighten spacing */
.card[data-rank="10"] .card-svg .card-rank {
  letter-spacing: -1.8px;
}

/* Hand cards: boost readability without changing card size */
.player-cards .card-svg .card-rank {
  font-size: 26px;
  stroke-width: 1.8px;
}

.player-cards .card[data-rank="10"] .card-svg .card-rank {
  letter-spacing: -2.2px;
}

/* Hand cards: slightly larger center suit for readability */
.player-cards .card-svg .card-suit {
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(1.14);
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0) 45%),
    linear-gradient(120deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0) 55%);
  opacity: 0.55;
}

.card.deal-in {
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  filter: brightness(1.25);
}

.card.deal-in.deal-in-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: brightness(1);
}

/* Board cards (larger) */
.board .card {
  width: 52px;
  height: 72px;
  border-radius: 5px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
}

.board .card-svg .card-rank {
  font-size: 28px;
  stroke-width: 2px;
}

.board .card[data-rank="10"] .card-svg .card-rank {
  letter-spacing: -2.4px;
}

/* Card suit colors */
.card[data-suit="h"],
.card[data-suit="d"],
.card.hearts,
.card.diamonds {
  color: var(--suit-red);
}

.card[data-suit="s"],
.card[data-suit="c"],
.card.spades,
.card.clubs {
  color: var(--suit-black);
}

/* Hidden card (face down) */
.card.hidden {
  background:
    linear-gradient(135deg, rgba(16, 52, 90, 1) 0%, rgba(28, 73, 122, 1) 100%),
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.06) 0px,
      rgba(255, 255, 255, 0.06) 2px,
      transparent 2px,
      transparent 6px
    );
  color: transparent;
  border: 1px solid rgba(140, 190, 240, 0.25);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.card.hidden::before {
  opacity: 0.35;
}

/* Buttons */
button {
  font-family: var(--font-body);
  font-weight: 500;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--gray-700);
  padding: 12px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
  min-height: 44px;
}

button:hover {
  background: #213549;
  border-color: var(--gold-soft);
}

button:active {
  transform: scale(0.97);
}

button:disabled {
  background: #0f1c29;
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: var(--gray-700);
}

/* Action Buttons */
.actions button {
  padding: 14px 22px;
  font-size: 1rem;
  font-weight: 600;
  min-height: 48px;
}

.actions button.fold-btn {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
  border-color: #dc2626;
}

.actions button.fold-btn:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.actions button.call-btn {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  border-color: #059669;
}

.actions button.call-btn:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.actions button.raise-btn {
  background: linear-gradient(135deg, #b45309 0%, #92400e 100%);
  border-color: #d97706;
}

.actions button.raise-btn:hover {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

/* =====================================================
   5. ANALYSIS DRAWER
   ===================================================== */

/* Floating open button (visible when drawer is closed) */
.drawer-open-btn {
  position: fixed;
  top: 80px;
  right: 16px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--gray-800) 0%, var(--gray-900) 100%);
  border: 1px solid var(--gold-soft);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
}

.drawer-open-btn:hover {
  background: linear-gradient(135deg, var(--gray-700) 0%, var(--gray-800) 100%);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
  transform: translateY(-1px);
}

.drawer-open-btn .drawer-open-icon {
  font-size: 1rem;
}

.drawer-open-btn .drawer-open-label {
  font-family: var(--font-body);
}

/* Hide open button when drawer is open */
body.drawer-open .drawer-open-btn {
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
}

.analysis-drawer {
  position: fixed;
  top: 64px;
  right: 0;
  width: 280px;
  max-width: 80vw;
  height: calc(100% - 80px);
  background: linear-gradient(180deg, var(--bg-elevated) 0%, rgba(15, 23, 42, 0.98) 100%);
  border-left: 1px solid var(--border-accent);
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.25s ease-out;
  z-index: 20;
}

.analysis-drawer.collapsed {
  transform: translateX(100%);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--bg-elevated);
}

.drawer-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drawer-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.drawer-hero-pos {
  font-size: 0.78rem;
  color: var(--gold-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.drawer-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 10px;
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.2s ease, background 0.2s ease;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-toggle:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.drawer-body {
  padding: 10px 14px 16px;
  overflow-y: auto;
  font-size: 0.82rem;
}

.drawer-section {
  margin-bottom: 12px;
}

.drawer-section h4 {
  margin: 0 0 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #cbd5e1;
}

.drawer-section-body {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
}

.drawer-section-body p {
  margin: 0 0 3px;
  color: var(--text-secondary);
}

.drawer-section-body p:last-child {
  margin-bottom: 0;
}

.drawer-debug {
  margin-top: 10px;
}

.drawer-debug summary {
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.drawer-debug summary:hover {
  color: var(--text-secondary);
}

.drawer-debug pre {
  max-height: 140px;
  font-size: 0.72rem;
}

/* =====================================================
   6. ACTION NOTIFICATIONS
   ===================================================== */

/* Action notification toast near player seat */
.action-notification {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: var(--gold-bright);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  animation: notificationSlideIn 0.3s ease-out;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-accent);
}

.action-notification.fade-out {
  animation: notificationFadeOut 0.3s ease-out forwards;
}

@keyframes notificationSlideIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes notificationFadeOut {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
}

/* =====================================================
   7. STATES & MODIFIERS
   ===================================================== */

/* Active player (to act) */
.player-info.active {
  border-color: var(--action-glow);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.5), 0 4px 12px rgba(0, 0, 0, 0.25);
}

.player-info.active::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 12px;
  pointer-events: none;
  border: 1px solid rgba(251, 191, 36, 0.35);
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.22);
  animation: activePulse 1.35s ease-in-out infinite;
}

@keyframes activePulse {
  0%, 100% { opacity: 0.65; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
}

/* Human player */
.player-info.human {
  border-color: var(--human-blue);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4), 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Winner highlight */
.player-info.winner {
  border-color: var(--winner-glow);
  box-shadow: 0 0 16px rgba(0, 255, 136, 0.6), 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Loser state */
.player-info.loser {
  border-color: var(--loser-dim);
  box-shadow: 0 0 10px rgba(255, 71, 87, 0.4), 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* =====================================================
   8. ACCESSIBILITY
   ===================================================== */

/* Focus states */
button:focus-visible,
.drawer-toggle:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.25);
}

button:focus:not(:focus-visible) {
  outline: none;
}

a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .player-info {
    border: 2px solid white;
  }
  
  button {
    border: 2px solid white;
  }
  
  .card {
    border: 1px solid #000;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* =====================================================
   9. RESPONSIVE DESIGN
   ===================================================== */

@media (max-width: 768px) {
  main {
    padding: 0 12px;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .session-info {
    gap: 8px;
    font-size: 0.8rem;
  }

  .session-info span {
    padding: 5px 10px;
  }

  .poker-table {
    max-width: 480px;
    /* aspect-ratio inherited from base */
  }

  .seat {
    width: 68px;
  }

  .player-info {
    padding: 6px;
  }

  .player-name {
    font-size: 0.72rem;
  }

  .player-stack {
    font-size: 0.8rem;
  }

  .pot-amount {
    font-size: 1.3rem;
  }

  .actions button {
    padding: 12px 16px;
    font-size: 0.95rem;
    min-height: 48px;
  }

  /* Raise section adjustments for tablet */
  .actions-raise {
    max-width: 480px;
  }

  .raise-slider {
    width: 80px;
  }

  /* Floating open button - bottom position on mobile */
  .drawer-open-btn {
    top: auto;
    bottom: 16px;
    right: 16px;
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  /* Analysis drawer - bottom sheet on mobile */
  .analysis-drawer {
    top: auto;
    bottom: 0;
    height: 45vh;
    width: 100%;
    max-width: 100vw;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-top: 1px solid var(--border-accent);
  }

  .analysis-drawer.collapsed {
    transform: translateY(calc(100% - 52px));
  }

  /* Drawer drag handle indicator */
  .drawer-header::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--gray-600);
    border-radius: 2px;
  }

  .drawer-header {
    position: relative;
    padding-top: 18px;
  }

  /* Mobile: don't push main content, drawer overlays */
  body.drawer-open main {
    margin-right: 0;
  }
}

@media (max-width: 480px) {
  .poker-table {
    max-width: 340px;
  }

  .seat {
    width: 54px;
  }

  .player-name {
    font-size: 0.68rem;
  }

  .player-stack {
    font-size: 0.75rem;
  }

  .player-pos {
    font-size: 0.62rem;
  }

  .card {
    width: 24px;
    height: 34px;
  }

  .board .card {
    width: 44px;
    height: 62px;
  }

  .card-svg .card-rank {
    font-size: 20px;
    stroke-width: 1.5px;
  }

  .card[data-rank="10"] .card-svg .card-rank {
    letter-spacing: -1.6px;
  }

  .player-cards .card-svg .card-rank {
    font-size: 24px;
    stroke-width: 1.7px;
  }

  .player-cards .card[data-rank="10"] .card-svg .card-rank {
    letter-spacing: -2px;
  }

  .player-cards .card-svg .card-suit {
    transform: scale(1.12);
  }

  .board .card-svg .card-rank {
    font-size: 26px;
    stroke-width: 1.9px;
  }

  .pot-amount {
    font-size: 1.1rem;
  }

  .controls {
    gap: 6px;
  }

  .controls button {
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  /* Raise section compact for small screens - two rows */
  .actions-raise {
    max-width: 340px;
    flex-wrap: wrap;
  }

  .raise-presets .raise-preset {
    padding: 5px 8px;
    font-size: 0.75rem;
    min-height: 32px;
  }

  .raise-slider {
    width: 70px;
  }

  .raise-bound {
    font-size: 0.65rem;
    min-width: 28px;
  }

  .raise-amount-display {
    font-size: 0.8rem;
    min-width: 44px;
    padding: 3px 6px;
  }

  .raise-submit {
    padding: 6px 12px;
    font-size: 0.8rem;
    min-height: 32px;
  }
}

/* Touch device optimization */
@media (pointer: coarse) {
  button {
    min-height: 48px;
    min-width: 48px;
    padding: 14px 20px;
  }

  .player-info {
    padding: 10px;
  }

  .drawer-toggle {
    min-width: 48px;
    min-height: 48px;
  }

  /* Larger touch targets for actions */
  .actions button {
    min-height: 52px;
    padding: 16px 24px;
  }

  /* Larger slider thumb for touch */
  .raise-slider {
    height: 8px;
  }

  .raise-slider::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
  }

  .raise-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
  }

  .raise-presets .raise-preset {
    min-height: 40px;
    padding: 8px 12px;
  }

  .raise-submit {
    min-height: 40px;
  }
}
