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

:root {
  --bg: #0f0a1a;
  --bg-card: rgba(255,255,255,0.06);
  --text: #f0eaff;
  --text-dim: #c8bbdf;
  --accent: #f9a8d4;
  --accent2: #c4b5fd;
  --gold: #fde68a;
  --success: #6ee7b7;
  --danger: #fca5a5;
  --mint: #a7f3d0;
  --glow-purple: rgba(196, 181, 253, 0.25);
  --glow-pink: rgba(249, 168, 212, 0.2);
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 80%, rgba(196,181,253,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(249,168,212,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(167,243,208,0.04) 0%, transparent 60%);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
}

/* === Screens === */
.screen {
  display: none;
  padding: 24px 20px;
  min-height: 100dvh;
  animation: fadeIn 0.4s ease;
}
.screen.active { display: flex; flex-direction: column; }

/* === INTRO CINEMATIC === */
#screen-intro {
  padding: 0;
  position: relative;
  overflow: hidden;
  background: #0a0718;
}
.intro-cinematic {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.intro-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Portal */
.intro-portal {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  z-index: 2;
  opacity: 0;
  transition: transform 1.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 1s ease;
}
.intro-portal.visible {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}
.intro-portal.fade-out {
  opacity: 0;
  transition: opacity 1s ease;
}

.portal-ring {
  position: absolute;
  border-radius: 50%;
  border: 3px solid;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
.ring-outer {
  width: 180px; height: 180px;
  border-color: rgba(192,132,252,0.4);
  animation: ringRotate 8s linear infinite;
}
.ring-middle {
  width: 130px; height: 130px;
  border-color: rgba(251,191,36,0.5);
  animation: ringRotate 5s linear infinite reverse;
}
.ring-inner {
  width: 80px; height: 80px;
  border-color: rgba(255,107,157,0.6);
  animation: ringRotate 3s linear infinite;
}
@keyframes ringRotate {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.portal-core {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  animation: coreGlow 2s ease infinite alternate;
}
@keyframes coreGlow {
  from { filter: drop-shadow(0 0 8px rgba(251,191,36,0.3)); }
  to { filter: drop-shadow(0 0 24px rgba(251,191,36,0.8)); }
}

/* Portal glitch */
.intro-portal.glitch {
  animation: portalGlitch 0.5s ease;
}
@keyframes portalGlitch {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  20% { transform: translate(-48%, -52%) scale(1.05); filter: hue-rotate(90deg); }
  40% { transform: translate(-52%, -49%) scale(0.95); filter: hue-rotate(-90deg); }
  60% { transform: translate(-49%, -51%) scale(1.08); }
  80% { transform: translate(-51%, -50%) scale(0.97); filter: hue-rotate(45deg); }
}

/* Portal explode */
.intro-portal.explode .ring-outer {
  animation: ringExplode 1s ease forwards;
}
.intro-portal.explode .ring-middle {
  animation: ringExplode 0.8s ease 0.1s forwards;
}
.intro-portal.explode .ring-inner {
  animation: ringExplode 0.6s ease 0.2s forwards;
}
.intro-portal.explode .portal-core {
  animation: coreExplode 0.5s ease forwards;
}
@keyframes ringExplode {
  to { transform: translate(-50%, -50%) scale(3); opacity: 0; }
}
@keyframes coreExplode {
  50% { transform: translate(-50%, -50%) scale(2); filter: brightness(3); }
  100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
}

/* Text lines */
.intro-text-layer {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  text-align: center;
  width: 90%;
  max-width: 400px;
}
.intro-line {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease, transform 0.8s ease;
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 12px;
  text-shadow: 0 2px 20px rgba(0,0,0,0.8);
}
.intro-line.visible {
  opacity: 1;
  transform: translateY(0);
}
.intro-line.fade-out {
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.intro-line-3 {
  font-size: 4rem;
}
.intro-line-4 {
  font-size: 1.1rem;
  color: var(--gold);
}
.intro-text-layer.fade-out {
  opacity: 0;
  transition: opacity 1s ease;
}

/* Title card */
.intro-title-layer {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
}
.intro-title-layer.visible {
  opacity: 1;
  transition: opacity 1.5s ease;
  animation: titleReveal 1.5s ease;
}
@keyframes titleReveal {
  from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.intro-main-title {
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(135deg, var(--gold), var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 4px 20px rgba(251,191,36,0.4));
}
.intro-subtitle {
  font-size: 1.2rem;
  color: var(--text-dim);
  margin-top: 8px;
  letter-spacing: 6px;
  text-transform: uppercase;
}

/* Enter button */
.intro-enter-layer {
  position: absolute;
  bottom: 15%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  opacity: 0;
  pointer-events: none;
}
.intro-enter-layer.visible {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 1s ease;
}
.btn-enter-game {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  border: none;
  padding: 18px 40px;
  border-radius: 30px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  animation: pulse 2s infinite;
  letter-spacing: 1px;
}
.btn-enter-game:active { transform: scale(0.95); }

/* Tap to start */
.intro-tap {
  position: absolute;
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  transition: opacity 0.5s ease;
}
.tap-pulse {
  color: var(--text-dim);
  font-size: 1rem;
  animation: tapPulse 2s ease infinite;
}
@keyframes tapPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

@media (max-height: 700px) {
  .intro-portal { top: 15%; }
  .ring-outer { width: 140px; height: 140px; }
  .ring-middle { width: 100px; height: 100px; }
  .ring-inner { width: 60px; height: 60px; }
  .portal-core { font-size: 2rem; }
}
@media (max-width: 360px) {
  .intro-main-title { font-size: 2rem; letter-spacing: 2px; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Buttons === */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: var(--bg);
  border: none;
  padding: 16px 32px;
  border-radius: var(--radius);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 24px var(--glow-pink);
}
.btn-primary:active { transform: scale(0.96); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 2px solid var(--accent2);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:active { background: rgba(192,132,252,0.15); }

.btn-back {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 10px 18px;
  min-height: 44px;
  border-radius: 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s;
}
.btn-back:active {
  background: rgba(255,255,255,0.1);
  transform: scale(0.96);
}

.pulse {
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(255,107,157,0.3); }
  50% { box-shadow: 0 4px 40px rgba(255,107,157,0.6); }
}

/* === Welcome — "Sygnał odebrany" === */
.welcome-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  padding: 48px 20px 40px;
  position: relative;
}

.welcome-header {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.02em;
  animation: fadeIn 0.8s ease;
}
.welcome-header.hidden { display: none; }

.welcome-bottom-area {
  position: absolute;
  bottom: 40px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

@keyframes signalBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Zajączek z falami sygnału */
.signal-avatar {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.signal-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--accent2);
  opacity: 0;
  animation: signalPulse 3s ease-out infinite;
}
.signal-ring.ring-1 {
  width: 100%; height: 100%;
  animation-delay: 0s;
}
.signal-ring.ring-2 {
  width: 130%; height: 130%;
  animation-delay: 0.6s;
  border-color: var(--accent);
}
.signal-ring.ring-3 {
  width: 160%; height: 160%;
  animation-delay: 1.2s;
  border-color: var(--gold);
}
@keyframes signalPulse {
  0% { opacity: 0.6; transform: scale(0.6); }
  100% { opacity: 0; transform: scale(1); }
}

.signal-avatar .professor-bunny {
  font-size: 4.5rem;
  z-index: 1;
  animation: bunnyFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 0 20px var(--glow-purple));
}
@keyframes bunnyFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.03); }
}

h1 {
  font-size: 1.8rem;
  line-height: 1.3;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
h1 .subtitle {
  font-size: 1.2rem;
  display: block;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
}

/* Signal avatar — clickable */
.signal-avatar {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.signal-avatar:active .professor-bunny {
  transform: scale(1.15);
}
.signal-avatar.playing .signal-ring {
  border-color: var(--mint);
}
.signal-avatar.playing .professor-bunny {
  filter: drop-shadow(0 0 24px rgba(167, 243, 208, 0.5));
}

/* Transmission wave + label stacked */
.transmission-wave {
  width: 80%;
  max-width: 280px;
  height: 40px;
  overflow: visible;
}
.tw-line {
  fill: none;
  stroke: var(--accent2);
  stroke-width: 1.5;
  stroke-linecap: round;
  opacity: 0.15;
}
.tw-line-2 {
  stroke: var(--mint);
  opacity: 0;
}

.welcome-bottom-area.playing .tw-line {
  opacity: 0.2;
  animation: twAnim1 2s ease-in-out infinite;
}
.welcome-bottom-area.playing .tw-line-2 {
  opacity: 0.5;
  animation: twAnim2 1.6s ease-in-out infinite;
}

@keyframes twAnim1 {
  0%   { d: path("M0,20 Q25,20 50,20 T100,20 T150,20 T200,20"); }
  25%  { d: path("M0,20 Q25,6 50,20 T100,8 T150,28 T200,20"); }
  50%  { d: path("M0,20 Q25,34 50,20 T100,32 T150,10 T200,20"); }
  75%  { d: path("M0,20 Q25,10 50,20 T100,12 T150,30 T200,20"); }
  100% { d: path("M0,20 Q25,20 50,20 T100,20 T150,20 T200,20"); }
}
@keyframes twAnim2 {
  0%   { d: path("M0,20 Q25,20 50,20 T100,20 T150,20 T200,20"); }
  30%  { d: path("M0,20 Q25,30 50,20 T100,28 T150,14 T200,20"); }
  60%  { d: path("M0,20 Q25,10 50,20 T100,12 T150,26 T200,20"); }
  100% { d: path("M0,20 Q25,20 50,20 T100,20 T150,20 T200,20"); }
}

.transmission-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--mint);
  text-transform: uppercase;
  text-align: center;
  animation: signalBlink 2s ease infinite;
}

.welcome-bottom-area.paused .transmission-label {
  color: var(--gold);
  animation: none;
}
.welcome-bottom-area.paused .tw-line,
.welcome-bottom-area.paused .tw-line-2 {
  animation: none;
  opacity: 0.1;
}

.welcome-bottom-area.done .transmission-label {
  color: var(--gold);
  animation: none;
  opacity: 1;
}
.welcome-bottom-area.done .tw-line,
.welcome-bottom-area.done .tw-line-2 {
  animation: none;
  opacity: 0;
}

.dev-skip {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: 1px solid rgba(245,158,11,0.3);
  color: #f59e0b;
  font-size: 0.6rem;
  padding: 4px 8px;
  border-radius: 8px;
  opacity: 0.3;
  cursor: pointer;
  z-index: 99;
}

.fade-in {
  animation: fadeIn 0.8s ease;
}



/* === Hub — Mapa Czasoprzestrzeni === */
.hub-screen {
  padding: 0;
}

/* Full-screen map */
.map-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
}
.epochs-map {
  position: absolute;
  inset: 0;
  background: url('assets/img/map-bg.png') center/cover no-repeat;
  animation: mapFadeIn 4s ease;
}
@keyframes mapFadeIn {
  0% { opacity: 0; }
  30% { opacity: 0; }
  100% { opacity: 1; }
}

/* Staggered map entrance */
.map-node.map-enter {
  opacity: 0;
  animation: nodeAppear 0.8s ease forwards;
}
.map-lines.map-enter {
  opacity: 0;
  animation: fadeIn 1.2s ease forwards;
}
.map-empty-msg.map-enter {
  opacity: 0;
  animation: emptySlideIn 1.2s ease forwards;
}
@keyframes nodeAppear {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes emptySlideIn {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.hub-bottom.hidden { display: none; }
.epochs-map::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(15, 10, 26, 0.65);
  z-index: 0;
}

/* Empty map — centered dark panel */
.map-empty-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  z-index: 5;
  animation: fadeIn 0.8s ease;
}
.map-empty-msg.hidden { display: none; }
.map-empty-msg .empty-panel {
  background: rgba(15, 10, 26, 0.88);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 32px 28px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  max-width: 300px;
}
.map-empty-msg .empty-icon {
  font-size: 3.5rem;
  margin-bottom: 14px;
  animation: floatSlow 4s ease-in-out infinite;
}
.map-empty-msg p {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.map-empty-msg .empty-hint {
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 18px;
}
.btn-empty-scan {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: var(--bg);
  border: none;
  padding: 14px 28px;
  border-radius: 24px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
}
.btn-empty-scan:active { transform: scale(0.95); }

.btn-empty-code {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 12px 16px;
  min-height: 44px;
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0.4;
  margin-top: 8px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-empty-code:active {
  opacity: 0.8;
}
@keyframes floatSlow {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}

/* Bottom bar — progress + reset */
.hub-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(15, 10, 26, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.progress-ring {
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.progress-count {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.progress-sep {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-weight: 300;
}
.progress-total {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-weight: 600;
}

.hub-bottom-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hub-bottom-spacer { flex: 1; }

/* SVG constellation lines */
.map-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.map-line {
  stroke: rgba(196,181,253,0.08);
  stroke-width: 1;
  stroke-dasharray: 6 4;
}
.map-line.active {
  stroke: rgba(196,181,253,0.25);
  stroke-width: 1.5;
  animation: linePulse 3s ease-in-out infinite;
}
@keyframes linePulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Map nodes */
.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 1;
  transition: transform 0.3s, opacity 0.3s;
  cursor: default;
}

.map-node .node-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto;
  transition: all 0.3s;
}

.map-node .node-label {
  font-size: 0.65rem;
  font-weight: 700;
  margin-top: 5px;
  white-space: nowrap;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.6);
  background: rgba(15,10,26,0.6);
  padding: 2px 6px;
  border-radius: 4px;
}

.map-node .node-check {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: var(--success);
  color: var(--bg);
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Locked node — ghostly "?" */
.map-node.locked {
  cursor: pointer;
}
.map-node.locked .node-icon {
  background: rgba(15, 10, 26, 0.6);
  border: 2px dashed rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.25);
  font-size: 1.2rem;
  font-weight: 700;
  animation: starTwinkle 3s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.4s);
}
@keyframes starTwinkle {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); border-color: rgba(196,181,253,0.4); }
}
.map-node.locked:active .node-icon {
  border-color: rgba(255,255,255,0.3);
}

/* Unlocked node — glowing, clickable */
.map-node.unlocked {
  cursor: pointer;
}
/* Freshly discovered — dramatic entrance */
.map-node.discovered {
  animation: nodeAppear 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes nodeAppear {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0) rotate(-20deg); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.3) rotate(5deg); }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
}
.map-node.unlocked .node-icon {
  background: rgba(15, 10, 26, 0.85);
  border: 2px solid rgba(196,181,253,0.7);
  box-shadow: 0 0 20px var(--glow-purple), 0 0 40px rgba(196,181,253,0.25), inset 0 0 12px rgba(196,181,253,0.1);
  animation: nodeGlow 2.5s ease-in-out infinite;
}
.map-node.unlocked:active {
  transform: translate(-50%, -50%) scale(0.92);
}
.map-node.unlocked .node-label {
  color: var(--accent2);
}
@keyframes nodeGlow {
  0%, 100% { box-shadow: 0 0 16px var(--glow-purple), 0 0 32px rgba(196,181,253,0.08); }
  50% { box-shadow: 0 0 24px var(--glow-purple), 0 0 48px rgba(196,181,253,0.2); }
}

/* Solved node — solid, calm */
.map-node.solved .node-icon {
  background: rgba(15, 10, 26, 0.75);
  border: 2px solid rgba(110,231,183,0.5);
  box-shadow: 0 0 12px rgba(110,231,183,0.2);
}
.map-node.solved .node-label {
  color: var(--success);
  opacity: 0.8;
}

/* QR Scanner button */
.btn-scan-qr {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: var(--bg);
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
}
.btn-scan-qr:active {
  transform: scale(0.95);
}


/* QR Scanner wrap */
.qr-scanner-wrap {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.qr-scanner-wrap.hidden { display: none; }
.qr-scanner-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  color: var(--text);
  font-weight: 600;
}
.qr-scanner-close {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  font-size: 1.4rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
}
#qr-reader {
  flex: 1;
  width: 100%;
}
#qr-reader video { border-radius: 0; }
.qr-scanner-fallback {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 14px;
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0.5;
  text-decoration: underline;
  text-align: center;
}

.btn-reset {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(15,10,26,0.7);
  border: 1.5px solid rgba(252,165,165,0.3);
  color: var(--danger);
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.btn-reset:active {
  opacity: 1;
  border-color: var(--danger);
}

.btn-reset-inline {
  background: none;
  border: 1px solid rgba(252,165,165,0.3);
  color: rgba(252,165,165,0.6);
  font-size: 0.75rem;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-reset-inline:active {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-global-reset {
  position: fixed;
  bottom: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(15,10,26,0.7);
  border: 1.5px solid rgba(252,165,165,0.4);
  color: var(--danger);
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.6;
  z-index: 9998;
  transition: opacity 0.2s;
}
.btn-global-reset:active {
  opacity: 1;
  border-color: var(--danger);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 440px;
  background: rgba(15,10,26,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0.01em;
  font-style: italic;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: toastUp 0.3s ease;
  transition: opacity 0.3s ease;
}
.toast.hidden {
  opacity: 0;
  pointer-events: none;
}
@keyframes toastUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
}
.modal-content h3 { margin-bottom: 6px; }
.modal-hint { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 16px; }
.modal-content input {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--accent2);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.2rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 12px;
  outline: none;
}
.modal-content input:focus { border-color: var(--accent); }
.error { color: var(--danger); font-size: 0.85rem; margin-top: 8px; }
.hidden { display: none !important; }

/* === Epoch Screen === */
#screen-epoch {
  padding: 0;
  position: relative;
  overflow-x: clip;
  overflow-y: auto;
}
#screen-epoch::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, var(--epoch-glow, rgba(196,181,253,0.12)) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, var(--epoch-glow2, rgba(249,168,212,0.08)) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* Floating particles */
#screen-epoch::after {
  content: '';
  position: fixed;
  width: 200%;
  height: 200%;
  top: -50%;
  left: -50%;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(253,230,138,0.4), transparent),
    radial-gradient(1px 1px at 30% 60%, rgba(196,181,253,0.3), transparent),
    radial-gradient(1.5px 1.5px at 50% 40%, rgba(249,168,212,0.35), transparent),
    radial-gradient(1px 1px at 70% 80%, rgba(167,243,208,0.3), transparent),
    radial-gradient(1px 1px at 90% 30%, rgba(253,230,138,0.25), transparent),
    radial-gradient(1.5px 1.5px at 20% 90%, rgba(196,181,253,0.3), transparent),
    radial-gradient(1px 1px at 60% 10%, rgba(249,168,212,0.25), transparent),
    radial-gradient(1px 1px at 80% 50%, rgba(167,243,208,0.35), transparent);
  animation: epochDrift 30s linear infinite;
  pointer-events: none;
  z-index: 0;
}
@keyframes epochDrift {
  from { transform: translate(0, 0); }
  to { transform: translate(10%, 10%); }
}

.epoch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  position: relative;
  z-index: 1;
}
.epoch-badge {
  font-size: 0.7rem;
  background: rgba(255,255,255,0.06);
  padding: 4px 10px;
  border-radius: 12px;
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.08);
  letter-spacing: 0.03em;
}

.epoch-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
  padding: 0 20px 24px;
  position: relative;
  z-index: 1;
}

/* --- Hero icon + title block --- */
.epoch-hero {
  padding: 12px 0 16px;
}
.epoch-icon {
  font-size: 4.5rem;
  animation: epochFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 24px var(--epoch-glow, rgba(196,181,253,0.4)));
  position: relative;
}
.epoch-icon::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 6px;
  background: var(--epoch-glow, rgba(196,181,253,0.3));
  border-radius: 50%;
  filter: blur(6px);
}
@keyframes epochFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}
#epoch-title {
  font-size: 1.5rem;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Professor speech bubble --- */
.epoch-intro {
  position: relative;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 14px 16px 14px 48px;
  color: var(--text-dim);
  line-height: 1.6;
  font-size: 0.88rem;
  width: 100%;
  font-style: italic;
  text-align: left;
  margin: 12px 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.epoch-intro::before {
  content: '🐰';
  position: absolute;
  left: 12px;
  top: 12px;
  font-size: 1.4rem;
  font-style: normal;
}
.epoch-intro::after {
  content: '';
  position: absolute;
  left: 42px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(253,230,138,0.2), transparent);
}

/* --- Part badge --- */
.part-info {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--gold);
  background: rgba(253,230,138,0.06);
  border: 1px solid rgba(253,230,138,0.12);
  letter-spacing: 0.02em;
  margin: 4px 0 12px;
}

/* --- Puzzle card --- */
.puzzle-section {
  width: 100%;
  padding: 20px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}
.puzzle-section::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 20px;
  padding: 1px;
  background: conic-gradient(from var(--border-angle, 0deg), transparent, var(--epoch-glow, rgba(196,181,253,0.3)), transparent, var(--epoch-glow2, rgba(249,168,212,0.2)), transparent);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: borderSpin 8s linear infinite;
  pointer-events: none;
}
@keyframes borderSpin {
  to { --border-angle: 360deg; }
}
@property --border-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

.puzzle-text {
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 16px;
  color: var(--text);
}

.puzzle-interactive {
  margin: 12px 0;
}
.puzzle-interactive input[type="text"] {
  width: 100%;
  max-width: 300px;
  padding: 12px;
  border: 2px solid var(--accent2);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.1rem;
  text-align: center;
  outline: none;
}
.puzzle-interactive input[type="text"]:focus { border-color: var(--accent); }
.puzzle-interactive .btn-answer {
  margin-top: 10px;
}
.puzzle-interactive .answer-feedback {
  margin-top: 8px;
  font-size: 0.9rem;
  min-height: 1.3em;
}
.puzzle-interactive .answer-feedback.wrong {
  color: var(--danger);
  animation: shake 0.4s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.puzzle-interactive .answer-feedback.correct {
  color: var(--success);
}

/* ================================================
   PUZZLE UI — Interactive, animated, kid-friendly
   ================================================ */

/* --- Shared --- */
.puzzle-mission {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(253,230,138,0.08), rgba(249,168,212,0.06));
  border-radius: 12px;
  text-align: left;
  width: 100%;
  line-height: 1.5;
}
.puzzle-sub {
  font-size: 0.83rem;
  color: var(--text-dim);
  margin: 10px 0;
  line-height: 1.5;
}
.answer-input-styled {
  width: 100%;
  padding: 14px;
  border: 2px solid rgba(196,181,253,0.25);
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  color: var(--text);
  font-size: 1.15rem;
  text-align: center;
  letter-spacing: 0.08em;
  font-weight: 600;
  transition: all 0.3s;
}
.answer-input-styled:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--glow-pink), 0 0 40px rgba(249,168,212,0.08);
  background: rgba(255,255,255,0.05);
}
.answer-input-styled::placeholder {
  font-weight: 400;
  letter-spacing: 0;
  opacity: 0.5;
}
.btn-answer-main {
  margin-top: 14px;
  padding: 14px 28px;
  width: 100%;
  font-size: 1.05rem;
  font-weight: 700;
  position: relative;
  overflow: hidden;
}
.btn-answer-main::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%);
  animation: btnShimmer 3s ease-in-out infinite;
}
@keyframes btnShimmer {
  0%, 80% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.answer-feedback {
  margin-top: 12px;
  font-weight: 600;
  min-height: 1.5em;
  font-size: 0.95rem;
}
.answer-feedback.correct {
  color: var(--success);
  animation: correctPop 0.4s ease;
}
@keyframes correctPop {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
.answer-feedback.wrong {
  color: var(--danger);
  animation: shake 0.3s;
}

/* Assembled word display */
.assembled-display {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 16px 0;
  min-height: 52px;
  flex-wrap: wrap;
  padding: 10px 8px;
  background: rgba(0,0,0,0.15);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.04);
}
.letter-bubble {
  width: 42px; height: 46px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border: 2px dashed rgba(255,255,255,0.1);
  border-radius: 10px;
  font-size: 1.3rem; font-weight: 800;
  color: rgba(255,255,255,0.2);
  transition: all 0.3s;
}
.letter-bubble small {
  font-size: 0.5rem; opacity: 0.4; line-height: 1;
}
.letter-bubble.filled {
  border-color: var(--gold);
  border-style: solid;
  color: var(--gold);
  background: rgba(253,230,138,0.08);
  animation: popIn 0.25s ease;
  box-shadow: 0 0 10px rgba(253,230,138,0.12);
}
@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

/* --- DIG / OCEAN: Flip-to-reveal letter slots --- */
.slot-grid {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
}
.letter-slot {
  width: 58px; height: 68px;
  perspective: 500px;
  cursor: pointer;
  position: relative;
}
.letter-slot .slot-front,
.letter-slot .slot-back {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-radius: 14px;
  backface-visibility: hidden;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.letter-slot .slot-front {
  background: rgba(196,181,253,0.1);
  border: 2px solid rgba(196,181,253,0.2);
  font-size: 1.6rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.letter-slot .slot-front:active { transform: scale(0.92); }
.dino-theme .slot-front { background: rgba(74,222,128,0.08); border-color: rgba(74,222,128,0.25); }
.dino-theme .slot-front:hover { box-shadow: 0 0 12px rgba(74,222,128,0.2); }
.ocean-theme .slot-front { background: rgba(34,211,238,0.08); border-color: rgba(34,211,238,0.25); }
.ocean-theme .slot-front:hover { box-shadow: 0 0 12px rgba(34,211,238,0.2); }
.slot-num { font-size: 0.6rem; color: var(--text-dim); margin-top: 2px; }
.letter-slot .slot-back {
  background: rgba(253,230,138,0.06);
  border: 2px solid var(--gold);
  transform: rotateY(180deg);
  box-shadow: 0 0 16px rgba(253,230,138,0.15);
}
.letter-slot.flipped .slot-front { transform: rotateY(180deg); }
.letter-slot.flipped .slot-back { transform: rotateY(0deg); }
.letter-slot .slot-back .tap-char {
  width: 100%; height: 100%;
  border: none; background: none;
  border-radius: 12px;
  font-size: 1.4rem;
}

/* --- KNIGHT: Shield grid --- */
.shield-interactive {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 260px;
  margin: 16px auto;
  padding: 16px;
  background: radial-gradient(circle at center, rgba(196,181,253,0.06), transparent 70%);
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.06);
}
.tap-quad {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  padding: 16px 10px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.tap-quad:active { transform: scale(0.93); }
.tap-quad.filled {
  border-color: var(--q-color, var(--accent2));
  background: rgba(255,255,255,0.05);
  box-shadow: 0 0 16px color-mix(in srgb, var(--q-color, var(--accent2)) 30%, transparent);
}
.q-emoji { font-size: 1.8rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); }
/* tap-digit styles in JUICE section */

/* --- PIRATE: Piece tracker cards --- */
.pirate-tracker {
  display: flex; justify-content: center;
  gap: 10px; margin: 16px 0;
}
.piece-card {
  width: 64px; height: 76px;
  background: rgba(245,158,11,0.06);
  border: 2px dashed rgba(245,158,11,0.25);
  border-radius: 14px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.piece-card:active { transform: scale(0.93); }
.piece-front { font-size: 1.6rem; transition: all 0.3s; }
.piece-num { font-size: 0.65rem; color: var(--text-dim); margin-top: 2px; }
.piece-found-mark {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: var(--success);
  opacity: 0; transition: all 0.3s;
}
.piece-card.found {
  border-color: var(--success); border-style: solid;
  background: rgba(110,231,183,0.08);
  box-shadow: 0 0 12px rgba(110,231,183,0.15);
}
.piece-card.found .piece-found-mark { opacity: 1; animation: popIn 0.3s ease; }
.piece-card.found .piece-front { opacity: 0.2; transform: scale(0.8); }

.pirate-x-hint {
  text-align: center; padding: 14px;
  background: rgba(248,113,113,0.05);
  border: 1px solid rgba(248,113,113,0.15);
  border-radius: 14px;
  opacity: 0; transform: translateY(8px);
  transition: all 0.5s;
  margin-top: 14px;
}
.pirate-x-hint.revealed {
  opacity: 1;
  transform: translateY(0);
}
.x-mark {
  display: inline-block;
  color: var(--danger); font-size: 1.4rem; font-weight: 900;
  margin-right: 6px;
  animation: xPulse 1.5s ease-in-out infinite;
}
@keyframes xPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* --- CIPHER: Mirror visual + Symbol cards --- */
.mirror-visual {
  margin: 12px 0;
}
.mirror-frame {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 28px;
  background: linear-gradient(135deg, rgba(196,181,253,0.08), rgba(249,168,212,0.05));
  border: 2px solid rgba(196,181,253,0.15);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
}
.mirror-frame::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg, transparent, rgba(255,255,255,0.05), transparent);
  animation: mirrorShine 4s linear infinite;
}
@keyframes mirrorShine {
  to { transform: rotate(360deg); }
}
.mirror-reflection {
  font-size: 2.5rem;
  animation: mirrorPulse 2s ease-in-out infinite alternate;
}
@keyframes mirrorPulse {
  from { filter: drop-shadow(0 0 8px rgba(196,181,253,0.3)); transform: scale(1); }
  to { filter: drop-shadow(0 0 20px rgba(196,181,253,0.5)); transform: scale(1.05); }
}
.mirror-frame p {
  font-size: 0.82rem;
  color: var(--text-dim);
  position: relative;
}

.cipher-grid {
  display: flex; justify-content: center;
  gap: 8px; margin: 16px 0; flex-wrap: wrap;
}
.cipher-card {
  display: flex; flex-direction: column;
  align-items: center; gap: 5px;
  padding: 10px 12px;
  border: 2px solid rgba(244,114,182,0.12);
  border-radius: 14px;
  background: rgba(244,114,182,0.03);
  transition: all 0.25s;
  min-width: 54px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.cipher-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--glow-pink), 0 0 30px rgba(249,168,212,0.08);
  background: rgba(244,114,182,0.06);
  transform: translateY(-2px);
}
.cipher-symbol { font-size: 1.4rem; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3)); }
.cipher-equals { font-size: 0.65rem; color: var(--text-dim); opacity: 0.6; }
/* cipher now uses .tap-char */

/* --- CONSTELLATION: Star sky --- */
.star-sky {
  position: relative;
  width: 100%; height: 220px;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(56,189,248,0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 60%, rgba(253,230,138,0.04) 0%, transparent 50%),
    rgba(5,3,15,0.6);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 20px;
  margin: 16px 0;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.3);
}
/* ambient stars */
.star-sky::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 15% 25%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 45% 75%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 75% 15%, rgba(255,255,255,0.25), transparent),
    radial-gradient(1px 1px at 85% 55%, rgba(255,255,255,0.15), transparent),
    radial-gradient(1px 1px at 25% 85%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 55% 45%, rgba(255,255,255,0.15), transparent);
  animation: twinkleField 3s ease-in-out infinite alternate;
}
@keyframes twinkleField {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}
.sky-star {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
  cursor: pointer;
  transition: all 0.3s;
  z-index: 1;
}
.star-glow {
  font-size: 1.5rem;
  color: rgba(253,230,138,0.5);
  animation: twinkle 2s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 4px rgba(253,230,138,0.3));
  transition: all 0.3s;
}
.sky-star.active .star-glow {
  color: var(--gold);
  font-size: 1.8rem;
  filter: drop-shadow(0 0 12px rgba(253,230,138,0.6));
}
@keyframes twinkle {
  0% { opacity: 0.4; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1.1); }
}
.sky-num {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.4);
  background: rgba(0,0,0,0.3);
  padding: 1px 5px;
  border-radius: 4px;
}
.tap-star {
  width: 32px; height: 32px;
  font-size: 1rem;
  background: rgba(0,0,0,0.5);
  border: 1.5px dashed rgba(253,230,138,0.25);
  border-radius: 8px;
  opacity: 0; transition: all 0.3s;
  backdrop-filter: blur(4px);
}
.sky-star.active .tap-star {
  opacity: 1;
  border-style: solid;
}
.tap-star[data-val]:not([data-val=""]) {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(253,230,138,0.3);
}

/* --- ICE: Tap to melt --- */
.ice-scene {
  text-align: center;
  margin: 16px 0;
  padding: 20px;
  background: radial-gradient(ellipse at center, rgba(103,232,249,0.06) 0%, transparent 70%);
  border-radius: 20px;
}
.ice-cube {
  font-size: 3rem;
  padding: 24px 28px;
  display: inline-block;
  border: 3px solid rgba(103,232,249,0.35);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(103,232,249,0.1), rgba(196,181,253,0.06));
  cursor: pointer;
  transition: all 0.3s;
  user-select: none;
  box-shadow: 0 0 24px rgba(103,232,249,0.1), inset 0 0 20px rgba(103,232,249,0.05);
  position: relative;
}
.ice-cube::after {
  content: '';
  position: absolute;
  top: 6px; left: 10%;
  width: 80%; height: 30%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.08), transparent);
  border-radius: 50%;
  pointer-events: none;
}
.ice-cube:active { transform: scale(0.95); }
.ice-cube.shake { animation: iceShake 0.15s; }
@keyframes iceShake {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-4px) rotate(-2deg); }
  75% { transform: translateX(4px) rotate(2deg); }
}
.ice-cube.melted {
  border-color: var(--success);
  background: rgba(110,231,183,0.08);
  box-shadow: 0 0 30px rgba(110,231,183,0.2);
}
.ice-instruction {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 10px 0;
}
.ice-meter {
  width: 80%; max-width: 220px; height: 10px;
  background: rgba(255,255,255,0.05);
  border-radius: 5px; margin: 10px auto;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
}
.ice-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, rgba(103,232,249,0.6), var(--mint));
  border-radius: 5px;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(103,232,249,0.3);
}
.ice-tips-compact {
  display: flex; justify-content: center;
  gap: 16px; font-size: 0.75rem; color: var(--text-dim);
  margin-top: 10px;
  opacity: 0.8;
}

/* --- BALLOON: Tap to inflate --- */
.balloon-scene {
  text-align: center;
  margin: 16px 0;
  padding: 24px 16px;
  background: radial-gradient(ellipse at center, rgba(251,146,60,0.06) 0%, transparent 70%);
  border-radius: 20px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.balloon-body {
  font-size: 4rem;
  display: inline-block;
  cursor: pointer;
  transition: transform 0.3s ease;
  user-select: none;
  filter: drop-shadow(0 6px 16px rgba(251,146,60,0.25));
}
.balloon-body.pumped { animation: pumpBounce 0.15s; }
@keyframes pumpBounce {
  0% { transform: var(--balloon-scale, scale(1)); }
  50% { transform: var(--balloon-scale, scale(1)) scale(1.08); }
  100% { transform: var(--balloon-scale, scale(1)); }
}
.balloon-body.popped {
  animation: popBurst 0.5s;
  filter: drop-shadow(0 0 30px rgba(251,146,60,0.5));
}
@keyframes popBurst {
  0% { transform: scale(2.5); opacity: 1; filter: brightness(2); }
  50% { transform: scale(0.8); }
  100% { transform: scale(1); opacity: 1; filter: brightness(1); }
}
.balloon-tap-hint {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 12px;
  transition: all 0.3s;
}

/* --- FINALE: Envelope deck --- */
.envelope-deck {
  display: flex; justify-content: center;
  gap: 12px; margin: 16px 0;
}
.env-card {
  width: 95px; min-height: 120px;
  perspective: 500px;
  cursor: pointer;
  position: relative;
}
.env-front, .env-back {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-radius: 14px;
  backface-visibility: hidden;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 10px;
}
.env-front {
  background: rgba(255,255,255,0.04);
  border: 2px solid var(--env-color, var(--accent2));
  font-size: 1.3rem; font-weight: 600;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2), 0 0 16px color-mix(in srgb, var(--env-color, var(--accent2)) 15%, transparent);
}
.env-front:active { transform: scale(0.95); }
.env-back {
  background: rgba(15,10,26,0.9);
  border: 2px solid var(--env-color, var(--accent2));
  transform: rotateY(180deg);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.env-card.opened .env-front { transform: rotateY(180deg); }
.env-card.opened .env-back { transform: rotateY(0deg); }
.env-for { font-size: 0.65rem; color: var(--text-dim); margin-bottom: 8px; text-align: center; opacity: 0.8; }
.env-input {
  width: 100%;
  background: rgba(255,255,255,0.04); border: 1px dashed rgba(255,255,255,0.2);
  border-radius: 8px; color: var(--text);
  font-size: 0.85rem; text-align: center; padding: 6px;
}
.env-input:focus { outline: none; border-color: var(--gold); border-style: solid; }

/* === FOTO-MISJE === */
.foto-misja-section {
  width: 100%;
  margin-top: 16px;
  background: linear-gradient(135deg, rgba(255,107,157,0.1), rgba(192,132,252,0.1));
  border: 2px dashed rgba(255,107,157,0.4);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.foto-misja-header {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}
.foto-misja-instruction {
  font-size: 0.95rem;
  color: var(--text-dim);
  margin-bottom: 12px;
  line-height: 1.5;
}

/* Photo challenge UI */
.photo-challenge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.photo-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.btn-camera {
  background: var(--accent);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s;
  display: inline-block;
}
.btn-camera:active { transform: scale(0.95); }
.btn-send-photo { font-size: 0.9rem; }

.photo-result {
  width: 100%;
}
.professor-photo-comment {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  text-align: left;
}
.prof-avatar-small { font-size: 2rem; flex-shrink: 0; }
.prof-bubble {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
}

.photo-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 0.9rem;
}
.loading-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--accent2);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* === JUICE: ripple, tap-char, shooting stars, badges === */
.juice-ripple {
  position: absolute;
  width: 20px; height: 20px;
  border-radius: 50%;
  transform: scale(0);
  animation: juiceRip 0.6s ease-out forwards;
  pointer-events: none;
  opacity: 0.5;
}
@keyframes juiceRip {
  to { transform: scale(8); opacity: 0; }
}

/* Tap-cycler character */
.tap-char {
  width: 44px; height: 50px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 800;
  color: var(--gold);
  background: rgba(0,0,0,0.25);
  border: 2px dashed rgba(253,230,138,0.2);
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}
.tap-char[data-val=""]:not(.tap-pop) { color: rgba(255,255,255,0.2); }
.tap-char:active { transform: scale(0.9); }
.tap-char.tap-pop {
  animation: tapPop 0.15s ease;
}
@keyframes tapPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.tap-char[data-val]:not([data-val=""]) {
  border-style: solid;
  border-color: var(--gold);
  background: rgba(253,230,138,0.08);
}
.tap-digit {
  width: 42px; height: 42px;
  font-size: 1.5rem;
  border-radius: 8px;
}

/* Shooting stars */
.shooting-star {
  position: fixed;
  top: -40px;
  width: 2px; height: 60px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.6), transparent);
  transform: rotate(35deg);
  animation: shootStar 0.8s ease-out forwards;
  pointer-events: none;
  z-index: 0;
}
@keyframes shootStar {
  to { top: 110vh; opacity: 0; }
}

/* Badge flyout */
.badge-flyout {
  position: fixed;
  top: 40%; left: 50%;
  transform: translate(-50%, -50%) scale(0.3);
  font-size: 1.2rem; font-weight: 800;
  padding: 14px 32px;
  border-radius: 40px;
  background: linear-gradient(145deg, var(--mint), var(--accent2));
  color: var(--bg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 1000;
  animation: badgeFly 2.2s ease forwards;
  pointer-events: none;
  white-space: nowrap;
}
@keyframes badgeFly {
  10% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); }
  40% { opacity: 1; transform: translate(-50%, -60%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -200%) scale(0.5); }
}

/* Screen shake (balloon pop) */
.screen-shake {
  animation: screenShake 0.4s ease;
}
@keyframes screenShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-4px) rotate(-0.5deg); }
  30% { transform: translateX(4px) rotate(0.5deg); }
  45% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-1px); }
}

/* Ice cracks */
.ice-crack {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  animation: crackAppear 0.3s ease forwards;
}
@keyframes crackAppear {
  to { opacity: 1; }
}
.ice-crack-1::before, .ice-crack-2::before, .ice-crack-3::before {
  content: '';
  position: absolute;
  background: rgba(255,255,255,0.3);
}
.ice-crack-1::before {
  top: 20%; left: 30%; width: 40%; height: 2px;
  transform: rotate(-15deg);
}
.ice-crack-2::before {
  top: 50%; left: 20%; width: 60%; height: 2px;
  transform: rotate(25deg);
}
.ice-crack-3::before {
  top: 70%; left: 15%; width: 50%; height: 2px;
  transform: rotate(-35deg);
}
.ice-crack-1::after { content: ''; position: absolute; top: 22%; left: 50%; width: 2px; height: 25%; background: rgba(255,255,255,0.2); transform: rotate(10deg); }
.ice-crack-2::after { content: ''; position: absolute; top: 40%; left: 45%; width: 2px; height: 30%; background: rgba(255,255,255,0.25); transform: rotate(-20deg); }

/* Ice steam */
.ice-steam {
  position: absolute;
  bottom: 0;
  width: 6px; height: 6px;
  background: rgba(255,255,255,0.3);
  border-radius: 50%;
  animation: steamRise 1.5s ease-out forwards;
  pointer-events: none;
}
@keyframes steamRise {
  0% { transform: translateY(0) scale(1); opacity: 0.5; }
  100% { transform: translateY(-60px) scale(2.5); opacity: 0; }
}

/* Constellation SVG lines */
.star-lines {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}
.star-line {
  stroke: rgba(167,243,208,0.1);
  stroke-width: 0.5;
  stroke-dasharray: 90;
  stroke-dashoffset: 0;
}
.star-line.drawn {
  stroke: var(--mint);
  stroke-width: 0.8;
  stroke-dasharray: 90;
  stroke-dashoffset: 90;
  animation: drawLine 0.8s ease forwards;
}
@keyframes drawLine {
  to { stroke-dashoffset: 0; }
}

/* === Photo capture (local) === */
.photo-capture {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.photo-prompt {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 4px;
}
.photo-preview-area {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 4/3;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(255,107,157,0.3);
}
.camera-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.camera-icon { font-size: 2.5rem; }
.photo-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-saved {
  font-size: 0.8rem;
  color: var(--success);
}

/* === Collage === */
.collage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 12px;
  width: 100%;
}
.collage-item {
  background: var(--bg-card);
  border-radius: 10px;
  overflow: hidden;
}
.collage-item img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}
.collage-label {
  padding: 4px 8px;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
}
.collage-time {
  opacity: 0.6;
}

/* Hints */
.hints-section {
  margin-top: 14px;
  text-align: center;
}
.btn-hint {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 10px 16px;
  min-height: 44px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0.5;
}
.btn-hint:active { opacity: 0.8; }
.btn-hint:disabled { opacity: 0.2; cursor: default; }

.hints-container {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hint-item {
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
  animation: hintSlide 0.4s ease;
  text-align: left;
  font-style: italic;
}
@keyframes hintSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Solved — Vortex Celebration === */
.epoch-solved {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-height: 80dvh;
  position: relative;
  padding-top: 24px;
}

/* --- Vortex overlay --- */
.vortex-overlay {
  position: relative;
  width: 100%;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  margin-top: 20px;
}

.vortex-ring {
  position: absolute;
  width: 220px; height: 220px;
  border-radius: 50%;
  border: 3px solid transparent;
  background:
    conic-gradient(from 0deg, var(--gold), var(--accent), var(--accent2), var(--mint), var(--gold));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #fff calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #fff calc(100% - 3px));
  opacity: 0;
  animation: vortexRingIn 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
             vortexSpin 3s linear 0.5s infinite;
  filter: blur(1px);
}
.vortex-ring-2 {
  width: 160px; height: 160px;
  animation: vortexRingIn 1s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s forwards,
             vortexSpinReverse 2.5s linear 0.6s infinite;
  filter: blur(0.5px);
}
.vortex-ring-3 {
  width: 100px; height: 100px;
  animation: vortexRingIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards,
             vortexSpin 2s linear 0.7s infinite;
  filter: none;
}

@keyframes vortexRingIn {
  0% { opacity: 0; transform: scale(0) rotate(-90deg); }
  60% { opacity: 0.9; transform: scale(1.15) rotate(180deg); }
  100% { opacity: 0.7; transform: scale(1) rotate(360deg); }
}
@keyframes vortexSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes vortexSpinReverse {
  from { transform: rotate(0deg); }
  to { transform: rotate(-360deg); }
}

/* Vortex icon — spins in and lands */
.vortex-icon {
  position: absolute;
  font-size: 4rem;
  z-index: 2;
  opacity: 0;
  filter: drop-shadow(0 0 20px rgba(253,230,138,0.6));
  animation: iconVortexIn 1.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s forwards;
}
@keyframes iconVortexIn {
  0% { opacity: 0; transform: scale(0.3) rotate(-180deg); filter: drop-shadow(0 0 0px transparent); }
  50% { opacity: 1; transform: scale(1.4) rotate(540deg); filter: drop-shadow(0 0 30px rgba(253,230,138,0.8)); }
  70% { transform: scale(0.95) rotate(680deg); }
  100% { opacity: 1; transform: scale(1) rotate(720deg); filter: drop-shadow(0 0 16px rgba(253,230,138,0.5)); }
}

/* Shockwave ring */
.vortex-shockwave {
  position: absolute;
  width: 60px; height: 60px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  opacity: 0;
  z-index: 1;
  animation: shockwaveExpand 0.8s ease-out 1.6s forwards;
}
@keyframes shockwaveExpand {
  0% { opacity: 0.8; transform: scale(0.5); }
  100% { opacity: 0; transform: scale(4); }
}

/* Vortex fade-out */
.vortex-overlay.fade-out .vortex-ring,
.vortex-overlay.fade-out .vortex-ring-2,
.vortex-overlay.fade-out .vortex-ring-3 {
  animation: vortexFadeOut 0.8s ease forwards;
}
@keyframes vortexFadeOut {
  to { opacity: 0; transform: scale(0.5); }
}
.vortex-overlay.fade-out .vortex-icon {
  animation: iconSettle 0.8s ease forwards;
}
@keyframes iconSettle {
  0% { opacity: 1; transform: scale(1) rotate(720deg); }
  100% { opacity: 0; transform: scale(1.5) rotate(720deg); }
}

/* --- Solved content --- */
.solved-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 0 16px 24px;
  animation: solvedContentIn 0.8s ease;
}
.solved-content.hidden { display: none; }
@keyframes solvedContentIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.solved-hero-icon {
  font-size: 4.5rem;
  filter: drop-shadow(0 0 20px rgba(253,230,138,0.4));
  animation: heroFloat 3s ease-in-out infinite;
}
@keyframes heroFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.solved-hero-name {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: linear-gradient(90deg, var(--gold), var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.epoch-solved h3 {
  color: var(--success);
  font-size: 1.4rem;
  text-shadow: 0 0 20px rgba(110,231,183,0.3);
}
#solved-message {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
}
.next-clue {
  position: relative;
  background: linear-gradient(135deg, rgba(196,181,253,0.12), rgba(249,168,212,0.08));
  border: 2px solid var(--accent2);
  box-shadow: 0 0 18px 2px var(--glow-purple);
  border-radius: 18px;
  padding: 18px 20px 18px 20px;
  font-size: 1rem;
  color: var(--text);
  width: 100%;
  text-align: left;
  line-height: 1.6;
  animation: cluePopIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.next-clue.hidden { display: none; }
.clue-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 6px;
  text-shadow: 0 2px 12px var(--glow-pink);
}
.clue-text {
  font-weight: 600;
}
@keyframes cluePopIn {
  0% { opacity: 0; transform: translateY(20px) scale(0.96); box-shadow: 0 0 0 0 var(--glow-purple); }
  60% { opacity: 1; transform: translateY(-4px) scale(1.03); box-shadow: 0 0 28px 6px var(--glow-purple); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Clue mini-modal */
.clue-modal-content {
  text-align: center;
  padding: 28px 24px;
}
.clue-modal-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}
.clue-modal-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}
.clue-modal-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 18px;
}
.clue-modal-buttons {
  display: flex;
  gap: 10px;
  width: 100%;
}
.clue-modal-buttons .btn-primary,
.clue-modal-buttons .btn-secondary {
  flex: 1;
}
.clue-modal-photo {
  width: 100%;
  margin-bottom: 14px;
}
.clue-modal-photo.hidden { display: none; }

/* --- Solved actions (bottom) --- */
.solved-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

/* Foto accordion */
.foto-accordion {
  border: 1.5px solid rgba(249,168,212,0.3);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255,255,255,0.03);
}
.foto-accordion.hidden { display: none; }
.foto-accordion-toggle {
  width: 100%;
  padding: 14px 18px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
}
.foto-accordion-toggle:active {
  background: rgba(249,168,212,0.06);
}
.foto-accordion-toggle::after {
  content: '▸';
  float: right;
  transition: transform 0.3s;
}
.foto-accordion.expanded .foto-accordion-toggle::after {
  transform: rotate(90deg);
}
.foto-accordion-body {
  padding: 0 16px 16px;
}
.foto-accordion-body.hidden { display: none; }

/* === Finale === */
.finale-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  gap: 20px;
  position: relative;
  overflow: hidden;
}

/* --- Assembly animation phase --- */
.assembly-phase {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 24px;
  position: relative;
}
.assembly-title {
  font-size: 1.3rem;
  color: var(--gold);
  opacity: 0.9;
  animation: fadeIn 0.6s ease;
}
.assembly-ring-wrap {
  position: relative;
  width: 220px;
  height: 220px;
}
.assembly-ring {
  position: absolute;
  inset: 0;
}
.assembly-part {
  position: absolute;
  font-size: 1.8rem;
  left: 50%;
  top: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0);
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 0 6px rgba(253,230,138,0.3));
}
.assembly-part.landed {
  opacity: 1;
  transform:
    translate(-50%, -50%)
    rotate(calc(360deg / var(--total) * var(--i)))
    translateY(-90px)
    rotate(calc(-360deg / var(--total) * var(--i)))
    scale(1);
}
.assembly-core {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  transition: all 0.8s ease;
  filter: drop-shadow(0 0 8px rgba(253,230,138,0.2));
}
.assembly-core.powered {
  font-size: 4rem;
  filter: drop-shadow(0 0 30px rgba(253,230,138,0.7));
  animation: corePulse 0.6s ease infinite alternate;
}
@keyframes corePulse {
  from { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  to { transform: translate(-50%, -50%) scale(1.1) rotate(10deg); }
}

@keyframes solvedAppear {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* --- Congrats phase --- */
.congrats-phase {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
  animation: solvedAppear 0.6s ease;
}
.congrats-phase.hidden { display: none; }

.machine-assembly {
  position: relative;
}
.machine-final {
  font-size: 6rem;
  animation: machineGlow 2s ease infinite alternate;
}
@keyframes machineGlow {
  from { filter: drop-shadow(0 0 10px rgba(251,191,36,0.3)); transform: scale(1); }
  to { filter: drop-shadow(0 0 30px rgba(251,191,36,0.8)); transform: scale(1.05); }
}

.finale-content h1 {
  font-size: 2.4rem;
  margin: 0;
}
.congrats-subtitle {
  font-size: 1.1rem;
  color: var(--accent2);
  font-weight: 600;
  margin: -8px 0 4px;
}

.professor-speech {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  font-style: italic;
  line-height: 1.6;
  color: var(--text-dim);
}

.easter-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 20px;
  background: linear-gradient(135deg, rgba(253,230,138,0.1), rgba(249,168,212,0.08));
  border: 2px solid rgba(253,230,138,0.25);
  border-radius: 20px;
  width: 100%;
}
.easter-banner-icon {
  font-size: 2.5rem;
  animation: bunnyFloat 3s ease-in-out infinite;
}
.easter-msg {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--gold);
  line-height: 1.3;
  margin: 0;
  text-shadow: 0 0 20px rgba(253,230,138,0.5);
}

.finale-album {
  width: 100%;
  border-color: rgba(196,181,253,0.3);
}

/* --- Finale flash & starburst --- */
.finale-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(253,230,138,0.8), rgba(249,168,212,0.4), transparent 70%);
  z-index: 50;
  animation: finaleFlash 0.8s ease-out forwards;
  pointer-events: none;
}
@keyframes finaleFlash {
  0% { opacity: 0; transform: scale(0.3); }
  20% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.5); }
}

.starburst-ray {
  position: absolute;
  top: 40%;
  left: 50%;
  width: 3px;
  height: 120px;
  background: linear-gradient(to top, rgba(253,230,138,0.8), transparent);
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(var(--angle)) scaleY(0);
  z-index: 49;
  animation: rayShoot 1s ease-out forwards;
  pointer-events: none;
}
@keyframes rayShoot {
  0% { transform: translateX(-50%) rotate(var(--angle)) scaleY(0); opacity: 1; }
  40% { transform: translateX(-50%) rotate(var(--angle)) scaleY(1.2); opacity: 0.8; }
  100% { transform: translateX(-50%) rotate(var(--angle)) scaleY(2); opacity: 0; }
}

/* --- Congrats entrance animations --- */
.congrats-phase .machine-final {
  animation: machineGlow 2s ease infinite alternate, machinePopIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes machinePopIn {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  60% { transform: scale(1.2) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

.congrats-phase h1 {
  animation: titleSlamIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}
@keyframes titleSlamIn {
  0% { transform: scale(0.5) translateY(30px); opacity: 0; }
  60% { transform: scale(1.08) translateY(-5px); opacity: 1; }
  100% { transform: scale(1) translateY(0); }
}

.congrats-phase .congrats-subtitle {
  animation: fadeIn 0.6s ease 0.5s both;
}
.congrats-phase .professor-speech {
  animation: fadeIn 0.6s ease 0.7s both;
}

/* Continue button on congrats screen — hidden until JS reveals */
.finale-continue-btn {
  opacity: 0;
  margin-top: 8px;
  transition: opacity 0.5s ease;
}
.finale-continue-btn.visible {
  opacity: 1;
}

/* === Farewell screen === */
.farewell-content {
  gap: 24px;
  padding: 30px 16px;
}
.farewell-speech {
  animation: fadeIn 0.8s ease both;
}
.farewell-content .easter-banner {
  animation: bannerDropIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.6s both;
}
@keyframes bannerDropIn {
  0% { transform: translateY(-60px) scale(0.8); opacity: 0; }
  60% { transform: translateY(8px) scale(1.05); opacity: 1; }
  100% { transform: translateY(0) scale(1); }
}
.easter-banner-icon {
  animation: eggHop 1.5s ease-in-out 1.4s infinite;
}
@keyframes eggHop {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-8px) rotate(-5deg); }
  50% { transform: translateY(0) rotate(0deg); }
  75% { transform: translateY(-6px) rotate(5deg); }
}
.farewell-content .finale-album {
  animation: fadeIn 0.6s ease 1.2s both;
}
.farewell-content .btn-secondary {
  animation: fadeIn 0.6s ease 1.5s both;
}

/* Confetti */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* === Responsive Tweaks === */
@media (max-width: 360px) {
  h1 { font-size: 1.6rem; }
  h1 .subtitle { font-size: 1.1rem; }
  .signal-avatar { width: 130px; height: 130px; }
  .signal-avatar .professor-bunny { font-size: 3.5rem; }
  .map-node .node-icon { width: 44px; height: 44px; font-size: 1.3rem; }
  .map-node .node-label { font-size: 0.6rem; }
  .epoch-icon { font-size: 3.5rem; }
  .machine-final { font-size: 4rem; }
  .solved-animation { font-size: 3rem; }
  .balloon-body { font-size: 3rem; }
  .assembly-core.powered { font-size: 3rem; }
  .assembly-ring-wrap { width: 180px; height: 180px; }
}

@media (min-height: 800px) {
  .welcome-wrapper { gap: 28px; }
}

/* Make solved section visible when not hidden */
.epoch-solved:not(.hidden) {
  display: flex;
}

/* Focus-visible outlines for keyboard/accessibility */
:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

/* Initial attention pulse on tap-cycler elements */
.tap-char:not([data-val]):not(.tap-pop),
.tap-digit:not([data-val]):not(.tap-pop) {
  animation: tapHint 1.5s ease-in-out 0.5s 2;
}
@keyframes tapHint {
  0%, 100% { border-color: rgba(253,230,138,0.2); }
  50% { border-color: rgba(253,230,138,0.6); box-shadow: 0 0 10px rgba(253,230,138,0.15); }
}

/* 360px modal fix */
@media (max-width: 360px) {
  .modal-content {
    padding: 20px 16px;
  }
}

