/* =========================================================
   TAVLA — Themes & Design Tokens
   ========================================================= */
:root {
  --font-sans: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: Georgia, 'Times New Roman', serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-lg: 0 22px 50px rgba(0, 0, 0, 0.45);
  --transition: 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Theme 1: Geleneksel Ceviz & Sedef Ahşap */
html[data-theme="walnut"] {
  --bg-page: radial-gradient(circle at 50% 25%, #2a1c14 0%, #150e0a 75%, #0d0805 100%);
  --bg-topbar: rgba(24, 15, 10, 0.88);
  --bg-dock: rgba(24, 15, 10, 0.92);
  --bg-card: #241710;
  --bg-card-alt: #301f16;
  --border-ui: rgba(214, 175, 108, 0.24);
  --text-main: #f6ead6;
  --text-muted: #c2ab8a;
  --accent: #d8a648;
  --accent-strong: #f0c36d;
  --accent-text: #1c1108;
  --danger: #d9534f;
  --success: #5cb85c;

  --frame-bg: linear-gradient(145deg, #5a351e 0%, #3d2111 45%, #4c2b17 75%, #2e180b 100%);
  --frame-grain: repeating-linear-gradient(
    92deg,
    rgba(255, 210, 160, 0.03) 0px,
    rgba(255, 210, 160, 0.03) 2px,
    rgba(0, 0, 0, 0.06) 4px,
    rgba(0, 0, 0, 0.06) 7px
  );
  --frame-border: #7a4b2b;
  --brass: linear-gradient(180deg, #f3d58d 0%, #b98932 50%, #f1cf7a 100%);

  --bed-bg: linear-gradient(180deg, #dfcaa7 0%, #d2b88d 50%, #c8ac7d 100%);
  --bed-shadow: inset 0 0 28px rgba(45, 22, 8, 0.42);
  --bar-bg: linear-gradient(90deg, #3a2011 0%, #52301b 50%, #3a2011 100%);
  --tray-bg: linear-gradient(180deg, #2b180d 0%, #392012 100%);

  --point-dark: #7a261d;
  --point-dark-edge: #5a1811;
  --point-light: #f4e6cc;
  --point-light-edge: #ccb794;

  --checker-white-bg: radial-gradient(circle at 34% 30%, #ffffff 0%, #f5ebd6 45%, #d6c5a3 85%, #b59f79 100%);
  --checker-white-rim: #9f8760;
  --checker-white-inner: rgba(255, 255, 255, 0.65);

  --checker-black-bg: radial-gradient(circle at 34% 30%, #524a46 0%, #2b2421 48%, #16110f 86%, #090706 100%);
  --checker-black-rim: #0c0908;
  --checker-black-inner: rgba(220, 185, 130, 0.22);

  --die-bg: linear-gradient(145deg, #fffdf8 0%, #ede0c8 100%);
  --die-pip: #22150d;
  --die-border: #bca580;

  --highlight-target: rgba(240, 195, 109, 0.92);
  --highlight-glow: rgba(240, 195, 109, 0.35);
}

/* Theme 2: Apple Siyahı / OLED Dark */
html[data-theme="midnight"] {
  --bg-page: radial-gradient(circle at 50% 0%, #141416 0%, #000000 70%, #000000 100%);
  --bg-topbar: rgba(12, 12, 14, 0.88);
  --bg-dock: rgba(12, 12, 14, 0.94);
  --bg-card: #1c1c1e;
  --bg-card-alt: #2c2c2e;
  --border-ui: rgba(255, 255, 255, 0.13);
  --text-main: #f5f5f7;
  --text-muted: #98989d;
  --accent: #f5c542;
  --accent-strong: #ffd60a;
  --accent-text: #000000;
  --danger: #ff453a;
  --success: #30d158;

  --frame-bg: linear-gradient(145deg, #262629 0%, #121214 52%, #1c1c1e 100%);
  --frame-grain: linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0%, transparent 60%);
  --frame-border: #3a3a3c;
  --brass: linear-gradient(180deg, #d1d1d6 0%, #636366 50%, #d1d1d6 100%);

  --bed-bg: linear-gradient(180deg, #111113 0%, #0b0b0d 50%, #08080a 100%);
  --bed-shadow: inset 0 0 36px rgba(0, 0, 0, 0.85);
  --bar-bg: linear-gradient(90deg, #060608 0%, #161618 50%, #060608 100%);
  --tray-bg: linear-gradient(180deg, #0c0c0e 0%, #161618 100%);

  --point-dark: #1d4d42;
  --point-dark-edge: #12332b;
  --point-light: #36363a;
  --point-light-edge: #242427;

  --checker-white-bg: radial-gradient(circle at 34% 30%, #ffffff 0%, #f2f2f7 52%, #d1d1d6 88%, #aeaeb2 100%);
  --checker-white-rim: #8e8e93;
  --checker-white-inner: rgba(255, 255, 255, 0.85);

  --checker-black-bg: radial-gradient(circle at 34% 30%, #3a3a3c 0%, #1c1c1e 52%, #09090b 88%, #000000 100%);
  --checker-black-rim: #ffd60a;
  --checker-black-inner: rgba(255, 214, 10, 0.32);

  --die-bg: linear-gradient(145deg, #ffffff 0%, #e5e5ea 100%);
  --die-pip: #09090b;
  --die-border: #8e8e93;

  --highlight-target: rgba(48, 209, 88, 0.95);
  --highlight-glow: rgba(48, 209, 88, 0.34);
}

/* Theme 3: Minimal Açık */
html[data-theme="minimal"] {
  --bg-page: linear-gradient(180deg, #f3efe7 0%, #e7e0d4 100%);
  --bg-topbar: rgba(252, 249, 244, 0.92);
  --bg-dock: rgba(252, 249, 244, 0.95);
  --bg-card: #ffffff;
  --bg-card-alt: #f4efe6;
  --border-ui: rgba(45, 42, 38, 0.14);
  --text-main: #23201c;
  --text-muted: #6e655a;
  --accent: #c55d3b;
  --accent-strong: #d86d49;
  --accent-text: #ffffff;
  --danger: #c62828;
  --success: #2e7d32;

  --frame-bg: linear-gradient(145deg, #d7c3a3 0%, #c4ae8a 50%, #ccb796 100%);
  --frame-grain: repeating-linear-gradient(90deg, rgba(255,255,255,0.04) 0 3px, rgba(0,0,0,0.02) 3px 6px);
  --frame-border: #b39b76;
  --brass: linear-gradient(180deg, #d6cfc2 0%, #9b9284 50%, #d6cfc2 100%);

  --bed-bg: linear-gradient(180deg, #faf6ee 0%, #f1eadc 100%);
  --bed-shadow: inset 0 0 18px rgba(80, 60, 30, 0.14);
  --bar-bg: linear-gradient(90deg, #cbb592 0%, #dac7a8 50%, #cbb592 100%);
  --tray-bg: linear-gradient(180deg, #e7dcc8 0%, #efe6d6 100%);

  --point-dark: #c56245;
  --point-dark-edge: #a34c32;
  --point-light: #7c9684;
  --point-light-edge: #5f7867;

  --checker-white-bg: radial-gradient(circle at 34% 30%, #ffffff 0%, #f5f2eb 55%, #dcd6ca 90%, #beb5a4 100%);
  --checker-white-rim: #9f9687;
  --checker-white-inner: rgba(255, 255, 255, 0.8);

  --checker-black-bg: radial-gradient(circle at 34% 30%, #5a5f66 0%, #34383d 52%, #1d2024 90%, #111316 100%);
  --checker-black-rim: #121417;
  --checker-black-inner: rgba(255, 255, 255, 0.16);

  --die-bg: linear-gradient(145deg, #ffffff 0%, #efebe2 100%);
  --die-pip: #23201c;
  --die-border: #c5bdb0;

  --highlight-target: rgba(197, 93, 59, 0.95);
  --highlight-glow: rgba(197, 93, 59, 0.28);
}

/* Theme 4: Zümrüt Kulüp (VIP) */
html[data-theme="emerald_club"] {
  --bg-page: radial-gradient(circle at 50% 20%, #0d3329 0%, #061b16 75%, #030e0b 100%);
  --bg-topbar: rgba(6, 28, 22, 0.9);
  --bg-dock: rgba(6, 28, 22, 0.94);
  --bg-card: #0b261f;
  --bg-card-alt: #12362d;
  --border-ui: rgba(74, 222, 128, 0.25);
  --text-main: #ecfdf5;
  --text-muted: #93c5b2;
  --accent: #34d399;
  --accent-strong: #6ee7b7;
  --accent-text: #042419;
  --danger: #f87171;
  --success: #4ade80;

  --frame-bg: linear-gradient(145deg, #1b4332 0%, #0d281d 50%, #153829 100%);
  --frame-grain: repeating-linear-gradient(90deg, rgba(255,255,255,0.025) 0 2px, rgba(0,0,0,0.08) 2px 5px);
  --frame-border: #2d6a4f;
  --brass: linear-gradient(180deg, #a7f3d0 0%, #34d399 50%, #a7f3d0 100%);

  --bed-bg: linear-gradient(180deg, #103b30 0%, #0b2e25 100%);
  --bed-shadow: inset 0 0 32px rgba(0, 0, 0, 0.55);
  --bar-bg: linear-gradient(90deg, #072019 0%, #12382d 50%, #072019 100%);
  --tray-bg: linear-gradient(180deg, #08231c 0%, #0f3329 100%);

  --point-dark: #9b2226;
  --point-dark-edge: #6b1518;
  --point-light: #e6dfd1;
  --point-light-edge: #b9ae99;

  --checker-white-bg: radial-gradient(circle at 34% 30%, #ffffff 0%, #edf6f9 50%, #c8dce3 88%, #98b4bf 100%);
  --checker-white-rim: #6c8a96;
  --checker-white-inner: rgba(255, 255, 255, 0.78);

  --checker-black-bg: radial-gradient(circle at 34% 30%, #374151 0%, #182026 52%, #0b0f12 88%, #040608 100%);
  --checker-black-rim: #34d399;
  --checker-black-inner: rgba(110, 231, 183, 0.35);

  --die-bg: linear-gradient(145deg, #ffffff 0%, #d8efe6 100%);
  --die-pip: #052e22;
  --die-border: #6ee7b7;

  --highlight-target: rgba(110, 231, 183, 0.96);
  --highlight-glow: rgba(52, 211, 153, 0.32);
}

/* Theme 5: Kraliyet Altını (VIP) */
html[data-theme="royal_gold"] {
  --bg-page: radial-gradient(circle at 50% 20%, #30220a 0%, #160f04 75%, #0c0802 100%);
  --bg-topbar: rgba(24, 17, 6, 0.92);
  --bg-dock: rgba(24, 17, 6, 0.95);
  --bg-card: #221809;
  --bg-card-alt: #31230d;
  --border-ui: rgba(251, 191, 36, 0.32);
  --text-main: #fef3c7;
  --text-muted: #d6b672;
  --accent: #f59e0b;
  --accent-strong: #fcd34d;
  --accent-text: #1c1203;
  --danger: #ef4444;
  --success: #4ade80;

  --frame-bg: linear-gradient(145deg, #5c4012 0%, #382508 50%, #4d350d 100%);
  --frame-grain: repeating-linear-gradient(90deg, rgba(253,224,71,0.04) 0 2px, rgba(0,0,0,0.08) 2px 6px);
  --frame-border: #b45309;
  --brass: linear-gradient(180deg, #fef08a 0%, #d97706 50%, #fef08a 100%);

  --bed-bg: linear-gradient(180deg, #291e0b 0%, #1c1406 100%);
  --bed-shadow: inset 0 0 34px rgba(0, 0, 0, 0.72);
  --bar-bg: linear-gradient(90deg, #1b1305 0%, #33240a 50%, #1b1305 100%);
  --tray-bg: linear-gradient(180deg, #1c1406 0%, #2b1f09 100%);

  --point-dark: #7f1d1d;
  --point-dark-edge: #521010;
  --point-light: #d4a74a;
  --point-light-edge: #9a7424;

  --checker-white-bg: radial-gradient(circle at 34% 30%, #fffbeb 0%, #fde68a 50%, #d97706 90%, #92400e 100%);
  --checker-white-rim: #78350f;
  --checker-white-inner: rgba(255, 255, 255, 0.65);

  --checker-black-bg: radial-gradient(circle at 34% 30%, #44403c 0%, #1c1917 52%, #0c0a09 90%, #050404 100%);
  --checker-black-rim: #fbbf24;
  --checker-black-inner: rgba(251, 191, 36, 0.45);

  --die-bg: linear-gradient(145deg, #fffbeb 0%, #fde68a 100%);
  --die-pip: #291804;
  --die-border: #d97706;

  --highlight-target: rgba(252, 211, 77, 0.96);
  --highlight-glow: rgba(245, 158, 11, 0.32);
}

/* =========================================================
   Base & Reset
   ========================================================= */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font-sans);
  color: var(--text-main);
  background: var(--bg-page);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.show-mobile-only,
.icon-btn.show-mobile-only {
  display: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  font-family: var(--font-sans);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.18);
  margin-left: 4px;
}

html[data-theme="minimal"] kbd {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.16);
}

/* =========================================================
   App Shell (100dvh)
   ========================================================= */
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  width: 100vw;
  position: relative;
}

/* =========================================================
   Top Bar
   ========================================================= */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 6px;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-ui);
  backdrop-filter: blur(10px);
  z-index: 20;
  min-width: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--accent);
}

.brand-mark svg {
  width: 28px;
  height: 28px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-title {
  font-family: var(--font-serif);
  font-weight: 800;
  letter-spacing: 0.1em;
  font-size: 18px;
}

.ruleset-pill {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

.scoreboard-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(128, 128, 128, 0.08);
  border: 1px solid var(--border-ui);
  border-radius: 999px;
  padding: 4px 10px;
}

.player-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 8px;
  border-radius: 999px;
  transition: background var(--transition), box-shadow var(--transition);
}

.player-badge.is-turn {
  background: rgba(216, 166, 72, 0.16);
  box-shadow: 0 0 0 1px var(--accent);
}

.checker-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.swatch-white {
  background: var(--checker-white-bg);
  border: 1px solid var(--checker-white-rim);
}

.swatch-black {
  background: var(--checker-black-bg);
  border: 1px solid var(--checker-black-rim);
}

.p-name {
  font-size: 13px;
  font-weight: 600;
}

.p-pip {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(128, 128, 128, 0.14);
  padding: 1px 6px;
  border-radius: 999px;
}

.p-score {
  font-size: 16px;
  color: var(--accent-strong);
  min-width: 14px;
  text-align: center;
}

.match-target-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 6px;
  border-left: 1px solid var(--border-ui);
  border-right: 1px solid var(--border-ui);
}

.crawford-badge {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  flex: 0 1 auto;
}

.app-shell.is-in-game #btn-open-auth {
  display: none !important;
}

.topbar-actions button {
  white-space: nowrap;
}

.theme-switcher {
  display: flex;
  background: rgba(128, 128, 128, 0.12);
  border: 1px solid var(--border-ui);
  border-radius: 8px;
  padding: 2px;
}

.theme-btn {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 600;
  transition: all var(--transition);
}

.theme-btn.is-active {
  background: var(--accent);
  color: var(--accent-text);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid var(--border-ui);
  background: rgba(128, 128, 128, 0.08);
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.icon-btn.is-active {
  background: rgba(216, 166, 72, 0.16);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.btn-subtle {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-ui);
  background: rgba(128, 128, 128, 0.1);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition);
}

.btn-subtle:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn-primary {
  padding: 8px 18px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-strong) 0%, var(--accent) 100%);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: transform var(--transition), filter var(--transition);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn-secondary {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: rgba(216, 166, 72, 0.15);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  transition: all var(--transition);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(216, 166, 72, 0.28);
}

.btn-confirm {
  padding: 8px 18px;
  border-radius: 10px;
  background: linear-gradient(135deg, #43b56c 0%, #2f8e52 100%);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  transition: transform var(--transition), filter var(--transition);
}

.btn-confirm:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-lg {
  padding: 11px 24px;
  font-size: 15px;
}

/* =========================================================
   Board Stage
   ========================================================= */
.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  min-height: 0;
  overflow: hidden;
}

.board-stage {
  display: grid;
  grid-template-columns: 74px minmax(0, 1020px) 84px;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  max-width: 1200px;
  height: 100%;
  max-height: 690px;
}

/* Side Rails */
.side-rail {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  gap: 10px;
}

.left-rail {
  justify-content: center;
  gap: 24px;
}

.cube-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.rail-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.doubling-cube {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  background: var(--die-bg);
  color: var(--die-pip);
  border: 2px solid var(--accent);
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: transform var(--transition), box-shadow var(--transition);
}

.doubling-cube.can-offer {
  animation: pulse-ring 1.6s infinite;
}

.doubling-cube.can-offer:hover {
  transform: scale(1.07);
}

.doubling-cube.is-locked {
  opacity: 0.5;
  filter: grayscale(0.6);
}

.cube-owner-label {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  font-weight: 600;
}

.direction-guide {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 6px;
  border-radius: 10px;
  background: rgba(128, 128, 128, 0.08);
  border: 1px solid var(--border-ui);
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  font-weight: 600;
}

/* =========================================================
   Tavla Board
   ========================================================= */
.tavla-board {
  position: relative;
  background: var(--frame-grain), var(--frame-bg);
  border: 3px solid var(--frame-border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  display: flex;
  min-height: 0;
  touch-action: none;
}

.hinge {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 8px;
  background: var(--brass);
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  z-index: 5;
}

.hinge-top { top: 3px; }
.hinge-bottom { bottom: 3px; }

.board-inner {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 58px 1fr;
  background: var(--bed-bg);
  box-shadow: var(--bed-shadow);
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(0, 0, 0, 0.35);
  min-height: 0;
}

.board-half {
  display: grid;
  grid-template-rows: 1fr 48px 1fr;
  min-height: 0;
  min-width: 0;
  position: relative;
}

.quadrant {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  min-height: 0;
  min-width: 0;
  position: relative;
}

.board-mid-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 8;
}

.mid-dice-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.mid-dice-slot > * {
  pointer-events: auto;
}

.board-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-strong) 0%, var(--accent) 100%);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 800;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.45);
  transition: transform var(--transition), filter var(--transition);
}

.board-action-btn:hover {
  transform: translateY(-1px) scale(1.04);
  filter: brightness(1.07);
}

.board-action-btn.is-confirm {
  background: linear-gradient(135deg, #43b56c 0%, #2b8a4e 100%);
  color: #ffffff;
}

.board-action-btn.is-undo {
  padding: 6px 10px;
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-ui);
}

.dice-swap-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-card);
  color: var(--accent-strong);
  border: 1px solid var(--accent);
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  transition: transform var(--transition), background var(--transition);
}

.dice-swap-btn:hover {
  transform: rotate(180deg) scale(1.08);
  background: var(--bg-card-alt);
}

/* =========================================================
   Center Bar
   ========================================================= */
.center-bar {
  background: var(--bar-bg);
  border-left: 2px solid rgba(0, 0, 0, 0.38);
  border-right: 2px solid rgba(0, 0, 0, 0.38);
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.45);
}

.bar-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 2px;
  gap: 5px;
  position: relative;
  touch-action: none;
  transition: background var(--transition), box-shadow var(--transition);
}

.bar-zone.has-broken {
  background: radial-gradient(circle at 50% 50%, rgba(217, 67, 63, 0.28) 0%, rgba(217, 67, 63, 0.08) 70%, transparent 100%);
  box-shadow: inset 0 0 16px rgba(217, 67, 63, 0.32);
}

.bar-zone.is-urgent {
  background: radial-gradient(circle at 50% 50%, rgba(255, 92, 82, 0.42) 0%, rgba(217, 67, 63, 0.14) 75%, transparent 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 110, 96, 0.9), inset 0 0 20px rgba(255, 92, 82, 0.45);
}

.bar-zone.is-movable {
  cursor: pointer;
}

.bar-zone.is-selected {
  background: var(--highlight-glow);
  box-shadow: inset 0 0 0 2.5px var(--highlight-target);
}

.bar-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 700;
  text-align: center;
}

.bar-label.is-alert {
  background: #d9433f;
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 8px rgba(217, 67, 63, 0.65);
  border: 1px solid rgba(255, 215, 212, 0.7);
}

html[data-theme="minimal"] .bar-label:not(.is-alert) {
  color: rgba(35, 32, 28, 0.65);
}

.bar-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.bar-stack .checker.is-broken-checker {
  width: min(38px, 84%);
  height: auto;
  aspect-ratio: 1;
  min-width: 24px;
  min-height: 24px;
  box-shadow: 0 0 0 2.5px #ff5a52, 0 0 14px rgba(255, 90, 82, 0.72), 0 4px 10px rgba(0, 0, 0, 0.55);
}

.bar-stack .checker.is-urgent-checker {
  animation: broken-pulse 1.3s ease-in-out infinite;
}

.bar-divider {
  padding: 4px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.bar-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--accent);
}

/* =========================================================
   Board Points (Triangles) & Checkers
   ========================================================= */
.point {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 2px;
  min-width: 0;
  min-height: 0;
  cursor: default;
  transition: filter var(--transition);
}

.point.is-top {
  justify-content: flex-start;
}

.point.is-bottom {
  justify-content: flex-end;
}

/* Triangle graphic via SVG background */
.point-tri {
  position: absolute;
  left: 3%;
  right: 3%;
  height: 86%;
  pointer-events: none;
  z-index: 1;
}

.point.is-top .point-tri {
  top: 0;
}

.point.is-bottom .point-tri {
  bottom: 0;
}

.point-tri svg {
  width: 100%;
  height: 100%;
  display: block;
}

.point-tri .tri-fill-dark {
  fill: var(--point-dark);
  stroke: var(--point-dark-edge);
  stroke-width: 1.5;
}

.point-tri .tri-fill-light {
  fill: var(--point-light);
  stroke: var(--point-light-edge);
  stroke-width: 1.5;
}

.point-number {
  position: absolute;
  font-size: 10px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.55);
  z-index: 2;
  pointer-events: none;
  line-height: 1;
}

html[data-theme="midnight"] .point-number {
  color: rgba(226, 232, 240, 0.55);
}

.hide-numbers .point-number {
  display: none;
}

.point.is-top .point-number {
  bottom: 2px;
}

.point.is-bottom .point-number {
  top: 2px;
}

.point-checkers {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.point.is-top .point-checkers {
  justify-content: flex-start;
}

.point.is-bottom .point-checkers {
  justify-content: flex-end;
}

/* Interactive states on points */
.point.is-movable {
  cursor: pointer;
}

.point.is-movable:hover .point-tri {
  filter: brightness(1.08);
}

.point.is-selected {
  background: var(--highlight-glow);
  box-shadow: inset 0 0 0 2px var(--highlight-target);
}

.point.is-last-ai {
  box-shadow: inset 0 0 18px rgba(216, 166, 72, 0.28);
}

.point.is-target {
  cursor: pointer;
  background: var(--highlight-glow);
  transition: background var(--transition), box-shadow var(--transition);
}

.point.is-target:hover {
  box-shadow: inset 0 0 0 2px var(--highlight-target);
}

.point.is-target::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--highlight-target);
  box-shadow: 0 0 14px var(--highlight-target), 0 0 0 4px rgba(255, 255, 255, 0.25);
  z-index: 6;
  pointer-events: none;
  transition: transform var(--transition);
}

.point.is-target:hover::after {
  transform: scale(1.22);
}

.point.is-top.is-target::after {
  bottom: 18%;
}

.point.is-bottom.is-target::after {
  top: 18%;
}

.point.is-drop-hover {
  box-shadow: inset 0 0 0 3px var(--highlight-target);
}

.target-badge {
  position: absolute;
  z-index: 7;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-text);
  color: var(--accent-strong);
  border: 1px solid var(--accent-strong);
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.target-badge.is-hit {
  background: var(--danger);
  color: #ffffff;
  border-color: #ffd3d1;
}

.point.is-top .target-badge {
  bottom: 4%;
}

.point.is-bottom .target-badge {
  top: 4%;
}

/* =========================================================
   Checkers (Pullar)
   ========================================================= */
.checker {
  width: min(44px, 3.6vw, calc((100dvh - 230px) / 11));
  height: min(44px, 3.6vw, calc((100dvh - 230px) / 11));
  min-width: 24px;
  min-height: 24px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.42), inset 0 1px 1px rgba(255, 255, 255, 0.45);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.checker::before {
  content: '';
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  border: 2px solid transparent;
}

.checker.white {
  background: var(--checker-white-bg);
  border: 2px solid var(--checker-white-rim);
  color: #2b2114;
}

.checker.white::before {
  border-color: var(--checker-white-inner);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.14);
}

.checker.black {
  background: var(--checker-black-bg);
  border: 2px solid var(--checker-black-rim);
  color: #f3e5c8;
}

.checker.black::before {
  border-color: var(--checker-black-inner);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
}

.checker.is-top-movable {
  pointer-events: auto;
  cursor: pointer;
  touch-action: none;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.48), 0 0 0 2px rgba(240, 195, 109, 0.72);
  animation: movable-pulse 2s ease-in-out infinite;
}

.checker.is-top-movable:hover {
  transform: translateY(-2px) scale(1.06);
  box-shadow: 0 7px 14px rgba(0, 0, 0, 0.52), 0 0 0 2.5px var(--accent-strong);
  animation: none;
}

.checker-count-badge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
}

/* =========================================================
   Bear-off Trays (Sağ Toplama Alanı)
   ========================================================= */
.off-tray {
  width: 100%;
  flex: 1;
  background: var(--tray-bg);
  border: 2px solid var(--frame-border);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.45);
  position: relative;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.off-tray.is-target {
  cursor: pointer;
  border-color: var(--highlight-target);
  box-shadow: 0 0 16px var(--highlight-glow), inset 0 0 12px var(--highlight-glow);
}

.off-tray.is-drop-hover {
  box-shadow: 0 0 22px var(--highlight-target), inset 0 0 14px var(--highlight-glow);
}

.off-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.off-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

html[data-theme="minimal"] .off-title {
  color: var(--text-muted);
}

.off-count {
  font-size: 13px;
  color: var(--accent-strong);
}

.off-stack {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  padding: 4px 2px;
}

.off-tray.off-black .off-stack {
  justify-content: flex-start;
}

.off-chip {
  height: 9px;
  width: 100%;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.off-chip.white {
  background: var(--checker-white-bg);
  border: 1px solid var(--checker-white-rim);
}

.off-chip.black {
  background: var(--checker-black-bg);
  border: 1px solid var(--checker-black-rim);
}

/* =========================================================
   Bottom Action Dock & 3D Dice
   ========================================================= */
.action-dock {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 9px 18px max(9px, env(safe-area-inset-bottom));
  background: var(--bg-dock);
  border-top: 1px solid var(--border-ui);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.dock-left {
  display: flex;
  align-items: center;
  min-width: 0;
}

.turn-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.turn-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

.turn-dot.is-white {
  background: var(--checker-white-bg);
  border: 2px solid var(--accent);
}

.turn-dot.is-black {
  background: var(--checker-black-bg);
  border: 2px solid var(--accent);
}

.turn-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.turn-copy strong {
  font-size: 14px;
}

.turn-copy span {
  font-size: 12px;
  color: var(--text-muted);
}

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

.dice-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.die-face {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: var(--die-bg);
  border: 1.5px solid var(--die-border);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.8), inset 0 -2px 4px rgba(0, 0, 0, 0.12);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 5px;
  gap: 2px;
  transition: opacity 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.mid-dice-slot .die-face {
  width: 44px;
  height: 44px;
  padding: 6px;
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.85), inset 0 -2px 5px rgba(0, 0, 0, 0.14);
}

.die-face.is-swappable {
  cursor: pointer;
}

.die-face.is-primary-die {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-strong), 0 6px 16px rgba(0, 0, 0, 0.42);
}

.die-face.is-spent {
  opacity: 0.32;
  transform: scale(0.88);
}

.die-face.is-throwing-a {
  animation: die-throw-left 520ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.die-face.is-throwing-b {
  animation: die-throw-right 520ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.die-face.is-settled-pop {
  animation: die-settle-pop 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

.die-face.is-opening-white {
  box-shadow: 0 0 0 2px #f5ebd6, 0 4px 10px rgba(0, 0, 0, 0.35);
}

.die-face.is-opening-black {
  background: linear-gradient(145deg, #3b3532 0%, #191513 100%);
  border-color: var(--accent);
}

.die-face.is-opening-black .pip {
  background: #f5ebd6;
}

.pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--die-pip);
  align-self: center;
  justify-self: center;
  opacity: 0;
}

.pip.on {
  opacity: 1;
}

.dice-name-badge {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-strong);
  background: rgba(216, 166, 72, 0.14);
  border: 1px solid var(--border-ui);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.dock-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* =========================================================
   Toast, Log Drawer, Modals, FX Layer
   ========================================================= */
.toast-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  color: var(--accent-strong);
  border: 1px solid var(--accent);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  z-index: 30;
  pointer-events: none;
}

.log-drawer {
  position: fixed;
  top: 52px;
  right: 0;
  bottom: 0;
  width: 320px;
  background: var(--bg-card);
  border-left: 1px solid var(--border-ui);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.4);
  transform: translateX(100%);
  transition: transform 220ms ease;
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.log-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-ui);
}

.drawer-header h2 {
  margin: 0;
  font-size: 15px;
}

.log-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-item {
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
  font-size: 12px;
  line-height: 1.4;
}

.log-item-head {
  display: flex;
  justify-content: space-between;
  color: var(--accent-strong);
  font-weight: 700;
  margin-bottom: 2px;
}

.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

.flying-checker {
  position: fixed;
  margin: 0;
  z-index: 65;
  pointer-events: none;
  transition: left 210ms cubic-bezier(0.22, 1, 0.36, 1), top 210ms cubic-bezier(0.22, 1, 0.36, 1);
}

.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 70;
  transform: translate(-50%, -50%) scale(1.12);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.55);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 5, 4, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal-backdrop.modal-topmost {
  z-index: 55;
}

.modal-card {
  width: 100%;
  max-width: min(580px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  border: 1px solid var(--border-ui);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-lg);
}

.modal-rules {
  max-width: min(680px, 100%);
}

.modal-double,
.modal-gameover {
  max-width: min(440px, 100%);
  text-align: center;
  position: relative;
}

.modal-corner-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.modal-head h1, .modal-head h2 {
  margin: 2px 0 0;
  font-family: var(--font-serif);
}

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

.subcopy {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.setup-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.setup-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill-option {
  flex: 1 1 auto;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-ui);
  background: var(--bg-card-alt);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all var(--transition);
}

.pill-option small {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.pill-option.is-selected {
  border-color: var(--accent);
  background: rgba(216, 166, 72, 0.18);
  color: var(--accent-strong);
  box-shadow: 0 0 0 1px var(--accent);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: 2px;
}

.modal-footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-footer-row {
  justify-content: space-between;
}

.double-cube-preview {
  width: 68px;
  height: 68px;
  margin: 14px auto;
  border-radius: 14px;
  background: var(--die-bg);
  color: var(--die-pip);
  border: 3px solid var(--accent);
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 800;
}

.gameover-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(216, 166, 72, 0.2);
  border: 1px solid var(--accent);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.stat-box {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
  border-radius: 10px;
  padding: 10px 8px;
}

.stat-box strong {
  display: block;
  font-size: 18px;
  color: var(--accent-strong);
}

.stat-box span {
  font-size: 11px;
  color: var(--text-muted);
}

.rules-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 13px;
  line-height: 1.55;
}

.rules-block h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--accent-strong);
}

.rules-block ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dice-names-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.dice-name-item {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
  border-radius: 8px;
  padding: 5px 8px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.dice-name-item strong {
  color: var(--accent-strong);
}

/* =========================================================
   Animations & Responsive
   ========================================================= */
@keyframes die-throw-left {
  0% {
    transform: translate(-34px, -22px) rotate(-380deg) scale(0.65);
    opacity: 0.45;
    box-shadow: 0 18px 26px rgba(0, 0, 0, 0.45);
  }
  42% {
    transform: translate(6px, -14px) rotate(-130deg) scale(1.18);
    opacity: 1;
    box-shadow: 0 16px 24px rgba(0, 0, 0, 0.48);
  }
  68% {
    transform: translate(-2px, 3px) rotate(18deg) scale(0.95);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  }
  84% {
    transform: translate(1px, -5px) rotate(-6deg) scale(1.07);
    box-shadow: 0 9px 16px rgba(0, 0, 0, 0.4);
  }
  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
}

@keyframes die-throw-right {
  0% {
    transform: translate(34px, -24px) rotate(360deg) scale(0.65);
    opacity: 0.45;
    box-shadow: 0 18px 26px rgba(0, 0, 0, 0.45);
  }
  45% {
    transform: translate(-6px, -16px) rotate(120deg) scale(1.18);
    opacity: 1;
    box-shadow: 0 16px 24px rgba(0, 0, 0, 0.48);
  }
  70% {
    transform: translate(2px, 3px) rotate(-14deg) scale(0.95);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  }
  86% {
    transform: translate(-1px, -5px) rotate(5deg) scale(1.07);
    box-shadow: 0 9px 16px rgba(0, 0, 0, 0.4);
  }
  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
}

@keyframes die-settle-pop {
  0% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

@keyframes movable-pulse {
  0%, 100% { box-shadow: 0 4px 8px rgba(0, 0, 0, 0.48), 0 0 0 2px rgba(240, 195, 109, 0.55); }
  50% { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(240, 195, 109, 0.95); }
}

@keyframes broken-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 2.5px #ff5a52, 0 0 12px rgba(255, 90, 82, 0.65), 0 4px 10px rgba(0, 0, 0, 0.55);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 0 3.5px #ffd06b, 0 0 20px rgba(255, 90, 82, 0.95), 0 6px 14px rgba(0, 0, 0, 0.6);
  }
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(240, 195, 109, 0.65); }
  70% { box-shadow: 0 0 0 10px rgba(240, 195, 109, 0); }
  100% { box-shadow: 0 0 0 0 rgba(240, 195, 109, 0); }
}

@media (max-width: 1020px) {
  .topbar {
    padding: 6px 10px;
    gap: 6px;
  }
  .topbar-left {
    gap: 8px;
  }
  .p-pip {
    display: none;
  }
  .board-stage {
    grid-template-columns: 52px minmax(0, 1fr) 58px;
    gap: 6px;
  }
  .tavla-board {
    padding: 8px;
    min-width: 0;
  }
  .board-inner {
    grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr);
  }
  .hide-sm { display: none; }
  .direction-guide { display: none; }
  .mid-dice-slot .die-face {
    width: 34px;
    height: 34px;
    padding: 4px;
  }
  .board-action-btn {
    padding: 5px 10px;
    font-size: 12px;
  }
  .setup-row { grid-template-columns: 1fr; }
  .dice-names-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
    padding: 6px 8px;
    gap: 5px;
  }
  .topbar-left {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }
  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 5px;
  }
  .brand-mark {
    width: 24px;
    height: 24px;
  }
  .brand-mark svg {
    width: 22px;
    height: 22px;
  }
  .brand-title {
    font-size: 15px;
  }
  .ruleset-pill {
    font-size: 10px;
  }
  .scoreboard-bar {
    padding: 3px 6px;
    gap: 4px;
  }
  .player-badge {
    padding: 2px 5px;
    gap: 4px;
  }
  .p-name {
    font-size: 11px;
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .p-score {
    font-size: 14px;
  }
  .match-target-pill {
    font-size: 10px;
    padding: 0 4px;
  }
  .theme-switcher {
    display: none;
  }
  .show-mobile-only,
  .icon-btn.show-mobile-only {
    display: inline-flex;
  }
  .app-shell.is-in-game .brand-text .ruleset-pill,
  .app-shell.is-in-game #btn-open-social {
    display: none !important;
  }
  .app-shell.is-in-game .brand-title {
    font-size: 13px;
    letter-spacing: 0.04em;
  }
  .app-shell.is-in-game .topbar-left {
    flex-wrap: nowrap;
    gap: 5px;
  }
  .app-shell.is-in-game .scoreboard-bar {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: space-between;
  }
  .app-shell.is-in-game .p-name {
    max-width: 44px;
  }
  kbd {
    display: none;
  }
  .icon-btn {
    padding: 5px 7px;
    font-size: 11px;
  }
  .btn-subtle {
    padding: 5px 9px;
    font-size: 12px;
  }

  .stage {
    padding: 6px;
  }
  .board-stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    max-height: none;
    gap: 6px;
  }
  .left-rail {
    flex-direction: row;
    justify-content: center;
    padding: 0;
    gap: 8px;
  }
  .left-rail.is-empty {
    height: 0;
    padding: 0;
    margin: 0 0 -6px 0;
    overflow: hidden;
    visibility: hidden;
  }
  .cube-wrapper {
    flex-direction: row;
    gap: 8px;
  }
  .doubling-cube {
    width: 34px;
    height: 34px;
    font-size: 15px;
    border-radius: 7px;
  }
  .tavla-board {
    padding: 5px;
    border-radius: 10px;
    border-width: 2px;
  }
  .hinge {
    width: 18px;
    height: 6px;
  }
  .board-inner {
    grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
    border-width: 1.5px;
  }
  .board-half {
    grid-template-rows: 1fr 38px 1fr;
  }
  .point {
    padding: 2px 1px;
  }
  .point-number {
    font-size: 8px;
  }
  .checker {
    width: min(28px, calc((100vw - 64px) / 13.5), calc((100dvh - 250px) / 11));
    height: min(28px, calc((100vw - 64px) / 13.5), calc((100dvh - 250px) / 11));
    min-width: 20px;
    min-height: 20px;
  }
  .checker-count-badge {
    font-size: 10px;
  }
  .bar-zone {
    padding: 3px 1px;
    gap: 3px;
  }
  .bar-label {
    font-size: 7px;
  }
  .bar-label.is-alert {
    font-size: 8px;
    padding: 1px 4px;
  }
  .bar-stack .checker.is-broken-checker {
    width: 26px;
    height: 26px;
    min-width: 22px;
    min-height: 22px;
  }
  .mid-dice-slot {
    gap: 5px;
  }
  .mid-dice-slot .die-face {
    width: 28px;
    height: 28px;
    padding: 3px;
    border-radius: 6px;
  }
  .mid-dice-slot .pip {
    width: 5px;
    height: 5px;
  }
  .dice-swap-btn {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }
  .board-action-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
  .target-badge {
    font-size: 8px;
    padding: 1px 4px;
  }

  .right-rail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 0;
    width: 100%;
    flex-direction: row;
  }
  .off-tray {
    flex-direction: row;
    padding: 5px 8px;
    min-height: 36px;
    gap: 8px;
    border-radius: 8px;
  }
  .off-header {
    align-items: flex-start;
    flex-shrink: 0;
  }
  .off-title {
    font-size: 9px;
  }
  .off-count {
    font-size: 11px;
  }
  .off-stack,
  .off-tray.off-black .off-stack {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 2px;
    padding: 0;
    overflow: hidden;
  }
  .off-chip {
    width: 5px;
    height: 18px;
    border-radius: 2px;
    flex-shrink: 0;
  }

  .action-dock {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 6px;
    padding: 6px 10px max(8px, env(safe-area-inset-bottom));
  }
  .dock-left {
    grid-column: 1 / 2;
  }
  .dock-center {
    grid-column: 2 / 3;
    justify-content: flex-end;
    gap: 6px;
  }
  .dock-right {
    grid-column: 1 / -1;
    justify-content: stretch;
  }
  .dock-right > button {
    flex: 1 1 auto;
    justify-content: center;
  }
  .turn-copy strong {
    font-size: 12px;
  }
  .turn-copy span {
    font-size: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .die-face {
    width: 32px;
    height: 32px;
    padding: 4px;
    border-radius: 7px;
  }
  .pip {
    width: 5px;
    height: 5px;
  }
  .dice-name-badge {
    font-size: 11px;
    padding: 3px 7px;
  }
  .log-drawer {
    width: min(100vw, 320px);
  }
  .modal-card {
    padding: 16px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .topbar {
    padding: 4px 10px;
    flex-wrap: nowrap;
  }
  .topbar-left, .topbar-actions {
    width: auto;
  }
  .ruleset-pill,
  .p-pip,
  .theme-switcher {
    display: none;
  }
  .show-mobile-only,
  .icon-btn.show-mobile-only {
    display: inline-flex;
  }
  .app-shell.is-in-game .brand-text .ruleset-pill,
  .app-shell.is-in-game #btn-open-social {
    display: none !important;
  }
  .app-shell.is-in-game .brand-title {
    font-size: 13px;
    letter-spacing: 0.04em;
  }
  .app-shell.is-in-game .topbar-left {
    flex-wrap: nowrap;
    gap: 5px;
  }
  .app-shell.is-in-game .scoreboard-bar {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: space-between;
  }
  .app-shell.is-in-game .p-name {
    max-width: 44px;
  }
  .stage {
    padding: 4px 8px;
  }
  .board-stage {
    grid-template-columns: 48px minmax(0, 1fr) 54px;
    grid-template-rows: 1fr;
    gap: 6px;
  }
  .left-rail {
    flex-direction: column;
    justify-content: center;
  }
  .left-rail.is-empty {
    height: auto;
    margin: 0;
    visibility: visible;
    display: flex;
  }
  .cube-wrapper {
    flex-direction: column;
    gap: 4px;
  }
  .doubling-cube {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }
  .right-rail {
    display: flex;
    flex-direction: column;
    width: auto;
  }
  .off-tray {
    flex-direction: column;
    padding: 4px;
    gap: 2px;
  }
  .off-stack {
    flex-direction: column;
  }
  .off-chip {
    width: 100%;
    height: 6px;
  }
  .checker {
    width: min(30px, calc((100dvh - 130px) / 11));
    height: min(30px, calc((100dvh - 130px) / 11));
  }
  .action-dock {
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: 1fr;
    padding: 5px 12px max(6px, env(safe-area-inset-bottom));
  }
  .dock-left, .dock-center, .dock-right {
    grid-column: auto;
  }
  .dock-right > button {
    flex: 0 0 auto;
  }
  .modal-card {
    max-height: calc(100dvh - 12px);
    padding: 12px;
  }
}

/* =========================================================
   BaklaTavla Lobby Hub, Social, Quests, Waiting Room
   ========================================================= */
.brand-btn {
  text-align: left;
  padding: 2px 4px;
  border-radius: 8px;
  transition: background var(--transition);
}
.brand-btn:hover {
  background: rgba(216, 166, 72, 0.12);
}

.eco-hud {
  display: flex;
  align-items: center;
  gap: 5px;
}

.bakla-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(216, 166, 72, 0.16);
  border: 1px solid var(--accent);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.lvl-pill {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
}

.nav-badge {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
}

.btn-xs {
  padding: 5px 10px;
  font-size: 12px;
}

.turn-timer-pill {
  background: rgba(216, 166, 72, 0.2);
  color: var(--accent-strong);
  border: 1px solid var(--accent);
  font-size: 11px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
}

.turn-timer-pill.is-low {
  background: rgba(217, 83, 79, 0.25);
  border-color: var(--danger);
  color: #ffb3b0;
}

/* Lobby Hub View */
.hub-view {
  grid-row: 2 / 4;
  overflow-y: auto;
  padding: 16px 20px 28px;
  min-height: 0;
}

.hub-container {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hub-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-ui);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
}

.hub-banner h1 {
  margin: 2px 0 4px;
  font-family: var(--font-serif);
  font-size: 24px;
}

.hub-live-stats {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.hub-stat {
  min-width: 82px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
  text-align: center;
}

.hub-stat strong {
  display: block;
  font-size: 18px;
  color: var(--accent-strong);
}

.hub-stat span {
  font-size: 11px;
  color: var(--text-muted);
}

.hub-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}

.hub-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.hub-card {
  background: var(--bg-card);
  border: 1px solid var(--border-ui);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.hub-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hub-card-head h2 {
  margin: 0;
  font-size: 16px;
  font-family: var(--font-serif);
}

.hub-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hub-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.hub-form label.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.hub-form input[type="text"],
.hub-form input[type="password"],
.inline-input-row input,
.select-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--border-ui);
  background: var(--bg-card-alt);
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
}

.inline-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inline-input-row input {
  flex: 1;
  min-width: 0;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-lbl {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.hub-checks {
  justify-content: center;
  gap: 6px;
}

.hub-quick-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.hub-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 290px;
  overflow-y: auto;
}

.room-row-card,
.list-row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
}

.room-row-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.room-row-meta strong {
  font-size: 13px;
  color: var(--accent-strong);
}

.room-row-meta span {
  font-size: 11px;
  color: var(--text-muted);
}

.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 190px;
  overflow-y: auto;
  padding: 8px;
  border-radius: 10px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
  user-select: text;
  -webkit-user-select: text;
}

.chat-msg {
  font-size: 12px;
  line-height: 1.4;
  word-break: break-word;
}

.chat-msg.is-system {
  color: var(--text-muted);
  font-style: italic;
}

.chat-author-btn {
  color: var(--accent-strong);
  font-weight: 700;
  padding: 0;
}
.chat-author-btn:hover {
  text-decoration: underline;
}

.muted-xs {
  font-size: 11px;
  color: var(--text-muted);
}

.link-btn {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-strong);
}
.link-btn:hover {
  text-decoration: underline;
}

.hub-quests-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quest-row {
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quest-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.quest-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.22);
  overflow: hidden;
}

.quest-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-strong) 100%);
}

/* Modals & Drawer additions */
.modal-auth {
  max-width: 420px;
}
.modal-wide {
  max-width: 660px;
}
.modal-room-lobby {
  max-width: 560px;
}

.auth-tabs,
.social-tabs,
.drawer-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.drawer-tabs {
  margin-bottom: 0;
}

.auth-tab,
.social-tab,
.drawer-tab {
  flex: 1;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--border-ui);
  background: var(--bg-card-alt);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

.auth-tab.is-active,
.social-tab.is-active,
.drawer-tab.is-active {
  background: rgba(216, 166, 72, 0.2);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.auth-error {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(217, 83, 79, 0.2);
  border: 1px solid var(--danger);
  color: #ffd5d4;
  font-size: 12px;
  font-weight: 600;
}

.auth-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-ui);
}

.avatar-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.avatar-opt {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-ui);
  background: var(--bg-card-alt);
  font-size: 18px;
  display: grid;
  place-items: center;
}

.avatar-opt.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1.5px var(--accent);
  background: rgba(216, 166, 72, 0.2);
}

.rl-seats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0;
}

.rl-seat {
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
  display: flex;
  align-items: center;
  gap: 10px;
}

.rl-controls {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meta-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
  color: var(--accent-strong);
}

.level-banner {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.subhead {
  margin: 8px 0 6px;
  font-size: 13px;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.achievements-grid,
.themes-market-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.theme-market-card {
  padding: 10px;
  border-radius: 10px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.theme-swatch-box {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}

.room-chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  min-height: 0;
}

.room-chat-panel .chat-feed {
  flex: 1;
  height: auto;
}

.presence-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
  margin-right: 4px;
}
.presence-dot.is-lobby { background: #22c55e; }
.presence-dot.is-playing { background: #f59e0b; }

/* Profile Trigger Pill, In-Game Quick Controls, Profile Quick Grid & Toggles */
.app-shell.is-in-game .lobby-only {
  display: none !important;
}

#btn-log-toggle {
  position: relative;
}

#btn-game-sound.is-muted {
  opacity: 0.65;
}

#btn-game-autoconfirm.is-active {
  background: rgba(212, 168, 83, 0.22);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.profile-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
}

.profile-trigger-btn .bakla-pill {
  padding: 2px 7px;
  font-size: 12px;
}

.profile-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.profile-quick-grid button {
  justify-content: center;
  position: relative;
}

.profile-toggles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
}

.profile-toggles .checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
}

/* Lobby Footer */
.site-footer {
  margin-top: 18px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-ui);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.footer-brand strong {
  color: var(--accent-strong);
  font-family: var(--font-serif);
  letter-spacing: 0.08em;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-actions .link-btn {
  font-size: 13px;
  font-weight: 600;
}

/* Opening Roll 3s Result Overlay */
.opening-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(6, 5, 4, 0.56);
  backdrop-filter: blur(4px);
  z-index: 42;
  cursor: pointer;
}

.opening-card {
  width: min(440px, 100%);
  padding: 20px 22px 16px;
  border-radius: 18px;
  background: var(--bg-card);
  border: 2px solid var(--accent);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.55);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: opening-pop 0.24s ease-out;
}

@keyframes opening-pop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.opening-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--accent);
}

.opening-duel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.opening-side {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 8px;
  border-radius: 12px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
  transition: transform 0.2s, border-color 0.2s;
}

.opening-side.is-winner {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(212, 168, 83, 0.28);
  transform: scale(1.04);
}

.opening-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  max-width: 82px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opening-vs {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
}

.opening-die-slot .die-face.opening-die {
  width: 42px;
  height: 42px;
  padding: 5px;
  border-radius: 9px;
}

.opening-die-slot .die-face.opening-die .pip {
  width: 7px;
  height: 7px;
}

.opening-winner-banner {
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(212, 168, 83, 0.14);
  border: 1px solid rgba(212, 168, 83, 0.35);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 14px;
}

.opening-countdown-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--bg-card-alt);
  overflow: hidden;
}

.opening-countdown-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transform-origin: left center;
}

@keyframes opening-countdown {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.trn-participants-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.trn-intermission-banner {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(212, 168, 83, 0.14);
  border: 1px solid rgba(212, 168, 83, 0.45);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trn-intermission-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-strong);
}

.trn-champion-banner {
  margin-top: 10px;
  padding: 14px;
  border-radius: 12px;
  text-align: center;
  background: linear-gradient(135deg, rgba(212, 168, 83, 0.22), rgba(212, 168, 83, 0.06));
  border: 1px solid var(--accent);
  color: var(--accent-strong);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trn-actions-bar {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trn-round-tabs {
  margin-top: 12px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.trn-matches-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.trn-match-card {
  padding: 10px;
  border-radius: 11px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trn-match-card.is-live {
  border-color: rgba(34, 197, 94, 0.55);
}

.trn-match-card.is-mine {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(212, 168, 83, 0.25);
}

.trn-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.trn-player-row.is-winner {
  color: var(--accent-strong);
  font-weight: 700;
}

.trn-player-row.is-eliminated {
  opacity: 0.55;
  text-decoration: line-through;
}

.trn-match-foot {
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid var(--border-ui);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.trn-live-dot {
  color: #4ade80;
  font-weight: 700;
}

.trn-part-chip {
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-ui);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
}

.trn-part-chip.is-eliminated {
  opacity: 0.55;
}

@media (max-width: 1080px) {
  .hub-grid {
    grid-template-columns: 1fr 1fr;
  }
  .hub-quests-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .hide-mobile {
    display: none !important;
  }
  .modal-backdrop {
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)) 8px;
  }
  .modal-card {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 16px);
    padding: 14px 12px;
    border-radius: 14px;
  }
  .modal-head {
    position: sticky;
    top: -14px;
    background: var(--bg-card);
    z-index: 4;
    margin: -4px -2px 12px;
    padding: 6px 2px 10px;
    border-bottom: 1px solid var(--border-ui);
  }
  .modal-head h1,
  .modal-head h2 {
    font-size: 18px;
    line-height: 1.2;
  }
  .modal-footer,
  .modal-footer-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-footer-row > button {
    flex: 1 1 auto;
  }
  .form-row-2 {
    grid-template-columns: 1fr;
  }
  .dice-names-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .social-tabs {
    flex-wrap: wrap;
  }
  .social-tab {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }
  .list-row-card,
  .room-row-card {
    flex-wrap: wrap;
    gap: 8px;
  }
  .rl-controls {
    flex-wrap: wrap;
    justify-content: stretch;
  }
  .log-drawer {
    width: min(320px, 92vw);
    max-width: 100vw;
  }
  .trn-matches-grid,
  .trn-participants-grid {
    grid-template-columns: 1fr;
  }
  .topbar-actions {
    gap: 6px;
  }
  .profile-trigger-btn {
    padding: 3px 8px;
    gap: 5px;
  }
  .app-shell.is-in-game .profile-trigger-btn {
    padding: 4px 7px;
  }
  .app-shell.is-in-game #hud-bakla,
  .app-shell.is-in-game #hud-level {
    display: none !important;
  }
  .profile-quick-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .profile-toggles {
    grid-template-columns: 1fr;
  }
  .hub-view {
    padding: 10px 10px 24px;
  }
  .hub-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px;
  }
  .site-footer {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 14px;
    gap: 10px;
  }
  .opening-duel {
    gap: 6px;
  }
  .opening-side {
    flex-direction: column;
    padding: 8px 6px;
    gap: 5px;
  }
  .hub-grid,
  .achievements-grid,
  .themes-market-grid,
  .rl-seats {
    grid-template-columns: 1fr;
  }
  .eco-hud {
    flex-wrap: nowrap;
    justify-content: flex-end;
  }
}
