@font-face {
  font-family: "FuturaHandwritten";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/FuturaHandwritten.ttf") format("truetype");
}

:root {
  --home-background-color: #faf5ee;
  --bg-step-1: url("../assets/background/home-background.png");
  --bg-step-2: url("../assets/background/bg-step2.png");
  --bg-step-3: url("../assets/background/bg-step3.png");
  --bg-step-4: url("../assets/background/bg-step4.png");
  --bg-step-5: var(--bg-step-4);
  --bg-step-6: var(--bg-step-3);
  --stage-scale: 1;
  --footer-height: 60px;
}

html, body { width: 100%; height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--home-background-color);
  font-family: "FuturaHandwritten", sans-serif;
  color: #333;
  font-size: 20px;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; }
#main {
  position: relative;
  width: 100%;
  height: calc(100% - var(--footer-height));
  overflow: hidden;
  background-color: var(--home-background-color);
}

/* Background Cross-fade Layers */
.bg-layers {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.bg-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
  will-change: opacity;
}
.bg-layer.active {
  opacity: 1;
}
.bg-layer[data-step="1"] { background-image: var(--bg-step-1); }
.bg-layer[data-step="2"] { background-image: var(--bg-step-2); }
.bg-layer[data-step="3"] { background-image: var(--bg-step-3); }
.bg-layer[data-step="4"] { background-image: var(--bg-step-4); }
.bg-layer[data-step="5"] { background-image: var(--bg-step-5); }
.bg-layer[data-step="6"] { background-image: var(--bg-step-6); }

#splash {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
#slideshow-container {
  width: 0;
  height: 0;
  position: absolute;
  margin: auto;
  inset: 0;
  z-index: 5;
}
#slideshow {
  width: 960px;
  height: 540px;
  position: absolute;
  left: -480px;
  top: -270px;
  transform: scale(var(--stage-scale));
  transform-origin: center;
  pointer-events: none;
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}
#slideshow.transition-exit {
  opacity: 0;
  transform: scale(calc(var(--stage-scale) * 0.9));
  pointer-events: none;
}
/* Exact first-screen coordinates from upstream 0_Slides_Intro.js. */
#title {
  position: absolute;
  left: 130px;
  top: 80px;
  width: 700px;
  margin: 0;
  font-size: 100px;
  font-weight: 400;
  line-height: 0.9em;
  text-align: center;
}
#title .small { font-size: 0.75em; }
#subtitle {
  position: absolute;
  left: 267px;
  top: 356px;
  width: 420px;
  margin: 0;
  color: #aaa;
  font-size: 15px;
  font-weight: 400;
  text-align: center;
}
#start-button {
  position: absolute;
  left: 382px;
  top: 410px;
  width: 195px;
  height: 55px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #000;
  cursor: pointer;
  transform-origin: 97.5px 27.5px;
  transition: transform 0.1s ease-out;
  text-align: center;
  user-select: none;
  pointer-events: auto;
}
#start-button .button-background {
  position: absolute;
  background-image: url("../assets/ui/button.png");
  background-size: 100%;
  width: 250px;
  height: 125px;
  top: -35px;
  left: -30px;
  pointer-events: none;
}
#start-button .button-text {
  position: absolute;
  top: 14px;
  left: 5px;
  width: 180px;
  height: 30px;
  font-family: "FuturaHandwritten", sans-serif;
  font-size: 24px;
  font-weight: 400;
  line-height: normal;
  text-align: center;
  pointer-events: none;
}
#start-button:hover, #start-button:focus-visible { transform: scale(1.02); }
#start-button:hover .button-background, #start-button:focus-visible .button-background { background-position: 0 -125px; }
#start-button:active { transform: scale(0.95); }
#start-button:disabled { cursor: default; }
#start-button:disabled .button-background { background-position: 0 -250px; }
#start-button:disabled .button-text { color: #ccc; }
#start-button:disabled { transform: none; }
#start-button:focus-visible { outline: 2px dashed #666; outline-offset: 8px; border-radius: 8px; }

#footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  width: 100%;
  height: var(--footer-height);
  background: #181818;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-sizing: border-box;
}

/* Brand Partnerships & Honors Section */
.footer-brand-section {
  display: flex;
  align-items: center;
  gap: 18px;
  user-select: none;
  z-index: 2;
}

.brand-item {
  display: flex;
  align-items: center;
  gap: 10px;
  transition: opacity 0.2s ease, transform 0.2s ease;
  cursor: default;
}
.brand-item:hover {
  transform: translateY(-1px);
}

.brand-logo {
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}
.brand-logo.pku-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
}
.brand-logo.reddot-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.brand-divider {
  width: 1px;
  height: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.04));
}

.brand-label {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: #ffffff;
  white-space: nowrap;
  line-height: 1.1;
}

.brand-label .red-accent {
  color: #e30613;
  font-weight: 700;
}

.brand-label-group {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-sublabel {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.8px;
  color: #9e9e9e;
  text-transform: uppercase;
  line-height: 1;
  margin-top: 2px;
}

/* Pro Version Button & Footer Actions */
.footer-actions {
  display: flex;
  align-items: center;
  z-index: 2;
}

.btn-pro-version {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px 0 12px;
  background: linear-gradient(135deg, #1f1d18 0%, #2b251a 50%, #1a1814 100%);
  border: 1px solid rgba(220, 185, 125, 0.45);
  border-radius: 17px;
  color: #f7e6c4;
  cursor: pointer;
  outline: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 230, 180, 0.2);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.btn-pro-version::before {
  content: "";
  position: absolute;
  top: 0;
  left: -75%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 235, 185, 0.25), transparent);
  transform: skewX(-22deg);
  transition: left 0.6s ease;
  pointer-events: none;
}

.btn-pro-version:hover::before {
  left: 130%;
}

.btn-pro-version:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #2c271d 0%, #3a311f 50%, #242017 100%);
  border-color: rgba(240, 205, 140, 0.85);
  box-shadow: 0 6px 20px rgba(212, 175, 105, 0.25), 0 2px 6px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 240, 200, 0.35);
  color: #fff3d8;
}

.btn-pro-version:active {
  transform: translateY(0) scale(0.96);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(0, 0, 0, 0.4);
}

.btn-pro-version:focus-visible {
  outline: 2px solid #d4af69;
  outline-offset: 3px;
}

.pro-sparkle {
  font-size: 13px;
  color: #f5c46b;
  line-height: 1;
  text-shadow: 0 0 6px rgba(245, 196, 107, 0.6);
  transition: transform 0.3s ease;
}

.btn-pro-version:hover .pro-sparkle {
  transform: rotate(20deg) scale(1.15);
}

.pro-text {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.8px;
  color: #f7e6c4;
}

.pro-tag {
  display: inline-block;
  padding: 1px 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #d4af69 0%, #aa8238 100%);
  color: #12100a;
  border-radius: 8px;
  line-height: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Pro Modal & Toast */
.pro-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s;
}
.pro-modal:not([hidden]) {
  opacity: 1;
  visibility: visible;
}
.pro-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.pro-modal-card {
  position: relative;
  width: 90%;
  max-width: 480px;
  background: #1c1c1e;
  border: 1px solid rgba(220, 185, 125, 0.32);
  border-radius: 16px;
  padding: 28px 28px 24px;
  box-sizing: border-box;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
  transform: translateY(12px) scale(0.97);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  color: #f2f2f2;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
}
.pro-modal:not([hidden]) .pro-modal-card {
  transform: translateY(0) scale(1);
}
.pro-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  color: #aaa;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.pro-modal-close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.pro-modal-header {
  margin-bottom: 12px;
}
.pro-modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: rgba(212, 175, 105, 0.15);
  border: 1px solid rgba(212, 175, 105, 0.4);
  color: #e5be75;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}
.pro-modal-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.5px;
}
.pro-modal-desc {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
  color: #c2c2c2;
}
.pro-modal-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.32);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}
.pro-feature-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.pro-feature-icon {
  font-size: 18px;
  line-height: 1.2;
}
.pro-feature-text strong {
  display: block;
  font-size: 13px;
  color: #f0f0f0;
  font-weight: 600;
  margin-bottom: 2px;
}
.pro-feature-text p {
  margin: 0;
  font-size: 12px;
  color: #8e8e93;
  line-height: 1.4;
}
.pro-modal-footer {
  display: flex;
  justify-content: flex-end;
}
.pro-modal-action-btn {
  padding: 10px 22px;
  background: linear-gradient(135deg, #d4af69 0%, #aa8238 100%);
  border: none;
  border-radius: 8px;
  color: #12100a;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.pro-modal-action-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.pro-toast {
  position: fixed;
  bottom: calc(var(--footer-height) + 16px);
  right: 28px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(28, 28, 30, 0.95);
  border: 1px solid rgba(212, 175, 105, 0.5);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  color: #f7e6c4;
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.pro-toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.pro-toast .toast-sparkle {
  color: #f5c46b;
  font-size: 14px;
}
#sound {
  position: absolute;
  left: 13px;
  top: 5px;
  width: 100px;
  height: 50px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  user-select: none;
  text-align: left;
}
#sound > span { position: absolute; }
#sound-icon {
  background: url("../assets/ui/sound.png");
  background-size: auto 100%;
  width: 40px;
  height: 40px;
  top: 5px;
  left: 2px;
}
#sound-on, #sound-off { left: 52px; top: 0; font-size: 30px; line-height: 55px; }
#sound-on { color: #fff; }
#sound-off { color: #595959; }
#sound[data-sound="off"] #sound-icon { background-position: -40px 0; }
#sound[data-sound="on"] #sound-off, #sound[data-sound="off"] #sound-on { display: none; }
.sharing { position: absolute; width: 120px; height: 40px; top: 10px; right: 13px; display: flex; }
.sharing img { width: 40px; height: 40px; border: 0; }
#sound:focus-visible, a:focus-visible { outline: 2px dashed #fff; outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ==========================================================
   EXPERIMENT 2: 4-Stage Wizard Flow, Paper Logo & Resident Dots
   ========================================================== */
.flow-stage {
  width: 960px;
  height: 540px;
  position: absolute;
  left: -480px;
  top: -270px;
  transform: scale(var(--stage-scale));
  transform-origin: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease-out, transform 0.35s ease-out, visibility 0.35s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  z-index: 5;
}
.flow-stage.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#step-6-stage {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 540px;
  box-sizing: border-box;
}

/* Common Typography & Nav Buttons */
.stage-title {
  margin: 25px 0 6px 0;
  font-size: 42px;
  letter-spacing: 2px;
  color: #1a1a1a;
  text-align: center;
}
.stage-subtitle {
  margin: 0 0 20px 0;
  font-size: 18px;
  color: #665;
  text-align: center;
}
.step-nav-bar {
  margin-top: 55px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.step-nav-btn {
  padding: 8px 22px;
  border-radius: 20px;
  border: 1.5px solid #222;
  background: rgba(255, 255, 255, 0.9);
  font-family: inherit;
  font-size: 18px;
  color: #222;
  cursor: pointer;
  transition: all 0.15s ease-out;
}
.step-nav-btn:hover {
  background: #222;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.step-nav-btn.next-btn {
  background: #222;
  color: #fff;
}
.step-nav-btn.next-btn:hover {
  background: #444;
}

/* ----------------------------------------------------
   Step 2 (2/4): Paper-torn Logo Emerge & Float Animation
   ---------------------------------------------------- */
.logo-wrapper {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 380px;
  height: 290px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.paper-logo {
  max-width: 340px;
  max-height: 270px;
  width: auto;
  height: auto;
  object-fit: contain;
  opacity: 0;
  transform: translateY(6px);
  filter: drop-shadow(0 8px 18px rgba(45, 30, 15, 0.22));
  user-select: none;
  -webkit-user-drag: none;
  will-change: opacity, transform, filter;
}

#step-2-stage.active .paper-logo,
#step-3-stage.active .paper-logo {
  animation: logoGentleIntro 2.2s cubic-bezier(0.25, 1, 0.5, 1) forwards,
             logoContinuousFloat 3.6s ease-in-out 2.2s infinite;
}

@keyframes logoGentleIntro {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  38% {
    opacity: 1;
    transform: translateY(0);
  }
  68% {
    opacity: 1;
    transform: translateY(-4px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes logoContinuousFloat {
  0% {
    transform: translateY(0);
    filter: drop-shadow(0 8px 18px rgba(45, 30, 15, 0.22));
  }
  50% {
    transform: translateY(-16px);
    filter: drop-shadow(0 18px 26px rgba(45, 30, 15, 0.28));
  }
  100% {
    transform: translateY(0);
    filter: drop-shadow(0 8px 18px rgba(45, 30, 15, 0.22));
  }
}

.upload-wrapper {
  position: absolute;
  top: 310px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 500px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.upload-button {
  display: block;
  position: relative;
  width: 230px;
  height: 55px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  outline: none;
  transition: transform 0.12s ease-out;
  margin: 0 auto;
}
.upload-button:hover { transform: scale(1.05); }
.upload-button:active { transform: scale(0.95); }
.upload-button:focus-visible { outline: 2px dashed #333; outline-offset: 6px; border-radius: 8px; }

.upload-button-bg {
  position: absolute;
  top: -35px;
  left: -10px;
  width: 250px;
  height: 125px;
  background-image: url("../assets/ui/button.png");
  background-size: 100% auto;
  background-position: 0 0;
  pointer-events: none;
}
.upload-button:hover .upload-button-bg,
.upload-button.file-ready .upload-button-bg {
  background-position: 0 -125px;
}
.upload-button-text {
  position: relative;
  display: block;
  font-size: 26px;
  line-height: 55px;
  color: #111;
  text-align: center;
  user-select: none;
  letter-spacing: 0.5px;
}
.upload-hint {
  margin: 30px 0 0 0;
  font-size: 12px;
  letter-spacing: 0.4px;
  color: #665;
  user-select: none;
}
.upload-feedback {
  margin-top: 8px;
  min-height: 24px;
  font-size: 15px;
  padding: 4px 12px;
  border-radius: 6px;
  display: inline-block;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
  pointer-events: none;
}
.upload-feedback.show-error {
  opacity: 1;
  transform: translateY(0);
  background: rgba(220, 50, 50, 0.12);
  border: 1px dashed #d33;
  color: #b11;
  pointer-events: auto;
}
.upload-feedback.show-success {
  opacity: 1;
  transform: translateY(0);
  background: rgba(40, 140, 60, 0.12);
  border: 1px dashed #284;
  color: #162;
  pointer-events: auto;
}

/* ----------------------------------------------------
   Step 4 (4/4): Options & Final Submission Stage
   ---------------------------------------------------- */
.options-container {
  width: 640px;
  max-width: 640px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.options-container .stage-title {
  margin: 6px 0 4px 0;
  font-size: 36px;
  letter-spacing: 2px;
  color: #1a1a1a;
}
.options-container .stage-subtitle {
  margin: 0 0 10px 0;
  font-size: 15px;
  color: #665;
}

/* Layer 1: Population Slider */
.population-slider-container {
  width: 100%;
  max-width: 600px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.population-badge-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 4px;
}
.population-badge {
  display: inline-block;
  padding: 3px 20px;
  background: #faf5ee;
  color: #1a1a1a;
  border: 2px solid #1a1a1a;
  border-radius: 25px 22px 24px 23px / 22px 25px 23px 24px;
  font-family: "FuturaHandwritten", sans-serif;
  font-size: 26px;
  font-weight: bold;
  letter-spacing: 1px;
  box-shadow: 2px 3px 0 rgba(26, 26, 26, 0.9);
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.slider-track-wrapper {
  position: relative;
  width: 100%;
  max-width: 600px;
  padding: 0 4px;
  box-sizing: border-box;
}
#population-slider {
  --slider-percent: 25%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #1a1a1a 0%, #1a1a1a var(--slider-percent), #dedbd4 var(--slider-percent), #dedbd4 100%);
  outline: none;
  border: 1.5px solid #1a1a1a;
  margin: 6px 0;
  cursor: pointer;
  box-sizing: border-box;
  display: block;
}
#population-slider:focus-visible {
  outline: 2px dashed #1a1a1a;
  outline-offset: 4px;
}
#population-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: transparent;
}
#population-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #faf5ee;
  border: 2.5px solid #1a1a1a;
  cursor: pointer;
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.2);
  margin-top: -8.5px;
  transition: transform 0.1s ease, background 0.1s ease;
}
#population-slider::-webkit-slider-thumb:hover {
  transform: scale(1.18);
  background: #ffffff;
}
#population-slider::-webkit-slider-thumb:active {
  transform: scale(0.95);
  background: #f0ebe2;
}
#population-slider::-moz-range-track {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #dedbd4;
  border: 1.5px solid #1a1a1a;
}
#population-slider::-moz-range-progress {
  height: 8px;
  border-radius: 4px;
  background: #1a1a1a;
}
#population-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #faf5ee;
  border: 2.5px solid #1a1a1a;
  cursor: pointer;
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s ease, background 0.1s ease;
}
#population-slider::-moz-range-thumb:hover {
  transform: scale(1.18);
  background: #ffffff;
}
#population-slider::-moz-range-thumb:active {
  transform: scale(0.95);
  background: #f0ebe2;
}
.slider-ticks {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  height: 22px;
  margin-top: 2px;
  margin-bottom: 14px;
}
.slider-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  white-space: nowrap;
  user-select: none;
  transition: color 0.15s ease, font-weight 0.15s ease;
}
.slider-tick[data-index="0"] { left: 11px; }
.slider-tick[data-index="1"] { left: calc(11px + (100% - 22px) * 0.25); }
.slider-tick[data-index="2"] { left: calc(11px + (100% - 22px) * 0.5); }
.slider-tick[data-index="3"] { left: calc(11px + (100% - 22px) * 0.75); }
.slider-tick[data-index="4"] { left: calc(100% - 11px); }
.slider-tick:hover {
  color: #111;
  font-weight: bold;
}
.slider-tick.active {
  color: #111;
  font-weight: 600;
}
.slider-tick.locked {
  color: #444;
  font-weight: 500;
  opacity: 0.75;
}
.slider-tick.locked:hover {
  color: #777;
}
@keyframes lockShake {
  0%, 100% { transform: translateX(-50%); }
  20%, 60% { transform: translateX(calc(-50% - 4px)); }
  40%, 80% { transform: translateX(calc(-50% + 4px)); }
}
.slider-tick.locked.shake {
  animation: lockShake 0.3s ease-in-out;
}

/* Layer 2: 5 Toggle Factor Chips (compact, hand-drawn frame, centered text) */
.factor-grid {
  width: 100%;
  max-width: 620px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 10px;
  margin-bottom: 4px;
}
.factor-chip {
  position: relative;
  width: 196px;
  min-height: 62px;
  box-sizing: border-box;
  padding: 8px 12px;
  background: #faf5ee;
  border-radius: 16px 13px 15px 14px / 13px 16px 14px 15px;
  border: 2px solid #1a1a1a;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
  box-shadow: 2px 3px 0 rgba(26, 26, 26, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  user-select: none;
  font-family: inherit;
}
.factor-chip:hover {
  transform: translateY(-2px);
  box-shadow: 3px 5px 0 rgba(26, 26, 26, 0.85);
}
.factor-chip:active {
  transform: translate(2px, 3px);
  box-shadow: 0 0 0 rgba(26, 26, 26, 0.85);
}
.factor-chip:focus-visible {
  outline: 2px dashed #1a1a1a;
  outline-offset: 3px;
}
.factor-chip[aria-pressed="true"],
.factor-chip.selected {
  background: #1a1a1a;
  box-shadow: 1px 2px 0 rgba(26, 26, 26, 0.5);
}
.factor-chip[aria-pressed="true"] .factor-title,
.factor-chip.selected .factor-title,
.factor-chip[aria-pressed="true"] .factor-desc,
.factor-chip.selected .factor-desc {
  color: #faf5ee;
}
.factor-chip[aria-pressed="true"]::after,
.factor-chip.selected::after {
  content: "✓";
  position: absolute;
  top: 3px;
  right: 8px;
  font-size: 12px;
  font-weight: bold;
  color: #faf5ee;
}
.factor-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 3px;
  width: 100%;
}
.mode-title,
.factor-title {
  font-size: 14px;
  font-weight: bold;
  color: #111;
  line-height: 1.2;
}
.mode-desc,
.factor-desc {
  margin: 0;
  font-size: 11px;
  color: #555;
  line-height: 1.3;
}

/* Options Container overrides for Feedback & Submit button */
.options-container .upload-feedback {
  min-height: 20px;
  margin-top: 4px;
  margin-bottom: 4px;
  font-size: 14px;
  text-align: center;
}
.options-container .step-nav-bar {
  margin-top: 6px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 1.5x Sketch Submit Button */
.sketch-submit-btn {
  position: relative;
  width: 292px;
  height: 82px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform-origin: center center;
  transition: transform 0.1s ease-out;
  text-align: center;
  user-select: none;
  pointer-events: auto;
}
.sketch-submit-btn .button-background {
  position: absolute;
  background-image: url("../assets/ui/button.png");
  background-size: 100%;
  width: 375px;
  height: 188px;
  top: -55px;
  left: -44px;
  filter: invert(1);
  pointer-events: none;
  transition: filter 0.15s ease-out;
}
.sketch-submit-btn .button-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 292px;
  height: 82px;
  font-family: "FuturaHandwritten", sans-serif;
  font-size: 28px;
  font-weight: 400;
  line-height: 82px;
  color: #ffffff;
  text-align: center;
  pointer-events: none;
  letter-spacing: 0.5px;
}
.sketch-submit-btn:hover,
.sketch-submit-btn:focus-visible {
  transform: scale(1.02);
}
.sketch-submit-btn:hover .button-background,
.sketch-submit-btn:focus-visible .button-background {
  background-position: 0 -187.5px;
  filter: invert(1) brightness(1.15);
}
.sketch-submit-btn:active {
  transform: scale(0.96);
}
.sketch-submit-btn:disabled {
  cursor: default;
  transform: none;
}
.sketch-submit-btn:disabled .button-background {
  background-position: 0 -375px;
  filter: invert(1) opacity(0.6);
}
.sketch-submit-btn:disabled .button-text {
  color: #ccc;
}
.sketch-submit-btn:focus-visible {
  outline: 2px dashed #fff;
  outline-offset: 4px;
  border-radius: 6px;
}

/* ----------------------------------------------------
   Footer 4-Dot Progress with Resident Aura
   ---------------------------------------------------- */
#stage-progress {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-50% + 8px));
  margin: 0;
  height: 60px;
  width: auto;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease-out, transform 0.35s ease-out;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}
#stage-progress.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.progress-dot {
  position: relative;
  z-index: 2;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.75);
  margin: 0 12px;
  cursor: pointer;
  box-sizing: border-box;
  background: transparent;
  transition: all 0.25s ease-out;
}
.progress-dot:hover {
  transform: scale(1.18);
  border-color: #fff;
}
.progress-dot.completed {
  border-color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.4);
}
.progress-dot.active {
  background: #fff;
  border-color: #fff;
  transform: scale(1.12);
}

/* ----------------------------------------------------
   Footer Matrix Numbers & Data Stream (1.0s on switch, no outer frame)
   ---------------------------------------------------- */
.footer-matrix-canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  height: 60px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  border: none !important;
  background: transparent;
  transition: opacity 0.15s ease-out;
}

.footer-matrix-canvas.active {
  opacity: 1;
}

.footer-matrix-canvas.fade-out {
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

/* Tooltip for progress dots (matching upstream balloon.css) */
.progress-dot[data-balloon] { position: relative; }
.progress-dot[data-balloon]:before,
.progress-dot[data-balloon]:after {
  opacity: 0;
  pointer-events: none;
  transition: all 0.12s ease-out;
  bottom: 100%;
  left: 50%;
  position: absolute;
  z-index: 100;
  transform: translate(-50%, 4px);
  transform-origin: bottom center;
}
.progress-dot[data-balloon]:hover:before,
.progress-dot[data-balloon]:hover:after {
  opacity: 1;
  transform: translate(-50%, -6px);
}
.progress-dot[data-balloon]:after {
  background: rgba(17, 17, 17, 0.92);
  border-radius: 4px;
  color: #fff;
  content: attr(data-balloon);
  font-size: 15px;
  font-family: inherit;
  padding: 5px 11px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  margin-bottom: 8px;
}
.progress-dot[data-balloon]:before {
  content: "";
  border: 5px solid transparent;
  border-top-color: rgba(17, 17, 17, 0.92);
  margin-bottom: -2px;
}

/* Replay button */
.reset-button {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 8px 16px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  color: #333;
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-out, transform 0.15s ease-out;
}
.reset-button.visible { opacity: 1; pointer-events: auto; }
.reset-button:hover { background: #fff; transform: scale(1.05); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12); }

@media (prefers-reduced-motion: reduce) {
  #start-button { transition: none; }
  #slideshow { transition: none; }
  .paper-logo { animation: none !important; opacity: 1 !important; transform: none !important; }
  .footer-matrix-canvas { display: none !important; }
}

.upload-scope-note {
  margin: 6px 0 0 0;
  font-size: 12px;
  letter-spacing: 0.4px;
  color: #665;
  text-align: center;
  user-select: none;
}
