/* Blimp Jump — dark-carnival theme. The #stage is a fixed 480x800 logical
   playfield that scales to fit the viewport while preserving aspect ratio. */

:root {
  --bg-0: #0c0618;
  --bg-1: #1a0b2e;
  --gold: #ffd24a;
  --gold-soft: #ffb84a;
  --magenta: #ff5db1;
  --violet: #c98bff;
  --cyan: #7cf6ff;
  --ink: #0e0a1a;
  --panel: rgba(20, 10, 36, 0.82);
  --panel-border: rgba(255, 210, 90, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1200px 800px at 70% -10%, #3a1a5e 0%, transparent 60%),
    radial-gradient(900px 700px at 10% 110%, #4a1230 0%, transparent 55%),
    var(--bg-0);
  color: #f4ecff;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  /* Mobile: kill bounce/zoom/selection/callout. */
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding:
    max(6px, env(safe-area-inset-top))
    max(6px, env(safe-area-inset-right))
    max(6px, env(safe-area-inset-bottom))
    max(6px, env(safe-area-inset-left));
}

/* The playfield keeps a 480:800 aspect ratio and fits the viewport height. */
#stage {
  position: relative;
  height: min(96vh, calc(96vw * 800 / 480));
  aspect-ratio: 480 / 800;
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 210, 90, 0.25),
    0 24px 70px rgba(0, 0, 0, 0.6),
    0 0 90px rgba(120, 60, 200, 0.35);
}

@supports (height: 100dvh) {
  #stage { height: min(96dvh, calc(96vw * 800 / 480)); }
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: var(--bg-1);
}

#credit {
  font-size: 12px;
  color: rgba(244, 236, 255, 0.4);
  text-align: center;
  max-width: 520px;
  line-height: 1.5;
}

/* --- Overlays ---------------------------------------------------------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 35%, rgba(40, 16, 70, 0.55), rgba(8, 4, 16, 0.86));
  backdrop-filter: blur(2px);
  animation: fade 0.25s ease;
}
.overlay.hidden { display: none; }

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

.overlay__card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 22px 20px 20px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.kicker {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}

.title {
  margin: 6px 0 2px;
  font-size: 40px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #fff 0%, var(--gold) 60%, var(--gold-soft) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 4px 24px rgba(255, 180, 60, 0.25);
}
.title--sm { font-size: 30px; }

.subtitle {
  font-size: 13px;
  color: var(--violet);
  font-weight: 600;
  margin-bottom: 14px;
}

.lede {
  font-size: 13.5px;
  line-height: 1.6;
  color: rgba(244, 236, 255, 0.82);
  margin: 0 0 18px;
}

/* --- Buttons ----------------------------------------------------------- */

.btn {
  font: inherit;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 1px;
  padding: 12px 22px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.2s ease, filter 0.2s ease;
  user-select: none;
}
.btn:active { transform: translateY(1px) scale(0.99); }

.btn--primary {
  color: var(--ink);
  background: linear-gradient(180deg, #ffe27a, var(--gold) 55%, var(--gold-soft));
  border-color: rgba(255, 240, 200, 0.8);
  box-shadow: 0 8px 22px rgba(255, 180, 50, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.btn--primary:hover { filter: brightness(1.06); }

/* --- Score / hints ----------------------------------------------------- */

.score-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 8px 0 18px;
}
.score-block {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 6px;
}
.score-label { font-size: 11px; letter-spacing: 2px; color: rgba(244, 236, 255, 0.55); }
.score-num { font-size: 28px; font-weight: 900; color: #fff; margin-top: 2px; }

.best-badge {
  display: inline-block;
  margin: 0 0 10px;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--magenta), var(--gold));
  color: var(--ink);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 1px;
}
.best-badge.hidden { display: none; }

.hint-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  justify-content: center;
  margin-top: 14px;
  font-size: 12px;
  color: rgba(244, 236, 255, 0.6);
}
.hint-row.small { margin-top: 10px; font-size: 11px; }

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin: 0 1px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom-width: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: #fff;
}

/* --- Badges ------------------------------------------------------------ */

.badge {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(124, 246, 255, 0.18);
  border: 1px solid rgba(124, 246, 255, 0.6);
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
}
.badge.hidden { display: none; }

/* ============================ Mobile / touch ============================ */

/* Show/hide control hints by input modality (body gets is-touch/is-desktop). */
.touch-only { display: none; }
body.is-touch .touch-only { display: flex; }
body.is-touch .desktop-only { display: none; }

/* On touch devices the stage goes fullscreen-ish; drop the desk framing. */
body.is-touch #stage {
  height: 100%;
  width: 100%;
  border-radius: 0;
  box-shadow: none;
}
body.is-touch #app { gap: 0; padding: 0; }
body.is-touch #credit { display: none; }

/* On-screen mobile controls overlay. Container ignores pointer events; buttons handle them. */
#mobile-controls {
  display: block;
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
#mobile-controls .ctrl-hint {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 96px);
  left: 0; right: 0;
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  pointer-events: none;
  animation: hintFade 5s ease forwards;
}
@keyframes hintFade {
  0%, 60% { opacity: 1; }
  100% { opacity: 0; }
}

.ctrl-btn {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.dir-buttons {
  position: absolute;
  left: calc(env(safe-area-inset-left, 0px) + 18px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.dir-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(200, 160, 255, 0.75);
  background: radial-gradient(circle at 35% 30%, #a862ff, #6b21a8 70%, #4c1d95);
  color: #ffffff;
  font: 900 24px/1 "PingFang SC", system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45), inset 0 2px 4px rgba(255, 255, 255, 0.4);
  transition: transform 0.08s ease, filter 0.1s ease;
}
.dir-btn:active {
  transform: scale(0.92);
  filter: brightness(1.25);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45), inset 0 2px 6px rgba(0, 0, 0, 0.3);
}

.shoot-btn {
  position: absolute;
  right: calc(env(safe-area-inset-right, 0px) + 18px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid rgba(255, 240, 200, 0.85);
  background: radial-gradient(circle at 35% 30%, #ffe27a, #ffb84a 60%, #d6811e);
  color: #3a1d00;
  font: 800 18px/1 "PingFang SC", system-ui, sans-serif;
  letter-spacing: 2px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45), inset 0 2px 4px rgba(255, 255, 255, 0.6);
}
.shoot-btn:active {
  transform: scale(0.94);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45), inset 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Landscape rotate hint (touch only). */
#rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  background: rgba(8, 4, 16, 0.94);
  color: #f4ecff;
  font-size: 18px;
  font-weight: 700;
}
#rotate-hint .rotate-icon { font-size: 46px; animation: rot 2s ease-in-out infinite; }
@keyframes rot {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-90deg); }
}
@media (max-width: 900px) and (orientation: landscape) and (max-height: 520px) {
  body.is-touch #rotate-hint { display: flex; }
}

/* Tighter overlay cards on small phones. */
@media (max-width: 380px) {
  .title { font-size: 34px; }
  .overlay__card { padding: 18px 16px 16px; }
  .dir-btn { width: 62px; height: 62px; font-size: 20px; }
  .dir-buttons { gap: 8px; left: 12px; bottom: 18px; }
  .shoot-btn { width: 78px; height: 78px; font-size: 15px; right: 12px; bottom: 18px; }
}
