:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #02131d;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 20%, rgba(23, 109, 140, 0.26), transparent 46%),
    #02131d;
}

body {
  display: grid;
  place-items: center;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.app {
  position: relative;
  isolation: isolate;
  width: min(100vw, 480px);
  height: 100svh;
  max-height: 900px;
  overflow: hidden;
  background: #043248;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.58);
  touch-action: none;
}

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

.screen-grain,
.edge-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.screen-grain {
  z-index: 2;
  opacity: 0.08;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
}

.edge-shade {
  z-index: 3;
  background:
    linear-gradient(to bottom, rgba(0, 9, 17, 0.32), transparent 24%, transparent 72%, rgba(0, 10, 18, 0.24)),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 8, 14, 0.24) 100%);
}

.hud {
  position: absolute;
  z-index: 10;
  top: max(10px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  transition: opacity 300ms ease, transform 450ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hud.is-hidden {
  opacity: 0;
  transform: translateY(-18px);
  pointer-events: none;
}

.hud__topline {
  height: 38px;
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  align-items: center;
  gap: 8px;
}

.round-button {
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.96);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  box-shadow:
    0 0 0 3px rgba(255, 112, 28, 0.5),
    0 3px 12px rgba(0, 0, 0, 0.28);
}

.round-button--orange {
  background: linear-gradient(145deg, #ff8a25, #f65c11);
}

.round-button:focus-visible,
.continue-button:focus-visible,
.replay-button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.9);
  outline-offset: 3px;
}

#menuButton span {
  position: absolute;
  left: 9px;
  right: 9px;
  height: 1.5px;
  border-radius: 999px;
  background: #fff;
}

#menuButton span:nth-child(1) { top: 11px; }
#menuButton span:nth-child(2) { top: 17px; }
#menuButton span:nth-child(3) { top: 23px; }

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  white-space: nowrap;
}

.brand-lockup__globe {
  font-size: 16px;
  line-height: 1;
}

.brand-lockup__name {
  font-size: clamp(6px, 1.65vw, 8px);
  font-weight: 700;
  letter-spacing: 0.015em;
}

.brand-lockup__name--wide {
  letter-spacing: 0.18em;
}

.brand-lockup__divider {
  width: 1px;
  height: 12px;
  margin: 0 2px;
  background: rgba(255, 255, 255, 0.35);
}

.sound-button__waves {
  display: inline-block;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: -3px;
  transform: translateX(-1px) scaleX(0.9);
}

.sound-button[aria-pressed="false"] .sound-button__waves {
  opacity: 0.58;
}

.progress {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 8px;
}

.progress__segment {
  position: relative;
  height: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.38);
}

.progress__segment::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: scaleX(0);
  transform-origin: left;
  background: #ff6816;
  transition: transform 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.progress__segment--done::after,
.progress__segment--active::after {
  transform: scaleX(1);
}

.chapter-label {
  margin-top: 8px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.035em;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.panel {
  position: absolute;
  z-index: 8;
  inset: 0;
  pointer-events: none;
}

.panel--first {
  opacity: 1;
  transition: opacity 320ms ease;
}

.panel--first.is-hidden {
  opacity: 0;
}

.stat-copy {
  position: absolute;
  left: 12.5%;
  top: 30%;
  color: #fff;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
}

.stat-copy__number,
.stat-copy__accent {
  font-size: clamp(30px, 8.2vw, 42px);
  line-height: 0.92;
  font-weight: 900;
  letter-spacing: -0.035em;
}

.stat-copy__accent {
  color: #ff6816;
  font-size: clamp(22px, 6vw, 30px);
  letter-spacing: -0.02em;
}

.stat-copy__body {
  margin-top: 7px;
  padding-left: 9px;
  border-left: 3px solid #ff6816;
  font-size: clamp(18px, 4.8vw, 24px);
  line-height: 0.9;
  font-weight: 750;
}

.continue-button {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 12px));
  height: 52px;
  padding: 0 12px 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  font-size: 15px;
  font-weight: 760;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(14, 150, 211, 0.9), rgba(7, 99, 151, 0.92));
  box-shadow:
    0 0 0 4px rgba(0, 180, 255, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    0 8px 24px rgba(0, 34, 64, 0.45);
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 220ms ease, transform 220ms ease, filter 220ms ease;
}

.continue-button:not(:disabled):hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.continue-button:active {
  transform: translateY(1px) scale(0.995);
}

.continue-button:disabled {
  opacity: 0.58;
  cursor: progress;
}

.continue-button__arrow {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 50%;
  font-size: 19px;
}

.chapter-card {
  position: absolute;
  z-index: 20;
  inset: 0;
  padding: 0 12%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-align: center;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  will-change: opacity, transform;
}

.chapter-card__index {
  margin-bottom: 12px;
  color: #ff6816;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.32em;
}

.chapter-card h1 {
  margin: 0;
  font-size: clamp(38px, 10vw, 54px);
  line-height: 0.88;
  letter-spacing: -0.045em;
  font-weight: 950;
  text-wrap: balance;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
}

.chapter-card__line {
  width: 42px;
  height: 3px;
  margin: 18px 0 14px;
  background: #ff6816;
  transform: scaleX(0.15);
  transform-origin: center;
}

.chapter-card p {
  max-width: 280px;
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
  line-height: 1.35;
  font-weight: 560;
  letter-spacing: 0.01em;
}

.panel--lost {
  opacity: 0;
  transition: opacity 650ms ease;
}

.panel--lost.is-visible {
  opacity: 1;
}

.lost-copy {
  position: absolute;
  left: 7%;
  top: 18%;
  max-width: 270px;
  color: #fff;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.48);
}

.lost-copy__title {
  font-size: clamp(22px, 6.5vw, 31px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.025em;
}

.lost-copy__rule {
  width: 3px;
  height: 28px;
  margin-top: 8px;
  float: left;
  background: #ff6816;
}

.lost-copy__body {
  max-width: 195px;
  margin-top: 7px;
  margin-left: 10px;
  font-size: 13px;
  line-height: 1.1;
  font-weight: 720;
}

.swipe-hint {
  position: absolute;
  left: 50%;
  bottom: max(36px, calc(env(safe-area-inset-bottom) + 26px));
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.92);
  text-align: center;
  white-space: nowrap;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

.swipe-hint__chevrons {
  height: 24px;
  font-size: 27px;
  font-weight: 200;
  animation: floatChevron 1.5s ease-in-out infinite;
}

.replay-button {
  position: absolute;
  z-index: 2;
  right: 14px;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 8px));
  padding: 8px 10px;
  color: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(0, 24, 39, 0.35);
  backdrop-filter: blur(10px);
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
}

.loading-error {
  position: absolute;
  z-index: 30;
  left: 18px;
  right: 18px;
  bottom: 90px;
  display: none;
  padding: 10px 12px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(105, 20, 20, 0.78);
  font-size: 12px;
  line-height: 1.35;
}

.loading-error.is-visible {
  display: block;
}

@keyframes floatChevron {
  0%, 100% { transform: translateY(4px); opacity: 0.55; }
  50% { transform: translateY(-2px); opacity: 1; }
}

@media (max-height: 650px) {
  .stat-copy { top: 27%; }
  .lost-copy { top: 17%; }
  .continue-button { height: 46px; }
}

@media (min-width: 700px) {
  .app {
    height: min(92vh, 900px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
