:root {
  --bg: #05060a;
  --ink: #e8eaf0;
  --dim: #6b7088;
  --accent: #9fc5ff;
  --wrong: #ff5d6c;
  --win: #8fffb0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Space Mono", ui-monospace, monospace;
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---- HUD ---- */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  padding: 0.8rem 1.1rem;
  border-bottom: 1px solid #161a26;
  background: var(--bg);
  user-select: none;
  z-index: 3;
}
.hud-left { display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: 0.28em; text-transform: uppercase; }
.level { color: var(--dim); font-size: 0.78rem; letter-spacing: 0.16em; }

.hud-stats { display: flex; gap: 1.6rem; }
.stat { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.stat label { color: var(--dim); font-size: 0.62rem; letter-spacing: 0.2em; text-transform: uppercase; }
.stat span { font-size: 1.05rem; font-variant-numeric: tabular-nums; }

.hud-right { display: flex; gap: 0.5rem; }

.btn {
  font-family: inherit;
  background: transparent;
  color: var(--ink);
  border: 1px solid #2a3147;
  border-radius: 2px;
  padding: 0.45rem 0.95rem;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { border-color: var(--accent); color: var(--accent); }
.btn.primary:hover { background: rgba(159,197,255,0.1); }
.btn.ghost { padding: 0.45rem 0.7rem; color: var(--dim); }
.btn.muted { color: #394063; border-color: #20263a; }

/* ---- Stage / canvas ---- */
#stage { position: relative; flex: 1; min-height: 0; }
#sky { display: block; width: 100%; height: 100%; cursor: crosshair; }

/* ---- Narrative card overlay ---- */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(3, 4, 8, 0.45);
  backdrop-filter: blur(2px);
  z-index: 2;
}
#overlay.hidden { display: none; }
/* reveal/end mode: anchor the card to the bottom so the sky (or the THE END
   constellation) stays visible above it, and lighten the backdrop. */
#overlay.reveal-mode {
  align-items: flex-end;
  background: rgba(3, 4, 8, 0.12);
  backdrop-filter: none;
  padding-bottom: 1.8rem;
}

#card {
  max-width: 460px;
  width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(8, 10, 18, 0.94);
  border: 1px solid #2a3147;
  border-radius: 4px;
  padding: 1.8rem 1.9rem 1.3rem;
  cursor: pointer;
}
#cardText { overflow-y: auto; }
#cardActions, #cardHint { flex-shrink: 0; }
#cardText p {
  margin: 0 0 0.9rem;
  line-height: 1.75;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
#cardText p.shown { opacity: 1; transform: none; }
#cardText p.dedication { color: var(--dim); font-style: italic; }
#cardText p.stat-line { color: var(--ink); font-size: 0.92rem; }
#cardText p.title { color: var(--accent); letter-spacing: 0.2em; text-transform: uppercase; font-size: 0.85rem; }
#cardText em { color: var(--accent); font-style: normal; }

#leaderboard {
  list-style: none;
  margin: 0.4rem 0 1rem;
  padding: 0.6rem 0 0;
  border-top: 1px solid #161a26;
  font-size: 0.76rem;
}
#leaderboard li { display: flex; justify-content: space-between; padding: 0.16rem 0; color: var(--dim); }
#leaderboard li.me { color: var(--accent); }

.name-entry { margin: 0.2rem 0 0.9rem; }
.name-entry input {
  font-family: inherit;
  width: 100%;
  background: transparent;
  color: var(--ink);
  border: 1px solid #2a3147;
  border-radius: 2px;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}
.name-entry input:focus { outline: none; border-color: var(--accent); }
.name-entry input::placeholder { color: #394063; }

#cardActions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.4rem; }
#cardActions.hidden { display: none; }
#cardHint {
  margin-top: 1rem;
  color: #394063;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-align: right;
}
#cardHint.hidden { display: none; }

/* ---- In-round prompt ---- */
#findPrompt {
  position: absolute;
  left: 50%; bottom: 1.6rem;
  transform: translateX(-50%);
  color: var(--accent);
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  pointer-events: none;
  z-index: 2;
  text-shadow: 0 0 12px rgba(5,6,10,0.9);
}
#findPrompt.hidden { display: none; }
#findPrompt.flash-win { color: var(--win); }
