:root {
  color-scheme: dark;
  --gold: #f6c95d;
  --deep-gold: #9b6120;
  --ink: #f9f5e8;
  --forest: #09251d;
  font-family: Montserrat, "Avenir Next", Avenir, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; min-height: 100%; margin: 0; background: var(--forest); }
body { min-height: 100svh; }
button, a { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid #fff2ac; outline-offset: 4px; }

.adventure {
  position: relative;
  width: min(100vw, 560px);
  height: 100svh;
  min-height: 500px;
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
  background: #0b261d;
  color: var(--ink);
}
.fireflies { position: absolute; z-index: 6; inset: 0; pointer-events: none; }
.fireflies i { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #f5d578; box-shadow: 0 0 10px 3px rgba(255,221,113,.65); animation: blink 2.8s ease-in-out infinite; }
.fireflies i:nth-child(1) { top: 24%; left: 15%; animation-delay: -.4s; }
.fireflies i:nth-child(2) { top: 34%; right: 14%; animation-delay: -1.5s; }
.fireflies i:nth-child(3) { top: 47%; left: 9%; animation-delay: -2s; }
.fireflies i:nth-child(4) { top: 53%; right: 9%; animation-delay: -.8s; }
.fireflies i:nth-child(5) { top: 61%; left: 19%; animation-delay: -1.2s; }
.fireflies i:nth-child(6) { top: 31%; left: 78%; animation-delay: -2.2s; }
.fireflies i:nth-child(7) { top: 71%; right: 18%; animation-delay: -.6s; }
.fireflies i:nth-child(8) { top: 41%; left: 28%; animation-delay: -1.8s; }

.topbar { position: absolute; z-index: 10; top: max(14px, env(safe-area-inset-top)); left: 18px; right: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wordmark { display: inline-flex; align-items: center; gap: 7px; color: #fff3c6; text-decoration: none; line-height: .85; font-family: "Barlow Condensed", Impact, sans-serif; font-size: 10px; font-weight: 800; letter-spacing: .16em; text-shadow: 0 2px 10px #071b14; }
.wordmark img { display: block; filter: drop-shadow(0 2px 4px #001a12); }
.wordmark strong { display: block; margin-top: 4px; color: #fff5d5; font-size: 17px; letter-spacing: .035em; text-shadow: 0 2px 0 #68441e, 0 3px 12px #000; }

.scene { position: absolute; inset: 0; }
.intro { position: absolute; z-index: 2; top: clamp(74px, 10vh, 94px); left: 24px; right: 24px; text-align: center; text-shadow: 0 2px 16px rgba(1, 16, 15, .75); pointer-events: none; transition: opacity .3s ease; }
[data-state]:not([data-state="ready"]) .intro { opacity: 0; }
h1 { margin: 0; color: #fff4d6; font-family: "Barlow Condensed", Impact, sans-serif; font-size: clamp(40px, 12vw, 61px); font-weight: 900; line-height: .83; letter-spacing: -.025em; text-transform: uppercase; }
h1 span { color: #a8e9bd; }
.instruction { max-width: 320px; margin: 11px auto 0; color: #f5f1e2; font-size: 12px; font-weight: 600; line-height: 1.45; }

.quest-button {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
  border: 2px solid #b59355;
  border-radius: 7px;
  background: #263a2b;
  box-shadow: inset 0 1px #f3ce82b3, 0 4px #493720, 0 8px 15px #0008;
  color: #fff2ca;
  font-family: "Barlow Condensed", Impact, sans-serif;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: .055em;
  text-decoration: none;
  text-shadow: 0 2px 2px #031e16;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
}
.quest-button::before {
  position: absolute;
  z-index: -1;
  inset: 3px;
  border: 1px solid #7ac0a585;
  border-radius: 3px;
  background:
    linear-gradient(115deg, transparent 40%, #c6ffdb37 50%, transparent 60%) 100% 0 / 240% 100%,
    linear-gradient(#286951, #103d2f);
  box-shadow: inset 0 1px #b6e5b75c, inset 0 -5px #08281f55;
  transition: background-position .45s ease;
  content: "";
}
.quest-button:is(:hover, :focus-visible):not(:disabled) {
  border-color: #f5d491;
  box-shadow: inset 0 1px #f3ce82b3, 0 4px #493720, 0 0 20px #63dba256;
}
.quest-button:is(:hover, :focus-visible):not(:disabled)::before { background-position: 0 0, 0 0; }
.quest-button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: inset 0 1px #f3ce82b3, 0 1px #493720, 0 2px 7px #0009;
}
.quest-button:disabled { opacity: .72; cursor: default; }
.quest-gem { width: 11px; height: 11px; flex: 0 0 11px; rotate: 45deg; border: 1px solid #b9ebbb; background: linear-gradient(135deg, #c9ffd3, #459e77 52%, #176249 53%); box-shadow: 0 0 8px #7df5b867; }
.quest-arrow { position: relative; width: 15px; height: 12px; flex: 0 0 15px; color: #ffdf9c; transition: transform .18s ease; }
.quest-arrow::before { position: absolute; top: 5px; left: 0; width: 13px; height: 2px; background: currentColor; content: ""; }
.quest-arrow::after { position: absolute; top: 2px; right: 1px; width: 7px; height: 7px; border: solid currentColor; border-width: 2px 2px 0 0; rotate: 45deg; content: ""; }
.quest-button:is(:hover, :focus-visible):not(:disabled) .quest-arrow { transform: translateX(3px); }
.top-entry { min-height: 42px; gap: 8px; padding-inline: 12px; font-size: 14px; }
.wake-button { position: absolute; z-index: 6; bottom: max(67px, 8.8vh); left: 50%; translate: -50% 0; width: max-content; max-width: calc(100% - 32px); min-width: 224px; }
.status { position: absolute; z-index: 3; bottom: max(45px, 6vh); left: 20px; right: 20px; margin: 0; text-align: center; color: #ffefc9; font-size: 11px; letter-spacing: .02em; }

.treasure-dialog {
  width: min(91vw, 354px);
  max-height: calc(100dvh - 24px);
  padding: 30px 22px 21px;
  overflow-y: auto;
  border: 2px solid #d5ab59;
  border-radius: 9px;
  background: radial-gradient(ellipse at 50% 0%, #304e34, #1b2c20 53%, #0b2018);
  box-shadow: inset 0 0 0 3px #0c2319, 0 16px 50px #000a, 0 0 34px #edb34b38;
  color: var(--ink);
  text-align: center;
}
.treasure-dialog[open] { animation: treasure-pop .32s cubic-bezier(.21,.75,.28,1) both; }
.treasure-dialog::backdrop { background: #02130eb5; backdrop-filter: blur(2px); }
.dialog-close { position: absolute; top: 7px; right: 7px; }
.dialog-close button { display: grid; width: 44px; height: 44px; place-items: center; border: 0; border-radius: 50%; background: transparent; color: #ffe7ab; font: 25px/1 sans-serif; cursor: pointer; }
.dialog-close button:hover { background: #fff2b721; }
.game-app-icon { display: block; width: 120px; height: 120px; margin: 0 auto 12px; object-fit: contain; filter: drop-shadow(0 0 18px #80d49465) drop-shadow(0 7px 6px #0008); }
.treasure-dialog[open] .game-app-icon { animation: seal-reveal .55s cubic-bezier(.18,.72,.26,1) both; }
.treasure-dialog h2 { margin: 0; color: #ffe8a0; font-family: "Barlow Condensed", Impact, sans-serif; font-size: clamp(24px, 7.3vw, 31px); line-height: 1; text-transform: uppercase; }
.dialog-copy { max-width: 240px; margin: 10px auto 20px; color: #f0e7ce; font-size: 13px; line-height: 1.5; }
.enter-button { width: min(100%, 260px); min-height: 55px; }
.treasure-dialog[open] .enter-button:not(:hover):not(:focus-visible)::before { animation: quest-sheen .85s ease .22s; }
.dialog-responsible { margin: 17px 0 0; color: #e9ddbc; font-size: 11px; }
.responsible { position: absolute; z-index: 8; bottom: max(12px, env(safe-area-inset-bottom)); left: 18px; display: flex; align-items: center; gap: 8px; color: rgba(246,245,225,.75); font-size: 9px; line-height: 1.4; text-shadow: 0 1px 6px #00120d; }
.age-mark { display: grid; width: 29px; height: 29px; place-items: center; border: 1px solid #ece1bd; border-radius: 50%; color: #fff5d5; font-family: "Barlow Condensed", Impact, sans-serif; font-size: 14px; font-weight: 800; }
.noscript { position: fixed; z-index: 99; inset: auto 12px 12px; padding: 12px; background: #08241c; color: white; text-align: center; }

.departure-screen { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; overflow: hidden; visibility: hidden; opacity: 0; background: #061710; color: #fff4d6; transition: opacity .28s ease, visibility 0s linear .3s; }
.departure-screen.is-active { visibility: visible; opacity: 1; transition-delay: 0s; }
.departure-backdrop { position: absolute; inset: -4%; width: 108%; height: 108%; object-fit: cover; opacity: .22; filter: blur(12px) brightness(.65) saturate(1.2); transform: scale(1.06); transition: opacity .7s ease, filter .7s ease, transform 1s ease; }
.departure-screen.is-active .departure-backdrop { opacity: .34; filter: blur(8px) brightness(.65) saturate(1.2); transform: scale(1); }
.departure-content { position: relative; z-index: 1; width: min(100%, 560px); min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 15px; padding: max(24px, env(safe-area-inset-top)) 22px max(20px, env(safe-area-inset-bottom)); text-align: center; }
.departure-seal { width: min(140px, 42vw); height: auto; object-fit: contain; filter: drop-shadow(0 0 24px #80d49488); }
.departure-screen.is-active .departure-seal { animation: seal-reveal .52s cubic-bezier(.18,.72,.26,1) both; }
.departure-status { margin: 5px 0 -8px; color: #fff4d6; font-family: "Barlow Condensed", Impact, sans-serif; font-size: 19px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.departure-progress { width: min(76%, 260px); height: 3px; overflow: hidden; border-radius: 3px; background: #f6df9c35; }
.departure-progress span { display: block; width: 42%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #b4782a, #ffe185); box-shadow: 0 0 12px #ffdc77; animation: portal-loading .8s ease-in-out infinite alternate; }
.departure-responsible { margin: -3px 0 0; color: rgba(247,239,214,.7); font-size: 9px; letter-spacing: .04em; }


@keyframes blink { 0%,100% { opacity: .22; transform: scale(.75); } 50% { opacity: 1; transform: scale(1.25); } }
@keyframes portal-loading { from { transform: translateX(-45%); } to { transform: translateX(160%); } }
@keyframes treasure-pop { from { opacity: 0; transform: translateY(14px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes seal-reveal { from { opacity: 0; transform: translateY(6px) scale(.84); } to { opacity: 1; transform: none; } }
@keyframes quest-sheen { from { background-position: 100% 0, 0 0; } to { background-position: 0 0, 0 0; } }

@media (min-width: 700px) {
  .adventure { height: min(100svh, 1000px); border-inline: 1px solid rgba(247,212,131,.2); }
  .topbar { left: 28px; right: 28px; }
  .intro { top: 9%; }
  h1 { font-size: 68px; }
}
@media (max-height: 700px) and (min-width: 500px) {
  .intro { top: 9%; }
}
@media (max-height: 700px) and (max-width: 499px) {
  .intro { top: 74px; }
  h1 { font-size: 43px; }
  .instruction { margin-top: 7px; font-size: 11px; }
  .wake-button { bottom: 56px; min-height: 44px; font-size: 16px; }
  .status { bottom: 40px; font-size: 10px; }
  .responsible { bottom: 7px; }
  .enter-button { min-height: 44px; }
}
@media (max-height: 500px) {
  .treasure-dialog { padding-top: 16px; }
  .game-app-icon { width: 84px; height: 84px; margin-bottom: 8px; }
  .dialog-copy { margin-bottom: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
