/* THE HAUNTING — interface
   One typeface (Inter, bundled locally under the SIL OFL), one button style,
   one link style. The painting carries the screen; the interface only says
   what is needed to play. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --ink: #05040d;
  --text: #f1ecf6;
  --text-70: rgba(241, 236, 246, 0.72);
  --text-45: rgba(241, 236, 246, 0.45);
  --text-25: rgba(241, 236, 246, 0.25);
  --amber: #f0b86a;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

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

.app { position: fixed; inset: 0; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; }

.flash, .fade { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.flash { background: radial-gradient(circle at 50% 50%, rgba(255, 236, 205, 0.6), rgba(205, 180, 240, 0.12) 55%, transparent 80%); }
.flash.is-on { animation: flash 0.9s ease-out; }
.flash.is-hit { background: rgba(255, 255, 255, 0.35); animation: flash 0.25s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
.fade { background: #03030a; transition: opacity 0.26s ease; z-index: 20; }
.fade.is-on { opacity: 1; }

/* ----------------------------- controls --------------------------- */
.btn {
  appearance: none;
  font: 500 15px/1 var(--font);
  color: var(--text);
  background: rgba(5, 4, 13, 0.45);
  border: 1px solid var(--text-45);
  border-radius: 999px;
  padding: 0 28px;
  min-height: 48px;
  min-width: 180px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.12s;
}
.btn:hover { background: rgba(241, 236, 246, 0.1); border-color: var(--text); }
.btn:active { transform: scale(0.98); }
.link {
  appearance: none;
  font: 400 14px/1 var(--font);
  color: var(--text-70);
  background: none;
  border: 0;
  padding: 14px 4px;
  min-height: 44px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s;
}
.link:hover { color: var(--text); }
.link[hidden] { display: none; }
.btn:focus-visible, .link:focus-visible, .icon-btn:focus-visible, .vault__item:focus-visible, .player__btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}
.menu__links { display: flex; justify-content: center; gap: 4px 24px; flex-wrap: wrap; margin-top: 6px; }

/* ------------------------------- HUD ------------------------------ */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: calc(14px + var(--safe-t)) calc(12px + var(--safe-r)) 0 calc(20px + var(--safe-l));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.app.show-hud .hud { opacity: 1; }
.app.reward-open .hud { opacity: 0; }
.hud__score {
  font: 300 36px/1 var(--font);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7);
  transition: transform 0.15s ease;
}
.hud__score.is-bump { transform: scale(1.06); }
.hud__lanterns { display: flex; align-items: center; gap: 7px; }
.lantern-pip { width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--text-45); transition: background 0.3s, border-color 0.3s; }
.lantern-pip.is-next { border-color: var(--text); }
.lantern-pip.is-lit { background: var(--amber); border-color: var(--amber); }
.lantern-pip.is-new { animation: ignite 0.6s ease-out; }
@keyframes ignite { 50% { transform: scale(1.6); } }
.hud__actions { display: flex; justify-content: flex-end; gap: 2px; pointer-events: auto; }
.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-70);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.8)); }
.icon-btn:hover { color: var(--text); background: rgba(241, 236, 246, 0.08); }
.icon-btn .i-off { display: none; }
.icon-btn.is-muted .i-on { display: none; }
.icon-btn.is-muted .i-off { display: inline; }

.hint {
  position: absolute;
  left: 50%;
  bottom: calc(13% + var(--safe-b));
  transform: translateX(-50%);
  margin: 0;
  font-size: 14px;
  color: var(--text-70);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.app.show-hint .hint { opacity: 1; }

/* ----------------------------- screens ---------------------------- */
.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  touch-action: pan-y;
  animation: screen-in 0.35s ease both;
}
.screen[hidden] { display: none; }
@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }

/* Start: a small group low on the screen, over the dark foreground. */
.screen--title { background: linear-gradient(180deg, rgba(5, 4, 13, 0) 55%, rgba(5, 4, 13, 0.55) 100%); }
.menu {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(48px + var(--safe-b));
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.menu__help { margin: 0 0 18px; font-size: 14px; color: var(--text-70); text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9); }
.menu__note { margin: 6px 0 0; font-size: 12.5px; color: var(--text-45); }

/* Pause / game over / rewards list: centred, scene stays visible. */
.screen--panel { display: grid; place-items: center; padding: 24px; background: rgba(5, 4, 13, 0.55); }
.panel { display: flex; flex-direction: column; align-items: center; text-align: center; animation: rise 0.35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.panel__title { margin: 0 0 20px; font: 600 20px/1.2 var(--font); color: var(--text); }
.over__score { margin: 0; font: 200 88px/1 var(--font); font-variant-numeric: tabular-nums; color: var(--text); }
.over__best { margin: 8px 0 28px; font-size: 14px; color: var(--text-70); font-variant-numeric: tabular-nums; }
.over__best.is-record #overBestLabel { color: var(--amber); }
.finish__actions { display: flex; flex-direction: column; align-items: center; transition: opacity 0.3s ease; }
.screen--panel.is-quiet .finish__actions { opacity: 0; visibility: hidden; }

/* Reward: the material is the screen; one action below it. */
.screen--reward { z-index: 5; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b)); background: rgba(5, 4, 13, 0.72); }
.reward { width: min(820px, 100%); display: flex; flex-direction: column; align-items: center; animation: rise 0.4s ease both; }
.reward__media { width: 100%; }
.reward__actions { display: flex; justify-content: center; gap: 12px 24px; flex-wrap: wrap; margin-top: 24px; }
.media-frame { position: relative; overflow: hidden; background: #000; aspect-ratio: 16 / 9; border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55); }
/* Video plays inside the frame without native controls; a tap pauses/resumes. */
.media-frame--video { cursor: pointer; max-height: 72vh; margin: 0 auto; }
.media-frame--video::after {
  content: "";
  position: absolute; left: 50%; top: 50%;
  width: 0; height: 0;
  margin: -14px 0 0 -9px;
  border-style: solid; border-width: 14px 0 14px 24px;
  border-color: transparent transparent transparent rgba(241, 236, 246, 0.85);
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.7));
  opacity: 0; transition: opacity 0.2s ease;
  pointer-events: none;
}
.media-frame--video.is-paused::after { opacity: 1; }

/* "Odbierz nagrodę": a lantern glow that gathers, then one action. */
.app.reward-open #scrVault .panel { visibility: hidden; }   /* the list must not show through a reward opened from it */
.reward__intro { display: none; flex-direction: column; align-items: center; }
.screen--reward.is-intro .reward__intro { display: flex; }
.screen--reward.is-intro .reward__media, .screen--reward.is-intro .reward__actions { display: none; }
.reward__glow { position: relative; width: 140px; height: 140px; margin-bottom: 28px; }
.reward__glow::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 236, 200, 0.95) 0%, rgba(240, 184, 106, 0.55) 22%, rgba(240, 184, 106, 0.12) 48%, rgba(240, 184, 106, 0) 70%);
  animation: glow-in 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) both, glow-breathe 2.8s ease-in-out 1.1s infinite;
}
.reward__glow span {
  position: absolute; inset: 34px;
  border-radius: 50%;
  border: 1px solid rgba(240, 184, 106, 0.6);
  animation: glow-ring 2.4s ease-out 0.4s infinite;
}
@keyframes glow-in { from { opacity: 0; transform: scale(0.35); } }
@keyframes glow-breathe { 50% { transform: scale(1.08); opacity: 0.85; } }
@keyframes glow-ring { from { opacity: 0.9; transform: scale(0.6); } to { opacity: 0; transform: scale(1.9); } }
.media-frame video, .media-frame iframe, .media-frame img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: contain; background: #000; }
.media-frame--image { aspect-ratio: auto; background: transparent; }
.media-frame--image img { position: static; height: auto; max-height: 70vh; }
.media-empty { aspect-ratio: 16 / 9; border-radius: 6px; background: rgba(5, 4, 13, 0.6); border: 1px solid var(--text-25); }

.player { display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: 6px; background: rgba(5, 4, 13, 0.6); border: 1px solid var(--text-25); }
.player__cover { width: 72px; height: 72px; flex: none; object-fit: cover; border-radius: 4px; background: #120c22; }
.player__body { flex: 1; min-width: 0; }
.player__row { display: flex; align-items: center; gap: 12px; }
.player__btn { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--text-45); background: transparent; color: var(--text); cursor: pointer; }
.player__btn:hover { border-color: var(--text); }
.player__btn svg { width: 18px; height: 18px; fill: currentColor; }
.player__range { flex: 1; accent-color: var(--text); min-width: 0; }
.player__time { font-size: 12px; color: var(--text-45); font-variant-numeric: tabular-nums; min-width: 78px; text-align: right; }

.letter { padding: 28px; border-radius: 6px; font-size: 16px; line-height: 1.65; color: var(--text); background: rgba(5, 4, 13, 0.6); border: 1px solid var(--text-25); max-height: 60vh; overflow-y: auto; text-align: left; }
.letter p { margin: 0 0 0.8em; }
.letter__sig { margin: 1em 0 0; color: var(--text-70); }

/* Rewards list: four numbers. Locked ones are dimmed, not labelled. */
.vault { list-style: none; margin: 0 0 12px; padding: 0; display: flex; gap: 14px; }
.vault__item {
  width: 60px; height: 60px;
  display: grid; place-items: center;
  font: 300 24px/1 var(--font);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: rgba(5, 4, 13, 0.45);
  border: 1px solid var(--text-45);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.vault__item:hover:not(:disabled) { background: rgba(241, 236, 246, 0.1); border-color: var(--text); }
.vault__item:disabled { cursor: default; color: var(--text-25); border-color: rgba(241, 236, 246, 0.12); background: transparent; }

.noscript { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text); }

@media (max-width: 480px) {
  .menu { bottom: calc(36px + var(--safe-b)); }
  .btn { width: 100%; max-width: 320px; }
  .hud__score { font-size: 32px; }
  .over__score { font-size: 72px; }
  .vault { gap: 10px; }
  .vault__item { width: 56px; height: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  .lantern-pip.is-new, .screen, .panel, .reward, .reward__glow::before, .reward__glow span { animation: none; }
  .fade { transition: none; }
}
