:root {
  color-scheme: dark;
  --ink: #f6eedf;
  --muted: #cdbba6;
  --gold: #f5c451;
  --gold-hi: #fff0b0;
  --gold-lo: #b9781a;
  --ember: #ff8a3d;
  --panel: rgba(24, 15, 38, 0.74);
  --edge: rgba(245, 196, 81, 0.32);
  --heading: "Cinzel", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html { background: #120c24; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(60rem 30rem at 50% 108%, rgba(255, 150, 70, 0.55), transparent 70%),
    radial-gradient(1.5px 1.5px at 12% 14%, #fff8, transparent), radial-gradient(1px 1px at 28% 8%, #fff7, transparent),
    radial-gradient(1.5px 1.5px at 46% 18%, #fff6, transparent), radial-gradient(1px 1px at 63% 6%, #fff8, transparent),
    radial-gradient(1.5px 1.5px at 79% 15%, #fff6, transparent), radial-gradient(1px 1px at 91% 9%, #fff7, transparent),
    linear-gradient(180deg, #120c24 0%, #24174a 32%, #5b2c5e 62%, #b5505a 84%, #e9874c 100%);
  background-attachment: fixed;
}
body::after {
  content: "";
  position: fixed;
  inset: auto 0 0 0;
  height: 34vh;
  z-index: 0;
  pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 300' preserveAspectRatio='none'%3E%3Cpath d='M0 300V190l90-60 80 45 90-80 80 65 90-50 90 60 90-90 90 70 90-30 90 55 90-75 90 50 80-35 60 25v160z' fill='%23361d45'/%3E%3Cpath d='M0 300v-60l120-40 100 35 110-45 120 50 110-35 120 40 120-45 120 38 120-33 160 30v65z' fill='%231a0f26'/%3E%3C/svg%3E")
    bottom / 100% 100% no-repeat;
}
main { position: relative; z-index: 1; max-width: 54rem; margin: 0 auto; padding: 2.25rem 1rem 4rem; }
h1, h2, h3, .reward-title { font-family: var(--heading); letter-spacing: 0.02em; }
h1 {
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 3.8rem);
  font-weight: 800;
  line-height: 1.05;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, var(--gold-lo));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 14px rgba(245, 196, 81, 0.35));
}
h2 { margin: 0 0 0.3rem; font-size: 1.25rem; color: var(--gold); }
h3 { margin: 1.4rem 0 0.4rem; font-size: 1rem; color: var(--gold-hi); }
p { margin: 0.25rem 0; }
.muted { color: var(--muted); }
.hero { text-align: center; }
.kicker {
  margin-bottom: 0.4rem;
  color: var(--ember);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}
.panel {
  margin-top: 1.5rem;
  padding: 1.1rem 1.1rem 1.25rem;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 240, 176, 0.08);
  backdrop-filter: blur(6px);
}

/* quest track */
.quest {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}
.quest::before {
  content: "";
  position: absolute;
  top: 21px;
  left: 12.5%;
  right: 12.5%;
  border-top: 2px dashed rgba(245, 196, 81, 0.35);
}
.quest li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.45rem; text-align: center; }
.medal {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid rgba(245, 196, 81, 0.45);
  border-radius: 50%;
  background: #1d1330;
  color: var(--muted);
  font-family: var(--heading);
  font-weight: 800;
}
.label { color: var(--muted); font-size: 0.85rem; line-height: 1.25; }
.quest li.active .medal {
  border-color: var(--gold);
  color: var(--gold-hi);
  box-shadow: 0 0 0 4px rgba(245, 196, 81, 0.15), 0 0 22px rgba(245, 196, 81, 0.55);
}
.quest li.active .label { color: var(--ink); }
.quest li.done .medal {
  border-color: var(--gold-hi);
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, var(--gold-lo));
  color: #3a2208;
  font-size: 0;
}
.quest li.done .medal::after { content: "✓"; font-size: 1.15rem; }
.quest li.done .label { color: var(--gold); }

/* game stage */
.stage {
  position: relative;
  margin-top: 0.85rem;
  border: 1px solid var(--edge);
  border-radius: 10px;
  overflow: hidden;
  background: #140d24;
  aspect-ratio: 16 / 9;
}
#arena { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; cursor: crosshair; }
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(12, 7, 22, 0.72);
  backdrop-filter: blur(2px);
  text-align: center;
}
.overlay[hidden] { display: none; }
.o-body { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; }
#o-msg { font-family: var(--heading); font-size: clamp(1rem, 3vw, 1.45rem); font-weight: 800; color: var(--ink); }
#o-img { align-self: flex-end; height: 96%; margin-bottom: -1rem; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.6)); }
#o-img[hidden] { display: none; }
button {
  font: inherit;
  font-weight: 700;
  padding: 0.65rem 1.5rem;
  border: 1px solid var(--gold-hi);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 50%, #d99a2b);
  color: #3a2208;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(245, 196, 81, 0.35);
}
button:hover { filter: brightness(1.08); }
button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* loot */
.loot {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0 0.6rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: rgba(245, 196, 81, 0.08);
  text-decoration: none;
}
.loot:hover { background: rgba(245, 196, 81, 0.16); }
.loot img { width: 64px; filter: drop-shadow(0 0 10px rgba(255, 200, 80, 0.5)); }
.loot span { display: flex; flex-direction: column; }
.loot strong { color: var(--gold-hi); font-size: 1.1rem; }
a { color: var(--gold); overflow-wrap: anywhere; }
a:hover { color: var(--gold-hi); }
.size { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sums { margin-top: 1.25rem; }

/* reward popup */
.reward {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow-y: auto;
  background: radial-gradient(circle at 50% 40%, rgba(60, 35, 10, 0.75), rgba(6, 3, 12, 0.94) 70%);
  animation: fade 0.4s ease-out both;
}
.reward[hidden] { display: none; }
.reward-stage { position: relative; display: flex; flex-direction: column; align-items: center; width: min(26rem, 100%); padding-top: 120px; text-align: center; }
.rays, .glow { position: absolute; left: 50%; top: 220px; border-radius: 50%; pointer-events: none; }
.rays {
  width: 640px;
  height: 640px;
  margin: -320px 0 0 -320px;
  background: repeating-conic-gradient(from 0deg, rgba(255, 214, 110, 0.32) 0deg 7deg, transparent 7deg 18deg);
  -webkit-mask: radial-gradient(circle, #000 12%, transparent 68%);
  mask: radial-gradient(circle, #000 12%, transparent 68%);
  opacity: 0;
  animation: rays-in 0.8s ease-out 1.05s forwards, spin 24s linear 1.05s infinite;
}
.glow {
  width: 360px;
  height: 360px;
  margin: -180px 0 0 -180px;
  background: radial-gradient(circle, rgba(255, 246, 200, 0.95) 0, rgba(255, 196, 80, 0.6) 28%, transparent 66%);
  transform: scale(0);
  animation: burst 0.9s cubic-bezier(0.2, 1.4, 0.4, 1) 1.05s forwards, pulse 2.4s ease-in-out 2s infinite;
}
.chest { position: relative; width: 240px; height: 200px; overflow: visible; animation: drop 0.6s cubic-bezier(0.3, 1.5, 0.5, 1) both, shake 0.45s ease-in-out 0.6s 1; }
.chest .lid { transform-box: view-box; transform-origin: 120px 100px; animation: open 0.7s cubic-bezier(0.2, 1.3, 0.4, 1) 1.05s forwards; }
.chest .inner { opacity: 0; animation: fade 0.3s ease-out 1.1s forwards; }
.sparks { position: absolute; left: 50%; top: 210px; width: 0; height: 0; }
.spark {
  position: absolute;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: radial-gradient(circle, #fffbe6, #ffd25e 55%, transparent 70%);
  opacity: 0;
  animation: rise var(--t) ease-out var(--d) infinite;
}
.archive {
  position: absolute;
  top: 0;
  left: 50%;
  width: 130px;
  margin-left: -65px;
  opacity: 0;
  filter: drop-shadow(0 0 18px rgba(255, 210, 90, 0.9));
  animation: emerge 0.9s cubic-bezier(0.2, 1.3, 0.4, 1) 1.25s forwards, bob 2.2s ease-in-out 2.15s infinite;
}
.archive img { display: block; width: 100%; }
.reward-title {
  position: relative;
  margin: 0.6rem 0 0;
  font-size: clamp(1.5rem, 5.5vw, 2.1rem);
  font-weight: 800;
  line-height: 1.15;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, var(--gold-lo));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 12px rgba(255, 200, 80, 0.55));
  opacity: 0;
  animation: title-in 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) 1.7s forwards;
}
.medallion {
  position: relative;
  width: 120px;
  height: 120px;
  margin-top: 1rem;
  border: 4px solid var(--gold);
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 3px rgba(255, 240, 176, 0.35), 0 0 40px rgba(255, 196, 80, 0.75);
  transform: scale(0);
  animation: pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) 2.3s forwards;
}
.medallion img { display: block; width: 100%; height: 100%; object-fit: cover; }
.claim { position: relative; margin-top: 1.3rem; opacity: 0; animation: fade 0.5s ease-out 2.9s forwards; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes drop { from { transform: translateY(-120px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-4deg); }
  40% { transform: rotate(4deg); }
  60% { transform: rotate(-3deg); }
  80% { transform: rotate(2deg); }
}
@keyframes open { to { transform: translateY(-46px) rotate(-14deg); } }
@keyframes rays-in { to { opacity: 1; } }
@keyframes spin { from { rotate: 0deg; } to { rotate: 360deg; } }
@keyframes burst { to { transform: scale(1.15); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
@keyframes title-in { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes pop { to { transform: scale(1); } }
@keyframes emerge {
  from { opacity: 0; transform: translateY(200px) scale(0.15) rotate(-20deg); }
  30% { opacity: 1; }
  to { opacity: 1; transform: none; }
}
@keyframes bob { 0%, 100% { opacity: 1; transform: none; } 50% { opacity: 1; transform: translateY(-8px); } }
@keyframes rise {
  0% { opacity: 0; transform: translate(0, 0) scale(0.6); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x), -190px) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .reward *, .reward { animation-duration: 0.01s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
  .spark { display: none; }
}
@media (max-width: 560px) {
  .label { font-size: 0.72rem; }
  .medal { width: 36px; height: 36px; }
  .quest::before { top: 17px; }
  #o-img { height: 70%; }
}
