:root {
  color: #eef6ff;
  background: #07111f;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: #eef6ff;
  background: #07111f;
}

body.modal-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

.space-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    #07111f
    url("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDABQODxIPDRQSEBIXFRQYHjIhHhwcHj0sLiQySUBMS0dARkVQWnNiUFVtVkVGZIhlbXd7gYKBTmCNl4x9lnN+gXz/2wBDARUXFx4aHjshITt8U0ZTfHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHz/wAARCAAVAAwDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAMBBAUG/8QAIxAAAgEDAwQDAAAAAAAAAAAAAQIAAwQRBRIhIkGBwRUycf/EABUBAQEAAAAAAAAAAAAAAAAAAAED/8QAFxEBAQEBAAAAAAAAAAAAAAAAABEBIf/aAAwDAQACEQMRAD8A5tbZm6lUhe2TLa2tJEUPQd2IyTuwPGJr0NEuVI6rdjx9ufUf8JeLwLmkgHZTj1LTqdJoXVQDdk7v2S+qXJcncPIhCOB//9k=")
    center top / cover no-repeat;
}

/* A plain JPEG paints everywhere. Browsers that understand image-set prefer WebP. */
body.bg-ready .space-bg {
  background-image: url("./assets/space-bg-540.jpg");
  background-image: image-set(
    url("./assets/space-bg-540.webp") type("image/webp"),
    url("./assets/space-bg-540.jpg") type("image/jpeg")
  );
}

.space-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 12%, rgba(80, 160, 255, 0.18), transparent 26%),
    radial-gradient(circle at 82% 18%, rgba(110, 190, 255, 0.12), transparent 22%),
    linear-gradient(180deg, rgba(7, 17, 31, 0.38), rgba(7, 17, 31, 0.78));
  pointer-events: none;
}

button {
  font: inherit;
  touch-action: manipulation;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 6;
  padding: 8px 12px;
  border-radius: 10px;
  color: #07111f;
  background: #f7fbff;
  font-weight: 800;
}

.skip:focus {
  top: 12px;
}

.app {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  margin: 0 auto;
  padding:
    max(16px, env(safe-area-inset-top))
    16px
    calc(28px + env(safe-area-inset-bottom));
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 10px 10px 12px;
  border: 1px solid rgba(200, 230, 255, 0.16);
  border-radius: 12px;
  background: rgba(5, 12, 24, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.18);
}

.brand-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.brand-title {
  margin: 0;
  color: #f7fbff;
  font-size: clamp(16px, 4.5vw, 20px);
  font-weight: 800;
  line-height: 1.28;
  letter-spacing: 0;
}

.brand-sub {
  margin: 4px 0 0;
  color: #d7e8ff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.brand-sprite,
.brand-logo {
  display: block;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand-sprite {
  width: 44px;
  height: 44px;
}

.brand-logo {
  width: 74px;
  height: auto;
}

.brand-sprite:not([src]),
.brand-logo:not([src]) {
  visibility: hidden;
}

.progress,
.q-card,
.result-panel {
  border: 1px solid rgba(200, 230, 255, 0.14);
  border-radius: 14px;
  background: rgba(9, 18, 33, 0.84);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

.progress {
  margin-bottom: 14px;
  padding: 12px 14px 14px;
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #dcecff;
  font-size: 14px;
  font-weight: 700;
}

.progress-track {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(200, 230, 255, 0.12);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, #46a6ff, #7b6dff);
  transition: width 220ms ease;
}

.q-card {
  margin-top: 14px;
  overflow: hidden;
}

.q-card:first-of-type {
  margin-top: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(200, 230, 255, 0.08);
  color: #dcecff;
}

.panel-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.q-body,
.result-body {
  padding: 14px 14px 16px;
}

.stem {
  margin: 0 0 12px;
  color: #f7fbff;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.55;
}

.options {
  display: grid;
  gap: 8px;
}

.option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid rgba(200, 230, 255, 0.18);
  border-radius: 12px;
  color: #f4f8ff;
  background: rgba(5, 12, 24, 0.72);
  text-align: left;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    transform 120ms ease;
}

.option:active:not(:disabled) {
  transform: translateY(1px);
}

.key {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  color: #d7ecff;
  background: rgba(120, 180, 255, 0.16);
  font-size: 13px;
  font-weight: 800;
}

.label {
  flex: 1 1 auto;
}

.mark {
  flex: 0 0 auto;
  min-height: 1em;
  color: inherit;
  font-size: 13px;
  font-weight: 800;
}

.option:focus {
  outline: none;
}

.option:focus-visible,
.action:focus-visible,
.celebrate-close:focus-visible,
.brand-title:focus-visible {
  outline: 2px solid #9fd4ff;
  outline-offset: 2px;
}

@media (hover: hover) {
  .option:not(:disabled):hover {
    border-color: rgba(160, 210, 255, 0.5);
    background: rgba(16, 40, 72, 0.88);
  }
}

.option.is-correct {
  border-color: #7deec4;
  color: #f3fff9;
  background: rgba(16, 78, 58, 0.94);
}

.option.is-correct .key {
  color: #073226;
  background: #b9ffe4;
}

.option.is-wrong {
  border-color: #ff9aa6;
  color: #fff6f7;
  background: rgba(102, 28, 40, 0.94);
}

.option.is-wrong .key {
  color: #4a1018;
  background: #ffd0d6;
}

.q-card.is-locked .option:not(.is-correct):not(.is-wrong) {
  opacity: 0.72;
}

.option:disabled {
  cursor: default;
}

.feedback {
  margin: 12px 0 0;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.4;
}

.feedback.is-right {
  color: #b6ffd9;
}

.feedback.is-wrong {
  color: #ffc9d0;
}

.explain {
  margin: 8px 0 0;
  padding: 12px;
  border: 1px solid rgba(200, 230, 255, 0.12);
  border-radius: 12px;
  color: #f2f7ff;
  background: rgba(4, 10, 20, 0.78);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.65;
}

.result-panel {
  overflow: hidden;
}

.metric-label {
  margin: 14px 0 0;
  color: #b9d8ff;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.metric-label:first-child {
  margin-top: 0;
}

.metric-value {
  margin: 4px 0 0;
  color: #ffffff;
  font-size: clamp(42px, 12vw, 60px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  text-align: center;
}

.metric-percent {
  color: #f7fbff;
}

.prize-note {
  margin: 16px 0 0;
  color: #ffe3a3;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
}

.action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 54px;
  margin-top: 18px;
  border: 0;
  border-radius: 12px;
  color: #ffffff;
  background: linear-gradient(135deg, #46a6ff, #7b6dff);
  box-shadow: 0 16px 30px rgba(70, 166, 255, 0.24);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

.action:active {
  transform: translateY(1px);
}

.celebrate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.celebrate-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 8, 16, 0.72);
}

.celebrate-card {
  position: relative;
  width: min(100%, 360px);
  max-height: min(92vh, 760px);
  max-height: min(92dvh, 760px);
  overflow: auto;
  padding: 18px 18px 16px;
  border: 1px solid rgba(200, 230, 255, 0.22);
  border-radius: 18px;
  background: #0c1528;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  animation: celebrate-in 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.celebrate-art {
  display: block;
  width: min(62vw, 220px);
  height: auto;
  margin: 4px auto 2px;
}

.celebrate-art:not([src]) {
  visibility: hidden;
}

.celebrate-card h2 {
  margin: 0 0 8px;
  color: #ffffff;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
}

.celebrate-close {
  position: absolute;
  top: 10px;
  right: 10px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(200, 230, 255, 0.2);
  border-radius: 999px;
  color: #e7f2ff;
  background: rgba(255, 255, 255, 0.06);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.noscript {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  margin: 12px auto;
  padding: 0 16px;
  color: #ffe3a3;
  font-weight: 800;
}

.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;
}

@keyframes celebrate-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 420px) {
  .app {
    padding-right: 12px;
    padding-left: 12px;
  }

  .brand-logo {
    width: 64px;
  }

  .brand-sprite {
    width: 40px;
    height: 40px;
  }

  .celebrate-card h2 {
    font-size: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .progress-bar,
  .option,
  .celebrate-card {
    animation: none;
    transition: none;
  }
}
