/* ========================================
   FIRST LIGHT - Victorian Observatory UI
   A refined antique telescope interface
   ======================================== */

/* ========================================
   DESIGN TOKENS - Unified Theme System
   ======================================== */

:root {
  /* === Night Sky === */
  --sky-void: #030308;
  --sky-deep: #080812;
  --sky-night: #0c0c1a;
  --sky-ambient: #12122a;

  /* === Brass - Warm instrument hardware === */
  --brass-highlight: #e8c45a;
  --brass-light: #d4a84b;
  --brass-mid: #c49a2c;
  --brass-primary: #b8860b;
  --brass-dark: #8b6914;
  --brass-shadow: #5a4208;
  --brass-patina: #4a3806;

  /* === Leather - Rich aged leather === */
  --leather-dark: #1a0f0a;
  --leather-deep: #2a1810;
  --leather-mid: #3d2418;
  --leather-worn: #4a2c1c;
  --leather-light: #5c3824;
  --leather-highlight: #6d4530;

  /* === Wood - Deep mahogany === */
  --wood-ebony: #0d0806;
  --wood-dark: #1a120d;
  --wood-mahogany: #2a1f1a;
  --wood-walnut: #3d2e24;

  /* === Parchment - Aged paper === */
  --parchment-cream: #f5efe0;
  --parchment-light: #ebe3d0;
  --parchment-mid: #e2d4b8;
  --parchment-dark: #d4c4a8;
  --parchment-aged: #c4b090;
  --ink: #1a1410;
  --ink-faded: #3d2e24;

  /* === Functional === */
  --star-white: #f0f0ff;
  --star-blue: #b8c0ff;
  --star-gold: #ffd93d;
  --glow-warm: rgba(212, 168, 75, 0.4);
  --glow-cold: rgba(184, 192, 255, 0.3);

  /* === Typography === */
  --font-display: 'Cormorant Garamond', 'Palatino Linotype', 'Book Antiqua', serif;
  --font-body: 'Crimson Pro', 'Georgia', serif;

  /* === Sizing === */
  --telescope-size: min(85vw, 85vh);

  /* === Shadows === */
  --shadow-pressed: inset 0 2px 6px rgba(0,0,0,0.6);
  --shadow-flat: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-raised: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-floating: 0 12px 40px rgba(0,0,0,0.7);

  /* === Textures (inline SVG) === */
  --texture-noise: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
  --texture-leather: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='l'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.5' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23l)' opacity='0.12'/%3E%3C/svg%3E");
  --texture-paper: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.5' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='0.05'/%3E%3C/svg%3E");

  /* === Transitions === */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-fast: 0.15s var(--ease-out-expo);
  --transition-medium: 0.3s var(--ease-out-expo);
  --transition-slow: 0.5s var(--ease-out-expo);
}


/* ========================================
   RESET & BASE
   ======================================== */

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;  /* Dynamic viewport height - accounts for mobile browser chrome */
  overflow: hidden;
  background: var(--sky-void);
  color: var(--parchment-light);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Prevent pull-to-refresh and overscroll effects on mobile */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}


/* ========================================
   GAME CONTAINER
   ======================================== */

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 50%, var(--sky-night) 0%, var(--sky-void) 70%);
  /* Prevent all touch gestures on game area - we handle touch ourselves */
  touch-action: none;
}


/* ========================================
   SKY CANVAS
   ======================================== */

#sky-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: none;
  /* Prevent touch gestures - we handle touch ourselves */
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}


/* ========================================
   TELESCOPE OVERLAY
   ======================================== */

#telescope-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: var(--telescope-size);
  height: var(--telescope-size);
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;

  /* Brass rim from SVG */
  background-image: url('assets/telescope_overlay_detailed.svg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;

  /* Deep vignette surround */
  box-shadow:
    0 0 0 3000px rgba(0, 0, 0, 0.96),
    inset 0 0 80px 20px rgba(0, 0, 0, 0.6),
    0 0 0 3px var(--brass-shadow);
}

/* Lens glass effect - subtle chromatic tint */
.lens-glass-effect {
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 50%,
    transparent 0%,
    transparent 50%,
    rgba(100, 120, 180, 0.02) 70%,
    rgba(80, 100, 160, 0.05) 85%,
    rgba(60, 80, 140, 0.08) 100%
  );
  pointer-events: none;
}

/* Subtle dust motes on lens */
.lens-dust {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-image:
    radial-gradient(circle at 23% 34%, rgba(255,255,255,0.015) 0%, transparent 0.5%),
    radial-gradient(circle at 67% 23%, rgba(255,255,255,0.01) 0%, transparent 0.4%),
    radial-gradient(circle at 45% 78%, rgba(255,255,255,0.012) 0%, transparent 0.6%),
    radial-gradient(circle at 82% 56%, rgba(255,255,255,0.008) 0%, transparent 0.3%),
    radial-gradient(circle at 12% 67%, rgba(255,255,255,0.01) 0%, transparent 0.5%);
  pointer-events: none;
  opacity: 0.5;
}


/* ========================================
   LENS CASE - Victorian Instrument Box
   ======================================== */

#lens-case {
  position: fixed;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;

  /* Leather case construction */
  background:
    var(--texture-leather),
    linear-gradient(135deg,
      var(--leather-highlight) 0%,
      var(--leather-mid) 20%,
      var(--leather-deep) 80%,
      var(--leather-dark) 100%);

  padding: 16px 14px 12px;
  border-radius: 8px;

  /* Leather edge & stitching look */
  border: 3px solid var(--leather-dark);
  box-shadow:
    var(--shadow-floating),
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 -2px 8px rgba(0,0,0,0.4);
}

.case-lid {
  text-align: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--leather-dark);
}

.engraved-label {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass-light);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.lens-slots {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lens-slot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background:
    linear-gradient(180deg,
      rgba(255,255,255,0.03) 0%,
      transparent 50%,
      rgba(0,0,0,0.2) 100%),
    var(--leather-dark);
  border: 2px solid var(--leather-worn);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.lens-slot::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
  pointer-events: none;
}

.lens-slot:hover {
  border-color: var(--brass-dark);
  background:
    linear-gradient(180deg,
      rgba(255,255,255,0.05) 0%,
      transparent 50%,
      rgba(0,0,0,0.15) 100%),
    var(--leather-worn);
}

/* Touch feedback for mobile */
.lens-slot:active {
  transform: scale(0.95);
  border-color: var(--brass-primary);
}

.lens-slot.active {
  border-color: var(--brass-primary);
  background:
    linear-gradient(180deg,
      rgba(212, 168, 75, 0.1) 0%,
      transparent 30%,
      rgba(0,0,0,0.3) 100%),
    var(--leather-deep);
  box-shadow:
    inset 0 2px 6px rgba(0,0,0,0.5),
    0 0 12px rgba(212, 168, 75, 0.15);
}

/* Brass bezel holding the lens */
.lens-bezel {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(145deg,
    var(--brass-highlight) 0%,
    var(--brass-mid) 30%,
    var(--brass-dark) 70%,
    var(--brass-shadow) 100%);
  box-shadow:
    0 2px 4px rgba(0,0,0,0.4),
    inset 0 1px 1px rgba(255,255,255,0.3);
  flex-shrink: 0;
}

.lens-glass {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transition: all var(--transition-medium);
}

.standard-glass {
  background: radial-gradient(circle at 35% 35%,
    rgba(200, 220, 255, 0.5) 0%,
    rgba(140, 170, 220, 0.3) 40%,
    rgba(80, 110, 160, 0.5) 100%);
  box-shadow:
    inset 0 0 8px rgba(0,0,0,0.5),
    inset 0 2px 4px rgba(255,255,255,0.2);
}

.wide-glass {
  background: radial-gradient(circle at 50% 50%,
    rgba(180, 200, 230, 0.4) 0%,
    rgba(120, 150, 200, 0.35) 50%,
    rgba(70, 90, 130, 0.6) 100%);
  box-shadow:
    inset 0 0 12px rgba(0,0,0,0.6),
    inset 0 0 4px rgba(255,255,255,0.15);
}

.deep-glass {
  background: radial-gradient(circle at 40% 40%,
    rgba(160, 140, 200, 0.55) 0%,
    rgba(100, 80, 140, 0.45) 50%,
    rgba(50, 40, 80, 0.7) 100%);
  box-shadow:
    inset 0 0 10px rgba(0,0,0,0.7),
    inset 0 0 6px rgba(160, 140, 200, 0.25);
}

.lens-slot.active .lens-glass {
  box-shadow:
    inset 0 0 6px rgba(0,0,0,0.4),
    0 0 8px rgba(200, 220, 255, 0.3);
}

.lens-slot.active .deep-glass {
  box-shadow:
    inset 0 0 6px rgba(0,0,0,0.5),
    0 0 10px rgba(160, 140, 200, 0.4);
}

.lens-plate {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.lens-name {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--parchment-mid);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.lens-mag {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--brass-light);
  letter-spacing: 0.05em;
}

/* Engraved Brass Label - Scientific instrument nameplate styling */
.key-hint {
  display: flex;
  align-items: center;
  justify-content: center;

  min-width: 18px;
  height: 16px;
  padding: 0 5px;

  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;

  /* Aged brass plate gradient */
  background:
    linear-gradient(135deg,
      rgba(255,255,255,0.2) 0%,
      transparent 30%,
      rgba(0,0,0,0.15) 100%),
    linear-gradient(180deg,
      #c4a050 0%,
      #a68838 50%,
      #8b6f28 100%);

  /* Engraved text effect */
  color: #4a3820;
  text-shadow:
    0 -0.5px 0 rgba(0,0,0,0.3),
    0 0.5px 0 rgba(255,255,255,0.15);

  /* Subtle beveled edge */
  border: 1px solid #8b6f28;
  border-radius: 2px;

  /* Refined shadow - flatter than typewriter keys */
  box-shadow:
    0 1px 2px rgba(0,0,0,0.3),
    inset 0 0.5px 0 rgba(255,255,255,0.25),
    inset 0 -0.5px 0 rgba(0,0,0,0.2);

  flex-shrink: 0;
}

/* Position key hints within lens slots */
.lens-slot .key-hint {
  position: absolute;
  bottom: 6px;
  right: 6px;
}

/* Position key hints within dial sectors */
.dial-sector .key-hint {
  opacity: 0.7;
  margin-top: 2px;
}

.dial-sector.active .key-hint {
  opacity: 1;
  /* Slightly brighter brass for active state */
  background:
    linear-gradient(135deg,
      rgba(255,255,255,0.25) 0%,
      transparent 30%,
      rgba(0,0,0,0.12) 100%),
    linear-gradient(180deg,
      #d4b060 0%,
      #b89848 50%,
      #9a7b32 100%);
  color: #2a2010;
  border-color: #9a7b32;
}

/* Journal toggle key hint */
#discoveries-toggle .key-hint {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  min-width: max-content;
  padding: 0 6px;
}


/* ========================================
   OBSERVATORY DIAL - Brass Latitude Selector
   ======================================== */

#observatory-dial {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.dial-housing {
  width: 100px;
  height: 54px;
  background:
    var(--texture-leather),
    linear-gradient(180deg,
      var(--leather-light) 0%,
      var(--leather-mid) 30%,
      var(--leather-dark) 100%);
  border-radius: 27px;
  padding: 6px;
  box-shadow: var(--shadow-raised);
  border: 2px solid var(--leather-dark);
}

.dial-face {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg,
    var(--brass-highlight) 0%,
    var(--brass-light) 15%,
    var(--brass-primary) 50%,
    var(--brass-dark) 85%,
    var(--brass-shadow) 100%);
  border-radius: 21px;
  position: relative;
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.4),
    inset 0 -2px 4px rgba(0,0,0,0.3),
    0 2px 4px rgba(0,0,0,0.3);
  display: flex;
}

.dial-sector {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: all var(--transition-fast);
  border-radius: 21px;
}

.dial-sector:first-child {
  border-radius: 21px 0 0 21px;
}

.dial-sector:last-child {
  border-radius: 0 21px 21px 0;
}

.dial-sector.active {
  background: linear-gradient(180deg,
    rgba(0,0,0,0.15) 0%,
    rgba(0,0,0,0.25) 100%);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.4);
}

.dial-sector:not(.active):hover {
  background: rgba(255,255,255,0.1);
}

/* Touch feedback for mobile */
.dial-sector:not(.active):active {
  background: rgba(255,255,255,0.15);
  transform: scale(0.95);
}

.sector-icon {
  font-size: 0.7rem;
  color: var(--leather-dark);
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.dial-sector.active .sector-icon {
  opacity: 1;
  color: var(--parchment-cream);
  text-shadow: 0 0 6px rgba(255,255,255,0.5);
}

.sector-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--leather-dark);
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  position: relative;
  z-index: 1;
}

.dial-sector.active .sector-label {
  color: var(--parchment-cream);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Center divider line */
.dial-face::before {
  content: '';
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 50%;
  width: 2px;
  background: linear-gradient(180deg,
    var(--brass-shadow) 0%,
    var(--brass-dark) 50%,
    var(--brass-shadow) 100%);
  transform: translateX(-50%);
  z-index: 1;
}

/* Brass center rivet */
.dial-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%,
    var(--brass-highlight) 0%,
    var(--brass-primary) 50%,
    var(--brass-dark) 100%);
  box-shadow:
    0 2px 3px rgba(0,0,0,0.5),
    inset 0 1px 1px rgba(255,255,255,0.4);
  z-index: 5;
  pointer-events: none;
}

.observatory-nameplate {
  background: linear-gradient(180deg,
    var(--brass-light) 0%,
    var(--brass-primary) 40%,
    var(--brass-dark) 100%);
  padding: 6px 16px;
  border-radius: 4px;
  box-shadow:
    0 2px 6px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.3);
}

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

.observatory-location {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--leather-dark);
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}

.observatory-coords {
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--leather-worn);
}


/* ========================================
   DISCOVERIES JOURNAL PANEL
   ======================================== */

#discoveries-panel {
  position: fixed;
  top: 50%;
  right: 0;
  width: 300px;
  height: 70vh;
  max-height: 600px;
  transform: translateY(-50%);
  z-index: 25;

  display: flex;
  transition: transform var(--transition-slow);
}

#discoveries-panel.collapsed {
  transform: translate(calc(100% - 52px), -50%);
}

/* Toggle Button - Leather strap with brass clasp */
#discoveries-toggle {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translate(-100%, -50%);
  width: 52px;
  height: 140px;

  background:
    var(--texture-leather),
    linear-gradient(90deg,
      var(--leather-highlight) 0%,
      var(--leather-mid) 30%,
      var(--leather-deep) 100%);

  border: none;
  border-radius: 8px 0 0 8px;
  cursor: pointer;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;

  box-shadow:
    -6px 0 20px rgba(0,0,0,0.5),
    inset 1px 0 0 rgba(255,255,255,0.08);

  transition: all var(--transition-medium);
}

#discoveries-toggle:hover {
  width: 58px;
  background:
    var(--texture-leather),
    linear-gradient(90deg,
      var(--leather-highlight) 0%,
      var(--leather-light) 30%,
      var(--leather-mid) 100%);
}

.toggle-binding {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 8px;
  width: 3px;
  background: repeating-linear-gradient(180deg,
    var(--brass-dark) 0px,
    var(--brass-dark) 4px,
    transparent 4px,
    transparent 8px);
  opacity: 0.6;
}

.toggle-clasp {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 18px;
  height: 28px;
  background: linear-gradient(135deg,
    var(--brass-light) 0%,
    var(--brass-primary) 50%,
    var(--brass-dark) 100%);
  border-radius: 3px;
  box-shadow:
    0 2px 4px rgba(0,0,0,0.4),
    inset 0 1px 1px rgba(255,255,255,0.3);
}

.clasp-hook {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border: 2px solid var(--brass-shadow);
  border-top: none;
  border-radius: 0 0 4px 4px;
}

.toggle-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
}

.toggle-icon {
  font-size: 1.2rem;
  color: var(--brass-light);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.discovery-count {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--brass-light);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

#discoveries-toggle .toggle-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  padding: 2px 6px;
}

/* Leather spine edge */
.journal-spine {
  width: 14px;
  flex-shrink: 0;
  background:
    var(--texture-leather),
    linear-gradient(90deg,
      var(--leather-worn) 0%,
      var(--leather-dark) 50%,
      var(--leather-deep) 100%);
  border-radius: 4px 0 0 4px;
  box-shadow: inset -4px 0 8px rgba(0,0,0,0.4);
}

/* Main journal body */
.discoveries-content {
  flex: 1;
  padding: 20px 18px;
  overflow-y: auto;

  background:
    var(--texture-paper),
    linear-gradient(180deg,
      var(--parchment-cream) 0%,
      var(--parchment-light) 20%,
      var(--parchment-mid) 80%,
      var(--parchment-dark) 100%);

  box-shadow:
    inset 4px 0 12px rgba(0,0,0,0.12),
    inset 0 3px 8px rgba(0,0,0,0.08);

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--brass-dark) var(--parchment-dark);
}

.discoveries-content::-webkit-scrollbar {
  width: 8px;
}

.discoveries-content::-webkit-scrollbar-track {
  background: var(--parchment-dark);
}

.discoveries-content::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg,
    var(--brass-light) 0%,
    var(--brass-dark) 100%);
  border-radius: 4px;
}

/* Journal Header */
.journal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--parchment-aged);
}

.header-ornament {
  width: 20px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--brass-dark) 50%,
    transparent 100%);
}

.journal-header h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0;
}

/* Progress dial */
.journal-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(0,0,0,0.03);
  border-radius: 6px;
  border: 1px solid var(--parchment-aged);
}

.progress-dial {
  position: relative;
  width: 36px;
  height: 36px;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-bg {
  fill: none;
  stroke: var(--parchment-aged);
  stroke-width: 3;
}

.progress-fill {
  fill: none;
  stroke: var(--brass-primary);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s var(--ease-out-expo);
}

.progress-count {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink);
}

.progress-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-style: italic;
  color: var(--ink-faded);
}

/* Empty State */
.journal-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.empty-quill {
  width: 40px;
  height: 40px;
  margin-bottom: 16px;
  background: linear-gradient(135deg,
    var(--brass-light) 0%,
    var(--brass-dark) 100%);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M21.731 2.269a2.625 2.625 0 00-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 000-3.712zM19.513 8.199l-3.712-3.712-12.15 12.15a5.25 5.25 0 00-1.32 2.214l-.8 2.685a.75.75 0 00.933.933l2.685-.8a5.25 5.25 0 002.214-1.32L19.513 8.2z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M21.731 2.269a2.625 2.625 0 00-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 000-3.712zM19.513 8.199l-3.712-3.712-12.15 12.15a5.25 5.25 0 00-1.32 2.214l-.8 2.685a.75.75 0 00.933.933l2.685-.8a5.25 5.25 0 002.214-1.32L19.513 8.2z'/%3E%3C/svg%3E");
  mask-size: contain;
  -webkit-mask-size: contain;
  opacity: 0.4;
}

.empty-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-style: italic;
  color: var(--ink-faded);
  margin-bottom: 4px;
}

.empty-hint {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--parchment-aged);
}

/* Hide empty state when discoveries exist */
#discoveries-list:not(:empty) + .journal-empty-state {
  display: none;
}


/* ========================================
   DISCOVERY CARDS
   ======================================== */

.discovery-set-section {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--parchment-aged);
}

.discovery-set-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.discovery-set-header {
  margin-bottom: 12px;
}

.set-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}

.discovery-set-header h4 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0;
}

.set-upgrade-hint {
  font-family: var(--font-body);
  font-size: 0.6rem;
  padding: 2px 6px;
  background: rgba(184, 134, 11, 0.12);
  border: 1px solid rgba(184, 134, 11, 0.25);
  border-radius: 3px;
  color: var(--brass-dark);
}

.set-progress-text {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-style: italic;
  color: var(--ink-faded);
}

.set-progress-text.completed {
  color: var(--brass-dark);
  font-weight: 600;
  font-style: normal;
}

.discovery-set-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Individual Card */
.discovery-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;

  background:
    var(--texture-paper),
    linear-gradient(145deg,
      var(--parchment-cream) 0%,
      var(--parchment-light) 50%,
      var(--parchment-mid) 100%);

  border: 1px solid var(--parchment-aged);
  border-radius: 3px;
  position: relative;

  box-shadow:
    2px 2px 6px rgba(0,0,0,0.12),
    -1px -1px 0 rgba(255,255,255,0.8);

  transition: all var(--transition-fast);
  transform: rotate(-0.3deg);
}

.discovery-card:nth-child(even) {
  transform: rotate(0.4deg);
}

.discovery-card:hover {
  transform: rotate(0deg) translateY(-2px);
  box-shadow:
    4px 4px 12px rgba(0,0,0,0.18),
    -1px -1px 0 rgba(255,255,255,0.8);
}

/* Wax seal accent */
.discovery-card::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 8px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%,
    #c44 0%,
    #922 50%,
    #711 100%);
  box-shadow:
    0 1px 3px rgba(0,0,0,0.4),
    inset 0 1px 1px rgba(255,255,255,0.2);
  opacity: 0.9;
}

.discovery-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;

  background:
    radial-gradient(circle,
      var(--parchment-cream) 0%,
      var(--parchment-mid) 80%,
      var(--parchment-aged) 100%);

  border: 2px solid var(--ink-faded);
  border-radius: 50%;
  padding: 4px;

  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow:
    inset 0 1px 3px rgba(0,0,0,0.15),
    0 1px 0 rgba(255,255,255,0.6);
}

.discovery-icon svg {
  width: 100%;
  height: 100%;
  filter: sepia(0.25) saturate(0.7);
}

.discovery-info {
  flex: 1;
  min-width: 0;
}

.discovery-info h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 500;
  font-style: italic;
  color: var(--ink);
  margin: 0 0 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.discovery-info p {
  font-family: var(--font-body);
  font-size: 0.7rem;
  color: var(--ink-faded);
  margin: 0;
  font-style: italic;
}


/* ========================================
   DISCOVERY NOTIFICATION
   ======================================== */

#discovery-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 200;

  opacity: 0;
  visibility: hidden;
  transition: all 0.4s var(--ease-out-back);
  pointer-events: none;
}

#discovery-notification.visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.notification-frame {
  position: relative;
  padding: 8px;
}

/* Ornate corner brackets */
.frame-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid var(--brass-primary);
}

.frame-corner.tl {
  top: 0; left: 0;
  border-right: none;
  border-bottom: none;
}

.frame-corner.tr {
  top: 0; right: 0;
  border-left: none;
  border-bottom: none;
}

.frame-corner.bl {
  bottom: 0; left: 0;
  border-right: none;
  border-top: none;
}

.frame-corner.br {
  bottom: 0; right: 0;
  border-left: none;
  border-top: none;
}

.notification-plate {
  background:
    var(--texture-paper),
    linear-gradient(180deg,
      var(--parchment-cream) 0%,
      var(--parchment-light) 30%,
      var(--parchment-mid) 100%);

  padding: 28px 48px;
  text-align: center;

  border: 2px solid var(--brass-dark);

  box-shadow:
    var(--shadow-floating),
    inset 0 0 20px rgba(0,0,0,0.05);
}

.plate-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.plate-header .header-line {
  width: 30px;
  height: 1px;
  background: var(--brass-primary);
}

.notification-title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass-dark);
}

.constellation-name {
  display: block;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  font-style: italic;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.plate-footer {
  margin-top: 12px;
}

.star-ornament {
  color: var(--brass-primary);
  font-size: 1rem;
}


/* ========================================
   START SCREEN
   ======================================== */

#start-screen {
  position: fixed;
  inset: 0;
  z-index: 100;

  display: flex;
  align-items: center;
  justify-content: center;

  background: var(--sky-void);
  transition: opacity 1s ease-out, visibility 1s ease-out;
}

#start-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center,
    transparent 0%,
    transparent 40%,
    rgba(0,0,0,0.4) 100%);
  pointer-events: none;
}

.start-content {
  text-align: center;
  max-width: 500px;
  padding: 40px;
  position: relative;
}

.title-ornament {
  width: 60px;
  height: 2px;
  margin: 0 auto 20px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--brass-primary) 20%,
    var(--brass-light) 50%,
    var(--brass-primary) 80%,
    transparent 100%);
}

.title-ornament.bottom {
  margin: 20px auto 40px;
}

h1 {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 300;
  letter-spacing: 0.15em;
  color: var(--parchment-cream);
  margin: 0;
  text-shadow: 0 0 40px rgba(255,255,255,0.15);
}

.start-subtitle {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-style: italic;
  font-weight: 300;
  color: var(--parchment-mid);
  margin: 8px 0 0;
  letter-spacing: 0.1em;
}

#start-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;

  padding: 16px 36px;

  background: linear-gradient(180deg,
    var(--brass-light) 0%,
    var(--brass-primary) 50%,
    var(--brass-dark) 100%);

  border: none;
  border-radius: 4px;
  cursor: pointer;

  box-shadow:
    0 4px 16px rgba(0,0,0,0.5),
    inset 0 1px 1px rgba(255,255,255,0.3),
    inset 0 -1px 2px rgba(0,0,0,0.2);

  transition: all var(--transition-fast);
}

#start-button:hover {
  transform: translateY(-2px);
  box-shadow:
    0 6px 24px rgba(0,0,0,0.6),
    inset 0 1px 2px rgba(255,255,255,0.4),
    0 0 20px rgba(212, 168, 75, 0.2);
}

#start-button:active {
  transform: translateY(0);
  box-shadow:
    0 2px 8px rgba(0,0,0,0.5),
    inset 0 2px 4px rgba(0,0,0,0.2);
}

.button-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--leather-dark);
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}

.button-icon {
  font-size: 1.2rem;
  color: var(--leather-dark);
}

.start-hint {
  margin-top: 40px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--parchment-aged);
  line-height: 1.6;
}


/* ========================================
   UTILITY CLASSES
   ======================================== */

.hidden {
  display: none !important;
}

.pulse {
  animation: pulse-glow 0.5s ease-out;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 0 rgba(212, 168, 75, 0);
  }
  50% {
    box-shadow: 0 0 20px rgba(212, 168, 75, 0.4);
  }
}


/* ========================================
   MODAL SYSTEM
   ======================================== */

#modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0);
  z-index: 1000;
  transition: background 0.3s ease;
  pointer-events: none;
}

#modal-backdrop:not(.hidden) {
  pointer-events: auto;
}

#modal-backdrop.active {
  background: rgba(0, 0, 0, 0.8);
}

#modal-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#modal-container > * {
  pointer-events: auto;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#modal-container > *.active {
  opacity: 1;
  transform: scale(1);
}


/* ========================================
   PATTERN MATCHING MODAL - Victorian Observatory
   ======================================== */

.pattern-match-modal {
  position: relative;
  max-width: 720px;
  padding: 24px;
  background:
    /* Subtle paper texture noise */
    repeating-linear-gradient(
      0deg,
      rgba(74, 55, 40, 0.02) 0px,
      transparent 1px,
      transparent 2px,
      rgba(74, 55, 40, 0.02) 3px
    ),
    /* Aged parchment gradient */
    radial-gradient(
      ellipse at 30% 20%,
      rgba(244, 236, 216, 1) 0%,
      rgba(238, 226, 202, 1) 50%,
      rgba(232, 218, 188, 1) 100%
    );
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 0 80px rgba(184, 134, 11, 0.15);
  border-radius: 2px;
  filter: drop-shadow(0 4px 20px rgba(74, 55, 40, 0.3));
}

/* Parchment edge wear */
.pattern-match-modal::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 5% 5%, rgba(139, 109, 71, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 95% 5%, rgba(139, 109, 71, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 5% 95%, rgba(139, 109, 71, 0.07) 0%, transparent 40%),
    radial-gradient(circle at 95% 95%, rgba(139, 109, 71, 0.09) 0%, transparent 40%);
  pointer-events: none;
  border-radius: 2px;
  opacity: 0.6;
}

.modal-frame {
  position: relative;
  padding: 32px 40px;
}

/* Brass Corner Brackets - Victorian Instrument Detail */
.pattern-match-modal .frame-corner {
  position: absolute;
  width: 48px;
  height: 48px;
  background: linear-gradient(
    135deg,
    #D4A84B 0%,
    #B8860B 30%,
    #8B6914 70%,
    #6B5410 100%
  );
  clip-path: polygon(
    0 0,
    100% 0,
    100% 20%,
    20% 20%,
    20% 100%,
    0 100%
  );
  box-shadow:
    inset -1px -1px 2px rgba(0, 0, 0, 0.4),
    inset 1px 1px 1px rgba(255, 237, 160, 0.6),
    0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.pattern-match-modal .frame-corner::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 237, 160, 0.3) 0%,
    transparent 50%
  );
  clip-path: inherit;
}

/* Decorative screw details */
.pattern-match-modal .frame-corner::before {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  top: 6px;
  left: 6px;
  background: radial-gradient(
    circle,
    #6B5410 30%,
    #8B6914 50%,
    #6B5410 70%
  );
  border-radius: 50%;
  box-shadow:
    inset 0 1px 1px rgba(0, 0, 0, 0.6),
    0 1px 0 rgba(255, 237, 160, 0.3);
}

.pattern-match-modal .frame-corner.tl {
  top: 0;
  left: 0;
  transform: rotate(0deg);
}

.pattern-match-modal .frame-corner.tr {
  top: 0;
  right: 0;
  transform: rotate(90deg);
}

.pattern-match-modal .frame-corner.bl {
  bottom: 0;
  left: 0;
  transform: rotate(-90deg);
}

.pattern-match-modal .frame-corner.br {
  bottom: 0;
  right: 0;
  transform: rotate(180deg);
}

.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
}

/* Header - Victorian Scientific Elegance */
.modal-header {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  margin-bottom: 8px;
}

.modal-header .header-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(139, 109, 71, 0.3) 20%,
    rgba(139, 109, 71, 0.5) 50%,
    rgba(139, 109, 71, 0.3) 80%,
    transparent 100%
  );
  position: relative;
}

.modal-header .header-line::after {
  content: '◆';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 8px;
  color: rgba(184, 134, 11, 0.6);
}

.modal-header .header-line:first-child::after {
  left: -8px;
  right: auto;
}

.modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: #3A2817;
  text-align: center;
  margin: 0;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  font-style: italic;
}

.modal-instruction {
  font-family: 'Crimson Pro', serif;
  font-size: 16px;
  font-weight: 400;
  color: #5C4A3A;
  text-align: center;
  margin: 0;
  letter-spacing: 0.3px;
  line-height: 1.6;
}

/* Hourglass - Precision Victorian Timepiece */
.countdown-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
}

.hourglass {
  position: relative;
  width: 50px;
  height: 70px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  filter: drop-shadow(0 2px 4px rgba(74, 55, 40, 0.3));
}

.hourglass-top,
.hourglass-bottom {
  position: relative;
  width: 100%;
  height: 30px;
  background: linear-gradient(
    135deg,
    rgba(184, 134, 11, 0.15) 0%,
    rgba(184, 134, 11, 0.08) 50%,
    rgba(184, 134, 11, 0.15) 100%
  );
  border: 2px solid;
  border-image: linear-gradient(
    135deg,
    #D4A84B,
    #B8860B,
    #8B6914
  ) 1;
  clip-path: polygon(
    10% 0%,
    90% 0%,
    75% 30%,
    50% 50%,
    25% 30%
  );
}

.hourglass-bottom {
  clip-path: polygon(
    50% 50%,
    25% 70%,
    10% 100%,
    90% 100%,
    75% 70%
  );
}

/* Animated falling sand */
.sand {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: calc(25% * var(--progress, 0));
  background: linear-gradient(
    180deg,
    #C9A86A 0%,
    #B8975A 50%,
    #A78649 100%
  );
  clip-path: polygon(
    30% 0%,
    70% 0%,
    60% 50%,
    50% 100%,
    40% 50%
  );
  transition: height 0.1s linear;
  box-shadow:
    inset 0 -1px 2px rgba(0, 0, 0, 0.2),
    0 1px 2px rgba(184, 134, 11, 0.3);
}

/* Sand accumulation in bottom */
.hourglass-bottom::after {
  content: '';
  position: absolute;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  width: calc(30px * var(--progress, 0));
  height: calc(15px * var(--progress, 0));
  background: linear-gradient(
    180deg,
    #A78649 0%,
    #B8975A 50%,
    #C9A86A 100%
  );
  border-radius: 50% 50% 0 0;
  transition: all 0.1s linear;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.countdown-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 600;
  color: #8B6914;
  letter-spacing: 1px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Canvas - Embedded Observation Window */
.pattern-match-modal canvas {
  width: 600px;
  height: 300px;
  touch-action: none; /* Prevent scroll/zoom gestures during star tapping */
  background:
    radial-gradient(
      ellipse at center,
      rgba(10, 15, 35, 1) 0%,
      rgba(5, 8, 20, 1) 100%
    );
  border: 3px solid;
  border-image: linear-gradient(
    45deg,
    #6B5410 0%,
    #8B6914 25%,
    #B8860B 50%,
    #8B6914 75%,
    #6B5410 100%
  ) 1;
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.6),
    inset 0 4px 8px rgba(0, 0, 0, 0.4),
    0 4px 12px rgba(74, 55, 40, 0.4),
    0 0 0 1px rgba(184, 134, 11, 0.2);
  border-radius: 2px;
  cursor: crosshair;
}

/* Progress Tracker */
.progress-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: rgba(184, 134, 11, 0.08);
  border: 1px solid rgba(184, 134, 11, 0.2);
  border-radius: 2px;
  box-shadow: inset 0 1px 3px rgba(74, 55, 40, 0.1);
}

.progress-container::before {
  content: '✦';
  font-size: 14px;
  color: #B8860B;
  animation: pulse-star 2s ease-in-out infinite;
}

@keyframes pulse-star {
  0%, 100% {
    opacity: 0.6;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

.progress-text {
  font-family: 'Crimson Pro', serif;
  font-size: 15px;
  font-weight: 500;
  color: #5C4A3A;
  letter-spacing: 0.5px;
}

/* Entry Animation */
@keyframes modal-reveal {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.pattern-match-modal.active {
  animation: modal-reveal 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Ink spot detail - subtle authenticity */
.modal-content::before {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  top: -10px;
  right: 40px;
  background: radial-gradient(
    circle,
    rgba(74, 55, 40, 0.12) 0%,
    rgba(74, 55, 40, 0.06) 50%,
    transparent 70%
  );
  border-radius: 50%;
  transform: rotate(25deg);
}

/* Paper grain texture overlay */
.modal-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      rgba(139, 109, 71, 0.01) 1px,
      transparent 2px
    ),
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      rgba(139, 109, 71, 0.01) 1px,
      transparent 2px
    );
  pointer-events: none;
  opacity: 0.5;
}


/* Phase Transition Animations */
.modal-content {
  transition: opacity 0.3s ease-out, transform 0.3s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.modal-content.phase-transitioning {
  opacity: 0.4;
  transform: scale(0.98);
}

/* Study Phase - Emphasis on Learning */
.phase-study .modal-title {
  font-size: 32px;
  font-weight: 600;
  color: #3A2817;
  position: relative;
  padding-bottom: 8px;
}

.phase-study .modal-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(58, 40, 23, 0.4) 20%,
    rgba(58, 40, 23, 0.6) 50%,
    rgba(58, 40, 23, 0.4) 80%,
    transparent 100%
  );
  box-shadow: 0 1px 3px rgba(58, 40, 23, 0.3);
}

.phase-study .modal-instruction {
  font-style: italic;
  color: #5A4030;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Challenge Phase - Focus on Interaction */
.phase-challenge .modal-instruction {
  font-weight: 500;
  color: #5C4A3A;
}

/* Visual Progress Bar Enhancement */
.progress-container {
  position: relative;
  overflow: hidden;
}

.progress-container::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--progress-percent, 0%);
  background: linear-gradient(
    90deg,
    rgba(212, 168, 75, 0.15) 0%,
    rgba(184, 134, 11, 0.25) 50%,
    rgba(212, 168, 75, 0.15) 100%
  );
  border-right: 2px solid rgba(184, 134, 11, 0.4);
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: inset 0 0 10px rgba(212, 168, 75, 0.2);
}

.progress-text {
  position: relative;
  z-index: 1;
}

/* Star Click Feedback - Canvas Shimmer */
@keyframes canvas-shimmer {
  0% {
    box-shadow:
      inset 0 0 40px rgba(0, 0, 0, 0.6),
      inset 0 4px 8px rgba(0, 0, 0, 0.4),
      0 4px 12px rgba(74, 55, 40, 0.4),
      0 0 0 1px rgba(184, 134, 11, 0.2);
  }
  50% {
    box-shadow:
      inset 0 0 40px rgba(0, 0, 0, 0.6),
      inset 0 4px 8px rgba(0, 0, 0, 0.4),
      0 4px 12px rgba(74, 55, 40, 0.4),
      0 0 0 1px rgba(184, 134, 11, 0.2),
      0 0 20px rgba(212, 168, 75, 0.4),
      inset 0 0 15px rgba(212, 168, 75, 0.1);
  }
  100% {
    box-shadow:
      inset 0 0 40px rgba(0, 0, 0, 0.6),
      inset 0 4px 8px rgba(0, 0, 0, 0.4),
      0 4px 12px rgba(74, 55, 40, 0.4),
      0 0 0 1px rgba(184, 134, 11, 0.2);
  }
}

.pattern-match-modal canvas.star-clicked {
  animation: canvas-shimmer 0.3s ease-out;
}

/* Completion Flourish - Ornamental Celebration */
@keyframes completion-flourish {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(-5px);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes brass-shimmer {
  0%, 100% {
    text-shadow:
      0 1px 0 rgba(255, 255, 255, 0.4),
      0 0 10px rgba(212, 168, 75, 0);
  }
  50% {
    text-shadow:
      0 1px 0 rgba(255, 255, 255, 0.6),
      0 0 15px rgba(212, 168, 75, 0.6),
      0 0 25px rgba(184, 134, 11, 0.3);
  }
}

.modal-instruction.pattern-complete {
  animation:
    completion-flourish 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
    brass-shimmer 2s ease-in-out 0.6s;
  font-size: 20px;
  font-weight: 600;
  font-style: italic;
  background: linear-gradient(
    135deg,
    #8B6914 0%,
    #B8860B 30%,
    #D4A84B 50%,
    #B8860B 70%,
    #8B6914 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

.modal-instruction.pattern-complete::before {
  content: '✦';
  margin-right: 8px;
  color: #D4A84B;
  animation: pulse-star 1.5s ease-in-out infinite;
}

.modal-instruction.pattern-complete::after {
  content: '✦';
  margin-left: 8px;
  color: #D4A84B;
  animation: pulse-star 1.5s ease-in-out infinite 0.75s;
}

/* Enhanced Hourglass Sand Animation */
.sand {
  transition:
    height 0.15s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.15s ease-out;
  opacity: 0.95;
}

.hourglass-bottom::after {
  transition:
    all 0.15s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.2s ease-out;
}

/* Subtle sand grain texture */
.sand::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      45deg,
      transparent 0px,
      rgba(255, 237, 160, 0.1) 1px,
      transparent 2px
    );
  opacity: 0.4;
  clip-path: inherit;
}

/* Countdown urgency - final seconds */
.countdown-container.urgent .countdown-text {
  animation: urgent-pulse 0.5s ease-in-out infinite;
  color: #A34E00;
}

@keyframes urgent-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.85;
  }
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 900px) {
  :root {
    --telescope-size: min(90vw, 75vh);
  }

  #lens-case {
    left: 16px;
    padding: 12px 10px;
  }

  .lens-bezel {
    width: 36px;
    height: 36px;
  }

  #discoveries-panel {
    width: 280px;
  }

  #observatory-dial {
    bottom: 20px;
  }
}

@media (max-width: 600px) {
  :root {
    --telescope-size: min(95vw, 65vh);
  }

  /* Hide keyboard hints on mobile - no keyboard */
  .key-hint {
    display: none;
  }

  #lens-case {
    top: auto;
    bottom: 100px;
    left: 12px;
    transform: none;
  }

  #discoveries-panel {
    width: 100%;
    height: 35dvh;  /* Reduced from 50vh, using dvh for dynamic viewport */
    max-height: none;
    top: auto;
    bottom: 0;
    transform: translateY(0);
    border-radius: 16px 16px 0 0;
    padding: 12px;
  }

  #discoveries-panel.collapsed {
    transform: translateY(calc(100% - 44px));  /* Smaller peek */
  }

  #discoveries-toggle {
    top: 0;
    left: 50%;
    transform: translate(-50%, -100%) rotate(90deg);
    width: 44px;  /* Smaller toggle */
    height: 80px;
  }

  /* Tighter spacing in discoveries list */
  .discoveries-content {
    padding: 8px;
  }

  .discovery-card {
    padding: 8px;
    margin-bottom: 8px;
  }

  .journal-spine {
    display: none;
  }

  #observatory-dial {
    bottom: auto;
    top: 20px;
  }

  h1 {
    font-size: 2.5rem;
  }

  /* ========================================
     MOBILE MODAL OVERRIDES
     Scale down modals for phone screens
     ======================================== */

  /* Modal containers - reduce size and padding */
  .dso-modal,
  .pattern-match-modal {
    max-height: 85dvh;
    padding: 12px;
    margin: 8px;
    max-width: calc(100vw - 16px);
  }

  /* Canvas elements - scale down significantly */
  .pattern-match-modal canvas,
  .dso-modal canvas,
  .modal-canvas {
    width: 100% !important;
    max-width: 280px !important;
    height: auto !important;
    aspect-ratio: 2/1;
    margin: 0 auto;
  }

  /* Modal headers - smaller text */
  .dso-modal h2,
  .pattern-match-modal h2,
  .modal-title {
    font-size: 1.25rem;
    margin-bottom: 8px;
  }

  .dso-modal h3,
  .pattern-match-modal h3 {
    font-size: 1rem;
  }

  /* Instructions and body text */
  .dso-modal p,
  .pattern-match-modal p,
  .modal-instructions {
    font-size: 0.85rem;
    margin-bottom: 8px;
  }

  /* Challenge containers - tighter spacing */
  .nebula-feature-challenge,
  .galaxy-structure-challenge,
  .cluster-match-challenge {
    padding: 8px;
    gap: 8px;
  }

  /* Feature items - stack on mobile */
  .feature-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px;
  }

  .feature-toggles {
    width: 100%;
    justify-content: flex-start;
  }

  /* Toggle buttons - larger for touch */
  .toggle-btn {
    padding: 10px 16px;
    font-size: 0.8rem;
    min-height: 44px;
  }

  /* Cluster options - single column on very small screens */
  .cluster-options {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* Submit button - full width on mobile */
  .submit-btn {
    width: 100%;
    margin-top: 12px;
    padding: 14px 24px;
    font-size: 1rem;
  }

  /* Hourglass timer - smaller */
  .hourglass-container {
    transform: scale(0.7);
    margin: 8px auto;
  }

  /* Modal frame decorations - hide or reduce */
  .modal-frame-corner {
    width: 20px;
    height: 20px;
  }

  /* Progress indicators - smaller */
  .discovery-progress {
    width: 28px;
    height: 28px;
  }
}


/* ========================================
   LANDSCAPE MOBILE - Optimized for ~375px height
   ======================================== */

@media (max-width: 900px) and (orientation: landscape) {
  /* Modal containers - fit in limited height */
  .dso-modal,
  .pattern-match-modal {
    max-height: 95dvh;
    padding: 8px 12px;
    margin: 4px;
    overflow-y: auto;
  }

  /* Canvas - constrain height for landscape */
  .pattern-match-modal canvas,
  .dso-modal canvas,
  .modal-canvas {
    width: auto !important;
    max-width: 100% !important;
    height: 120px !important;
    max-height: 120px !important;
    aspect-ratio: auto;
    margin: 4px auto;
  }

  /* Modal headers - compact */
  .dso-modal h2,
  .pattern-match-modal h2,
  .modal-title {
    font-size: 1rem;
    margin-bottom: 4px;
  }

  .dso-modal h3,
  .pattern-match-modal h3 {
    font-size: 0.9rem;
    margin-bottom: 4px;
  }

  /* Instructions - minimal */
  .dso-modal p,
  .pattern-match-modal p,
  .modal-instructions {
    font-size: 0.75rem;
    margin-bottom: 4px;
    line-height: 1.3;
  }

  /* Challenge containers - minimal gaps */
  .nebula-feature-challenge,
  .galaxy-structure-challenge,
  .cluster-match-challenge {
    padding: 4px;
    gap: 4px;
  }

  /* Feature items - horizontal and compact */
  .feature-item {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
  }

  .feature-text {
    font-size: 0.75rem;
  }

  /* Toggle buttons - compact but still touchable */
  .toggle-btn {
    padding: 6px 10px;
    font-size: 0.7rem;
    min-height: 32px;
  }

  /* Cluster options - fit in landscape */
  .cluster-options {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .cluster-option canvas {
    height: 60px !important;
  }

  /* Submit button - compact */
  .submit-btn {
    width: auto;
    margin-top: 8px;
    padding: 10px 24px;
    font-size: 0.9rem;
  }

  /* Hourglass timer - much smaller */
  .hourglass-container {
    transform: scale(0.5);
    margin: 2px auto;
  }

  /* Modal frame decorations - minimal */
  .modal-frame-corner {
    width: 12px;
    height: 12px;
  }

  /* Header decorations - hide to save space */
  .modal-header-line,
  .ornate-divider {
    display: none;
  }

  /* Study phase text */
  .study-instruction {
    font-size: 0.7rem;
    margin: 4px 0;
  }

  /* Discovery card in modal */
  .discovery-card-modal {
    padding: 8px;
  }

  /* Modal frame - drastically reduce padding */
  .modal-frame {
    padding: 8px 12px !important;
  }

  /* Modal content - minimal gaps */
  .modal-content {
    gap: 6px !important;
  }

  /* Countdown container - compact */
  .countdown-container {
    padding: 4px 0 !important;
    gap: 4px !important;
  }

  /* Hourglass - much smaller in landscape */
  .hourglass {
    width: 24px !important;
    height: 30px !important;
    transform: scale(0.6);
  }

  .countdown-text {
    font-size: 0.8rem !important;
  }

  /* Progress container - compact */
  .progress-container {
    padding: 6px 12px !important;
    gap: 6px !important;
  }

  .progress-text {
    font-size: 0.75rem !important;
  }

  /* Modal header - minimal */
  .modal-header {
    gap: 6px !important;
    margin-bottom: 0 !important;
  }

  .modal-header h3,
  .modal-title {
    font-size: 0.9rem !important;
    margin: 0 !important;
  }

  /* Header lines - hide to save space */
  .header-line {
    display: none !important;
  }

  /* Frame corners - minimal or hidden */
  .frame-corner {
    width: 16px !important;
    height: 16px !important;
  }

  /* Challenge subheading - compact */
  .challenge-subheading {
    font-size: 0.7rem !important;
    margin: 2px 0 !important;
  }

  /* Modal instruction text */
  .modal-instruction {
    font-size: 0.75rem !important;
    margin: 2px 0 !important;
  }

  /* Prevent modal scrolling by ensuring content fits */
  .pattern-match-modal,
  .dso-modal {
    overflow: hidden !important;
    max-height: 100dvh !important;
  }

  /* Force canvas smaller if still overflowing */
  .pattern-match-modal canvas {
    height: 100px !important;
    max-height: 100px !important;
  }
}


/* ========================================
   DSO DISCOVERY MODALS
   Deep Sky Object Minigames
   Victorian Field Journal Aesthetic
   ======================================== */

/* Base DSO Modal - Inherits pattern-match-modal structure */
.dso-modal {
  position: relative;
  max-width: 720px;
  max-height: 90vh;  /* Constrain to viewport height */
  padding: 24px;
  overflow-y: auto;  /* Enable scrolling for long content */
  background:
    /* Subtle paper texture noise */
    repeating-linear-gradient(
      0deg,
      rgba(74, 55, 40, 0.02) 0px,
      transparent 1px,
      transparent 2px,
      rgba(74, 55, 40, 0.02) 3px
    ),
    /* Aged parchment gradient */
    radial-gradient(
      ellipse at 30% 20%,
      rgba(244, 236, 216, 1) 0%,
      rgba(238, 226, 202, 1) 50%,
      rgba(232, 218, 188, 1) 100%
    );
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 0 80px rgba(184, 134, 11, 0.15);
  border-radius: 2px;
  filter: drop-shadow(0 4px 20px rgba(74, 55, 40, 0.3));
}

/* Parchment edge wear */
.dso-modal::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 5% 5%, rgba(139, 109, 71, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 95% 5%, rgba(139, 109, 71, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 5% 95%, rgba(139, 109, 71, 0.07) 0%, transparent 40%),
    radial-gradient(circle at 95% 95%, rgba(139, 109, 71, 0.09) 0%, transparent 40%);
  pointer-events: none;
  border-radius: 2px;
  opacity: 0.6;
}

/* Dark sky background for DSO modal canvases */
.dso-modal canvas {
  background:
    radial-gradient(
      ellipse at center,
      rgba(10, 15, 35, 1) 0%,
      rgba(5, 8, 20, 1) 100%
    );
  border-radius: 4px;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.6),
    inset 0 0 40px rgba(0, 0, 0, 0.8);
}

/* Phase-based canvas visibility - ONLY for DSO modals */
.dso-modal .phase-study canvas {
  display: block;
}

.dso-modal .phase-challenge > canvas {
  display: none;
}


/* ========================================
   NEBULA & GALAXY FEATURE CHALLENGES
   True/False Feature Identification
   ======================================== */

.nebula-feature-challenge,
.galaxy-structure-challenge {
  width: 100%;
  max-width: 600px;
}

.challenge-subheading {
  font-family: 'Crimson Pro', serif;
  font-size: 15px;
  font-weight: 500;
  color: #5C4A3A;
  text-align: center;
  margin: 0 0 20px 0;
  letter-spacing: 0.4px;
  font-style: italic;
}

/* Challenge Section Container (for Galaxy modal) */
.challenge-section {
  margin-bottom: 28px;
}

.section-header {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  font-weight: 600;
  color: #3A2817;
  text-align: center;
  margin: 0 0 12px 0;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
  border-bottom: 1px solid rgba(139, 109, 71, 0.25);
  padding-bottom: 8px;
}

.section-question {
  font-family: 'Crimson Pro', serif;
  font-size: 15px;
  font-weight: 400;
  color: #5C4A3A;
  text-align: center;
  margin: 0 0 16px 0;
  font-style: italic;
}


/* ========================================
   FEATURE CHECKLIST - Hand-inked Observations
   ======================================== */

.feature-checklist {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.feature-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background:
    /* Fine linen texture */
    repeating-linear-gradient(
      90deg,
      rgba(139, 109, 71, 0.015) 0px,
      transparent 1px,
      transparent 2px
    ),
    linear-gradient(
      to bottom,
      rgba(255, 250, 240, 0.6) 0%,
      rgba(250, 245, 235, 0.4) 100%
    );
  border: 1px solid rgba(139, 109, 71, 0.2);
  border-radius: 3px;
  box-shadow:
    0 1px 3px rgba(74, 55, 40, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: all var(--ease-gentle) 200ms;
}

.feature-item:hover {
  background:
    repeating-linear-gradient(
      90deg,
      rgba(139, 109, 71, 0.02) 0px,
      transparent 1px,
      transparent 2px
    ),
    linear-gradient(
      to bottom,
      rgba(255, 252, 245, 0.8) 0%,
      rgba(252, 248, 240, 0.6) 100%
    );
  border-color: rgba(184, 134, 11, 0.3);
  transform: translateX(2px);
}

.feature-text {
  flex: 1;
  font-family: 'Crimson Pro', serif;
  font-size: 15px;
  font-weight: 400;
  color: #3A2817;
  line-height: 1.5;
  letter-spacing: 0.2px;
}


/* ========================================
   TOGGLE BUTTONS - Brass Slide Switches
   ======================================== */

.toggle-group {
  display: flex;
  gap: 6px;
  background: rgba(74, 55, 40, 0.08);
  padding: 3px;
  border-radius: 4px;
  box-shadow: inset 0 1px 3px rgba(74, 55, 40, 0.2);
}

.toggle-btn {
  padding: 6px 14px;
  font-family: 'Crimson Pro', serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #6B5A45;
  background:
    linear-gradient(
      to bottom,
      rgba(245, 239, 224, 1) 0%,
      rgba(235, 227, 210, 1) 100%
    );
  border: 1px solid rgba(139, 109, 71, 0.3);
  border-radius: 3px;
  cursor: pointer;
  transition: all var(--ease-snappy) 150ms;
  box-shadow:
    0 1px 2px rgba(74, 55, 40, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  position: relative;
  overflow: hidden;
}

.toggle-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.2) 0%,
    transparent 50%
  );
  opacity: 0;
  transition: opacity var(--ease-gentle) 200ms;
}

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

.toggle-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    0 2px 4px rgba(74, 55, 40, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  border-color: rgba(184, 134, 11, 0.4);
}

.toggle-btn:active {
  transform: translateY(0);
  box-shadow:
    0 1px 2px rgba(74, 55, 40, 0.2),
    inset 0 1px 3px rgba(74, 55, 40, 0.15);
}

/* Selected State - Brass Engagement */
.toggle-btn.selected {
  background:
    /* Polished brass gradient */
    linear-gradient(
      135deg,
      #D4A84B 0%,
      #B8860B 50%,
      #8B6914 100%
    );
  color: #2A1F0F;
  border-color: #8B6914;
  box-shadow:
    0 2px 6px rgba(139, 105, 20, 0.4),
    inset 0 1px 0 rgba(255, 237, 160, 0.6),
    inset 0 -1px 2px rgba(74, 55, 40, 0.3);
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(255, 237, 160, 0.4);
}

.toggle-btn.selected::before {
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 237, 160, 0.3) 0%,
    transparent 60%
  );
  opacity: 1;
}

.toggle-btn.selected:hover {
  background:
    linear-gradient(
      135deg,
      #DDB456 0%,
      #C59520 50%,
      #9A7520 100%
    );
  box-shadow:
    0 3px 8px rgba(139, 105, 20, 0.5),
    inset 0 1px 0 rgba(255, 237, 160, 0.7),
    inset 0 -1px 2px rgba(74, 55, 40, 0.4);
}


/* ========================================
   GALAXY TYPE SELECTION - Morphological Classification
   ======================================== */

.type-section {
  margin-bottom: 24px;
}

.type-options {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.type-btn {
  padding: 10px 20px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: #4A3828;
  background:
    /* Aged paper */
    linear-gradient(
      to bottom,
      rgba(250, 245, 235, 1) 0%,
      rgba(242, 235, 220, 1) 100%
    );
  border: 2px solid rgba(139, 109, 71, 0.3);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--ease-gentle) 200ms;
  box-shadow:
    0 2px 4px rgba(74, 55, 40, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  position: relative;
  min-width: 120px;
}

.type-btn:hover {
  background:
    linear-gradient(
      to bottom,
      rgba(255, 250, 240, 1) 0%,
      rgba(248, 242, 228, 1) 100%
    );
  border-color: rgba(184, 134, 11, 0.5);
  transform: translateY(-2px);
  box-shadow:
    0 4px 8px rgba(74, 55, 40, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

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

/* Selected Type - Brass Highlight */
.type-btn.selected {
  background:
    /* Rich brass */
    linear-gradient(
      135deg,
      #D4A84B 0%,
      #C29520 30%,
      #B8860B 60%,
      #8B6914 100%
    );
  color: #1F1609;
  border-color: #6B5410;
  border-width: 3px;
  box-shadow:
    0 3px 10px rgba(139, 105, 20, 0.5),
    inset 0 2px 0 rgba(255, 237, 160, 0.5),
    inset 0 -2px 4px rgba(74, 55, 40, 0.4);
  font-weight: 600;
  text-shadow: 0 1px 1px rgba(255, 237, 160, 0.5);
  transform: translateY(-2px) scale(1.03);
}

.type-btn.selected:hover {
  background:
    linear-gradient(
      135deg,
      #DDB456 0%,
      #CDA030 30%,
      #C59520 60%,
      #9A7520 100%
    );
  box-shadow:
    0 4px 12px rgba(139, 105, 20, 0.6),
    inset 0 2px 0 rgba(255, 237, 160, 0.6),
    inset 0 -2px 4px rgba(74, 55, 40, 0.5);
}


/* ========================================
   CLUSTER MATCHING CHALLENGE
   Visual Identification Grid
   ======================================== */

.cluster-match-challenge {
  width: 100%;
  max-width: 600px;
}

.cluster-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
  margin-top: 20px;
}

.cluster-option {
  aspect-ratio: 1;
  background:
    /* Dark sky background for cluster preview */
    radial-gradient(
      ellipse at 50% 50%,
      rgba(10, 15, 30, 1) 0%,
      rgba(5, 8, 20, 1) 100%
    );
  border: 3px solid var(--brass-primary);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--ease-gentle) 250ms;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.5),
    inset 0 0 20px rgba(0, 0, 0, 0.6),
    inset 0 2px 0 rgba(255, 237, 160, 0.1);
}

/* Brass frame decorative corners */
.cluster-option::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(184, 134, 11, 0.3);
  border-radius: 2px;
  pointer-events: none;
  opacity: 0.6;
  transition: opacity var(--ease-gentle) 250ms;
}

.cluster-option canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.cluster-option:hover {
  border-color: var(--brass-light);
  transform: scale(1.05);
  box-shadow:
    0 6px 20px rgba(184, 134, 11, 0.4),
    inset 0 0 20px rgba(0, 0, 0, 0.6),
    inset 0 2px 0 rgba(255, 237, 160, 0.2),
    0 0 30px rgba(184, 134, 11, 0.2);
}

.cluster-option:hover::before {
  opacity: 1;
  border-color: rgba(212, 168, 75, 0.6);
}

/* Correct Selection - Golden Glow */
.cluster-option.correct {
  border-color: #FFD700;
  border-width: 4px;
  animation: correctPulse 600ms var(--ease-gentle);
  box-shadow:
    0 0 30px rgba(255, 215, 0, 0.8),
    0 0 60px rgba(255, 215, 0, 0.4),
    inset 0 0 20px rgba(255, 215, 0, 0.2);
  pointer-events: none;
}

@keyframes correctPulse {
  0% {
    transform: scale(1);
    box-shadow:
      0 0 20px rgba(255, 215, 0, 0.6),
      0 0 40px rgba(255, 215, 0, 0.3);
  }
  50% {
    transform: scale(1.08);
    box-shadow:
      0 0 40px rgba(255, 215, 0, 1),
      0 0 80px rgba(255, 215, 0, 0.6),
      inset 0 0 30px rgba(255, 215, 0, 0.3);
  }
  100% {
    transform: scale(1.05);
    box-shadow:
      0 0 30px rgba(255, 215, 0, 0.8),
      0 0 60px rgba(255, 215, 0, 0.4),
      inset 0 0 20px rgba(255, 215, 0, 0.2);
  }
}

/* Incorrect Selection - Red Flash */
.cluster-option.incorrect {
  border-color: #C84030;
  animation: incorrectShake 400ms var(--ease-snappy);
  box-shadow:
    0 0 20px rgba(200, 64, 48, 0.6),
    inset 0 0 15px rgba(200, 64, 48, 0.2);
}

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


/* ========================================
   SUBMIT BUTTON - Brass Observatory Lever
   ======================================== */

.submit-btn {
  margin-top: 24px;
  padding: 12px 32px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #1F1609;
  background:
    /* Polished brass gradient */
    linear-gradient(
      135deg,
      #D4A84B 0%,
      #C29520 25%,
      #B8860B 50%,
      #8B6914 75%,
      #6B5410 100%
    );
  border: 3px solid #6B5410;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--ease-gentle) 250ms;
  box-shadow:
    0 4px 12px rgba(107, 84, 16, 0.5),
    inset 0 2px 0 rgba(255, 237, 160, 0.6),
    inset 0 -3px 8px rgba(74, 55, 40, 0.4);
  position: relative;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(255, 237, 160, 0.5);
}

/* Brass shine effect */
.submit-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      135deg,
      rgba(255, 237, 160, 0.3) 0%,
      transparent 40%,
      transparent 60%,
      rgba(255, 237, 160, 0.2) 100%
    );
  pointer-events: none;
}

/* Engraved detail */
.submit-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(74, 55, 40, 0.4) 50%,
    transparent 100%
  );
}

.submit-btn:hover {
  background:
    linear-gradient(
      135deg,
      #DDB456 0%,
      #CDA030 25%,
      #C59520 50%,
      #9A7520 75%,
      #7A5F18 100%
    );
  transform: translateY(-2px);
  box-shadow:
    0 6px 16px rgba(107, 84, 16, 0.6),
    inset 0 2px 0 rgba(255, 237, 160, 0.7),
    inset 0 -3px 8px rgba(74, 55, 40, 0.5),
    0 0 20px rgba(212, 168, 75, 0.3);
}

.submit-btn:active {
  transform: translateY(0);
  box-shadow:
    0 2px 6px rgba(107, 84, 16, 0.5),
    inset 0 1px 0 rgba(255, 237, 160, 0.5),
    inset 0 2px 8px rgba(74, 55, 40, 0.5);
}


/* ========================================
   VALIDATION FEEDBACK - Ink Blot Flash
   ======================================== */

.unanswered-flash {
  animation: unansweredPulse 400ms var(--ease-snappy) 2;
}

.incorrect-flash {
  animation: incorrectPulse 800ms var(--ease-snappy) 1;
}

/* Specific incorrect state for feature items - red border + shake like cluster */
.feature-item.incorrect-flash {
  border-color: #C84030;
  animation: incorrectShake 400ms var(--ease-snappy);
  box-shadow:
    0 0 12px rgba(200, 64, 48, 0.4),
    inset 0 0 8px rgba(200, 64, 48, 0.15);
}

/* Galaxy type section incorrect state */
.type-section.incorrect-flash .type-btn.selected {
  border-color: #C84030;
  animation: incorrectShake 400ms var(--ease-snappy);
  box-shadow:
    0 0 12px rgba(200, 64, 48, 0.4),
    inset 0 0 8px rgba(200, 64, 48, 0.15);
}

@keyframes unansweredPulse {
  0%, 100% {
    background:
      repeating-linear-gradient(
        90deg,
        rgba(139, 109, 71, 0.015) 0px,
        transparent 1px,
        transparent 2px
      ),
      linear-gradient(
        to bottom,
        rgba(255, 250, 240, 0.6) 0%,
        rgba(250, 245, 235, 0.4) 100%
      );
    border-color: rgba(139, 109, 71, 0.2);
  }
  50% {
    background:
      repeating-linear-gradient(
        90deg,
        rgba(200, 64, 48, 0.08) 0px,
        transparent 1px,
        transparent 2px
      ),
      linear-gradient(
        to bottom,
        rgba(255, 235, 230, 0.8) 0%,
        rgba(255, 240, 235, 0.6) 100%
      );
    border-color: rgba(200, 64, 48, 0.5);
    box-shadow:
      0 0 12px rgba(200, 64, 48, 0.3),
      inset 0 0 8px rgba(200, 64, 48, 0.15);
  }
}

@keyframes incorrectPulse {
  0%, 100% {
    background:
      repeating-linear-gradient(
        90deg,
        rgba(139, 109, 71, 0.015) 0px,
        transparent 1px,
        transparent 2px
      ),
      linear-gradient(
        to bottom,
        rgba(255, 250, 240, 0.6) 0%,
        rgba(250, 245, 235, 0.4) 100%
      );
    border-color: rgba(139, 109, 71, 0.2);
  }
  50% {
    background:
      repeating-linear-gradient(
        90deg,
        rgba(200, 64, 48, 0.12) 0px,
        transparent 1px,
        transparent 2px
      ),
      linear-gradient(
        to bottom,
        rgba(255, 220, 215, 0.9) 0%,
        rgba(255, 230, 225, 0.7) 100%
      );
    border-color: rgba(200, 64, 48, 0.6);
    box-shadow:
      0 0 16px rgba(200, 64, 48, 0.4),
      inset 0 0 10px rgba(200, 64, 48, 0.2);
  }
}

/* Error message styling for quiz feedback */
.challenge-instruction.error-message {
  color: rgba(200, 64, 48, 0.9);
  font-weight: 600;
  animation: errorPulse 400ms ease-out 2;
}

@keyframes errorPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Insufficient content states */
.insufficient-clusters,
.no-features {
  font-family: 'Crimson Pro', serif;
  font-size: 16px;
  font-style: italic;
  color: #6B5A45;
  text-align: center;
  padding: 40px 20px;
  opacity: 0.7;
}


/* ========================================
   ROTATE TO LANDSCAPE PROMPT
   Victorian astronomy manual aesthetic
   ======================================== */

.rotate-prompt {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(15, 15, 35, 0.97) 0%, rgba(3, 3, 8, 0.99) 70%),
    rgba(3, 3, 8, 0.98);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

/* Show only in portrait on mobile */
@media (max-width: 600px) and (orientation: portrait) {
  .rotate-prompt {
    display: flex;
  }
}

.rotate-prompt-content {
  position: relative;
  max-width: 280px;
}

/* Subtle background stars */
.rotate-prompt-stars {
  position: absolute;
  inset: -100px;
  background-image:
    radial-gradient(1px 1px at 20px 30px, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 40px 70px, rgba(255, 255, 255, 0.3), transparent),
    radial-gradient(1.5px 1.5px at 90px 40px, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 130px 80px, rgba(255, 255, 255, 0.3), transparent),
    radial-gradient(1.5px 1.5px at 160px 20px, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 200px 60px, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1px 1px at 60px 120px, rgba(255, 255, 255, 0.3), transparent),
    radial-gradient(1.5px 1.5px at 120px 140px, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(1px 1px at 180px 130px, rgba(255, 255, 255, 0.3), transparent);
  background-size: 220px 160px;
  opacity: 0.6;
  animation: twinkle-stars 4s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes twinkle-stars {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}

/* Phone rotation icon */
.rotate-icon {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 28px;
  animation: gentle-rock 2.5s ease-in-out infinite;
}

@keyframes gentle-rock {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(85deg); }
}

.phone-outline {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 56px;
  border: 2px solid var(--brass-light, #d4a84b);
  border-radius: 6px;
  background: rgba(3, 3, 8, 0.8);
  box-shadow:
    0 0 20px rgba(212, 168, 75, 0.15),
    inset 0 0 10px rgba(212, 168, 75, 0.05);
}

.phone-screen {
  position: absolute;
  top: 6px;
  left: 4px;
  right: 4px;
  bottom: 10px;
  background: linear-gradient(
    180deg,
    rgba(212, 168, 75, 0.1) 0%,
    rgba(212, 168, 75, 0.05) 100%
  );
  border-radius: 2px;
}

/* Curved rotation arrow */
.rotate-arrow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 70px;
  height: 70px;
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(212, 168, 75, 0.4);
  border-radius: 50%;
  border-top-color: transparent;
  border-left-color: transparent;
}

.rotate-arrow::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: 8px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid rgba(212, 168, 75, 0.5);
  transform: rotate(45deg);
}

/* Typography */
.rotate-title {
  font-family: var(--font-display, 'Cormorant Garamond'), 'Palatino Linotype', serif;
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--parchment-cream, #f5efe0);
  margin: 0 0 8px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.rotate-subtitle {
  font-family: var(--font-body, 'Crimson Pro'), 'Georgia', serif;
  font-size: 0.95rem;
  font-style: italic;
  font-weight: 300;
  letter-spacing: 0.04em;
  color: rgba(245, 239, 224, 0.7);
  margin: 0 0 24px;
}

/* Decorative ornament */
.rotate-ornament {
  width: 120px;
  height: 16px;
  margin: 0 auto;
  position: relative;
  opacity: 0.5;
}

.rotate-ornament::before {
  content: '✧ · ☽ · ✧';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  letter-spacing: 0.3em;
  color: var(--brass-light, #d4a84b);
}
