:root {
  /* Sky-climb: twilight navy void, sunrise-gold blocks, high-altitude cyan. */
  --bg: #050b18;
  --bg-2: #0a1830;
  --panel: rgba(8, 16, 34, 0.94);
  --ink: #eef6ff;
  --muted: #8fa8c8;
  --accent: #ffd166;     /* sunrise gold — the falling block / HUD */
  --accent-2: #4cc9f0;   /* stratosphere cyan — perfects / orbit */
  --warn: #ff5d6c;       /* shear-line red */
  --line: rgba(150, 190, 255, 0.13);
  --radius: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 700px at 50% -10%, var(--bg-2), var(--bg));
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

/* Mobile-first layout: portrait stage that fills the phone screen (minus safe
   areas), leaderboard below the fold. On desktop it becomes a centered column. */
.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 8px;
  padding-top: max(8px, env(safe-area-inset-top));
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  padding-left: max(8px, env(safe-area-inset-left));
  padding-right: max(8px, env(safe-area-inset-right));
}

/* Ads */
.ad-rail { display: flex; justify-content: center; align-items: center; min-height: 90px; }
.ad-slot { width: 100%; max-width: 728px; }
.ad-placeholder {
  width: 100%; max-width: 728px; min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line); border-radius: 12px;
  color: var(--muted); font-size: 12px; letter-spacing: 0.18em;
  text-transform: uppercase; background: rgba(255, 255, 255, 0.02);
}
.ad-rail.ad-live .ad-placeholder { display: none; }
.ad-rail:not(.ad-live) .ad-slot { display: none !important; }

/* Stage — portrait 3:5, sized so the whole canvas fits one phone screen. */
.stage { width: 100%; margin: 0 auto; max-width: min(480px, calc((100dvh - 16px) * 0.6)); }
.game-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 5;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
#game {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #02030c 0%, #0a1830 55%, #1b2f52 100%);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* HUD — kept clear of the top-right controls; shrinks on narrow screens. */
.hud {
  position: absolute;
  top: 12px; left: 14px; right: 108px;
  display: flex; gap: 14px; align-items: center;
  pointer-events: none;
  font-size: 12px; letter-spacing: 0.08em;
  color: var(--muted);
}
.hud b { color: var(--ink); font-size: 16px; margin-left: 4px; font-variant-numeric: tabular-nums; }
@media (max-width: 420px) {
  .hud { gap: 9px; right: 94px; font-size: 10px; letter-spacing: 0.03em; }
  .hud b { font-size: 13px; margin-left: 3px; }
}

.controls {
  position: absolute; top: 10px; right: 10px; z-index: 5;
  display: flex; gap: 8px; align-items: center;
}
.ctrl-btn {
  height: 40px; border-radius: 20px;
  border: 1px solid var(--line); background: rgba(10, 22, 44, 0.72);
  color: var(--ink); font-size: 14px; font-weight: 700; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  backdrop-filter: blur(4px);
  transition: filter 0.15s ease, transform 0.06s ease;
}
.ctrl-btn:hover { filter: brightness(1.25); }
.ctrl-btn:active { transform: scale(0.94); }
.back-btn { padding: 0 14px; }
.mute-btn { width: 40px; border-radius: 50%; font-size: 16px; }
.mute-btn.is-muted { opacity: 0.6; }

/* One hint for touch, one for pointer devices. */
.touch-hint { display: none; }
.mouse-hint { display: inline; }
body.is-touch .touch-hint { display: inline; }
body.is-touch .mouse-hint { display: none; }

/* Overlay */
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3, 6, 16, 0.62); backdrop-filter: blur(3px);
  transition: opacity 0.2s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.panel {
  width: min(430px, 90%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 22px; text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.logo {
  margin: 0 0 10px; font-size: clamp(28px, 8vw, 42px); font-weight: 800;
  letter-spacing: 0.10em;
  text-shadow: 0 0 22px rgba(255, 209, 102, 0.45);
}
.logo span { color: var(--accent); }
.msg { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0 0 18px; }
.msg b { color: var(--ink); }
.kbd {
  display: inline-block; min-width: 18px; padding: 1px 6px; margin: 0 1px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  background: rgba(255, 255, 255, 0.04); color: var(--ink);
  font: 600 12px/1.4 ui-monospace, "SFMono-Regular", Menlo, monospace;
}
.result { margin-bottom: 16px; }
.big-score { font-size: 54px; font-weight: 800; color: var(--accent); line-height: 1; text-shadow: 0 0 24px rgba(255, 209, 102, 0.4); }
.result-line { color: var(--muted); font-size: 14px; margin-top: 6px; }
.btn {
  border: none; border-radius: 12px; padding: 15px 18px;
  font-size: 17px; font-weight: 700; cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #161000;
}
.btn--primary:hover { filter: brightness(1.06); }
.hint { margin-top: 12px; color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

.btn--ghost { background: rgba(255, 255, 255, 0.08); color: var(--ink); white-space: nowrap; }
.name-row { display: flex; gap: 8px; margin-bottom: 16px; }
#name-input {
  flex: 1; min-width: 0; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line);
  border-radius: 10px; color: var(--ink); padding: 12px; font-size: 16px; outline: none;
}
#name-input:focus { border-color: var(--accent); }

/* Leaderboard */
.leaderboard {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.leaderboard h2 {
  margin: 0 0 12px; font-size: 15px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}
#leaderboard-list { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
#leaderboard-list li {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
#leaderboard-list li:last-child { border-bottom: none; }
#leaderboard-list li:not(.lb-empty)::before {
  counter-increment: rank; content: counter(rank);
  width: 26px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.lb-name { flex: 1; margin: 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.lb-empty { color: var(--muted); justify-content: center !important; }
li.is-you { color: var(--accent); }

/* --- About / how-to-play (crawlable page content) -------------------------- */
.game-info {
  max-width: 900px; margin: 26px auto 10px; padding: 22px 26px;
  border: 1px solid rgba(255, 255, 255, 0.09); border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}
.game-info h2 { margin: 0 0 10px; font-size: 20px; color: var(--ink); }
.game-info h3 { margin: 20px 0 8px; font-size: 16px; color: var(--ink); }
.game-info p, .game-info li { color: var(--muted); line-height: 1.65; font-size: 14.5px; }
.game-info ul { padding-left: 20px; margin: 8px 0; }
.game-info a { color: var(--accent); text-decoration: none; }
.game-info a:hover { text-decoration: underline; }
.game-info .foot-link { margin-top: 16px; }

/* --- Review widget ---------------------------------------------------------- */
.review-form { display: flex; flex-direction: column; gap: 10px; max-width: 520px; margin-top: 6px; }
.review-stars { display: flex; gap: 4px; }
.review-stars button {
  background: none; border: none; cursor: pointer; padding: 2px;
  font-size: 26px; line-height: 1; color: rgba(255, 255, 255, 0.25);
  transition: color 0.12s, transform 0.12s;
}
.review-stars button:hover { transform: scale(1.15); }
.review-stars button.on { color: #ffc83c; }
.review-form input, .review-form textarea {
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px; padding: 9px 12px; color: var(--ink); font: inherit; font-size: 14px;
}
.review-form textarea { resize: vertical; }
.review-send {
  align-self: flex-start; cursor: pointer; border: none; border-radius: 8px;
  padding: 9px 18px; font: inherit; font-size: 14px; font-weight: 700;
  background: var(--accent); color: #0a0a14;
}
.review-send:disabled { opacity: 0.6; cursor: default; }
.review-msg { min-height: 1em; font-size: 13.5px; color: var(--muted); }

/* --- Public reviews display ------------------------------------------------- */
.review-stars span { color: rgba(255, 255, 255, 0.25); font-size: 16px; line-height: 1; }
.review-stars span.on { color: #ffc83c; }
.review-stars.big span { font-size: 20px; }
.reviews-summary { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; }
.reviews-summary .rv-avg { font-size: 28px; font-weight: 800; color: var(--ink); }
.reviews-summary .rv-count { color: var(--muted); font-size: 13.5px; }
.reviews-list { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.reviews-list li { border: 1px solid rgba(255, 255, 255, 0.09); border-radius: 10px; padding: 10px 14px; background: rgba(255, 255, 255, 0.02); }
.reviews-list .rv-row { display: flex; align-items: center; gap: 8px; }
.reviews-list .rv-row b { font-size: 14px; }
.reviews-list .rv-when { color: var(--muted); font-size: 12px; margin-left: auto; }
.reviews-list p { margin: 6px 0 0; line-height: 1.55; font-size: 14px; color: var(--ink); white-space: pre-wrap; }
