/* ═══════════════════════════════════════════════════
   DominOnline — Modern UI
   Premium domino arena with dark/light themes
   ═══════════════════════════════════════════════════ */

/* ── Theme variables (dark default) ─────────────────────────── */
:root {
  --game-bg: #05050a;
  --game-surface: rgba(18, 20, 38, 0.75);
  --game-border: rgba(255, 255, 255, 0.08);
  --game-text: #f1f5f9;
  --game-muted: #8e9bb0;
  --board-a: #083327;
  --board-b: #021a14;
  --tile-a: #fffaf0;
  --tile-b: #f3edd7;
  --tile-shadow: rgba(0, 0, 0, 0.45);
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.12);
  --accent-dim: rgba(16, 185, 129, 0.20);
  --accent-gold: #fbbf24;
  --warning: #fbbf24;
  --danger: #ef4444;
  --hero-overlay: rgba(16, 185, 129, 0.10);
  --panel-glass: rgba(18, 20, 38, 0.65);
  --pip-color: #111111;
  --hand-bg: rgba(18, 20, 38, 0.75);
  --btn-primary: linear-gradient(145deg, #10b981, #065f46);
  --btn-primary-shadow: rgba(16, 185, 129, 0.28);
  --btn-secondary: linear-gradient(145deg, #fbbf24, #d97706);
  --btn-secondary-shadow: rgba(217, 119, 6, 0.28);
  --btn-ghost: rgba(255, 255, 255, 0.08);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-full: 999px;
}

/* ── Light theme ────────────────────────────────────────────── */
body.light {
  --game-bg: #f1f5f9;
  --game-surface: rgba(255, 255, 255, 0.82);
  --game-border: rgba(15, 23, 42, 0.08);
  --game-text: #0f172a;
  --game-muted: #64748b;
  --board-a: #1e6b5e;
  --board-b: #0a352d;
  --panel-glass: rgba(255, 255, 255, 0.72);
  --hand-bg: rgba(255, 255, 255, 0.82);
  --tile-shadow: rgba(0, 0, 0, 0.15);
  --hero-overlay: rgba(15, 118, 110, 0.08);
  --pip-color: #1e293b;
  --btn-ghost: rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Segoe UI', Tahoma, system-ui, sans-serif;
  color: var(--game-text);
  background:
    radial-gradient(ellipse at 50% 0%, var(--hero-overlay) 0%, transparent 50%),
    linear-gradient(180deg, var(--game-bg), #020617);
  background-attachment: fixed;
  transition: background 0.3s ease, color 0.3s ease;
}

button, input, select {
  font: inherit;
}

/* ── Shell layout ──────────────────────────────────────────── */
.shell {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

/* ── Hero ──────────────────────────────────────────────────── */
.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px;
  margin-bottom: 24px;
  background: var(--panel-glass);
  border: 1px solid var(--game-border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.hero-compact {
  padding: 16px 20px;
  margin-bottom: 14px;
}

.hero-compact > div:first-child {
  max-width: 520px;
}

.hero h1 {
  margin: 6px 0 10px;
  font-size: clamp(2.4rem, 5.5vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  font-weight: 800;
  background: linear-gradient(145deg, var(--game-text), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-logo {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  margin: 6px 0 16px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.25));
}

.hero-copy {
  max-width: 520px;
  font-size: 0.98rem;
  color: var(--game-muted);
  line-height: 1.5;
}

.ranking-spotlight {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(251, 191, 36, 0.18);
  background:
    radial-gradient(circle at top left, rgba(251, 191, 36, 0.16), transparent 55%),
    linear-gradient(180deg, rgba(15, 18, 34, 0.96), rgba(9, 12, 22, 0.94));
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
}

.ranking-spotlight-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 12px;
}

.ranking-spotlight-header h2 {
  margin: 4px 0 0;
  font-size: 1.15rem;
}

.ranking-eyebrow {
  color: var(--accent-gold);
}

.hero-ranking-podium {
  display: grid;
  gap: 8px;
}

.hero-ranking-chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
}

.hero-ranking-chip-1 {
  border-color: rgba(251, 191, 36, 0.28);
  background:
    radial-gradient(circle at left top, rgba(251, 191, 36, 0.28), transparent 42%),
    rgba(251, 191, 36, 0.12);
  transform: scale(1.05);
  box-shadow: 0 16px 34px rgba(251, 191, 36, 0.16);
}

.hero-ranking-chip-2 {
  border-color: rgba(148, 163, 184, 0.18);
}

.hero-ranking-chip-3 {
  border-color: rgba(180, 83, 9, 0.18);
}

.hero-ranking-position {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  font-weight: 800;
  color: #09111e;
  background: linear-gradient(180deg, #fde68a, #f59e0b);
}

.hero-ranking-chip strong {
  font-size: 0.96rem;
}

.hero-ranking-chip-1 strong {
  font-size: 1.08rem;
}

.hero-ranking-score {
  color: var(--accent-gold);
  font-weight: 800;
}

.hero-ranking-chip-1 .hero-ranking-score {
  font-size: 1.08rem;
}

.hero-ranking-nameblock {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.hero-ranking-nameblock strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-ranking-kpis {
  color: var(--game-muted);
  font-size: 0.78rem;
}

.hero-ranking-stack {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.hero-ranking-chip-highlight,
.hero-ranking-chip-meta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.hero-ranking-chip-highlight {
  color: #09111e;
  background: linear-gradient(180deg, #fde68a, #f59e0b);
}

.hero-ranking-chip-meta {
  color: var(--game-muted);
  border: 1px solid var(--game-border);
  background: rgba(255, 255, 255, 0.04);
}

.hero-ranking-empty {
  padding: 12px 14px;
  border-radius: 16px;
  color: var(--game-muted);
  background: rgba(255, 255, 255, 0.03);
}

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.entry-primary {
  min-width: 170px;
}

.entry-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.text-link-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--game-muted);
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.text-link-button:hover {
  color: var(--game-text);
  background: rgba(255, 255, 255, 0.06);
}

.entry-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(1, 6, 12, 0.72);
  backdrop-filter: blur(10px);
}

.entry-overlay.hidden {
  display: none;
}

.entry-card {
  width: min(680px, 100%);
  padding: 24px;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(14, 18, 32, 0.98), rgba(8, 12, 22, 0.96));
  border: 1px solid var(--game-border);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.entry-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.entry-card-header h2 {
  margin: 4px 0 0;
}

.entry-choice-grid {
  display: grid;
  gap: 12px;
}

.entry-choice {
  text-align: left;
  border: 1px solid var(--game-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--game-text);
  border-radius: 18px;
  padding: 16px 18px;
  display: grid;
  gap: 6px;
  cursor: pointer;
}

.entry-choice strong {
  font-size: 1rem;
}

.entry-choice span {
  color: var(--game-muted);
}

.entry-choice:hover {
  border-color: var(--accent-dim);
  background: rgba(255, 255, 255, 0.06);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 700;
}

.hero-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 280px;
  max-width: 380px;
  flex: 1 1 300px;
}

/* ── Donation Card ────────────────────────────────────────── */
.donation-card {
  padding: 20px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(16, 185, 129, 0.18);
  background:
    radial-gradient(circle at top right, rgba(16, 185, 129, 0.16), transparent 55%),
    linear-gradient(180deg, rgba(15, 18, 34, 0.96), rgba(9, 12, 22, 0.94));
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

body.light .donation-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.65) 0%, rgba(240, 244, 248, 0.75) 100%);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}

.donation-card h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.donation-text {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--game-muted);
}

.donation-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

body.light .donation-block {
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid rgba(15, 23, 42, 0.03);
}

.donation-paypal {
  background: radial-gradient(circle at top right, rgba(16, 185, 129, 0.15), transparent 70%), rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

body.light .donation-paypal {
  background: radial-gradient(circle at top right, rgba(16, 185, 129, 0.1), transparent 70%), rgba(16, 185, 129, 0.02);
  border: 1px solid rgba(16, 185, 129, 0.15);
}

.donation-btn {
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.92rem;
  width: 100%;
}

.donation-paypal-btn {
  background: var(--btn-primary);
  box-shadow: 0 4px 15px var(--btn-primary-shadow);
  color: #ffffff;
}

.donation-paypal-btn:hover {
  filter: brightness(1.08);
}

.donation-bank-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--game-text);
}

.donation-bank-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}

.account-num {
  font-family: monospace;
  font-weight: 700;
  color: var(--game-text);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
}

body.light .account-num {
  background: rgba(0, 0, 0, 0.05);
}

.donation-copy-btn, .donation-wa-btn {
  padding: 8px 14px;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.donation-wa-btn {
  background: var(--btn-ghost);
  border: 1px solid var(--game-border);
  color: var(--game-text);
}

.donation-subtext {
  margin: 0;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--game-text);
}

.donation-desc {
  margin: 0;
  font-size: 0.8rem;
  color: var(--game-muted);
  line-height: 1.35;
}

.donation-icon, .copy-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  justify-content: end;
  gap: 7px;
  min-width: 200px;
}

.hero-compact .hero-badges {
  opacity: 0.86;
}

.hero-compact .hero-badges span,
.hero-compact .hero-badges .mute-button {
  opacity: 0.9;
}

.hero-badges span,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: var(--radius-full);
  border: 1px solid var(--game-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--game-text);
  font-size: 0.82rem;
  font-weight: 700;
}

/* ── Grid ──────────────────────────────────────────────────── */
.grid {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
}

body:not(.shell-open) .grid {
  display: none;
}

.shell-hidden {
  display: none;
}

body.shell-open .shell-hidden {
  display: grid;
}

.sidebar,
.game-panel {
  padding: 22px;
  background: var(--panel-glass);
  border: 1px solid var(--game-border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.20);
}

.game-panel {
  background: linear-gradient(180deg, rgba(18, 20, 38, 0.68), rgba(18, 20, 38, 0.56));
}

/* ── Forms ──────────────────────────────────────────────────── */
.stack {
  display: grid;
  gap: 14px;
}

label { display: grid; gap: 8px; }
label span, .muted { color: var(--game-muted); }

input, select {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--game-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--game-text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input::placeholder { color: var(--game-muted); opacity: 0.6; }

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

select option { background: #1e293b; color: #f1f5f9; }

/* ── Buttons ────────────────────────────────────────────────── */
.primary-button,
.secondary-button,
.ghost-button {
  border: none;
  border-radius: var(--radius-full);
  padding: 12px 20px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active {
  transform: translateY(1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
  transform: none;
}

.primary-button {
  background: var(--btn-primary);
  color: #06130f;
  box-shadow: 0 10px 22px var(--btn-primary-shadow), inset 0 1px 0 rgba(255,255,255,0.30);
}

.primary-button:hover { filter: brightness(1.06); }

.secondary-button {
  background: var(--btn-secondary);
  color: #06130f;
  box-shadow: 0 10px 22px var(--btn-secondary-shadow), inset 0 1px 0 rgba(255,255,255,0.35);
}

.secondary-button:hover { filter: brightness(1.04); }

.ghost-button {
  background: var(--btn-ghost);
  color: var(--game-text);
  border: 1px solid var(--game-border);
}

.ghost-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.ghost-button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.ghost-button.small {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.join-form {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--game-border);
}

.room-primary-card {
  padding: 18px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(16, 185, 129, 0.18);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08), rgba(255, 255, 255, 0.03));
}

.room-secondary-card {
  padding: 14px 16px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.025);
}

.room-primary-button {
  min-height: 48px;
}

.room-secondary-button {
  min-height: 44px;
}

.lobby-panel {
  display: grid;
  gap: 12px;
}

/* ── Section headers ────────────────────────────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.section-header h2,
.section-header h3 { margin: 0; }

.section-header.compact { margin-bottom: 12px; }

.section-block--collapsible {
  margin-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 8px;
}

.section-block-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  color: var(--game-text);
  font-weight: 650;
  opacity: 0.8;
  letter-spacing: 0.01em;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.section-chip-summary {
  display: inline-flex;
  width: fit-content;
  min-width: 110px;
  margin-bottom: 2px;
  padding-inline: 14px;
}

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

.section-block-body {
  display: grid;
  gap: 12px;
  padding: 10px 0 2px;
}

.section-block--collapsible:not([open]) .section-block-body {
  display: none;
}

.section-block--collapsible:not([open]) {
  padding-bottom: 10px;
}

.section-block--collapsible[open] .section-block-summary {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.16);
}

body.in-game .sidebar {
  opacity: 0.94;
}

body.in-game .sidebar .section-block:first-child {
  padding-bottom: 14px;
}

body.in-game .sidebar .auth-summary {
  background: rgba(255, 255, 255, 0.03);
}

body.in-game .sidebar .section-block--collapsible {
  opacity: 0.82;
}

body.in-game .sidebar .section-chip-summary {
  opacity: 0.72;
}

body.in-game .sidebar details.section-block--collapsible:nth-of-type(n+2) {
  margin-bottom: 10px;
}

body.in-game .sidebar details.section-block--collapsible:nth-of-type(n+2) .section-block-body {
  gap: 10px;
}

body.in-game .sidebar details.section-block--collapsible:nth-of-type(n+2) .section-block-summary {
  padding-block: 7px;
}

.lobby-list,
.history-list,
.players-list {
  display: grid;
  gap: 12px;
}

.lobby-card,
.player-card,
.history-card {
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--game-border);
  background: rgba(255, 255, 255, 0.04);
}

.lobby-card,
.history-card,
.tournament-card,
.chat-card {
  box-shadow: none;
  backdrop-filter: none;
}

.auth-summary,
.lobby-card,
.ranking-list .ranking-card,
.tournaments-list .tournament-card {
  background: rgba(255, 255, 255, 0.025);
  border-color: rgba(255, 255, 255, 0.055);
}

.ranking-list .ranking-card,
.tournaments-list .tournament-card {
  padding: 12px 14px;
}

.lobby-card { display: grid; gap: 10px; }
.lobby-card strong,
.player-card strong { display: block; margin-bottom: 4px; }

.room-meta,
.player-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--game-muted);
}

.status-line,
.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.status-banner {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  border: 1px solid var(--accent-dim);
  color: var(--game-text);
  margin-bottom: 14px;
  min-height: 48px;
  display: flex;
  align-items: center;
  backdrop-filter: blur(4px);
}

/* ── Game status panel ──────────────────────────────────────── */
.game-status-panel {
  width: min(920px, 94vw);
  margin: 0 auto 16px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-radius: var(--radius-lg);
  background: var(--panel-glass);
  border: 1px solid var(--game-border);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
}

/* ── Game table layout ──────────────────────────────────────── */
.game-table {
  position: relative;
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 120px;
  grid-template-rows: auto minmax(420px, 1fr) auto;
  grid-template-areas:
    "top    top    top"
    "left   board  right"
    "hand   hand   hand";
  gap: 14px;
  min-height: 620px;
  margin-bottom: 18px;
}

.game-topbar {
  position: sticky;
  top: 12px;
  z-index: 8;
  margin-bottom: 10px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--panel-glass) 84%, transparent);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(18px);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-logo {
  height: 36px;
  width: auto;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.22));
}

.status-banner {
  min-height: 44px;
  margin-bottom: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid var(--accent-dim);
  display: flex;
  align-items: center;
  backdrop-filter: blur(4px);
}

/* ── Opponent slots ─────────────────────────────────────────── */
.opponent-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--game-border);
  background: var(--panel-glass);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.20);
  color: var(--game-text);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.opponent-top {
  grid-area: top;
  justify-content: center;
  flex-direction: row;
  min-height: 70px;
}

.opponent-left {
  grid-area: left;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 220px;
}

.opponent-right {
  grid-area: right;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 220px;
}

.opponent-slot:empty { display: none; }

.opponent-slot.is-current-turn {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent-dim),
    0 14px 32px rgba(0, 0, 0, 0.26);
}

.opponent-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), #0f766e);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
}

.opponent-left .opponent-avatar,
.opponent-right .opponent-avatar {
  width: 36px;
  height: 36px;
  font-size: 1rem;
}

.opponent-name { font-weight: 700; font-size: 0.95rem; }

.opponent-score {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
}

.opponent-tiles {
  display: flex;
  gap: 2px;
  align-items: center;
}

.opponent-tiles-vertical {
  flex-direction: column;
  gap: 4px;
}

.opponent-tile-stub {
  width: 24px;
  height: 42px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.04));
  border: 1px solid var(--game-border);
  border-radius: 6px;
}

.opponent-tile-stub--small {
  width: 20px;
  height: 36px;
  border-radius: 4px;
}

.opponent-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

/* ── Board area ─────────────────────────────────────────────── */
.board-area {
  grid-area: board;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  padding: 12px 14px 14px;
  border-radius: var(--radius-xl);
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid var(--game-border);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.board.empty-board {
  background: radial-gradient(circle at center, rgba(16, 185, 129, 0.10), rgba(6, 95, 70, 0.12));
}

.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
}

.board-header h3 {
  margin: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--game-muted);
}

.board-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#modeLabel {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--accent);
}

/* ── The board (dark felt table) ────────────────────────────── */
.board {
  position: relative;
  aspect-ratio: 1 / 1;
  width: min(850px, 100%);
  max-width: 850px;
  height: min(850px, 82vmin);
  border-radius: 32px;
  overflow: hidden;
  background: #064436;
  touch-action: none;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.45),
    inset 0 0 0 2px rgba(255, 255, 255, 0.06),
    inset 0 0 80px rgba(0, 0, 0, 0.40);
}

.board::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%);
  background-size: 18px 18px;
}

.board-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.board.empty-board {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--game-muted);
  text-align: center;
}

/* ── Board status bar ──────────────────────────────────────────────── */
.board-status {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--game-border);
  font-size: 0.85rem;
  min-height: 36px;
  backdrop-filter: blur(4px);
}

.board-status:empty { display: none; }

.board-status .open-end-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.30);
  border: 1px solid var(--game-border);
  font-weight: 600;
  color: var(--game-text);
  transition: border-color 0.2s, background 0.2s;
}

.board-status .open-end-badge--active {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.40);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.20);
}

.board-status .open-end-label {
  color: var(--game-muted);
  font-weight: 500;
  font-size: 0.8rem;
}

.board-status .open-end-value {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
}

/* ── Open end markers on the board (active endpoints) ──────────────── */
.open-end-marker {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(52, 211, 153, 0.75);
  box-shadow:
    0 0 18px rgba(52, 211, 153, 0.45),
    inset 0 0 10px rgba(52, 211, 153, 0.20);
  animation: openEndPulse 1.4s ease-in-out infinite;
  pointer-events: none;
  z-index: 5;
}

@keyframes openEndPulse {
  0%, 100% { transform: scale(1); opacity: 0.70; }
  50%      { transform: scale(1.15); opacity: 1; }
}

/* ── Scoreboard ────────────────────────────────────────────────────── */
.scoreboard {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  background: var(--panel-glass);
  border: 1px solid var(--game-border);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.scoreboard[hidden] { display: none; }

.scoreboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}

.turn-order-label {
  margin-bottom: 6px;
  padding: 0 2px;
  opacity: 0.85;
}

.turn-order-prefix {
  margin-right: 8px;
  font-weight: 600;
}

.turn-order-track {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.turn-order-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--game-border);
  background: rgba(0, 0, 0, 0.16);
  color: var(--text);
  font-weight: 600;
}

.turn-order-chip.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: #06130f;
  animation: turn-chip-pulse 1.8s ease-in-out infinite;
}

.session-label-current {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: var(--text);
  animation: turn-chip-pulse 1.8s ease-in-out infinite;
}

.session-label-current {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: var(--text);
  animation: turn-chip-pulse 1.8s ease-in-out infinite;
}

.turn-order-arrow {
  opacity: 0.65;
  font-size: 0.9em;
}

@keyframes turn-chip-pulse {
  0%, 100% {
    transform: translateY(0);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.0);
  }

  50% {
    transform: translateY(-1px);
    box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.12);
  }
}

.scoreboard-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.scoreboard-entry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.scoreboard-entry .score-name { font-weight: 500; }

.scoreboard-entry .score-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.20);
  border: 1px solid var(--accent-dim);
  font-weight: 600;
  color: var(--accent);
}

.scoreboard-entry.is-leader .score-value {
  background: var(--accent);
  color: #06130f;
  border-color: var(--accent);
}

.scoreboard-entry.is-you .score-name::after {
  content: " (tu)";
  color: var(--game-muted);
  font-weight: 400;
}

/* ── Hand area ─────────────────────────────────────────────────────── */
.hand-area {
  grid-area: hand;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 0;
  border-top: 1px solid var(--game-border);
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-xl);
}

.hand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  gap: 12px;
  flex-wrap: wrap;
}

.hand-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.hand-header h3 {
  margin: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--game-muted);
}

.action-buttons-inline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.action-buttons-inline .primary-button,
.action-buttons-inline .secondary-button,
.action-buttons-inline .ghost-button {
  padding: 8px 14px;
  font-size: 0.9rem;
}

/* ── Player hand (glassmorphism dock) ──────────────────────────────── */
.hand {
  width: min(920px, 94vw);
  margin: 0 auto;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  display: flex;
  gap: 12px;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  justify-content: flex-start;
  background: var(--hand-bg);
  border: 1px solid var(--game-border);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px);
  perspective: 600px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.20) transparent;
}

.hand::-webkit-scrollbar { height: 6px; }
.hand::-webkit-scrollbar-track { background: transparent; }
.hand::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}

.hand.empty-hand {
  justify-content: center;
  flex-wrap: wrap;
  text-align: center;
  color: var(--game-muted);
}

.hand-pulse {
  animation: handPulse 1.4s ease-in-out infinite;
}

@keyframes handPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
  50%      { box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.30); }
}

/* ── Tile stack (hand) ─────────────────────────────────────────────── */
.tile-stack {
  display: grid;
  gap: 6px;
  justify-items: center;
  flex-shrink: 0;
}

.hand-divider {
  flex: 0 0 2px;
  width: 2px;
  height: 60px;
  background: var(--game-border);
  align-self: center;
  border-radius: var(--radius-full);
  margin: 0 4px;
  opacity: 0.4;
}

/* ── Tile card — hand (48x88) ── */
.tile-card {
  display: grid;
  width: 48px;
  height: 88px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: linear-gradient(135deg, var(--tile-a), var(--tile-b));
  color: var(--pip-color);
  opacity: 1;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.45),
    inset 0 1.5px 2px rgba(255, 255, 255, 0.85),
    inset 0 -1.5px 2px rgba(0, 0, 0, 0.15);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    filter 0.18s ease;
}

/* ── Board tiles: smaller fixed size ── */
.tile-card--board {
  border-radius: 5px;
  border-width: 1px;
  --pip-size: 3.5px;
  opacity: 1;
  filter: none;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Vertical orientation: rows = face / divider / face, columns = single */
.tile-card--vertical {
  grid-template-rows: 1fr 1.5px 1fr;
  grid-template-columns: 1fr;
}

.tile-card--board.tile-card--vertical {
  width: 24px;
  height: 44px;
}

.tile-card--vertical > .tile-divider {
  width: 100%;
  height: 1.5px;
  justify-self: stretch;
  align-self: center;
}

/* Horizontal orientation: columns = face | divider | face, rows = single */
.tile-card--horizontal {
  grid-template-columns: 1fr 1.5px 1fr;
  grid-template-rows: 1fr;
}

.tile-card--board.tile-card--horizontal {
  width: 44px;
  height: 24px;
}

.board .tile-card--board .tile-face {
  padding: 1px;
  background: transparent;
}

.board .tile-card--board .tile-divider {
  background: var(--pip-color);
}

.tile-card--horizontal > .tile-divider {
  width: 1.5px;
  height: 100%;
  justify-self: center;
  align-self: stretch;
}

.tile-card--hand {
  border-radius: 10px;
  --pip-size: 7px;
}

.tile-card--hand.tile-card--vertical {
  width: 48px;
  height: 88px;
}

.tile-card--hand.tile-card--horizontal {
  width: 88px;
  height: 48px;
}

.tile-card--placed {
  opacity: 1;
  filter: none;
  outline: 1px solid rgba(255, 255, 255, 0.04);
}

.board-tile-pos {
  position: absolute;
  pointer-events: none;
}

/* Board container uses CSS transform for uniform scaling */
.board-container {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

/* ── Divider base ──────────────────────────────────────────────────────────── */
.tile-divider {
  background: var(--pip-color, #111111);
  border-radius: 0;
  box-shadow: inset 0 0.5px 1px rgba(0,0,0,0.3);
  position: relative;
}

.tile-divider::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  background: radial-gradient(circle at 30% 30%, #ffd700, #b8860b); /* Gold pin! */
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0.5px 1.5px rgba(0,0,0,0.4);
  z-index: 2;
}

.tile-card--board .tile-divider::after {
  width: 2.2px;
  height: 2.2px;
}

/* ── Tile face ─────────────────────────────────────────────────────────── */
.tile-face {
  position: relative;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 1px;
  overflow: hidden;
  background: transparent;
}

.tile-face--empty {
  background: transparent;
}

/* ── Pips: todas relativas a top/left, centradas con translate ────────────── */
.pip {
  position: absolute;
  width: var(--pip-size, 1.9px);
  height: var(--pip-size, 1.9px);
  border-radius: 999px;
  background: var(--pip-color, #111111);
  transform: translate(-50%, -50%);
  box-shadow: inset 0 0.5px 1px rgba(0,0,0,0.4);
}

.pip--tl { top: 24%; left: 26%; }
.pip--tc { top: 24%; left: 50%; }
.pip--tr { top: 24%; left: 74%; }
.pip--ml { top: 50%; left: 26%; }
.pip--mc { top: 50%; left: 50%; }
.pip--mr { top: 50%; left: 74%; }
.pip--bl { top: 76%; left: 26%; }
.pip--bc { top: 76%; left: 50%; }
.pip--br { top: 76%; left: 74%; }

.tile-card--double {
  box-shadow:
    0 12px 22px rgba(0, 0, 0, 0.4),
    0 0 0 1.5px rgba(255, 255, 255, 0.15);
}

/* ── Tile states ───────────────────────────────────────────────────────── */
.tile-playable {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px rgba(52, 211, 153, 0.85),
    0 14px 26px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  cursor: pointer;
}

.tile-playable:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow:
    0 0 0 3px rgba(52, 211, 153, 0.95),
    0 20px 34px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.tile-muted {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(0.25);
  transition: opacity 0.2s;
}

.tile-muted:hover { opacity: 0.50; }

.tile-card--board.tile-muted {
  opacity: 0.35;
  filter: grayscale(0.25);
}

.tile-stack .tile-card:not(.tile-muted) {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent-dim),
    0 8px 20px var(--tile-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.tile-card--selected {
  filter: brightness(1.04);
  box-shadow:
    0 0 0 3px rgba(250, 204, 21, 0.90),
    0 18px 34px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  z-index: 10;
}

.tile-card--invalid {
  animation: invalidShake 0.22s ease-in-out;
  box-shadow:
    0 0 0 2px var(--danger),
    0 12px 28px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.tile-card--last-played {
  animation: tileDrop 0.28s ease-out;
}

/* ── Drag-and-drop states ───────────────────────────────────────────── */
.tile-card--hand[draggable="true"] {
  cursor: grab;
  touch-action: none;
}

.tile-card--hand[draggable="true"]:active {
  cursor: grabbing;
}

.tile-card--hand.tile-dragging {
  opacity: 0.5;
  transform: scale(0.95);
  box-shadow:
    0 0 0 2px var(--warning),
    0 20px 40px rgba(0, 0, 0, 0.5);
  z-index: 100;
}

.tile-card--hand.tile-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  transform: translate(-50%, -50%) rotate(5deg);
  box-shadow:
    0 0 0 3px var(--accent),
    0 24px 48px rgba(0, 0, 0, 0.6);
  transition: none;
}

/* ── Drop zone indicators ──────────────────────────────────────────── */
.board-drop-zone {
  position: absolute;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 3px dashed transparent;
  background: transparent;
  transition: all 0.2s ease;
  pointer-events: auto;
}

.board-drop-zone--active {
  border-color: rgba(52, 211, 153, 0.6);
  background: rgba(52, 211, 153, 0.12);
}

.board-drop-zone--hover {
  border-color: var(--accent);
  background: rgba(52, 211, 153, 0.25);
  box-shadow: 0 0 24px rgba(52, 211, 153, 0.4);
  transform: scale(1.08);
}

.board-drop-zone--invalid {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
}

@keyframes dropZonePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
  50% { box-shadow: 0 0 20px 6px rgba(52, 211, 153, 0.35); }
}

@keyframes dropZoneInvalid {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.02) translateX(-2px); }
  75% { transform: scale(1.02) translateX(2px); }
}

/* ── Drag hint overlay ─────────────────────────────────────────────── */
.drag-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.6);
  color: var(--game-muted);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 20;
}

.hand:hover .drag-hint,
.hand.drag-active .drag-hint {
  opacity: 1;
}

/* ── Tile action buttons ───────────────────────────────────────────── */
.tile-actions {
  display: flex;
  gap: 6px;
}

.mini-button {
  padding: 6px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--accent-dim);
  background: rgba(52, 211, 153, 0.08);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.mini-button:hover {
  background: rgba(52, 211, 153, 0.18);
}

/* ── Players list (hidden) ─────────────────────────────────────────── */
.players-list-hidden {
  display: none !important;
}

/* ── Collapsible ───────────────────────────────────────────────────── */
.collapsible {
  margin-top: 12px;
  border-top: 1px solid var(--game-border);
  padding-top: 12px;
}

.drawer-panel {
  margin-top: 18px;
  border-top: 1px solid var(--game-border);
  padding-top: 14px;
}

.drawer-panel[open] {
  padding-bottom: 4px;
}

.collapsible summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--game-muted);
  padding: 8px 0;
  list-style: none;
  user-select: none;
  transition: color 0.2s;
}

.collapsible summary::before {
  content: '\25B6';
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.2s;
}

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

.collapsible summary:hover {
  color: var(--game-text);
}

.drawer-panel-body {
  display: grid;
  gap: 16px;
  margin-top: 14px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--game-border);
  background: rgba(255, 255, 255, 0.03);
  transform-origin: top;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.drawer-panel:not([open]) .drawer-panel-body {
  opacity: 0;
  transform: translateY(-8px);
}

.drawer-section {
  display: grid;
  gap: 10px;
}

.drawer-section + .drawer-section {
  padding-top: 14px;
  border-top: 1px solid var(--game-border);
}

.muted.small { font-size: 0.8rem; }

/* ── In-game: compact sidebar ───────────────────────────────────────── */
body.in-game .grid {
  grid-template-columns: 1fr;
  max-width: 1400px;
}

body.in-game .sidebar {
  position: fixed;
  right: 18px;
  top: 18px;
  width: min(320px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  z-index: 6;
  opacity: 0.92;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

body.in-game .sidebar .section-block {
  margin-bottom: 14px;
}

body.in-game .sidebar .section-block:last-child {
  margin-bottom: 0;
}

body.in-game .sidebar .section-block--collapsible:not([open]) .section-block-summary {
  opacity: 0.78;
}

/* ── Misc ──────────────────────────────────────────────────────────── */
.with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
}

.pill {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
}

.pill.turn {
  background: rgba(250, 204, 21, 0.15);
  color: var(--warning);
}

.pill.you {
  background: var(--accent-soft);
}

.pill.bot {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
}

.pill.offline {
  background: rgba(239, 68, 68, 0.10);
  color: var(--danger);
}

.pill.team-a {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.72rem;
}

.pill.team-b {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.72rem;
}

/* ── History cards ─────────────────────────────────────────────────── */
.history-card {
  display: grid;
  gap: 4px;
}

.history-card time {
  font-size: 0.78rem;
  color: var(--game-muted);
}

/* ── Chat ──────────────────────────────────────────────────────────── */
.chat-section {
  display: grid;
  gap: 12px;
}

.chat-messages {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.chat-card {
  padding: 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--game-border);
  background: rgba(255, 255, 255, 0.04);
}

.chat-card--you {
  border-color: var(--accent-dim);
  background: var(--accent-soft);
}

.chat-card--system {
  background: rgba(255, 255, 255, 0.03);
}

.chat-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.chat-form {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

/* ── Tournaments ───────────────────────────────────────────────────── */
.tournaments-list {
  display: grid;
  gap: 12px;
}

.tournament-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--game-border);
  background: rgba(255, 255, 255, 0.04);
}

.tournament-actions,
.tournament-participants {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tournament-bracket {
  display: grid;
  gap: 10px;
}

.tournament-match {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--game-border);
}

/* ── Ranking ───────────────────────────────────────────────────────── */
.ranking-list {
  display: grid;
  gap: 12px;
}

.ranking-card {
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--game-border);
  background: rgba(255, 255, 255, 0.04);
}

.ranking-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

/* ── Auth ──────────────────────────────────────────────────────────── */
.auth-summary {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--game-border);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar > .section-block:first-child {
  border-bottom-color: rgba(255, 255, 255, 0.04);
}

.sidebar .section-block--collapsible {
  opacity: 0.92;
}

.auth-form {
  margin-top: 4px;
}

/* ── Sections blocks ───────────────────────────────────────────────── */
.section-block {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--game-border);
}

.section-block:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input { width: auto; }

/* ── Stats panel overlay ───────────────────────────────────────────── */
.stats-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.stats-overlay.hidden { display: none; }

.stats-panel {
  background: var(--game-bg);
  border: 1px solid var(--game-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  display: grid;
  gap: 20px;
}

.stats-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stats-panel-header h2 { margin: 0; font-weight: 700; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-card {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--game-border);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 4px;
}

.stat-card .stat-icon { font-size: 1.2rem; }

.stat-card .stat-label {
  font-size: 0.78rem;
  color: var(--game-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-card.stat-card--wide { grid-column: 1 / -1; }

.stats-reset-zone {
  display: grid;
  gap: 10px;
}

.stats-confirm-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.stats-confirm-row.hidden { display: none; }

.stats-no-name {
  color: var(--game-muted);
  text-align: center;
  padding: 24px 0;
}

/* ── Mute button ───────────────────────────────────────────────────── */
.mute-button {
  background: var(--btn-ghost);
  color: var(--game-text);
  border: 1px solid var(--game-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.mute-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ── Controls section ──────────────────────────────────────────────── */
.controls-section { margin-bottom: 18px; }

/* ── Board badges ──────────────────────────────────────────────────── */
.board-badges {
  display: flex;
  justify-content: space-between;
  padding: 10px 4px 0;
  gap: 8px;
}

/* ── Connection lost banner ──────────────────────────────────────────── */
.connection-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  padding: 12px 20px;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: connectionSlideDown 0.3s ease-out;
}

@keyframes connectionSlideDown {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}

/* ── Board zoom indicator ──────────────────────────────────────────── */
.board-zoom-indicator {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.6);
  color: var(--game-muted);
  font-size: 0.7rem;
  font-weight: 600;
  pointer-events: none;
  z-index: 25;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.board-zoom-indicator.visible {
  opacity: 1;
}

/* ── Turn timer bar ───────────────────────────────────────────────── */
.turn-timer-bar {
  position: relative;
  height: 36px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.30);
  border: 1px solid var(--game-border);
  overflow: hidden;
  margin-bottom: 12px;
  backdrop-filter: blur(4px);
}

.turn-timer-bar.hidden { display: none; }

.turn-timer-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--accent), #0f766e);
  border-radius: var(--radius-full);
  transition: width 1s linear;
  width: 100%;
}

.turn-timer-fill.urgent {
  background: linear-gradient(90deg, var(--danger), #dc2626);
  animation: timerPulse 0.6s ease-in-out infinite;
}

.turn-timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--game-text);
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  z-index: 1;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ── Quick chat buttons ──────────────────────────────────────────── */
.quick-chat {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.quick-chat-btn {
  padding: 6px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--game-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--game-text);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.quick-chat-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.1);
}

/* ── Last played tile highlight ───────────────────────────────────── */
.tile-card--last-played {
  box-shadow:
    0 0 0 3px var(--warning),
    0 0 18px rgba(250, 204, 21, 0.50),
    0 8px 18px var(--tile-shadow) !important;
  z-index: 5;
}

/* ── Stock empty indicator ────────────────────────────────────────── */
.stock-empty {
  color: var(--danger);
  font-weight: 700;
}

/* ── Undo banner ──────────────────────────────────────────────────── */
.undo-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--warning);
  color: var(--game-text);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 150;
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  animation: undoSlideUp 0.25s ease-out;
}

.undo-banner.hidden { display: none; }

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

.undo-banner .undo-btn {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--btn-secondary);
  color: #06130f;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
}

.undo-banner .undo-timer {
  color: var(--warning);
  font-weight: 800;
}

/* ── Hidden utility ────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ════════════════════════════════════════════════════
   ANIMATIONS
   ════════════════════════════════════════════════════ */

@keyframes tile-enter-kf {
  0%   { opacity: 0; transform: translateX(60px); }
  70%  { opacity: 1; transform: translateX(-4px); }
  100% { opacity: 1; transform: translateX(0); }
}

@keyframes tile-flip-in-kf {
  0%   { opacity: 0; transform: rotateY(90deg); }
  100% { opacity: 1; transform: rotateY(0deg); }
}

@keyframes tileDrop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.82); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes invalidShake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

@keyframes board-shimmer-kf {
  0%, 100% { box-shadow: 0 8px 18px var(--tile-shadow); }
  50%      { box-shadow: 0 0 12px 4px rgba(250, 204, 21, 0.50); }
}

/* ── Board tile staggered entrance ──────────────────────────────── */
@keyframes boardTileAppear {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); filter: blur(2px); }
  60%  { opacity: 1; transform: translate(-50%, -50%) scale(1.05); filter: blur(0); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: blur(0); }
}

@keyframes boardTileGlow {
  0%   { box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1); }
  50%  { box-shadow: 0 0 14px 3px rgba(52, 211, 153, 0.45), 0 2px 6px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1); }
  100% { box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1); }
}

.board-tile-appear {
  animation: boardTileAppear 350ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.board-tile-last {
  animation: boardTileAppear 350ms cubic-bezier(0.34, 1.56, 0.64, 1) both,
             boardTileGlow 600ms ease-out 350ms both;
}

.board-first-tile-enter {
  animation: boardFirstTileEnter 720ms cubic-bezier(0.16, 1, 0.3, 1) both;
  transform-origin: center;
}

.board-first-tile-flash {
  animation: boardFirstTileFlash 720ms ease-out;
}

@keyframes boardFirstTileEnter {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.58) rotate(-8deg);
    filter: blur(2px) saturate(0.9);
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08) rotate(0deg);
    filter: blur(0) saturate(1.08);
    box-shadow: 0 0 0 6px rgba(250, 204, 21, 0.22);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    filter: blur(0) saturate(1);
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0);
  }
}

@keyframes boardFirstTileFlash {
  0% {
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0);
    filter: brightness(0.98);
  }
  55% {
    box-shadow:
      0 0 0 8px rgba(250, 204, 21, 0.18),
      0 0 18px rgba(250, 204, 21, 0.22);
    filter: brightness(1.04) saturate(1.08);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0);
    filter: brightness(1) saturate(1);
  }
}

/* ── Hand tile entrance from above ──────────────────────────────── */
@keyframes handTileEnter {
  0%   { opacity: 0; transform: translateY(-20px) scale(0.85); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.hand-tile-enter {
  animation: handTileEnter 300ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ── Status banner crossfade ────────────────────────────────────── */
@keyframes statusFadeIn {
  0%   { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

.status-banner.animate {
  animation: statusFadeIn 280ms ease-out;
}

.status-banner-flash {
  animation: statusBannerFlash 420ms ease-out;
}

@keyframes statusBannerFlash {
  0%   { transform: translateY(-4px) scale(0.985); filter: saturate(0.95); }
  55%  { transform: translateY(0) scale(1.01); filter: saturate(1.08); }
  100% { transform: translateY(0) scale(1); filter: saturate(1); }
}

.event-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(2, 6, 23, 0.06), rgba(2, 6, 23, 0.42));
}

.event-overlay.hidden { display: none; }

.event-overlay-card {
  min-width: min(540px, calc(100vw - 32px));
  max-width: 620px;
  padding: 22px 24px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.94), rgba(2, 6, 23, 0.86));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
  text-align: center;
  backdrop-filter: blur(18px);
}

.event-overlay[data-kind="start"] .event-overlay-card {
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 28px 80px rgba(37, 99, 235, 0.18), 0 28px 80px rgba(0, 0, 0, 0.45);
}

.event-overlay[data-kind="round"] .event-overlay-card {
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow: 0 28px 80px rgba(16, 185, 129, 0.18), 0 28px 80px rgba(0, 0, 0, 0.45);
}

.event-overlay[data-kind="blocked"] .event-overlay-card {
  border-color: rgba(251, 191, 36, 0.42);
  box-shadow: 0 28px 80px rgba(251, 191, 36, 0.16), 0 28px 80px rgba(0, 0, 0, 0.45);
}

.event-overlay[data-kind="win"] .event-overlay-card {
  border-color: rgba(168, 85, 247, 0.42);
  box-shadow: 0 28px 80px rgba(168, 85, 247, 0.18), 0 28px 80px rgba(0, 0, 0, 0.45);
}

.event-overlay-kicker {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 8px;
}

.event-overlay-title {
  font-size: clamp(1.25rem, 2.8vw, 2rem);
  font-weight: 800;
  color: var(--game-text);
  margin-bottom: 8px;
}

.event-overlay-body {
  color: var(--game-muted);
  line-height: 1.5;
}

.event-overlay-animate .event-overlay-card {
  animation: eventOverlayPop 560ms cubic-bezier(0.2, 1, 0.2, 1);
}

@keyframes eventOverlayPop {
  0% { opacity: 0; transform: scale(0.92) translateY(16px); }
  65% { opacity: 1; transform: scale(1.01) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── History/chat entry slide-in ────────────────────────────────── */
@keyframes entrySlideIn {
  0%   { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

.entry-animate {
  animation: entrySlideIn 250ms ease-out both;
}

/* ── Opponent turn pulse ────────────────────────────────────────── */
@keyframes opponentTurnPulse {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
  50%  { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0.25); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.opponent-slot.is-current-turn {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent-dim),
    0 14px 32px rgba(0, 0, 0, 0.26);
  animation: opponentTurnPulse 1.6s ease-in-out infinite;
}

/* ── Game start flash ────────────────────────────────────────────── */
@keyframes gameStartFlash {
  0%   { opacity: 0; }
  20%  { opacity: 1; background: rgba(52, 211, 153, 0.15); }
  100% { opacity: 1; background: transparent; }
}

.game-flash-start {
  animation: gameStartFlash 800ms ease-out both;
}

/* ── Game win celebration ───────────────────────────────────────── */
@keyframes winCelebration {
  0%   { transform: scale(1); }
  15%  { transform: scale(1.02); }
  30%  { transform: scale(1); }
  45%  { transform: scale(1.015); }
  60%  { transform: scale(1); }
}

.game-flash-win {
  animation: winCelebration 1s ease-in-out;
}

/* ── Score pop animation ────────────────────────────────────────── */
@keyframes scorePop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); color: var(--warning); }
  100% { transform: scale(1); }
}

.score-pop {
  animation: scorePop 400ms ease-out;
}

/* ── Board container smooth scale transition ────────────────────── */
.board-container {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  transition: transform 0.3s ease;
}

/* ── Tile card smooth state transitions ─────────────────────────── */
.tile-card {
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    filter 0.18s ease,
    opacity 0.18s ease;
}

.tile-card--board.tile-card--placed {
  transition: box-shadow 0.25s ease;
}

/* ── Hand tile stack entrance stagger ───────────────────────────── */
.tile-stack {
  transition: transform 0.2s ease;
}

.tile-stack:hover {
  transform: translateY(-2px);
}

/* ── Animation utility classes ─────────────────────────────────────── */
.tile-enter {
  animation: tile-enter-kf 320ms ease-out both;
}

.tile-flip-in {
  animation: tile-flip-in-kf 380ms ease-out both;
}

.board-shimmer {
  animation: board-shimmer-kf 1200ms ease-in-out 1;
  animation-fill-mode: both;
}

/* ── Debug mode ────────────────────────────────────────────────────── */
.board.debug-mode {
  background:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(255, 255, 255, 0.08) 0%, transparent 42%),
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.06) 0%, transparent 35%),
    linear-gradient(145deg, var(--board-a), var(--board-b) 70%);
  background-size: 34px 34px, 34px 34px, auto, auto, auto;
}

.board.debug-mode .board-tile-pos {
  outline: 2px dashed rgba(239, 68, 68, 0.50);
  outline-offset: -1px;
}

.board.debug-mode .board-tile-pos::after {
  content: attr(data-coords);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(2, 6, 23, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 2px 5px;
  border-radius: 5px;
  font-size: 9px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

.debug-endpoint::after {
  content: attr(data-dir);
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: rgba(250, 204, 21, 0.90);
  color: #020617;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 10px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-weight: 700;
}

/* ── Open-end badge (legacy, kept for compatibility) ───────────────── */
.open-end-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--game-border);
  background: rgba(0, 0, 0, 0.20);
  color: var(--game-muted);
  font-size: 0.82rem;
  font-weight: 700;
  min-width: 40px;
  flex-shrink: 0;
  transition: border-color 0.2s, background 0.2s;
}

.open-end-badge--active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.open-end-value {
  font-size: 1.1rem;
}

/* ════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════ */

@media (max-width: 1080px) {
  .grid { grid-template-columns: 1fr; }
  .hero { flex-direction: column; }
  .hero-badges { justify-content: start; }
  .hero-side { max-width: 100%; min-width: 0; }
}

@media (max-width: 980px) {
  .game-topbar { position: static; top: auto; }
  .game-table {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
    grid-template-areas:
      "top"
      "board"
      "left"
      "right"
      "hand";
    min-height: auto;
  }
  .opponent-slot { min-height: auto; }
  .board-area { min-height: 460px; }
  .hand-area { padding: 8px 0 0; }
  .opponent-left,
  .opponent-right {
    flex-direction: row;
    justify-content: center;
  }
  .opponent-tiles-vertical { flex-direction: row; }
}

@media (max-width: 720px) {
  .shell { padding-inline: 14px; }
  .sidebar,
  .game-panel,
  .hero {
    padding: 18px;
    border-radius: var(--radius-lg);
  }
  .board { width: 94vw; min-height: 140px; }
  .hand { padding: 12px; gap: 10px; }
  .opponent-avatar { width: 32px; height: 32px; font-size: 0.9rem; }
  .game-status-panel {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
  }
  .drawer-panel { margin-top: 12px; }
  .drawer-panel-body { padding: 12px; gap: 12px; }
  .drawer-panel:not([open]) .drawer-panel-body {
    opacity: 0;
    transform: translateY(-6px);
  }
  /* Larger board tiles on mobile for better visibility */
  .tile-card--board.tile-card--vertical {
    width: 32px;
    height: 58px;
  }
  .tile-card--board.tile-card--horizontal {
    width: 58px;
    height: 32px;
  }
  .tile-card--board {
    --pip-size: 5px;
  }

  .entry-overlay {
    align-items: end;
    padding: 10px;
  }

  .entry-card {
    width: 100%;
    padding: 18px;
    border-radius: 22px 22px 16px 16px;
    max-height: 88vh;
    overflow: auto;
  }

  .entry-card-header {
    margin-bottom: 14px;
  }

  .entry-choice {
    padding: 14px 16px;
  }
}

@media (max-width: 480px) {
  .board {
    border-radius: var(--radius-lg);
  }
  .hand {
    width: 98vw;
    padding: 10px;
    gap: 8px;
    border-radius: var(--radius-md);
  }
  .board-status {
    flex-direction: column;
    gap: 8px;
  }
  /* Even larger tiles on small phones */
  .tile-card--board.tile-card--vertical {
    width: 38px;
    height: 68px;
  }
  .tile-card--board.tile-card--horizontal {
    width: 68px;
    height: 38px;
  }
  .tile-card--board {
    --pip-size: 6px;
    border-radius: 6px;
  }
}

/* ── Accessibility: focus-visible ──────────────────────────────────── */
.tile-card:focus-visible,
.game-btn:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(250, 204, 21, 0.90);
  outline-offset: 3px;
}

/* ── Reduced motion ────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
