/* ============================================================
   The Midnight Academy / 午夜学院 — Global Styles
   ============================================================ */

:root {
  /* Core palette */
  --midnight-900: #070a1f;
  --midnight-800: #0a0e27;
  --midnight-700: #121838;
  --midnight-600: #1a2050;
  --midnight-500: #252d6b;
  --stone-700: #2d2d44;
  --stone-600: #3d3d5c;
  --stone-500: #5a5a7a;

  /* Accents */
  --amber-400: #d4a24c;
  --amber-300: #e8be6a;
  --amber-200: #f0d494;
  --gold-500: #c9953a;
  --gold-400: #dbae58;
  --gold-glow: rgba(212, 162, 76, 0.6);
  --ember-500: #ff6b35;
  --ember-400: #ff8c5a;

  /* Parchment */
  --parchment-300: #e8dcc4;
  --parchment-400: #d4c4a0;
  --parchment-500: #b8a67d;
  --ink-900: #2a1f14;
  --ink-800: #3d2e1e;

  /* States */
  --success: #6bbf7a;
  --error: #d96565;
  --locked: #5a5a7a;

  /* Typography scale */
  --fs-display: clamp(2rem, 5vw, 3.5rem);
  --fs-h1: clamp(1.5rem, 3vw, 2.5rem);
  --fs-h2: clamp(1.2rem, 2.2vw, 1.75rem);
  --fs-h3: clamp(1rem, 1.6vw, 1.25rem);
  --fs-body: clamp(0.9rem, 1.2vw, 1.05rem);
  --fs-small: clamp(0.75rem, 1vw, 0.875rem);
  --fs-micro: 0.7rem;

  /* Spacing */
  --space-xs: 0.375rem;
  --space-sm: 0.75rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  --space-2xl: 5rem;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Cormorant Garamond', 'Noto Serif SC', Georgia, serif;
  font-size: var(--fs-body);
  color: var(--parchment-300);
  background: var(--midnight-800);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  position: relative;
}

/* Night sky gradient background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(60, 40, 100, 0.3) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(40, 30, 80, 0.4) 0%, transparent 50%),
    linear-gradient(180deg, var(--midnight-900) 0%, var(--midnight-800) 40%, var(--midnight-700) 100%);
  z-index: -2;
  pointer-events: none;
}

/* ---- Ember particles canvas ---- */
#ember-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* ---- Typography ---- */
.display-serif {
  font-family: 'Cinzel Decorative', 'Noto Serif SC', serif;
  font-weight: 700;
  letter-spacing: 0.05em;
}

h1, h2, h3, h4 {
  font-family: 'Cinzel Decorative', 'Noto Serif SC', serif;
  font-weight: 600;
  color: var(--amber-300);
  letter-spacing: 0.03em;
  line-height: 1.3;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

p { margin-bottom: var(--space-sm); }

.bilingual {
  display: flex;
  flex-direction: column;
  gap: 0.15em;
  align-items: center;
}

.bilingual .en { font-family: 'Cinzel Decorative', 'Noto Serif SC', serif; font-weight: 600; }
.bilingual .zh { font-family: 'Noto Serif SC', serif; font-size: 0.8em; color: var(--parchment-400); }

.bilingual-inline .en::after { content: ' / '; color: var(--amber-400); opacity: 0.6; }
.bilingual-inline .zh { font-family: 'Noto Serif SC', serif; }

/* ---- Top Navigation ---- */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  background: rgba(10, 14, 39, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(212, 162, 76, 0.2);
}

.nav-logo {
  font-family: 'Cinzel Decorative', 'Noto Serif SC', serif;
  font-size: var(--fs-h3);
  color: var(--amber-300);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

.nav-logo:hover {
  color: var(--amber-200);
  text-shadow: 0 0 20px var(--gold-glow);
}

.nav-logo .zh-sub {
  font-family: 'Noto Serif SC', serif;
  font-size: 0.7em;
  color: var(--parchment-400);
  letter-spacing: 0.15em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  list-style: none;
}

.nav-links a {
  color: var(--parchment-400);
  text-decoration: none;
  font-family: 'Cinzel Decorative', 'Noto Serif SC', serif;
  font-size: var(--fs-small);
  letter-spacing: 0.05em;
  transition: color 0.3s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.3;
}

.nav-links a .zh {
  font-family: 'Noto Serif SC', serif;
  font-size: 0.75em;
  opacity: 0.7;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--amber-300);
}

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: var(--amber-400);
  box-shadow: 0 0 8px var(--gold-glow);
}

.nav-progress {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: rgba(212, 162, 76, 0.1);
  border: 1px solid rgba(212, 162, 76, 0.3);
  border-radius: 20px;
  font-family: 'Cinzel Decorative', 'Noto Serif SC', serif;
  font-size: var(--fs-small);
  color: var(--amber-300);
}

.nav-progress .count {
  font-weight: 700;
  font-size: 1.1em;
}

/* ---- Layout ---- */
.page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
  min-height: calc(100vh - 70px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.page-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.page-header h1 {
  margin-bottom: var(--space-sm);
}

.page-header .subtitle {
  color: var(--parchment-400);
  font-style: italic;
  max-width: 600px;
  margin: 0 auto;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-sm) var(--space-lg);
  background: transparent;
  border: 2px solid var(--amber-400);
  color: var(--amber-300);
  font-family: 'Cinzel Decorative', 'Noto Serif SC', serif;
  font-size: var(--fs-body);
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  min-height: 52px;
  line-height: 1.2;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(212, 162, 76, 0.15), rgba(212, 162, 76, 0.05));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn:hover::before { opacity: 1; }

.btn:hover {
  border-color: var(--amber-200);
  color: var(--amber-200);
  box-shadow: 0 0 20px var(--gold-glow), inset 0 0 20px rgba(212, 162, 76, 0.1);
  transform: translateY(-1px);
}

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

.btn .zh {
  font-family: 'Noto Serif SC', serif;
  font-size: 0.75em;
  font-weight: 400;
  opacity: 0.8;
}

.btn-primary {
  background: linear-gradient(135deg, var(--amber-400), var(--gold-500));
  color: var(--ink-900);
  border-color: var(--amber-300);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--amber-300), var(--amber-400));
  color: var(--ink-800);
  box-shadow: 0 0 30px var(--gold-glow);
}

.btn-primary .zh { opacity: 0.9; }

.btn-ghost {
  border-color: rgba(212, 162, 76, 0.4);
  color: var(--parchment-400);
}

.btn-ghost:hover {
  border-color: var(--amber-400);
  color: var(--amber-300);
}

.btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--fs-h3);
  min-height: 72px;
}

.btn-sm {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--fs-small);
  min-height: 36px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ---- Card / Panel ---- */
.panel {
  background: rgba(18, 24, 56, 0.6);
  border: 1px solid rgba(212, 162, 76, 0.2);
  border-radius: 4px;
  padding: var(--space-lg);
  backdrop-filter: blur(4px);
  position: relative;
}

.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--amber-400), transparent);
  opacity: 0.5;
}

/* ---- Parchment scroll ---- */
.parchment {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(0,0,0,0.08), transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(0,0,0,0.08), transparent 60%),
    linear-gradient(180deg, var(--parchment-300), var(--parchment-400));
  color: var(--ink-900);
  padding: var(--space-xl) var(--space-lg);
  border-radius: 2px;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.4),
    inset 0 0 60px rgba(139, 115, 85, 0.2);
  position: relative;
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
}

.parchment::before,
.parchment::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 20px;
  background: linear-gradient(90deg,
    var(--parchment-500) 0%,
    var(--parchment-400) 10%,
    var(--parchment-300) 30%,
    var(--parchment-300) 70%,
    var(--parchment-400) 90%,
    var(--parchment-500) 100%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.parchment::before { top: -4px; border-radius: 50% 50% 0 0; }
.parchment::after { bottom: -4px; border-radius: 0 0 50% 50%; }

/* ---- Sigil / decorative ---- */
.sigil {
  width: 60px;
  height: 60px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sigil svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--amber-400);
  stroke-width: 1.5;
  filter: drop-shadow(0 0 4px var(--gold-glow));
}

/* ---- Glow text ---- */
.glow-text {
  text-shadow: 0 0 10px var(--gold-glow), 0 0 20px rgba(212, 162, 76, 0.3);
}

/* ---- Tooltip ---- */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(10, 14, 39, 0.95);
  color: var(--parchment-300);
  padding: var(--space-xs) var(--space-sm);
  border-radius: 4px;
  border: 1px solid rgba(212, 162, 76, 0.3);
  font-size: var(--fs-small);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  text-align: center;
  line-height: 1.4;
}

.tooltip:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* ---- Landing page ---- */
.landing-hero {
  text-align: center;
  max-width: 700px;
}

.landing-title {
  font-size: var(--fs-display);
  margin-bottom: var(--space-md);
  line-height: 1.1;
}

.landing-title .en {
  display: block;
  color: var(--amber-300);
  text-shadow: 0 0 30px var(--gold-glow);
}

.landing-title .zh {
  display: block;
  font-family: 'Noto Serif SC', serif;
  font-size: 0.5em;
  color: var(--parchment-400);
  letter-spacing: 0.3em;
  margin-top: var(--space-sm);
  font-weight: 400;
}

.landing-premise {
  font-size: var(--fs-h3);
  color: var(--parchment-300);
  font-style: italic;
  line-height: 1.8;
  margin-bottom: var(--space-xl);
}

.landing-sigil-wrap {
  margin: 0 auto var(--space-xl);
  width: 120px;
  height: 120px;
  position: relative;
}

.landing-sigil-wrap svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--amber-400);
  stroke-width: 1;
  animation: sigil-pulse 4s ease-in-out infinite;
  filter: drop-shadow(0 0 15px var(--gold-glow));
}

@keyframes sigil-pulse {
  0%, 100% { stroke-width: 1; opacity: 0.8; transform: rotate(0deg); }
  50% { stroke-width: 1.5; opacity: 1; transform: rotate(2deg); }
}

/* ---- Lobby / Atrium ---- */
.atrium-map {
  position: relative;
  width: 100%;
  max-width: 720px;
  aspect-ratio: 3 / 4;
  margin: var(--space-xl) auto;
}

.atrium-paths {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.atrium-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 150px;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(212, 162, 76, 0.12) 0%, rgba(212, 162, 76, 0.04) 50%, transparent 70%);
  z-index: 1;
}

.center-sigil-svg {
  width: 110px;
  height: 110px;
  fill: none;
  stroke: var(--amber-400);
  stroke-width: 1;
  filter: drop-shadow(0 0 8px var(--gold-glow));
  animation: sigil-breathe 6s ease-in-out infinite;
}

@keyframes sigil-breathe {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

.hall-door {
  position: absolute;
  width: 190px;
  display: flex;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: transform 0.3s ease;
  z-index: 2;
}

.hall-door .door-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-md) var(--space-sm);
  background: rgba(18, 24, 56, 0.5);
  border: 1px solid rgba(212, 162, 76, 0.15);
  border-radius: 6px;
  backdrop-filter: blur(2px);
  transition: all 0.3s ease;
}

.hall-door:hover .door-card {
  border-color: rgba(212, 162, 76, 0.4);
  background: rgba(18, 24, 56, 0.7);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35), 0 0 25px rgba(212, 162, 76, 0.1);
}

.hall-door:hover {
  transform: translateY(-4px);
}

.hall-door svg.door-icon {
  width: 65px;
  height: 85px;
  fill: none;
  stroke: var(--amber-400);
  stroke-width: 2;
  filter: drop-shadow(0 0 8px rgba(212, 162, 76, 0.4));
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.hall-door:hover svg.door-icon {
  stroke: var(--amber-200);
  filter: drop-shadow(0 0 15px var(--gold-glow));
}

.hall-door.completed svg.door-icon {
  stroke: var(--success);
  filter: drop-shadow(0 0 12px rgba(107, 191, 122, 0.5));
}

.hall-door.locked svg.door-icon {
  stroke: var(--stone-500);
  filter: none;
}

.hall-door .door-name {
  text-align: center;
  line-height: 1.4;
}

.hall-door .door-name .en {
  font-family: 'Cinzel Decorative', 'Noto Serif SC', serif;
  font-size: var(--fs-h3);
  color: var(--amber-300);
  display: block;
}

.hall-door .door-name .zh {
  font-family: 'Noto Serif SC', serif;
  font-size: var(--fs-body);
  color: var(--parchment-400);
  margin-top: 2px;
  display: block;
}

.hall-door .door-status {
  font-family: 'Cinzel Decorative', 'Noto Serif SC', serif;
  font-size: var(--fs-small);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 16px;
  border-radius: 12px;
  min-width: 130px;
  white-space: nowrap;
  text-align: center;
  display: inline-block;
}

.hall-door .door-status.completed {
  color: var(--success);
  background: rgba(107, 191, 122, 0.15);
  border: 1px solid rgba(107, 191, 122, 0.3);
}

.hall-door .door-status.available {
  color: var(--amber-300);
  background: rgba(212, 162, 76, 0.1);
  border: 1px solid rgba(212, 162, 76, 0.3);
}

/* Door positions — four compass points around center */
/* North: top-center, content flows down */
.hall-door.north {
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
}
.hall-door.north:hover {
  transform: translateX(-50%) translateY(-4px);
}

/* East: right-middle, content flows right — icon left, text right */
.hall-door.east {
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 200px;
}
.hall-door.east:hover {
  transform: translateY(-50%) translateX(4px);
}
.hall-door.east .door-card {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  padding: var(--space-sm) var(--space-sm) var(--space-sm) var(--space-md);
  text-align: left;
}
.hall-door.east svg.door-icon {
  width: 55px;
  height: 70px;
}
.hall-door.east .door-name {
  text-align: left;
  flex: 1;
}
.hall-door.east .door-status {
  width: 100%;
  margin-top: var(--space-xs);
  text-align: center;
}
.hall-door.east .door-card {
  flex-wrap: wrap;
}
.hall-door.east .door-card > *:nth-child(n+3) {
  width: 100%;
}

/* South: bottom-center, content flows up — text above icon */
.hall-door.south {
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
}
.hall-door.south:hover {
  transform: translateX(-50%) translateY(4px);
}
.hall-door.south .door-card {
  flex-direction: column-reverse;
}

/* West: left-middle, content flows left — text left, icon right */
.hall-door.west {
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 200px;
}
.hall-door.west:hover {
  transform: translateY(-50%) translateX(-4px);
}
.hall-door.west .door-card {
  flex-direction: row-reverse;
  align-items: center;
  justify-content: flex-start;
  padding: var(--space-sm) var(--space-md) var(--space-sm) var(--space-sm);
  text-align: right;
  flex-wrap: wrap;
}
.hall-door.west svg.door-icon {
  width: 55px;
  height: 70px;
}
.hall-door.west .door-name {
  text-align: right;
  flex: 1;
}
.hall-door.west .door-status {
  width: 100%;
  margin-top: var(--space-xs);
  text-align: center;
}
.hall-door.west .door-card > *:nth-child(n+3) {
  width: 100%;
}

/* ---- Pathfinding Hall ---- */
.hall-container {
  width: 100%;
  max-width: 1000px;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.game-canvas-wrap {
  background: rgba(10, 14, 39, 0.5);
  border: 1px solid rgba(212, 162, 76, 0.2);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.game-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
}

.game-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: rgba(18, 24, 56, 0.5);
  border: 1px solid rgba(212, 162, 76, 0.15);
  border-radius: 4px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-item .label {
  font-family: 'Noto Serif SC', serif;
  font-size: var(--fs-micro);
  color: var(--parchment-400);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.info-item .value {
  font-family: 'Cinzel Decorative', 'Noto Serif SC', serif;
  font-size: var(--fs-h3);
  color: var(--amber-300);
}

.game-controls {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  justify-content: center;
}

/* ---- Cipher Hall ---- */
.cipher-text {
  font-family: 'Courier New', 'Noto Serif SC', monospace;
  font-size: var(--fs-h3);
  letter-spacing: 0.1em;
  line-height: 1.8;
  text-align: center;
  padding: var(--space-lg);
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: break-word;
}

.cipher-text.cipher {
  color: var(--stone-500);
}

.cipher-text.plain {
  color: var(--ink-800);
  font-weight: 600;
}

.shift-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  margin: var(--space-md) 0;
}

.slider-wrap {
  width: 100%;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.slider-wrap input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--stone-600);
  border-radius: 2px;
  outline: none;
}

.slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--amber-400);
  cursor: pointer;
  box-shadow: 0 0 10px var(--gold-glow);
  transition: transform 0.2s ease;
}

.slider-wrap input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider-wrap .shift-value {
  font-family: 'Cinzel Decorative', 'Noto Serif SC', serif;
  font-size: var(--fs-h2);
  color: var(--amber-300);
  min-width: 60px;
  text-align: center;
}

.frequency-chart {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 100px;
  margin-top: var(--space-md);
  padding: var(--space-sm) 0;
}

.freq-bar {
  width: 18px;
  background: var(--amber-400);
  border-radius: 2px 2px 0 0;
  opacity: 0.6;
  transition: all 0.3s ease;
  position: relative;
}

.freq-bar:hover { opacity: 1; }

.freq-bar.highlight {
  background: var(--ember-500);
  opacity: 1;
  box-shadow: 0 0 8px rgba(255, 107, 53, 0.5);
}

.freq-bar::after {
  content: attr(data-letter);
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Courier New', monospace;
  font-size: 10px;
  color: var(--parchment-400);
}

.frequency-hint {
  text-align: center;
  font-size: var(--fs-small);
  color: var(--parchment-400);
  font-style: italic;
  margin-top: var(--space-md);
}

/* ---- Bayes Hall ---- */
.bayes-hypotheses {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.hypothesis-card {
  background: rgba(18, 24, 56, 0.5);
  border: 1px solid rgba(212, 162, 76, 0.2);
  border-radius: 4px;
  padding: var(--space-md);
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
}

.hypothesis-card:hover {
  border-color: var(--amber-400);
  transform: translateY(-2px);
}

.hypothesis-card.selected {
  border-color: var(--amber-300);
  box-shadow: 0 0 20px var(--gold-glow);
  background: rgba(212, 162, 76, 0.1);
}

.hypothesis-card.correct {
  border-color: var(--success);
  box-shadow: 0 0 20px rgba(107, 191, 122, 0.5);
}

.hypothesis-card.wrong {
  border-color: var(--error);
  box-shadow: 0 0 20px rgba(217, 101, 101, 0.5);
}

.hypothesis-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-sm);
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hypothesis-name {
  font-family: 'Cinzel Decorative', 'Noto Serif SC', serif;
  font-size: var(--fs-body);
  color: var(--amber-300);
  margin-bottom: var(--space-xs);
}

.hypothesis-name .zh {
  display: block;
  font-family: 'Noto Serif SC', serif;
  font-size: 0.8em;
  color: var(--parchment-400);
}

.prob-bar-wrap {
  width: 100%;
  height: 8px;
  background: var(--stone-700);
  border-radius: 4px;
  overflow: hidden;
  margin: var(--space-sm) 0;
}

.prob-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--amber-400), var(--gold-400));
  border-radius: 4px;
  transition: width 0.8s ease;
}

.prob-value {
  font-family: 'Cinzel Decorative', serif;
  font-size: var(--fs-h3);
  color: var(--amber-300);
  font-weight: 700;
}

.prob-label {
  font-size: var(--fs-micro);
  color: var(--parchment-400);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.bayes-formula {
  text-align: center;
  padding: var(--space-md);
  background: rgba(10, 14, 39, 0.5);
  border: 1px solid rgba(212, 162, 76, 0.15);
  border-radius: 4px;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: var(--parchment-300);
  margin-bottom: var(--space-md);
}

.bayes-formula .formula-main {
  font-size: var(--fs-h2);
  color: var(--amber-300);
  margin-bottom: var(--space-xs);
}

.clue-box {
  padding: var(--space-md);
  background: rgba(212, 162, 76, 0.08);
  border: 1px solid rgba(212, 162, 76, 0.3);
  border-radius: 4px;
  text-align: center;
  margin-bottom: var(--space-md);
}

.clue-box .clue-label {
  font-size: var(--fs-micro);
  color: var(--amber-400);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: var(--space-xs);
}

.clue-box .clue-text {
  font-size: var(--fs-h3);
  color: var(--parchment-300);
  font-style: italic;
}

.likelihoods {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-md);
  font-size: var(--fs-small);
  color: var(--parchment-400);
}

.likelihood-item {
  text-align: center;
}

.likelihood-item .lh-val {
  color: var(--amber-300);
  font-family: 'Cinzel Decorative', serif;
  font-size: var(--fs-body);
}

/* ---- Recursion Hall (Tower of Hanoi) ---- */
.tower-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 60px;
  padding: var(--space-xl) var(--space-lg) var(--space-lg);
  min-height: 300px;
  position: relative;
}

.tower-peg {
  position: relative;
  width: 120px;
  height: 200px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  cursor: pointer;
  transition: filter 0.3s ease;
}

.tower-peg::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 180px;
  background: linear-gradient(180deg, var(--stone-600), var(--stone-700));
  border-radius: 4px 4px 0 0;
}

.tower-peg::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 12px;
  background: linear-gradient(180deg, var(--stone-600), var(--stone-700));
  border-radius: 4px 4px 0 0;
}

.tower-peg.selected {
  filter: brightness(1.3) drop-shadow(0 0 10px var(--gold-glow));
}

.tower-peg:hover {
  filter: brightness(1.1);
}

.disk {
  height: 28px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--amber-400), var(--gold-500));
  box-shadow:
    0 2px 4px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.3);
  position: relative;
  z-index: 1;
  transition: all 0.3s ease;
  border: 1px solid rgba(212, 162, 76, 0.5);
}

.disk.size-1 { width: 40px; }
.disk.size-2 { width: 65px; }
.disk.size-3 { width: 90px; }

.disk.moving {
  transform: translateY(-20px);
  box-shadow: 0 0 20px var(--gold-glow);
}

.peg-label {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Cinzel Decorative', serif;
  font-size: var(--fs-small);
  color: var(--parchment-400);
  letter-spacing: 0.1em;
}

/* ---- Spellbook ---- */
.spellbook-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
  width: 100%;
  max-width: 900px;
}

.spell-entry {
  background: rgba(18, 24, 56, 0.5);
  border: 1px solid rgba(212, 162, 76, 0.2);
  border-radius: 4px;
  padding: var(--space-lg);
  position: relative;
  transition: all 0.3s ease;
}

.spell-entry.mastered {
  border-color: rgba(107, 191, 122, 0.4);
  background: rgba(107, 191, 122, 0.05);
}

.spell-entry.sealed {
  opacity: 0.5;
}

.spell-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.spell-header .sigil {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.spell-title {
  flex: 1;
}

.spell-title .en {
  font-family: 'Cinzel Decorative', 'Noto Serif SC', serif;
  font-size: var(--fs-h3);
  color: var(--amber-300);
  display: block;
}

.spell-title .zh {
  font-family: 'Noto Serif SC', serif;
  font-size: var(--fs-small);
  color: var(--parchment-400);
}

.spell-status {
  font-size: var(--fs-micro);
  font-family: 'Cinzel Decorative', serif;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  border-radius: 10px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.spell-status.mastered {
  color: var(--success);
  background: rgba(107, 191, 122, 0.15);
  border: 1px solid rgba(107, 191, 122, 0.3);
}

.spell-status.sealed {
  color: var(--stone-500);
  background: rgba(90, 90, 122, 0.15);
  border: 1px solid rgba(90, 90, 122, 0.3);
}

.spell-desc {
  color: var(--parchment-300);
  font-size: var(--fs-body);
  line-height: 1.7;
}

.spell-desc .term {
  color: var(--amber-300);
  font-weight: 600;
}

/* ---- Gate ---- */
.gate-scene {
  text-align: center;
  max-width: 600px;
}

.gate-icon {
  width: 200px;
  height: 240px;
  margin: 0 auto var(--space-xl);
  position: relative;
}

.gate-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--stone-500);
  stroke-width: 2;
  transition: all 0.8s ease;
}

.gate-icon.open svg {
  stroke: var(--amber-300);
  filter: drop-shadow(0 0 30px var(--gold-glow));
  animation: gate-glow 2s ease-in-out infinite;
}

@keyframes gate-glow {
  0%, 100% { filter: drop-shadow(0 0 20px var(--gold-glow)); }
  50% { filter: drop-shadow(0 0 40px rgba(255, 215, 100, 0.8)); }
}

.gate-message {
  font-size: var(--fs-h2);
  margin-bottom: var(--space-md);
  font-style: italic;
}

.gate-message.sealed { color: var(--parchment-400); }
.gate-message.open {
  color: var(--amber-200);
  text-shadow: 0 0 20px var(--gold-glow);
}

/* ---- Win overlay ---- */
.win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 31, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  backdrop-filter: blur(4px);
}

.win-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.win-panel {
  text-align: center;
  padding: var(--space-xl);
  max-width: 500px;
  animation: win-rise 0.6s ease-out;
}

@keyframes win-rise {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.win-panel h2 {
  font-size: var(--fs-h1);
  color: var(--amber-200);
  margin-bottom: var(--space-md);
  text-shadow: 0 0 20px var(--gold-glow);
}

.win-panel .win-message {
  color: var(--parchment-300);
  font-size: var(--fs-body);
  margin-bottom: var(--space-lg);
  line-height: 1.8;
}

.win-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

/* ---- Confetti ---- */
.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
}

/* ---- Explanation box ---- */
.explanation {
  padding: var(--space-md);
  background: rgba(212, 162, 76, 0.06);
  border-left: 3px solid var(--amber-400);
  border-radius: 0 4px 4px 0;
  color: var(--parchment-300);
  font-style: italic;
  line-height: 1.7;
}

/* ---- Utility ---- */
.text-center { text-align: center; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.hidden { display: none !important; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .top-nav {
    padding: var(--space-xs) var(--space-md);
    flex-wrap: wrap;
    gap: var(--space-xs);
  }

  .nav-logo { font-size: var(--fs-body); }

  .nav-links {
    gap: var(--space-sm);
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .page-wrapper {
    padding: var(--space-lg) var(--space-md);
  }

  .atrium-map {
    max-width: 520px;
  }

  .atrium-center {
    width: 110px;
    height: 110px;
  }

  .center-sigil-svg {
    width: 80px;
    height: 80px;
  }

  .hall-door {
    width: 150px;
  }

  .hall-door.east,
  .hall-door.west {
    width: 160px;
  }

  .hall-door svg.door-icon {
    width: 50px;
    height: 65px;
  }

  .hall-door.east svg.door-icon,
  .hall-door.west svg.door-icon {
    width: 45px;
    height: 58px;
  }

  .hall-door .door-name .en {
    font-size: var(--fs-body);
  }

  .hall-door .door-name .zh {
    font-size: var(--fs-small);
  }

  .hall-door .door-status {
    font-size: var(--fs-micro);
    padding: 3px 10px;
    min-width: 110px;
    white-space: nowrap;
    text-align: center;
    display: inline-block;
  }

  .bayes-hypotheses {
    grid-template-columns: 1fr;
  }

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

  .tower-container {
    gap: 20px;
  }

  .tower-peg {
    width: 90px;
  }

  .tower-peg::after {
    width: 90px;
  }

  .disk.size-1 { width: 30px; }
  .disk.size-2 { width: 50px; }
  .disk.size-3 { width: 70px; }

  .frequency-chart {
    height: 70px;
    gap: 2px;
  }

  .freq-bar {
    width: 12px;
  }
}

@media (max-width: 480px) {
  .atrium-map {
    max-width: 360px;
    aspect-ratio: 2 / 3;
  }

  .atrium-center {
    width: 80px;
    height: 80px;
  }

  .center-sigil-svg {
    width: 60px;
    height: 60px;
  }

  .hall-door {
    width: 120px;
  }

  .hall-door.east,
  .hall-door.west {
    width: 130px;
  }

  .hall-door svg.door-icon {
    width: 40px;
    height: 52px;
  }

  .hall-door.east svg.door-icon,
  .hall-door.west svg.door-icon {
    width: 36px;
    height: 46px;
  }

  .hall-door .door-card {
    padding: var(--space-xs);
    gap: var(--space-xs);
  }

  .hall-door.north .door-card,
  .hall-door.south .door-card {
    padding: var(--space-xs) var(--space-xs);
  }
}
