:root {
  --bg: #0b0a09;
  --ink: #f4efe6;
  --muted: #cbbba6;
  --accent: #ffb35a;
  --panel: rgba(10, 8, 7, 0.55);
  --stroke: rgba(244, 239, 230, 0.16);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --serif: "Fraunces", "Palatino Linotype", Palatino, serif;
  --sans: "Outfit", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  touch-action: none;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 42%, transparent 40%, rgba(0, 0, 0, 0.45) 100%),
    linear-gradient(to top, rgba(0, 0, 0, 0.35), transparent 28%, transparent 78%, rgba(0, 0, 0, 0.2));
  z-index: 2;
}

#grain {
  position: absolute;
  inset: -20%;
  pointer-events: none;
  opacity: 0.07;
  z-index: 3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.7'/%3E%3C/svg%3E");
  animation: grain 0.7s steps(2) infinite;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); }
  100% { transform: translate(0, 1%); }
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: end center;
  padding: 8vh 6vw 10vh;
  background:
    linear-gradient(to top, rgba(6, 5, 4, 0.78) 0%, rgba(6, 5, 4, 0.28) 42%, rgba(6, 5, 4, 0.15) 100%);
  transition: opacity 0.9s ease, visibility 0.9s ease;
}

.overlay.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.title-inner {
  max-width: 34rem;
  text-align: center;
}

.kicker {
  font-family: var(--sans);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--accent);
  margin-bottom: 0.85rem;
}

h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.6rem, 8vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.subtitle {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.15rem, 2.6vw, 1.6rem);
  color: var(--muted);
  margin-top: 0.6rem;
}

.lead {
  margin: 1.4rem auto 1.8rem;
  max-width: 26rem;
  font-weight: 300;
  font-size: 1.02rem;
  line-height: 1.55;
  color: #e8dfd2;
}

.hint-title, .hint {
  margin-top: 1rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: rgba(232, 223, 210, 0.7);
}

.btn {
  appearance: none;
  border: 1px solid var(--stroke);
  background: rgba(20, 16, 13, 0.7);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.72rem 1.15rem;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.btn:hover, .btn:focus-visible {
  background: rgba(40, 32, 26, 0.85);
  border-color: rgba(255, 179, 90, 0.45);
  outline: none;
}

.btn:active { transform: translateY(1px) scale(0.98); }

.btn.primary {
  background: linear-gradient(180deg, #ffc37a, #e8892d);
  color: #2a1606;
  border-color: transparent;
  font-weight: 600;
}

.btn.primary:hover, .btn.primary:focus-visible {
  background: linear-gradient(180deg, #ffd19a, #f0973a);
}

.btn kbd {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.1rem 0.38rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn.primary kbd {
  background: rgba(80, 40, 8, 0.18);
  color: #3a1d07;
}

.hud {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.hud.hidden, .hidden { opacity: 0; pointer-events: none !important; visibility: hidden; }

#hud-top {
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(1.1rem + env(safe-area-inset-top)) 1.4rem 0;
}

.hud-block {
  pointer-events: none;
  min-width: 5.5rem;
}

.hud-block.wide { flex: 1; text-align: center; }

.hud-block:last-child { text-align: right; }

.hud-block .label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(232, 223, 210, 0.62);
  margin-bottom: 0.2rem;
}

.hud-block strong {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.15rem;
}

#story {
  left: 50%;
  bottom: 7.6rem;
  transform: translateX(-50%);
  width: min(38rem, calc(100% - 2rem));
  text-align: center;
  pointer-events: none;
}

#story p {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.05rem, 2.3vw, 1.35rem);
  line-height: 1.45;
  color: #f7f1e8;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.7);
  background: linear-gradient(to right, transparent, var(--panel), transparent);
  padding: 0.85rem 1.2rem;
  border-radius: 12px;
}

#forgotten-banner {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  font-family: var(--serif);
  font-style: italic;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: #e8c9a0;
  padding: 0.4rem 0.9rem;
  border: 1px solid rgba(232, 201, 160, 0.35);
  border-radius: 999px;
  background: rgba(10, 8, 7, 0.45);
  transition: opacity 0.6s ease;
}

#hud-bottom {
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 1rem calc(1rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  pointer-events: none;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  pointer-events: auto;
}

#btn-mute {
  position: absolute;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  pointer-events: auto;
}

.icon-btn {
  appearance: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid var(--stroke);
  background: rgba(20, 16, 13, 0.7);
  color: var(--ink);
  cursor: pointer;
  backdrop-filter: blur(12px);
  font-size: 1rem;
}

.icon-btn.muted { opacity: 0.5; text-decoration: line-through; }

@media (max-width: 640px) {
  #hud-top { flex-wrap: wrap; }
  .hud-block, .hud-block:last-child, .hud-block.wide { text-align: left; min-width: 0; }
  #story { bottom: 9.4rem; }
  .btn kbd { display: none; }
  h1 { font-size: 2.6rem; }
}
