:root {
  --ink: #0d1a2e;
  --panel: rgba(13, 26, 46, .88);
  --line: rgba(255, 255, 255, .16);
  --snow: #f5f8fc;
  --mist: #a9bbd1;
  --gold: #f2c14e;
  --bad: #ff8d7a;
  --focus-y: 30%;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #2f6b3b;
  color: var(--snow);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

/* ---- the mountain ---- */
#world {
  position: fixed; left: 0; top: 0; width: 100vw; height: 320vh;
  background: linear-gradient(#0b1230 0%, #1c3566 18%, #3f76b8 42%, #8fc3ea 68%, #d9eef8 90%, #e9f6fb 100%);
  will-change: transform;
}
.moving #world { transition: transform 1.4s cubic-bezier(.3, .7, .2, 1); }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; }
#marks span {
  position: absolute; transform: translate(14px, -50%);
  padding: 2px 9px; border-radius: 99px; white-space: nowrap;
  background: rgba(9, 18, 36, .62); color: #fff; font-size: 12px; letter-spacing: .02em;
}
#marks span::before {
  content: ""; position: absolute; left: -12px; top: 50%; width: 10px; border-top: 1px dashed rgba(255, 255, 255, .8);
}
#marks span.passed { background: rgba(242, 193, 78, .92); color: #1b1404; }
#climber { position: absolute; width: 0; height: 0; }
.moving #climber { transition: left 1.4s cubic-bezier(.3, .7, .2, 1), top 1.4s cubic-bezier(.3, .7, .2, 1); }
#climber span {
  position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--gold); border: 3px solid #fff; box-shadow: 0 0 0 0 rgba(242, 193, 78, .7);
  animation: pulse 2s infinite;
}
@keyframes pulse { 70% { box-shadow: 0 0 0 16px rgba(242, 193, 78, 0); } 100% { box-shadow: 0 0 0 0 rgba(242, 193, 78, 0); } }

/* ---- top bar ---- */
header {
  position: fixed; left: 0; right: 0; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(rgba(9, 16, 36, .7), rgba(9, 16, 36, 0));
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.flower { width: 34px; height: 34px; flex: none; }
h1 { margin: 0; font-size: 19px; letter-spacing: .22em; text-transform: uppercase; font-weight: 700; }
.brand p { margin: 0; font-size: 12px; letter-spacing: .14em; color: var(--mist); text-transform: uppercase; }
.hud { text-align: right; font-variant-numeric: tabular-nums; line-height: 1.15; }
.hud .alt { font-size: 15px; color: var(--mist); white-space: nowrap; }
.brand { min-width: 0; }
@media (max-width: 400px) { h1 { font-size: 16px; letter-spacing: .14em; } .brand p { display: none; } }
.hud .pts { white-space: nowrap; }
@media (max-width: 340px) { h1 { font-size: 13px; letter-spacing: .08em; } .flower { width: 26px; height: 26px; } header { gap: 8px; padding-left: 10px; padding-right: 10px; } }
.hud .alt b { font-size: 22px; color: var(--snow); }
.hud .pts { font-size: 12px; color: var(--gold); letter-spacing: .08em; text-transform: uppercase; }
.round {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(13, 26, 46, .7); color: var(--snow); font-size: 17px; cursor: pointer;
}

/* ---- the card ---- */
#card {
  position: fixed; z-index: 2; left: 0; right: 0; bottom: 0;
  max-height: 68vh; overflow-y: auto;
  padding: 20px 16px max(20px, env(safe-area-inset-bottom));
  background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); border-radius: 20px 20px 0 0;
}
@media (min-width: 860px) {
  :root { --focus-y: 55%; }
  #card {
    left: auto; right: 5vw; bottom: auto; top: 50%; transform: translateY(-46%);
    width: min(440px, 40vw); max-height: 82vh; padding: 28px;
    border: 1px solid var(--line); border-radius: 20px;
  }
}
.eyebrow { margin: 0 0 6px; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
h2 { margin: 0 0 10px; font-size: 24px; line-height: 1.2; text-wrap: balance; }
p { margin: 0 0 12px; }
.muted { color: var(--mist); font-size: 14px; }
.btn {
  display: block; width: 100%; margin-top: 14px; padding: 14px 18px;
  border: 0; border-radius: 12px; background: var(--gold); color: #1b1404;
  font: inherit; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
}
.btn:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; color: var(--snow); border: 1px solid var(--line); }
.btn:focus-visible, .round:focus-visible, input:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.link { background: none; border: 0; padding: 0; color: var(--mist); font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; }

.timer { height: 8px; margin: 14px 0; border-radius: 99px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.timer i { display: block; height: 100%; width: 100%; background: var(--gold); border-radius: 99px; }
.timer.low i { background: var(--bad); }
.secs { float: right; font-variant-numeric: tabular-nums; color: var(--mist); font-size: 14px; }
form { display: flex; gap: 8px; }
input[type=text] {
  flex: 1; min-width: 0; padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .08); color: var(--snow);
  font: inherit; font-size: 17px;
}
input::placeholder { color: rgba(169, 187, 209, .7); }
form .btn { width: auto; margin: 0; }
.feedback { min-height: 22px; margin: 10px 0 0; font-size: 14px; color: var(--bad); }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.tier { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.tier .emoji { font-size: 40px; line-height: 1; }
.tier b { display: block; font-size: 13px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
.tier span { font-size: 22px; font-weight: 700; line-height: 1.2; }
.gain { font-size: 15px; }
.gain b { color: var(--gold); font-size: 20px; }
.top { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .07); font-size: 14px; }
.top h3 { margin: 0 0 6px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--mist); font-weight: 600; }
.bar { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 2px 0; }
.bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .pct { color: var(--mist); font-variant-numeric: tabular-nums; }
.bar.mine .name { color: var(--gold); font-weight: 700; }

.big { font-size: 44px; font-weight: 800; line-height: 1; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.big small { font-size: 18px; font-weight: 600; color: var(--mist); }
.row7 { font-size: 26px; letter-spacing: 4px; margin: 10px 0; }
.log { list-style: none; margin: 14px 0 0; padding: 0; }
.log li { padding: 10px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; }
.log .q { font-size: 13px; color: var(--mist); }
.log .a { font-weight: 600; }
.log .p { font-variant-numeric: tabular-nums; color: var(--gold); font-weight: 700; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 0; }
.stats div { padding: 10px 6px; border-radius: 12px; background: rgba(255, 255, 255, .07); text-align: center; }
.stats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--mist); }

dialog {
  width: min(520px, calc(100vw - 32px)); max-height: 86vh; overflow-y: auto;
  padding: 24px; border: 1px solid var(--line); border-radius: 18px;
  background: #0f1e36; color: var(--snow);
}
#feedback form { display: block; }
#feedback label { display: block; margin: 12px 0 6px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--mist); }
#feedback select, #feedback textarea {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: #17294a; color: var(--snow); font: inherit; resize: vertical;
}
#feedback select:focus-visible, #feedback textarea:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
#feedback .fine { margin: 10px 0 0; font-size: 13px; }
#feedback .feedback.ok { color: #9be3a8; }
#feedback .btn { width: 100%; }
dialog::backdrop { background: rgba(5, 10, 22, .7); }
dialog h2 { font-size: 18px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin-top: 6px; }
dialog ul { padding-left: 20px; margin: 0 0 16px; }
dialog li { margin-bottom: 8px; }
dialog p { color: var(--mist); font-size: 14px; }

/* ---- the chalet in the valley ---- */
#chalet {
  position: absolute; left: 36%; top: 93.6%; width: clamp(170px, 24vw, 320px);
  transform: translate(-50%, -100%); overflow: visible;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .28));
}
#chalet .glow { animation: lamp 4s ease-in-out infinite; }
@keyframes lamp { 0%, 100% { fill: #f2c14e; } 45% { fill: #ffd97a; } 55% { fill: #eeb53c; } }
#chalet .smoke circle { transform-box: fill-box; transform-origin: center; opacity: 0; animation: smoke 4.5s ease-out infinite; }
#chalet .smoke circle:nth-child(2) { animation-delay: -1.5s; }
#chalet .smoke circle:nth-child(3) { animation-delay: -3s; }
@keyframes smoke {
  0% { transform: translate(0, 0) scale(.5); opacity: 0; }
  15% { opacity: .85; }
  100% { transform: translate(-26px, -62px) scale(2.6); opacity: 0; }
}

/* ---- sheep in the meadow ---- */
.sheep { position: absolute; cursor: pointer; animation: wander linear infinite; }
.sheep svg { display: block; width: 100%; overflow: visible; animation: bob .5s ease-in-out infinite alternate; }
.sheep .leg { transform-box: fill-box; transform-origin: 50% 0; animation: step .5s ease-in-out infinite alternate; }
.sheep .leg.b { animation-direction: alternate-reverse; }
.sheep .head { transform-box: fill-box; transform-origin: 20% 60%; animation: nod 2.6s ease-in-out infinite; }
.sheep.jump svg { animation: hop .5s ease-out; }
@keyframes wander {
  0% { transform: translateX(0) scaleX(var(--face)); }
  49.5% { transform: translateX(var(--walk)) scaleX(var(--face)); }
  50% { transform: translateX(var(--walk)) scaleX(var(--back)); }
  99.5% { transform: translateX(0) scaleX(var(--back)); }
  100% { transform: translateX(0) scaleX(var(--face)); }
}
@keyframes bob { to { transform: translateY(-1.5px); } }
@keyframes step { from { transform: rotate(-20deg); } to { transform: rotate(20deg); } }
@keyframes nod { 0%, 70%, 100% { transform: rotate(0); } 80%, 90% { transform: rotate(14deg); } }
@keyframes hop { 40% { transform: translateY(-16px) rotate(-8deg); } }

/* ---- weather ---- */
#weather { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.cloud {
  position: absolute; left: -14em; width: 10em; height: 2.6em; border-radius: 99px;
  background: #fff; filter: blur(1.5px); animation: drift linear infinite;
}
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { left: 1.6em; top: -1.5em; width: 3.6em; height: 3.6em; }
.cloud::after { left: 4.4em; top: -2.3em; width: 4.6em; height: 4.6em; }
@keyframes drift { to { transform: translateX(calc(100vw + 28em)); } }
.cloud.rainy, .cloud.rainy::before, .cloud.rainy::after { background: #c3ccd8; }
.drop {
  position: absolute; width: 1.5px; border-radius: 2px;
  background: linear-gradient(rgba(255, 255, 255, 0), #dcebf7);
  transform: rotate(12deg); animation: rain linear infinite;
}
@keyframes rain {
  from { transform: translate(0, -9vh) rotate(12deg); }
  to { transform: translate(-3.8vh, 9vh) rotate(12deg); }
}
.flake { position: absolute; border-radius: 50%; background: #fff; opacity: 0; animation: snow linear infinite; }
@keyframes snow {
  0% { transform: translate(0, 0); opacity: 0; }
  12%, 80% { opacity: .9; }
  100% { transform: translate(34px, 34vh); opacity: 0; }
}
#scene circle { animation: twinkle 3.4s ease-in-out infinite; }
#scene circle:nth-child(2n) { animation-delay: -1.2s; }
#scene circle:nth-child(3n) { animation-delay: -2.3s; }
@keyframes twinkle { 50% { opacity: .25; } }

/* ---- motion in the interface ---- */
#card > * { animation: rise .42s cubic-bezier(.2, .7, .2, 1) both; }
#card > :nth-child(2) { animation-delay: .05s; }
#card > :nth-child(3) { animation-delay: .1s; }
#card > :nth-child(4) { animation-delay: .15s; }
#card > :nth-child(5) { animation-delay: .2s; }
#card > :nth-child(n+6) { animation-delay: .25s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.tier .emoji { display: inline-block; animation: pop .6s cubic-bezier(.3, 1.6, .5, 1) .15s both; }
.row7 span { display: inline-block; animation: pop .45s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes pop { from { transform: scale(0) rotate(-25deg); opacity: 0; } }
.bar { animation: rise .35s both; }
.bar:nth-child(3) { animation-delay: .3s; } .bar:nth-child(4) { animation-delay: .38s; }
.bar:nth-child(5) { animation-delay: .46s; } .bar:nth-child(6) { animation-delay: .54s; }
.bar:nth-child(2) { animation-delay: .22s; }
.timer.low { animation: throb .5s ease-in-out infinite alternate; }
@keyframes throb { to { transform: scaleY(1.5); } }
.btn { transition: transform .12s, filter .12s; }
.btn:active { transform: scale(.97); }
#marks span { transition: background .5s, color .5s; }
#marks span.passed { animation: flag .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes flag { 40% { transform: translate(14px, -50%) scale(1.18); } }
.gainfloat {
  position: absolute; left: 16px; top: -12px; white-space: nowrap; pointer-events: none;
  padding: 2px 10px; border-radius: 99px; background: var(--gold); color: #1b1404; font-size: 14px;
  animation: floatup 2.1s ease-out both;
}
@keyframes floatup {
  0% { transform: translateY(10px) scale(.6); opacity: 0; }
  15% { transform: translateY(0) scale(1); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translateY(-46px); opacity: 0; }
}
.petal {
  position: fixed; z-index: 9; width: 9px; height: 14px; border-radius: 60% 60% 60% 60% / 80% 80% 40% 40%;
  pointer-events: none; transform: translate(-50%, -50%);
}
header .round + .round { margin-left: -4px; }

@media (prefers-reduced-motion: reduce) {
  #chalet .glow, #chalet .smoke circle { animation: none; }
  .sheep, .sheep svg, .sheep .leg, .sheep .head { animation: none; }
  #card > *, .tier .emoji, .row7 span, .bar, .timer.low, #marks span.passed, #scene circle { animation: none; }
  .moving #world, .moving #climber { transition: none; }
  #climber span, .shake { animation: none; }
}
