/* Hop Up — a one-button flying game. Self-contained; no site CSS dependency,
   because the release pipeline serves this folder as static files only. */

:root {
  --ink: #10213a;
  --ink-2: #18304f;
  --paper: #fbfaf7;
  --text: #354458;
  --muted: #6d7c8e;
  --line: rgba(255 255 255 / .14);
  --accent: #315bd2;
  --accent-hi: #6f95ff;
  --accent-2: #e99b68;
  --mint: #9ce6d8;
  --display: "Avenir Next", Avenir, "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --body: Inter, "Avenir Next", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 22px;
  --shadow: 0 30px 80px rgb(6 14 28 / .45);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

/* The game owns the viewport. Nothing here is meant to scroll, on any device. */
html {
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  font-family: var(--body);
  color: var(--paper);
  background:
    radial-gradient(120% 90% at 50% -10%, #24406e 0%, #16294a 45%, #0d1a30 100%),
    var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 3vw, 34px);
  -webkit-font-smoothing: antialiased;
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

.frame {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.6vw, 16px);
  min-height: 0;
}

/* ---------- header ---------- */

.topbar {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--display);
  font-size: clamp(21px, 3.4vw, 27px);
  font-weight: 600;
  letter-spacing: -.02em;
}

.wordmark span { color: var(--accent-hi); }

.tagline {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- stage ---------- */

.stage-wrap {
  position: relative;
  aspect-ratio: 960 / 560;
  border-radius: var(--radius);
  overflow: hidden;
  background: #16294a;
  box-shadow: var(--shadow);
  outline: 1px solid var(--line);
  outline-offset: -1px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: clamp(12px, 2.4vw, 20px);
  pointer-events: none;
}

/* The score group sits left and the best-score group right; `:last-child`
   replaces the old `hud-best` class hook the markup no longer carries. */
.hud-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1;
}

.hud-item:last-child { align-items: flex-end; text-align: right; }

.hud-label {
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgb(255 255 255 / .62);
}

.hud-value {
  font-family: var(--display);
  font-size: clamp(26px, 5.4vw, 40px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 14px rgb(6 14 28 / .5);
}

.hud-item:last-child .hud-value { font-size: clamp(18px, 3.4vw, 24px); color: var(--mint); }

/* ---------- overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.8vw, 14px);
  padding: clamp(18px, 5vw, 44px);
  text-align: center;
  background: linear-gradient(180deg, rgb(10 20 38 / .5) 0%, rgb(10 20 38 / .78) 100%);
  backdrop-filter: blur(2px);
  transition: opacity .22s ease, visibility .22s ease;
}

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

.overlay-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(40px, 9vw, 68px);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1;
}

.overlay-title--sm { font-size: clamp(26px, 5.6vw, 38px); }

/* The rotate gate covers everything else on the stage and is opaque: while a
   phone is edge-up, the game underneath is not reachable or even readable. */
.rotate-gate {
  z-index: 6;
  gap: clamp(6px, 1.4vw, 10px);
  background: linear-gradient(180deg, #16294a 0%, #0d1a30 100%);
}

.rotate-figure {
  position: relative;
  width: clamp(112px, 24vh, 168px);
  height: clamp(112px, 24vh, 168px);
  display: grid;
  place-items: center;
  color: var(--mint);
}

.rotate-phone {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 54px;
  height: 92px;
  border: 3px solid currentColor;
  border-radius: 11px;
  box-shadow: inset 0 0 0 2px rgb(156 230 216 / .16);
  transform-origin: 50% 50%;
  animation: rotate-hint 2.6s cubic-bezier(.65, 0, .35, 1) infinite;
}

/* A dot riding the screen's long edge makes the target orientation obvious. */
.rotate-bird {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  margin: -5px;
  border-radius: 50%;
  background: var(--paper);
}

@keyframes rotate-hint {
  0%, 14%   { transform: rotate(0deg); }
  62%, 86%  { transform: rotate(-90deg); }
  100%      { transform: rotate(0deg); }
}

.rotate-arrow {
  position: absolute;
  right: 0;
  top: 0;
  width: 46%;
  height: 46%;
  opacity: .75;
  animation: arrow-sweep 2.6s ease-in-out infinite;
}

@keyframes arrow-sweep {
  0%, 14%  { opacity: .2; }
  38%      { opacity: .95; }
  62%, 86% { opacity: .25; }
  100%     { opacity: .2; }
}

.rotate-title {
  font-family: var(--display);
  font-size: clamp(20px, 4.6vh, 30px);
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 0;
}

.rotate-copy {
  margin: 0;
  max-width: 34ch;
  font-size: clamp(13px, 2.4vh, 16px);
  color: rgb(255 255 255 / .82);
}

.overlay-copy {
  margin: 0;
  max-width: 34ch;
  font-size: clamp(14px, 2.2vw, 16px);
  color: rgb(255 255 255 / .82);
}

.keys {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  display: flex;
  gap: clamp(10px, 2.4vw, 20px);
  flex-wrap: wrap;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
}

.keys li { display: flex; align-items: center; gap: 6px; }

kbd {
  font-family: var(--body);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 7px;
  background: rgb(255 255 255 / .1);
  border: 1px solid rgb(255 255 255 / .2);
  color: var(--paper);
}

.cta {
  margin-top: clamp(6px, 1.6vw, 12px);
  font-family: var(--display);
  font-size: clamp(15px, 2.4vw, 17px);
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  padding: 13px 26px;
  cursor: pointer;
  box-shadow: 0 12px 30px rgb(49 91 210 / .4);
  transition: transform .14s ease, background .14s ease;
}

.cta:hover { background: #2a4fbb; transform: translateY(-1px); }
.cta:active { transform: translateY(1px); }

.cta:focus-visible,
.mute:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}

.results {
  display: flex;
  gap: clamp(22px, 6vw, 46px);
  margin: 0;
}

.results dt {
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgb(255 255 255 / .6);
}

.results dd {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: clamp(30px, 6vw, 44px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#recordNote { color: var(--mint); font-size: 14px; }

/* ---------- mute ---------- */

.mute {
  position: absolute;
  z-index: 7;   /* above the gate: sound stays reachable while you rotate */
  right: clamp(10px, 2vw, 16px);
  bottom: clamp(10px, 2vw, 16px);
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid rgb(255 255 255 / .18);
  background: rgb(10 20 38 / .5);
  color: var(--paper);
  cursor: pointer;
  transition: background .14s ease;
}

.mute:hover { background: rgb(10 20 38 / .74); }

.mute-icon { font-size: 17px; line-height: 1; }

.mute[aria-pressed="true"] { color: var(--muted); }
.mute[aria-pressed="true"] .mute-icon::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 2px;
  background: currentColor;
  transform: rotate(-38deg);
}

/* ---------- footer ---------- */

.footbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.hint {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 60ch;
}

.backnav a {
  font-size: 13px;
  color: var(--accent-hi);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.backnav a:hover { border-bottom-color: currentColor; }
.backnav a:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }

/* ---------- small screens ---------- */

@media (max-width: 560px) {
  .keys li:nth-child(2) { display: none; }
  .footbar { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* ---------- phone layout ----------
   On a coarse pointer the game is the page: no header, no footer, no padding
   and nothing scrollable. In landscape the playfield fills edge to edge,
   including into the notch safe areas (`viewport-fit=cover` above). */

@media (pointer: coarse) {
  body { padding: 0; }
  .frame { gap: 0; max-width: none; height: 100%; }
  .topbar, .footbar { display: none; }
  .stage-wrap {
    flex: 1 1 auto;
    min-height: 0;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
    outline: none;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* Fullscreen and portrait are the same layout promise: the game owns every pixel
   of the viewport. `:fullscreen` covers the standard API and webkit prefixes
   (iOS Safari), and `is-portrait` is set by the script whenever the rotate gate
   is up — that keeps the stage edge-to-edge in portrait too, so the gate message
   fills the screen instead of floating inside a letterboxed card. */
:fullscreen,
:-webkit-full-screen,
html.is-portrait {
  width: 100%;
  height: 100%;
  background: #0d1a30;   /* flat: no gradient banding behind the stage edges */
}

:fullscreen .frame,
:-webkit-full-screen .frame,
html.is-portrait .frame {
  gap: 0;
  max-width: none;
  height: 100%;
}

:fullscreen .topbar, :fullscreen .footbar,
:-webkit-full-screen .topbar, :-webkit-full-screen .footbar,
html.is-portrait .topbar, html.is-portrait .footbar {
  display: none;
}

:fullscreen .stage-wrap,
:-webkit-full-screen .stage-wrap,
html.is-portrait .stage-wrap {
  flex: 1 1 auto;
  min-height: 0;
  aspect-ratio: auto;
  border-radius: 0;
  box-shadow: none;
  outline: none;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Portrait on a phone is the gated state: the field still fills the screen so
   the rotate message has somewhere to live, but it reads tall and narrow. */
@media (orientation: portrait) and (pointer: coarse) {
  .rotate-phone { animation-delay: .35s; }
}

@media (prefers-reduced-motion: reduce) {
  .overlay, .cta, .mute { transition: none; }
  .cta:hover, .cta:active { transform: none; }
  /* The gate must still say "turn the phone" without moving: hold the phone
     in the target orientation and drop the arrow pulse entirely. */
  .rotate-phone { animation: none; transform: rotate(-90deg); }
  .rotate-arrow { animation: none; opacity: .9; }
}
