/* Wicky Run v2 — Constellation theme: deep navy starfield, moody, atmospheric */
:root {
  --bg: #030610;
  --panel: #05091a;
  --ink: #e8f1ff;
  --muted-ink: #6b82a8;
  --teal: #22c9a7;
  --green: #22c58b;
  --green-hi: #43e8ac;
  --blue: #2e8ee8;
  --red: #ef5350;
  --gold: #f6c453;
  --border: rgba(103, 232, 199, 0.15);
  --font-display: "Orbitron", "Segoe UI", sans-serif;
  --font-pixel: "Pixelify Sans", "Comic Sans MS", cursive;
  --font-logo: "Bitcount", "Courier New", monospace;
  --font-body: "Exo 2", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Starfield background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background: 
    radial-gradient(1px 1px at 15% 20%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 45% 35%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1.5px 1.5px at 75% 15%, rgba(103,232,199,0.5), transparent),
    radial-gradient(1px 1px at 85% 65%, rgba(255,255,255,0.35), transparent),
    radial-gradient(1px 1px at 25% 75%, rgba(255,255,255,0.25), transparent),
    radial-gradient(1.5px 1.5px at 55% 85%, rgba(53,123,192,0.4), transparent),
    radial-gradient(1px 1px at 95% 45%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 35% 55%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1.5px 1.5px at 65% 25%, rgba(220,220,255,0.3), transparent);
  background-size: 200px 200px;
  pointer-events: none;
  animation: twinkle 8s ease-in-out infinite alternate;
}
@keyframes twinkle {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

.stage {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 22px 20px 28px;
}

/* ---------- masthead ---------- */
.mast {
  text-align: center;
  padding: 10px 0 20px;
}
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 8px;
}
.emblem {
  width: 44px;
  height: 42px;
  filter: drop-shadow(0 0 10px rgba(53,123,192,0.6));
}
.logo {
  font-family: var(--font-logo);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.logo span {
  background: linear-gradient(90deg, var(--teal), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tag {
  font-size: 14px;
  color: var(--muted-ink);
  font-style: italic;
  letter-spacing: 0.5px;
  margin: 0;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
  justify-content: center;
}
.chip {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}
/* stable widths so the row never reflows as numbers tick up */
#hud-dist { min-width: 6ch; text-align: center; }   /* "9999m" */
#hud-zig  { min-width: 5ch; text-align: center; }   /* "W 999" */
.chip.dist { border-color: rgba(46, 142, 232, 0.45); }
.chip.gold { border-color: rgba(246, 196, 83, 0.5); color: var(--gold); }
.chip.bull { border-color: rgba(67, 232, 172, 0.55); color: var(--green-hi); }
.chip.bear { border-color: rgba(239, 83, 80, 0.55); color: #ff8a80; }
.chip.best { color: var(--muted-ink); }
.btn-chip { cursor: pointer; font-size: 13px; line-height: 1; }
.btn-chip:hover { background: rgba(255, 255, 255, 0.08); }

/* ---------- game frame ---------- */
.frame {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  background: var(--panel);
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;              /* taps belong to the game, not scroll/zoom */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;     /* no iOS long-press menu */
}

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 20px;
  background: rgba(3, 6, 16, 0.72);
  backdrop-filter: blur(3px);
}
.overlay[hidden] { display: none; }   /* beats display:flex */
.overlay h2 {
  margin: 0 0 4px;
  font-family: var(--font-pixel);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
}
.overlay h2.ath {
  background: linear-gradient(90deg, var(--gold), var(--green-hi));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ov-line { margin: 2px 0 10px; color: var(--muted-ink); font-size: 15px; line-height: 1.55; }
.stats div { margin: 1px 0; font-size: 15px; font-variant-numeric: tabular-nums; }
.stats .muted { color: var(--muted-ink); font-size: 13px; }
.ath-flash {
  margin: 0;
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 2px;
  animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse {
  from { opacity: 0.65; transform: scale(1); }
  to { opacity: 1; transform: scale(1.06); }
}
.row { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }

.cta {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #052210;
  background: linear-gradient(135deg, var(--green), var(--green-hi));
  padding: 12px 24px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(34, 197, 139, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(34, 197, 139, 0.45); }
.cta:active { transform: translateY(0); }
.ghost {
  appearance: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid rgba(143, 163, 200, 0.4);
  padding: 11px 18px;
  border-radius: 999px;
}
.ghost:hover { background: rgba(255, 255, 255, 0.06); }

.hint { margin: 10px 0 0; color: var(--muted-ink); font-size: 13px; }
.landscape-tip {
  display: none;
  margin: 0 0 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(246, 196, 83, 0.1);
  border: 1px solid rgba(246, 196, 83, 0.35);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-align: center;
}
@media (pointer: coarse) and (orientation: portrait) {
  .landscape-tip { display: block; }
}
kbd {
  border: 1px solid rgba(143, 163, 200, 0.4);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
}

/* ---------- phase banner ---------- */
.banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 7px 16px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 2.5px;
  font-size: 12px;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.banner.show { opacity: 1; transform: translate(-50%, 0); }
.banner.bull { background: rgba(34, 197, 139, 0.16); color: var(--green-hi); border: 1px solid rgba(67, 232, 172, 0.5); }
.banner.bear { background: rgba(239, 83, 80, 0.14); color: #ff8a80; border: 1px solid rgba(239, 83, 80, 0.5); }
.banner.chop { background: rgba(94, 140, 255, 0.14); color: #a9c4ff; border: 1px solid rgba(94, 140, 255, 0.45); }

/* ---------- guide ---------- */
.guide {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.g-item {
  position: relative;
  padding: 14px;
  background: rgba(5, 9, 26, 0.7);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  color: var(--muted-ink);
  line-height: 1.5;
}
.g-item::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(53,123,192,0.15), transparent 70%);
  pointer-events: none;
}
.g-item b {
  display: inline-block;
  font-family: var(--font-pixel);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  line-height: 1.25;
  text-transform: uppercase;
  vertical-align: middle;
}
.g-candle, .g-coin, .g-phase { margin-right: 10px; }
.g-item b {
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
  color: var(--ink);
}
.g-item:nth-child(2) b { color: var(--red); }
.g-item:nth-child(3) b { color: var(--gold); }
.g-item:nth-child(4) b { color: var(--blue); }
.g-candle {
  display: inline-block;
  width: 10px; height: 22px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 6px;
}
.g-candle.green { background: var(--green); box-shadow: 0 0 10px rgba(34, 197, 139, 0.6); }
.g-candle.red { background: var(--red); box-shadow: 0 0 10px rgba(239, 83, 80, 0.6); }
.g-coin {
  display: inline-block;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe9a8, var(--gold) 70%);
  color: #8a5a00;
  font-weight: 800;
  font-size: 13px;
  text-align: center;
  line-height: 22px;
  margin-right: 6px;
  vertical-align: middle;
}
.g-phase { font-size: 16px; margin-right: 4px; }

/* ---------- footer ---------- */
.foot {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--muted-ink);
  letter-spacing: 0.5px;
}
.foot a { color: var(--teal); text-decoration: none; }
.foot a:hover { text-decoration: underline; }
.disclaimer {
  max-width: 640px;
  margin: 8px auto 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: rgba(107, 130, 168, 0.75);
}
.muted2 { opacity: 0.7; }

@media (max-width: 640px) {
  .logo { font-size: 22px; }
  .stage { padding: 16px 12px 24px; }
  .overlay h2 { font-size: 26px; }
  .guide { grid-template-columns: repeat(2, 1fr); }
}
