/* Base Layout, Reset, Floating HUD, Museum Drawer & Transitions */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang TC", "Noto Sans TC", "Segoe UI", Roboto, sans-serif;
  transition: background-color 0.45s ease, color 0.35s ease;
}

#bg-canvas,
#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#bg-canvas { z-index: 0; }
#stage {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 20px 28px;
  overflow: hidden;
}
#fx-canvas { z-index: 40; }

/* Transition Overlay */
#transition-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  background: #000;
  transition: opacity 0.2s ease;
}

#transition-overlay.flash-white {
  background: #fff;
  opacity: 0.92;
}

#transition-overlay.flash-black {
  background: #000;
  opacity: 0.95;
}

#transition-overlay.crt-off {
  background: #000;
  opacity: 1;
  animation: crtCollapse 0.42s ease-out forwards;
}

@keyframes crtCollapse {
  0% { box-shadow: inset 0 0 0 0 #000; background: rgba(51, 255, 51, 0.35); }
  55% { box-shadow: inset 0 49vh 0 0 #000, inset 0 -49vh 0 0 #000; background: #9eff9e; }
  100% { box-shadow: inset 0 50vh 0 0 #000, inset 0 -50vh 0 0 #000; background: #000; }
}

/* Custom Cursor (Stone Hammer etc.) */
#custom-cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 80;
  pointer-events: none;
  display: none;
  transform: translate(-25%, -25%);
  transition: transform 0.06s ease-out;
  font-size: 46px;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.55));
}

#custom-cursor.active {
  display: block;
}

#custom-cursor.swing {
  transform: translate(-25%, -25%) rotate(-58deg) scale(1.12);
}

/* Subtle Floating HUD */
#hud {
  position: fixed;
  top: 14px;
  left: 16px;
  right: 16px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.hud-chip, .hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.hud-chip:hover, .hud-btn:hover {
  background: rgba(30, 41, 59, 0.8);
  transform: translateY(-1px);
}

.hud-sep { opacity: 0.5; }

/* Era Toast */
#era-toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 55;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 500;
  max-width: min(92vw, 560px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

#era-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#era-toast.golden {
  background: linear-gradient(90deg, rgba(120, 53, 15, 0.96), rgba(180, 83, 9, 0.96));
  border-color: #fde047;
  color: #fef9c3;
  box-shadow: 0 12px 36px rgba(245, 158, 11, 0.45);
}

.museum-eggs-box {
  padding: 12px;
  border-radius: 12px;
  background: rgba(250, 204, 21, 0.08);
  border: 1px solid rgba(250, 204, 21, 0.28);
  margin-bottom: 6px;
}

.museum-eggs-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #fde047;
  margin-bottom: 8px;
}

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

.museum-egg-pill {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.museum-egg-pill.got {
  background: rgba(250, 204, 21, 0.2);
  color: #fef08a;
  border-color: rgba(250, 204, 21, 0.55);
  font-weight: 700;
}

/* Museum / Time Machine Drawer */
#museum-drawer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  justify-content: flex-end;
}

#museum-drawer.hidden {
  display: none;
}

.museum-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
  backdrop-filter: blur(6px);
}

.museum-panel {
  position: relative;
  width: min(92vw, 420px);
  height: 100%;
  background: rgba(15, 23, 42, 0.96);
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  padding: 22px 20px;
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.5);
}

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

.museum-header h2 {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 4px;
}

.museum-header p {
  font-size: 12.5px;
  color: #94a3b8;
}

.museum-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  cursor: pointer;
  font-size: 14px;
}

.museum-close:hover { background: rgba(255, 255, 255, 0.16); }

#museum-progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  margin-bottom: 16px;
}

#museum-progress-fill {
  height: 100%;
  width: 6%;
  background: linear-gradient(90deg, #38bdf8, #a855f7, #f59e0b);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.museum-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.museum-item {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  text-align: left;
  color: inherit;
}

.museum-item:hover:not(.locked) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(56, 189, 248, 0.55);
  transform: translateX(-2px);
}

.museum-item.current {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.14);
}

.museum-item.locked {
  opacity: 0.42;
  cursor: not-allowed;
}

.museum-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.museum-year {
  font-size: 12px;
  font-weight: 800;
  color: #38bdf8;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.museum-tag {
  font-size: 11px;
  color: #94a3b8;
}

.museum-name {
  font-size: 14.5px;
  font-weight: 700;
  margin-bottom: 4px;
}

.museum-note {
  font-size: 12px;
  line-height: 1.45;
  color: #cbd5e1;
}

@media (max-width: 640px) {
  #stage { padding: 58px 12px 20px; }
  .hud-label { display: none; }
}
