:root {
  --font-sans: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --bg-page: #fdf6ec;
  --bg-card: rgba(255, 252, 246, 0.92);
  --bg-subtle: #f4eadb;
  --text-main: #2d2520;
  --text-muted: #6c5d53;
  --border-soft: rgba(120, 92, 70, 0.16);
  --accent: #e07a3f;
  --accent-strong: #c85c23;
  --accent-soft: rgba(224, 122, 63, 0.14);
  --sq-light: #f6e7cf;
  --sq-dark: #c99d74;
  --sq-select: rgba(247, 198, 70, 0.7);
  --sq-last: rgba(133, 189, 125, 0.42);
  --sq-hint: rgba(58, 134, 107, 0.65);
  --sq-check: radial-gradient(circle, rgba(235, 64, 52, 0.88) 0%, rgba(235, 64, 52, 0.25) 70%, transparent 100%);
  --board-border: #8b5e3c;
  --board-glow: 0 14px 34px rgba(85, 55, 32, 0.18);
  --tier-aura: radial-gradient(circle, rgba(255, 200, 124, 0.35), transparent 72%);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 8px 24px rgba(50, 35, 20, 0.08);
}

/* Tier 1: Cozy Cub — Warm Honey & Meadow Pastel */
body[data-tier="1"] {
  --bg-page: #fdf7ec;
  --bg-card: rgba(255, 253, 248, 0.94);
  --bg-subtle: #f5ebd9;
  --accent: #df7d46;
  --accent-strong: #c45d27;
  --sq-light: #faeed9;
  --sq-dark: #cca37a;
  --board-border: #9a6d48;
  --tier-aura: radial-gradient(circle, rgba(255, 209, 136, 0.42), transparent 70%);
}

/* Tier 2: Curious Kit — Crisp Mint & Sage Meadow */
body[data-tier="2"] {
  --bg-page: #eef7f3;
  --bg-card: rgba(250, 255, 252, 0.94);
  --bg-subtle: #dfeee7;
  --text-main: #1d2e28;
  --text-muted: #526e64;
  --border-soft: rgba(45, 106, 86, 0.16);
  --accent: #2a9d78;
  --accent-strong: #1c7c5d;
  --accent-soft: rgba(42, 157, 120, 0.15);
  --sq-light: #edf5ea;
  --sq-dark: #7ba991;
  --board-border: #3d6b57;
  --board-glow: 0 14px 34px rgba(32, 82, 62, 0.2);
  --tier-aura: radial-gradient(circle, rgba(84, 214, 169, 0.38), transparent 70%);
}

/* Tier 3: Clever Critter — Warm Amber Dusk & Walnut */
body[data-tier="3"] {
  --bg-page: #f5efe6;
  --bg-card: rgba(254, 249, 242, 0.94);
  --bg-subtle: #eadbc9;
  --text-main: #2b211b;
  --text-muted: #685347;
  --border-soft: rgba(114, 70, 42, 0.2);
  --accent: #d97724;
  --accent-strong: #b45309;
  --accent-soft: rgba(217, 119, 36, 0.16);
  --sq-light: #f0dec4;
  --sq-dark: #a66f46;
  --board-border: #5c3820;
  --board-glow: 0 16px 38px rgba(78, 43, 18, 0.25);
  --tier-aura: radial-gradient(circle, rgba(245, 166, 62, 0.44), transparent 70%);
}

/* Tier 4: Crafty Tactician — Royal Twilight Indigo */
body[data-tier="4"] {
  --bg-page: #1f2238;
  --bg-card: rgba(34, 38, 62, 0.94);
  --bg-subtle: #2b3050;
  --text-main: #f0f2ff;
  --text-muted: #aeb5da;
  --border-soft: rgba(154, 165, 232, 0.2);
  --accent: #7b8cff;
  --accent-strong: #5869e8;
  --accent-soft: rgba(123, 140, 255, 0.2);
  --sq-light: #e4e8f7;
  --sq-dark: #636ea8;
  --board-border: #434b80;
  --board-glow: 0 18px 46px rgba(10, 12, 34, 0.55), 0 0 28px rgba(123, 140, 255, 0.2);
  --tier-aura: radial-gradient(circle, rgba(132, 148, 255, 0.45), transparent 70%);
  --shadow-card: 0 10px 30px rgba(7, 8, 22, 0.4);
}

/* Tier 5: Grandmaster Guardian — Obsidian & Molten Gold */
body[data-tier="5"] {
  --bg-page: #191318;
  --bg-card: rgba(33, 24, 31, 0.95);
  --bg-subtle: #2c1f29;
  --text-main: #fdf4e7;
  --text-muted: #ccb2aa;
  --border-soft: rgba(240, 185, 76, 0.24);
  --accent: #f0b43c;
  --accent-strong: #d49017;
  --accent-soft: rgba(240, 180, 60, 0.2);
  --sq-light: #f0dfc2;
  --sq-dark: #875046;
  --board-border: #c58c28;
  --board-glow: 0 20px 52px rgba(0, 0, 0, 0.65), 0 0 32px rgba(240, 180, 60, 0.26);
  --tier-aura: radial-gradient(circle, rgba(250, 192, 68, 0.5), transparent 70%);
  --shadow-card: 0 12px 34px rgba(0, 0, 0, 0.5);
}

/* Tier 6: Apex Fluffball — Celestial Cosmic Aurora */
body[data-tier="6"] {
  --bg-page: #0e0c1b;
  --bg-card: rgba(20, 17, 38, 0.94);
  --bg-subtle: #1d183b;
  --text-main: #f8f5ff;
  --text-muted: #b9aee6;
  --border-soft: rgba(192, 132, 252, 0.28);
  --accent: #f4b942;
  --accent-strong: #e29618;
  --accent-soft: rgba(192, 132, 252, 0.22);
  --sq-light: #ece6fa;
  --sq-dark: #5b4b8a;
  --board-border: #d9a036;
  --board-glow: 0 22px 58px rgba(0, 0, 0, 0.72), 0 0 36px rgba(192, 132, 252, 0.35), 0 0 14px rgba(244, 185, 66, 0.35);
  --tier-aura: radial-gradient(circle, rgba(226, 152, 255, 0.52), rgba(244, 185, 66, 0.24) 45%, transparent 72%);
  --shadow-card: 0 14px 38px rgba(4, 2, 14, 0.65);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text-main);
  background: var(--bg-page);
  transition: background-color 0.35s ease;
  overflow-x: hidden;
}

.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 14%, var(--accent-soft), transparent 42%),
    radial-gradient(circle at 88% 82%, var(--accent-soft), transparent 45%);
  transition: background 0.5s ease;
}

body[data-tier="6"] .ambient-bg {
  background:
    radial-gradient(circle at 18% 15%, rgba(168, 85, 247, 0.2), transparent 45%),
    radial-gradient(circle at 84% 20%, rgba(244, 185, 66, 0.16), transparent 42%),
    radial-gradient(circle at 50% 90%, rgba(56, 189, 248, 0.14), transparent 50%);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(8px);
}

.hidden {
  display: none !important;
}

/* Topbar */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-card);
}

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

.brand-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--border-soft);
  display: grid;
  place-items: center;
  font-size: 22px;
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.brand-text .subtitle {
  margin: 1px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.topbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.control-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-subtle);
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
}

.control-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.select-input {
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.select-input option {
  color: #1f1f1f;
  background: #ffffff;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 10px;
  padding: 8px 13px;
  border: 1px solid var(--border-soft);
  background: var(--bg-subtle);
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: transparent;
}

body[data-tier="5"] .btn-primary,
body[data-tier="6"] .btn-primary {
  color: #1a1208;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.btn-secondary.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-pill {
  border-radius: 999px;
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 1rem;
}

.btn-small {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-danger-ghost {
  background: rgba(220, 53, 69, 0.12);
  color: #e05260;
  border-color: rgba(220, 53, 69, 0.35);
}

/* Variant Ribbon */
.variant-ribbon {
  display: flex;
  gap: 8px;
  padding: 8px 20px;
  overflow-x: auto;
  scrollbar-width: thin;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(128, 128, 128, 0.04);
}

.variant-chip {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.16s ease;
}

.variant-chip:hover {
  color: var(--text-main);
  border-color: var(--accent);
}

.variant-chip.active {
  background: var(--accent);
  color: #ffffff;
  border-color: transparent;
}

body[data-tier="5"] .variant-chip.active,
body[data-tier="6"] .variant-chip.active {
  color: #191206;
}

.variant-chip .mastered-dot {
  font-size: 0.72rem;
}

/* Main 3-Column Arena */
.arena {
  display: grid;
  grid-template-columns: 295px minmax(360px, 1fr) 320px;
  gap: 16px;
  max-width: 1460px;
  margin: 0 auto;
  padding: 16px 20px 24px;
  align-items: start;
}

.sidebar-left,
.sidebar-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Mascot Card */
.mascot-card {
  padding: 14px;
  position: relative;
  overflow: hidden;
}

.mascot-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.tier-pill {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 3px;
}

.mascot-identity h2 {
  margin: 0;
  font-size: 1.15rem;
}

.mascot-title {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.ai-spec-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  white-space: nowrap;
}

.mascot-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 10px 0 8px;
}

.mascot-aura {
  position: absolute;
  width: 170px;
  height: 170px;
  top: -4px;
  border-radius: 50%;
  background: var(--tier-aura);
  z-index: 0;
  animation: auraPulse 3.6s ease-in-out infinite;
}

@keyframes auraPulse {
  0%, 100% { transform: scale(0.96); opacity: 0.82; }
  50% { transform: scale(1.06); opacity: 1; }
}

.mascot-portrait-btn {
  position: relative;
  z-index: 1;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.16s ease;
}

.mascot-portrait-btn:hover {
  transform: scale(1.04);
}

.mascot-portrait-btn:active {
  transform: scale(0.95);
}

.mascot-portrait {
  width: 150px;
  height: 150px;
  display: grid;
  place-items: center;
}

.mascot-portrait.thinking .pippin-head {
  animation: headBob 0.55s ease-in-out infinite alternate;
}

.mascot-portrait.thinking .pippin-tail {
  animation: tailSwish 1.1s ease-in-out infinite;
}

.pippin-tail {
  transform-origin: 108px 120px;
  animation: tailSwish 3.2s ease-in-out infinite;
}

.pippin-torso {
  transform-origin: 80px 136px;
  animation: bodyBreathe 3.4s ease-in-out infinite;
}

.pippin-head {
  transform-origin: 80px 102px;
  animation: headIdleTilt 4.8s ease-in-out infinite;
}

.pippin-ear-l {
  transform-origin: 54px 48px;
  animation: earTwitchL 5.5s ease-in-out infinite;
}

.pippin-ear-r {
  transform-origin: 106px 48px;
  animation: earTwitchR 6.2s ease-in-out infinite;
}

.pippin-eyes-blink {
  transform-origin: 80px 70px;
  animation: eyeBlink 4.3s ease-in-out infinite;
}

.pippin-eyes-glance {
  animation: eyeGlance 1.4s ease-in-out infinite alternate;
}

.pippin-paw-l {
  transform-origin: 52px 126px;
  animation: pawTapL 2.8s ease-in-out infinite;
}

.pippin-paw-r {
  transform-origin: 108px 126px;
  animation: pawTapR 2.8s ease-in-out infinite 1.4s;
}

.pippin-float-prop {
  animation: propFloat 2.4s ease-in-out infinite alternate;
}

.pippin-ring-spin {
  transform-origin: 80px 80px;
  animation: ringSpin 18s linear infinite;
}

.pippin-ring-spin-rev {
  transform-origin: 80px 80px;
  animation: ringSpin 14s linear infinite reverse;
}

.pippin-sweat {
  animation: sweatDrop 1.1s ease-in-out infinite;
}

.mascot-portrait.anim-hop {
  animation: pippinHop 0.48s cubic-bezier(0.22, 1.4, 0.4, 1);
}

.mascot-portrait.anim-gasp {
  animation: pippinGasp 0.45s ease-out;
}

.mascot-portrait.anim-boop {
  animation: pippinBoop 0.44s cubic-bezier(0.2, 1.5, 0.4, 1);
}

.mascot-portrait.anim-chuckle {
  animation: pippinChuckle 0.5s ease-in-out;
}

@keyframes headBob {
  from { transform: translateY(0) rotate(-3deg); }
  to { transform: translateY(-4px) rotate(3deg); }
}

@keyframes tailSwish {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(9deg); }
}

@keyframes bodyBreathe {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.028) translateY(-1px); }
}

@keyframes headIdleTilt {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  25% { transform: rotate(-2deg) translateY(-1.5px); }
  75% { transform: rotate(2.2deg) translateY(-1px); }
}

@keyframes earTwitchL {
  0%, 78%, 100% { transform: rotate(0deg); }
  82% { transform: rotate(-10deg); }
  86% { transform: rotate(3deg); }
  90% { transform: rotate(-7deg); }
}

@keyframes earTwitchR {
  0%, 62%, 100% { transform: rotate(0deg); }
  66% { transform: rotate(10deg); }
  70% { transform: rotate(-2deg); }
  74% { transform: rotate(6deg); }
}

@keyframes eyeBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

@keyframes eyeGlance {
  from { transform: translateX(-1.5px); }
  to { transform: translateX(2px); }
}

@keyframes pawTapL {
  0%, 75%, 100% { transform: translateY(0) rotate(0deg); }
  85% { transform: translateY(-4px) rotate(-8deg); }
}

@keyframes pawTapR {
  0%, 75%, 100% { transform: translateY(0) rotate(0deg); }
  85% { transform: translateY(-4px) rotate(8deg); }
}

@keyframes propFloat {
  from { transform: translateY(0); }
  to { transform: translateY(-4px); }
}

@keyframes ringSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes sweatDrop {
  0%, 100% { transform: translateY(0); opacity: 0.9; }
  50% { transform: translateY(4px); opacity: 0.45; }
}

@keyframes pippinHop {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-12px) scale(1.06, 0.96); }
  70% { transform: translateY(2px) scale(0.97, 1.03); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes pippinGasp {
  0% { transform: scale(1) rotate(0deg); }
  30% { transform: scale(1.09) rotate(-5deg); }
  65% { transform: scale(0.96) rotate(4deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes pippinBoop {
  0% { transform: scale(1); }
  30% { transform: scale(1.1, 0.88); }
  65% { transform: scale(0.95, 1.07); }
  100% { transform: scale(1); }
}

@keyframes pippinChuckle {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-5px) rotate(-2deg); }
  50% { transform: translateY(0) rotate(2deg); }
  75% { transform: translateY(-4px) rotate(-1deg); }
}

.mascot-mood-tag {
  position: relative;
  z-index: 2;
  margin-top: -6px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
}

/* Difficulty Meter */
.difficulty-meter {
  margin-top: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
}

.meter-row,
.meter-subrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

.meter-label {
  font-weight: 700;
}

.paw-gauge {
  display: flex;
  gap: 3px;
  font-size: 0.82rem;
}

.paw-pip {
  opacity: 0.22;
  filter: grayscale(1);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.paw-pip.lit {
  opacity: 1;
  filter: none;
  transform: scale(1.05);
}

.xp-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.2);
  overflow: hidden;
  margin: 6px 0;
}

.xp-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #f8c646);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.meter-subrow {
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* Speech Bubble */
.speech-bubble {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  position: relative;
  font-size: 0.85rem;
  line-height: 1.4;
}

.speech-bubble::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--bg-subtle);
  border-left: 1px solid var(--border-soft);
  border-top: 1px solid var(--border-soft);
}

.speech-bubble p {
  margin: 0;
}

.speech-bubble.pop {
  animation: bubblePop 0.25s ease;
}

@keyframes bubblePop {
  0% { transform: scale(0.96); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* Controls & Captured */
.controls-card {
  padding: 12px;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.captured-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.captured-row {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  align-items: center;
  gap: 6px;
  min-height: 24px;
}

.captured-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}

.captured-pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
}

.captured-mini {
  width: 19px;
  height: 19px;
}

.adv-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

/* Center Board Stage */
.board-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.stage-header {
  width: 100%;
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.stage-variant-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-variant-info h2 {
  margin: 0;
  font-size: 1.05rem;
}

.board-size-badge,
.mini-chip {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
}

.turn-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 700;
}

.turn-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #f5f5f5;
  border: 2px solid var(--text-main);
}

.turn-dot.black {
  background: #2c2a35;
  border-color: #9e9aad;
}

.turn-dot.thinking {
  background: var(--accent);
  border-color: transparent;
  animation: pulseDot 0.7s infinite alternate;
}

@keyframes pulseDot {
  from { transform: scale(0.85); opacity: 0.6; }
  to { transform: scale(1.25); opacity: 1; }
}

/* Arimaa Bar */
.arimaa-bar {
  width: 100%;
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-color: var(--accent);
}

.arimaa-steps-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.arimaa-label {
  font-size: 0.78rem;
  font-weight: 700;
}

.step-pips {
  display: flex;
  gap: 5px;
}

.step-pip {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--accent);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.step-pip.used {
  background: transparent;
  opacity: 0.35;
}

.arimaa-step-text {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
}

.arimaa-hint-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  flex: 1 1 240px;
}

.arimaa-actions {
  display: flex;
  gap: 6px;
}

.special-alert {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
}

/* Board Frame & Grid */
.board-frame {
  padding: 14px;
  box-shadow: var(--board-glow);
  border: 3px solid var(--board-border);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
  max-width: 100%;
}

.board-mount {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.flying-piece {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 30;
  will-change: transform;
}

.flying-piece svg {
  width: 86%;
  height: 86%;
  filter: drop-shadow(0 7px 10px rgba(0, 0, 0, 0.36));
}

.piece-wrap.flight-hidden {
  opacity: 0;
}

.sq.last-path {
  box-shadow: inset 0 0 0 999px rgba(133, 189, 125, 0.24);
}

.path-trail-pip {
  position: absolute;
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: rgba(245, 185, 58, 0.82);
  box-shadow: 0 0 8px rgba(245, 185, 58, 0.65);
  pointer-events: none;
  z-index: 1;
  animation: trailFadePulse 0.7s ease-out forwards;
  animation-delay: calc(var(--step-idx, 0) * 55ms);
  opacity: 0;
}

.path-trail-pip.persistent {
  opacity: 0.48;
  width: 18%;
  height: 18%;
  animation: none;
  background: rgba(102, 168, 92, 0.72);
  box-shadow: none;
}

.path-trail-pip.hurdle {
  width: 72%;
  height: 72%;
  border-radius: 50%;
  background: transparent;
  border: 3px dashed rgba(245, 158, 11, 0.85);
  box-shadow: none;
  opacity: 0.78;
  animation: hurdleHopRing 0.55s ease-out;
}

@keyframes trailFadePulse {
  0% { transform: scale(0.4); opacity: 0; }
  35% { transform: scale(1.2); opacity: 0.95; }
  100% { transform: scale(0.85); opacity: 0.48; }
}

@keyframes hurdleHopRing {
  0% { transform: scale(0.75); opacity: 0.3; }
  50% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 0.78; }
}

.board-grid {
  display: grid;
  user-select: none;
  touch-action: manipulation;
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  overflow: visible;
  background: transparent;
}

.board-grid.tamerlane-grid {
  border: none;
}

.sq {
  position: relative;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: filter 0.1s ease;
}

.sq.light {
  background: var(--sq-light);
}

.sq.dark {
  background: var(--sq-dark);
}

.sq.void-cell {
  background: transparent !important;
  border: none !important;
  cursor: default;
  pointer-events: none;
}

.sq.citadel-cell {
  background: linear-gradient(135deg, #d7b26d, #a57c3a);
  box-shadow: inset 0 0 0 2px #6b4817;
  border-radius: 4px;
}

.sq.citadel-cell::after {
  content: "🏰";
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 10px;
  opacity: 0.72;
  pointer-events: none;
}

.sq.hill-cell::before {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  border: 2px dashed rgba(224, 150, 32, 0.7);
  pointer-events: none;
}

.sq.trap-cell {
  box-shadow: inset 0 0 0 3px rgba(190, 44, 44, 0.52);
  background-image: radial-gradient(circle, rgba(200, 40, 40, 0.24) 22%, transparent 65%);
}

.sq.trap-cell::after {
  content: "⚠";
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 10px;
  color: rgba(165, 25, 25, 0.72);
  pointer-events: none;
}

.sq.selected {
  box-shadow: inset 0 0 0 4px #f7b924;
  background-color: var(--sq-select) !important;
}

.sq.last-move {
  box-shadow: inset 0 0 0 999px var(--sq-last);
}

.sq.in-check {
  background-image: var(--sq-check);
}

.sq.swap-candidate {
  box-shadow: inset 0 0 0 3px #38bdf8;
}

.sq-coord-rank {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 9px;
  font-weight: 700;
  opacity: 0.58;
  pointer-events: none;
  color: #2b211b;
}

.sq.dark .sq-coord-rank,
.sq.dark .sq-coord-file {
  color: #1f1712;
}

.sq-coord-file {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 9px;
  font-weight: 700;
  opacity: 0.58;
  pointer-events: none;
  color: #2b211b;
}

/* Move Hint Indicators */
.hint-dot {
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: var(--sq-hint);
  pointer-events: none;
  z-index: 3;
}

.hint-ring {
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  border: 4px solid rgba(217, 65, 54, 0.78);
  pointer-events: none;
  z-index: 3;
}

.hint-castle {
  position: absolute;
  inset: 7%;
  border-radius: 10px;
  border: 3px dashed #2563eb;
  pointer-events: none;
  z-index: 3;
}

.hint-push {
  position: absolute;
  inset: 6%;
  border-radius: 10px;
  border: 3px solid #f59e0b;
  background: rgba(245, 158, 11, 0.16);
  pointer-events: none;
  z-index: 3;
}

.hint-pull {
  position: absolute;
  inset: 6%;
  border-radius: 10px;
  border: 3px solid #a855f7;
  background: rgba(168, 85, 247, 0.18);
  pointer-events: none;
  z-index: 3;
  animation: pullPulse 1s infinite alternate;
}

@keyframes pullPulse {
  from { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.4); }
  to { box-shadow: 0 0 10px 2px rgba(168, 85, 247, 0.65); }
}

.hint-ring.atomic-hint {
  border-color: rgba(249, 115, 22, 0.92);
  box-shadow: 0 0 8px rgba(249, 115, 22, 0.55);
}

.hint-ring.atomic-hint::after {
  content: "💥";
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 12px;
  line-height: 1;
}

.sq.blast-scorch {
  box-shadow: inset 0 0 0 2px rgba(249, 115, 22, 0.55), inset 0 0 18px rgba(239, 68, 68, 0.28);
}

.sq.explosion-flash {
  animation: boomFlash 0.95s ease-out;
}

@keyframes boomFlash {
  0% { box-shadow: inset 0 0 0 999px rgba(255, 196, 60, 0.95); }
  30% { box-shadow: inset 0 0 0 999px rgba(249, 115, 22, 0.72); }
  100% { box-shadow: inset 0 0 0 2px rgba(249, 115, 22, 0.55), inset 0 0 18px rgba(239, 68, 68, 0.28); }
}

.board-frame.board-shake {
  animation: atomicBoardShake 0.34s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes atomicBoardShake {
  0%, 100% { transform: translate(0, 0); }
  18% { transform: translate(-5px, 3px); }
  36% { transform: translate(5px, -4px); }
  54% { transform: translate(-4px, -2px); }
  72% { transform: translate(4px, 3px); }
  90% { transform: translate(-2px, 1px); }
}

.blast-victim-ghost {
  position: absolute;
  inset: 7%;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 26;
}

.blast-victim-ghost svg {
  width: 100%;
  height: 100%;
}

.blast-victim-ghost.vaporizing {
  animation: victimVaporize 0.65s ease-out forwards;
}

@keyframes victimVaporize {
  0% { transform: scale(1); opacity: 1; filter: brightness(1); }
  25% { transform: scale(1.22); opacity: 1; filter: brightness(2) drop-shadow(0 0 10px #f97316); }
  100% { transform: scale(0.2) rotate(24deg); opacity: 0; filter: brightness(2.5) blur(3px); }
}

.atomic-blast-fx {
  position: absolute;
  pointer-events: none;
  z-index: 40;
  transform: translate(-50%, -50%);
}

.atomic-core {
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  background: radial-gradient(circle, #fffbeb 0%, #fde047 28%, #f97316 62%, rgba(220, 38, 38, 0) 100%);
  animation: boomCorePop 0.85s ease-out forwards;
}

.atomic-shockwave {
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  border: 5px solid rgba(251, 146, 60, 0.95);
  box-shadow: 0 0 22px rgba(239, 68, 68, 0.8);
  animation: boomShockwave 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.atomic-spark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fde047;
  box-shadow: 0 0 8px #f97316;
  animation: boomSpark 0.8s ease-out forwards;
}

.atomic-boom-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.05rem;
  color: #fff7ed;
  text-shadow: 0 2px 6px #9a3412, 0 0 12px #dc2626;
  white-space: nowrap;
  animation: boomLabelPop 1s ease-out forwards;
}

@keyframes boomCorePop {
  0% { transform: scale(0.18); opacity: 1; }
  35% { transform: scale(1.05); opacity: 0.96; }
  100% { transform: scale(1.32); opacity: 0; }
}

@keyframes boomShockwave {
  0% { transform: scale(0.2); opacity: 1; border-width: 7px; }
  100% { transform: scale(1.18); opacity: 0; border-width: 1px; }
}

@keyframes boomSpark {
  0% { transform: translate(-50%, -50%) rotate(var(--ang, 0deg)) translateX(0) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(var(--ang, 0deg)) translateX(var(--dist, 64px)) scale(0.2); opacity: 0; }
}

@keyframes boomLabelPop {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  22% { transform: translate(-50%, -72%) scale(1.18); opacity: 1; }
  75% { transform: translate(-50%, -86%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -105%) scale(0.92); opacity: 0; }
}

.piece-wrap.king-topple {
  transform-origin: 50% 82%;
  animation: kingCheckmateFall 1.55s cubic-bezier(0.25, 0.8, 0.35, 1) forwards;
  z-index: 15;
}

.piece-wrap.king-fallen {
  transform-origin: 50% 82%;
  transform: translate(4px, 5px) rotate(88deg);
  opacity: 0.84;
  filter: saturate(0.72) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

.piece-wrap.king-victor {
  animation: victorBounce 1.1s ease-in-out 2;
  filter: drop-shadow(0 0 10px rgba(250, 204, 21, 0.95));
  z-index: 16;
}

.sq.victory-square {
  box-shadow: inset 0 0 0 3px rgba(250, 204, 21, 0.9), inset 0 0 22px rgba(250, 204, 21, 0.38);
}

.sq.defeat-square {
  background-image: radial-gradient(circle, rgba(220, 38, 38, 0.65) 0%, rgba(220, 38, 38, 0.22) 68%, transparent 100%);
}

.gameover-board-tag {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 8px;
  border-radius: 999px;
  background: #991b1b;
  color: #fff7ed;
  border: 1.5px solid #fca5a5;
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
  z-index: 35;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  animation: defeatTagPop 1.4s ease-out forwards;
}

.gameover-board-tag.victor {
  background: #b45309;
  border-color: #fde047;
}

@keyframes kingCheckmateFall {
  0%   { transform: translate(0, 0) rotate(0deg); }
  6%   { transform: translate(-3px, -1px) rotate(-7deg); }
  12%  { transform: translate(3px, 0) rotate(7deg); }
  18%  { transform: translate(-3px, -2px) rotate(-8deg); }
  24%  { transform: translate(3px, 0) rotate(8deg); }
  30%  { transform: translate(-2px, -1px) rotate(-6deg); }
  36%  { transform: translate(2px, 0) rotate(6deg); }
  48%  { transform: translate(2px, -6px) rotate(26deg); }
  68%  { transform: translate(4px, 5px) rotate(91deg); }
  79%  { transform: translate(4px, 2px) rotate(80deg); }
  90%  { transform: translate(4px, 5px) rotate(89deg); }
  100% { transform: translate(4px, 5px) rotate(88deg); opacity: 0.84; filter: saturate(0.72); }
}

@keyframes victorBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-9px) scale(1.12); }
  65% { transform: translateY(1px) scale(0.98); }
}

@keyframes defeatTagPop {
  0% { transform: translate(-50%, 6px) scale(0.6); opacity: 0; }
  25% { transform: translate(-50%, -4px) scale(1.08); opacity: 1; }
  100% { transform: translate(-50%, -6px) scale(1); opacity: 1; }
}

.piece-wrap {
  width: 86%;
  height: 86%;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 2;
  transition: transform 0.12s ease;
}

.piece-wrap.frozen {
  filter: saturate(0.55) drop-shadow(0 0 4px rgba(56, 189, 248, 0.9));
}

.piece-wrap.frozen::after {
  content: "❄";
  position: absolute;
  top: -3px;
  right: -3px;
  font-size: 11px;
  line-height: 1;
}

.piece-wrap svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.28));
  pointer-events: none;
}

.sq:hover .piece-wrap:not(.king-topple):not(.king-fallen) {
  transform: scale(1.05);
}

/* Right Sidebar: Guide & History */
.guide-card,
.history-card {
  padding: 14px;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.card-header-row h3 {
  margin: 0;
  font-size: 0.98rem;
}

.variant-summary {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.variant-rules-list {
  margin: 0 0 12px;
  padding-left: 18px;
  font-size: 0.8rem;
  line-height: 1.45;
}

.variant-rules-list li + li {
  margin-top: 3px;
}

.piece-inspector {
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
}

.piece-guide-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.piece-pill-btn {
  border: 1px solid var(--border-soft);
  background: var(--bg-subtle);
  color: var(--text-main);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.piece-pill-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.piece-pill-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
}

.piece-preview-box {
  display: grid;
  grid-template-columns: 98px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
}

.piece-mini-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: 95px;
  height: 95px;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  overflow: hidden;
}

.mini-cell {
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
}

.mini-cell.light { background: var(--sq-light); }
.mini-cell.dark { background: var(--sq-dark); }
.mini-cell.center { box-shadow: inset 0 0 0 2px var(--accent); }
.mini-cell.move-dot::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a34a;
}
.mini-cell.capture-dot::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #dc2626;
}
.mini-cell.jump-dot::after {
  content: "★";
  color: #2563eb;
  font-size: 9px;
}

.piece-preview-meta h4 {
  margin: 0 0 4px;
  font-size: 0.85rem;
}

.piece-preview-meta p {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Move History */
.move-history-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
}

.empty-history {
  color: var(--text-muted);
  font-style: italic;
  padding: 6px 0;
}

.move-row {
  display: grid;
  grid-template-columns: 32px 1fr 1fr;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
}

.move-row:nth-child(odd) {
  background: var(--bg-subtle);
}

.move-num {
  color: var(--text-muted);
  font-weight: 700;
}

.move-san {
  font-family: ui-monospace, Consolas, monospace;
  font-weight: 600;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(12, 10, 20, 0.62);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
}

.modal-wide {
  max-width: 780px;
}

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

.modal-header-row h2,
.modal-card h3 {
  margin: 0;
}

.modal-sub {
  margin: 4px 0 12px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.promotion-choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.promo-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--bg-subtle);
  color: var(--text-main);
  cursor: pointer;
  min-width: 82px;
  font-weight: 600;
  font-size: 0.8rem;
}

.promo-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.promo-btn svg {
  width: 46px;
  height: 46px;
}

/* Game Over Card */
.gameover-card {
  text-align: center;
}

.gameover-portrait {
  width: 118px;
  height: 118px;
  margin: 0 auto 8px;
}

.gameover-reason {
  color: var(--text-muted);
  margin: 4px 0 10px;
  font-size: 0.9rem;
}

.gameover-quip {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bg-subtle);
  font-style: italic;
  font-size: 0.88rem;
}

.gameover-xp-box {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  margin-bottom: 16px;
  font-size: 0.86rem;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Progression Modal */
.prog-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat-tile {
  padding: 10px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  text-align: center;
}

.stat-val {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
}

.stat-lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.prog-override-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.section-subtitle {
  margin: 14px 0 8px;
  font-size: 0.95rem;
}

.tiers-showcase {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 10px;
}

.tier-card {
  padding: 10px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}

.tier-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.tier-card.locked {
  opacity: 0.6;
}

.tier-card-svg {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
}

.tier-card-meta h4 {
  margin: 0;
  font-size: 0.84rem;
}

.tier-card-meta p {
  margin: 2px 0 0;
  font-size: 0.73rem;
  color: var(--text-muted);
}

.variant-mastery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 8px;
}

.mastery-chip {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mastery-chip.won {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.help-content {
  display: grid;
  gap: 12px;
  font-size: 0.86rem;
  line-height: 1.5;
}

.help-block {
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-subtle);
}

.help-block h4 {
  margin: 0 0 6px;
}

.help-block p,
.help-block ul {
  margin: 0;
}

/* Responsive */
@media (max-width: 1180px) {
  .arena {
    grid-template-columns: 270px minmax(340px, 1fr);
  }
  .sidebar-right {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 860px) {
  .arena {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .sidebar-right {
    grid-template-columns: 1fr;
  }
  .prog-stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}
