/* Paper Lantern Courier — night-sky arcade */

:root {
  --night: #08071a;
  --night-2: #150d2e;
  --plum: #2b1233;
  --amber: #ffb454;
  --amber-soft: #ffdca8;
  --ember: #ff7a3d;
  --teal: #7fe6d4;
  --paper: #f7edda;
  --ink: #f4ecdf;
  --ink-dim: #b9aecb;
  --line: rgba(255, 220, 168, 0.18);

  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-text: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --radius: 14px;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}

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

[hidden] { display: none !important; }

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: var(--font-text);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  display: block;
  font-size: 1rem;
  line-height: 1.55;
}

#stage {
  position: fixed;
  inset: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #1a1136 0%, #08071a 70%);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ── Night progress ─────────────────────────────────────── */
.night-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.07);
  z-index: 6;
  pointer-events: none;
}

.night-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6f5bd6, var(--teal) 55%, var(--amber));
  box-shadow: 0 0 14px rgba(255, 180, 84, 0.7);
  transition: width 0.2s linear;
}

/* ── HUD ────────────────────────────────────────────────── */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 3vw, 2rem);
  padding: clamp(0.7rem, 2vw, 1.15rem) clamp(0.9rem, 3vw, 1.8rem);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.stat {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.stat-label {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.stat-value {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3.4vw, 1.75rem);
  color: var(--amber-soft);
  text-shadow: 0 0 18px rgba(255, 180, 84, 0.45);
}

.paper {
  margin-left: auto;
  display: flex;
  gap: 0.34rem;
  align-items: center;
}

.pip {
  width: 0.62rem;
  height: 0.95rem;
  border-radius: 45% 45% 45% 45% / 32% 32% 32% 32%;
  background: linear-gradient(180deg, var(--amber-soft), var(--ember));
  box-shadow: 0 0 12px rgba(255, 150, 70, 0.75);
  transition: opacity 0.25s, transform 0.25s, filter 0.25s;
}

.pip.torn {
  opacity: 0.22;
  filter: grayscale(1);
  transform: scaleY(0.62);
  box-shadow: none;
}

/* ── Top buttons ────────────────────────────────────────── */
.top-actions {
  position: absolute;
  right: clamp(0.7rem, 2.5vw, 1.4rem);
  bottom: clamp(0.7rem, 2.5vw, 1.4rem);
  z-index: 9;
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(12, 9, 28, 0.55);
  backdrop-filter: blur(8px);
  color: var(--amber-soft);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.icon-btn:hover {
  background: rgba(40, 26, 66, 0.85);
  border-color: rgba(255, 180, 84, 0.5);
}

.icon-btn:active { transform: scale(0.94); }

.icon-btn:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

.ico {
  display: block;
  width: 1.05rem;
  height: 1.05rem;
  position: relative;
}

.ico-sound::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 0.42rem;
  height: 0.5rem;
  transform: translateY(-50%);
  background: currentColor;
  clip-path: polygon(0 30%, 45% 30%, 100% 0, 100% 100%, 45% 70%, 0 70%);
}

.ico-sound::after {
  content: "";
  position: absolute;
  right: -0.1rem;
  top: 50%;
  width: 0.55rem;
  height: 0.55rem;
  transform: translateY(-50%);
  border: 1.6px solid currentColor;
  border-left-color: transparent;
  border-top-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
}

.muted .ico-sound::after {
  width: 0.7rem;
  height: 1.6px;
  border: 0;
  background: currentColor;
  transform: translateY(-50%) rotate(-45deg);
  border-radius: 0;
}

.ico-pause::before,
.ico-pause::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0.22rem;
  height: 0.85rem;
  transform: translateY(-50%);
  background: currentColor;
  border-radius: 1px;
}

.ico-pause::before { left: 0.16rem; }
.ico-pause::after { right: 0.16rem; }

/* ── Hint ───────────────────────────────────────────────── */
.hint {
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  z-index: 5;
  margin: 0;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: var(--amber-soft);
  background: rgba(10, 7, 24, 0.55);
  border: 1px solid var(--line);
  pointer-events: none;
  animation: hintPulse 2.4s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* ── Screens ────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: clamp(0.8rem, 3vw, 2rem);
  background: radial-gradient(90% 70% at 50% 40%, rgba(8, 7, 26, 0.32), rgba(5, 4, 16, 0.8));
  backdrop-filter: blur(2px);
  overflow-y: auto;
  animation: fadeIn 0.4s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.title-card {
  margin: auto;
  width: min(100%, 62rem);
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.22fr);
  gap: clamp(1.2rem, 3vw, 2.6rem);
  align-items: center;
}

.title-art {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 200, 140, 0.14) inset;
  aspect-ratio: 3 / 4;
  max-height: min(74vh, 34rem);
  justify-self: center;
  width: 100%;
}

.title-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.title-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 7, 26, 0) 45%, rgba(8, 7, 26, 0.75));
  pointer-events: none;
}

.kicker {
  margin: 0 0 0.6rem;
  font-size: 0.7rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--teal);
}

.title-copy h1 {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 6.4vw, 3.9rem);
  line-height: 0.98;
  margin: 0 0 0.9rem;
  color: var(--paper);
  text-shadow: 0 0 40px rgba(255, 180, 84, 0.28);
  letter-spacing: -0.015em;
}

.title-copy h1 em {
  font-style: italic;
  color: var(--amber);
  text-shadow: 0 0 34px rgba(255, 150, 60, 0.55);
}

.lede {
  margin: 0 0 1.1rem;
  max-width: 34ch;
  color: var(--ink-dim);
  font-size: clamp(0.9rem, 1.9vw, 1rem);
}

.how {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: grid;
  gap: 0.42rem;
  font-size: clamp(0.82rem, 1.8vw, 0.93rem);
  color: var(--ink-dim);
}

.how li {
  position: relative;
  padding-left: 1.15rem;
}

.how li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.52em;
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px rgba(255, 180, 84, 0.9);
}

.how b {
  color: var(--paper);
  font-weight: 600;
}

.how-center {
  justify-items: center;
  margin-bottom: 1.3rem;
}

.how-center li {
  padding-left: 0;
  padding-right: 0;
}

.how-center li::before {
  position: static;
  display: inline-block;
  margin-right: 0.55rem;
  vertical-align: 0.12em;
}

.btn-launch {
  display: inline-block;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.9rem;
  font-family: var(--font-text);
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: #2a1206;
  background: linear-gradient(180deg, #ffd79a, #ff9f45);
  box-shadow: 0 10px 34px rgba(255, 140, 50, 0.4), 0 0 0 1px rgba(255, 230, 190, 0.5) inset;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
}

.btn-launch:hover {
  filter: brightness(1.06);
  box-shadow: 0 14px 44px rgba(255, 150, 60, 0.55), 0 0 0 1px rgba(255, 240, 210, 0.7) inset;
  transform: translateY(-1px);
}

.btn-launch:active { transform: translateY(1px) scale(0.99); }

.btn-launch:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

.btn-quiet {
  display: block;
  margin-top: 0.9rem;
  border: 0;
  background: none;
  color: var(--ink-dim);
  font-size: 0.86rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0.3rem;
}

.btn-quiet:hover { color: var(--paper); }

.best {
  margin: 0.9rem 0 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  min-height: 1.2em;
}

/* ── End card ───────────────────────────────────────────── */
.end-card {
  margin: auto;
  width: min(100%, 34rem);
  text-align: center;
  padding: clamp(1.4rem, 4vw, 2.6rem);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(30, 20, 56, 0.92), rgba(12, 9, 28, 0.94));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.end-card h2 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 5vw, 2.5rem);
  margin: 0 0 0.7rem;
  color: var(--paper);
  line-height: 1.05;
}

.end-note {
  margin: 0 auto 1.4rem;
  max-width: 32ch;
  color: var(--ink-dim);
  font-size: 0.94rem;
}

.end-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin: 0 0 1.3rem;
  padding: 1rem 0.4rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.end-stats div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.end-stats span {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 4vw, 1.7rem);
  color: var(--amber-soft);
  font-variant-numeric: tabular-nums;
}

.end-stats small {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  line-height: 1.25;
}

.rating {
  margin: 0 0 1.4rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1rem, 2.6vw, 1.2rem);
  color: var(--teal);
}

/* ── Small screens ──────────────────────────────────────── */
@media (max-width: 720px) {
  .title-card {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .title-art {
    aspect-ratio: 16 / 9;
    max-height: 26vh;
    order: -1;
  }

  .lede { max-width: none; }

  .how {
    grid-template-columns: 1fr;
    gap: 0.3rem;
    margin-bottom: 1.1rem;
  }

  .end-stats { grid-template-columns: repeat(2, 1fr); gap: 0.9rem 0.5rem; }
}

@media (max-height: 560px) and (min-width: 721px) {
  .title-art { max-height: 62vh; }
  .how { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hint { animation: none; opacity: 0.9; }
  .screen { animation: none; }
}
