:root {
  --bg: #14171c;
  --panel: rgba(18, 22, 28, 0.88);
  --edge: #2a323d;
  --txt: #d7dde6;
  --dim: #7c8898;
  --accent: #e8b33a;
  --red: #d84f3a;
  --green: #4fca7d;
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg);
  font-family: "Segoe UI", system-ui, sans-serif; color: var(--txt); }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.panel {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 12px;
  backdrop-filter: blur(6px);
}

#ui-left {
  position: fixed; left: 12px; top: 12px; bottom: 12px; width: 250px;
  overflow-y: auto; z-index: 10;
}
#ui-left h1 { font-size: 1.15rem; margin: 0 0 10px; letter-spacing: 1px; color: var(--accent); }
#ui-left h1 .sub { color: var(--dim); font-weight: 400; font-size: 0.8rem; margin-left: 4px; }

.section-label { font-size: 0.68rem; color: var(--dim); letter-spacing: 1.5px; margin: 12px 0 6px; }

#fp-box { border: 1px solid var(--edge); border-radius: 8px; padding: 8px 10px; }
.fp-row { display: flex; justify-content: space-between; font-size: 0.8rem; }
.fp-row b { color: var(--accent); }
#fp-bar { height: 6px; background: #232a34; border-radius: 3px; margin: 6px 0 4px; overflow: hidden; }
#fp-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #b8791f, var(--accent)); transition: width .4s; }
#fp-next { font-size: 0.68rem; color: var(--dim); }

.stage-item {
  padding: 7px 9px; border: 1px solid var(--edge); border-radius: 7px;
  margin-bottom: 5px; cursor: pointer; font-size: 0.82rem;
  display: flex; justify-content: space-between; align-items: center;
  transition: border-color .15s, background .15s;
}
.stage-item:hover { border-color: var(--accent); }
.stage-item.active { background: rgba(232,179,58,.14); border-color: var(--accent); }
.stage-item.locked { opacity: 0.45; cursor: not-allowed; }
.stage-item .num { color: var(--dim); margin-right: 6px; font-size: 0.7rem; }
.stage-item .req { font-size: 0.66rem; color: var(--red); }
.stage-item .best { font-size: 0.66rem; color: var(--green); }

#stage-desc { font-size: 0.72rem; color: var(--dim); margin: 6px 2px; line-height: 1.45; min-height: 2.4em; }

.spawn-item {
  display: inline-block; padding: 4px 10px; border: 1px solid var(--edge);
  border-radius: 6px; margin: 0 4px 4px 0; cursor: pointer; font-size: 0.78rem;
}
.spawn-item.active { border-color: var(--accent); background: rgba(232,179,58,.14); }

.ctl { margin-bottom: 8px; }
.ctl label { display: flex; justify-content: space-between; font-size: 0.74rem; color: var(--dim); }
.ctl label b { color: var(--txt); }
.ctl input[type=range] { width: 100%; accent-color: var(--accent); }
.ctl select { width: 100%; background: #1d242e; color: var(--txt); border: 1px solid var(--edge);
  border-radius: 6px; padding: 5px; }

button {
  width: 100%; padding: 9px; margin-top: 8px; border: none; border-radius: 8px;
  background: var(--accent); color: #1a1405; font-weight: 700; font-size: 0.9rem;
  cursor: pointer; letter-spacing: 1px;
}
button:hover { filter: brightness(1.12); }
button.ghost { background: #232b36; color: var(--txt); font-weight: 500; }
button.small { font-size: 0.72rem; padding: 6px; }
.row { display: flex; gap: 6px; }
.row button { margin-top: 6px; }
kbd { background: #2c3540; border-radius: 4px; padding: 1px 5px; font-size: 0.68rem; }

#ui-right { position: fixed; right: 12px; top: 12px; width: 210px; z-index: 10; text-align: right; }
#score-box { display: inline-block; width: 100%; text-align: right; }
.score-label { font-size: 0.65rem; letter-spacing: 2px; color: var(--dim); }
#score { font-size: 2rem; font-weight: 800; color: var(--accent); line-height: 1.1; }
#stat-line { font-size: 0.75rem; color: var(--dim); }
#best-line { font-size: 0.68rem; color: var(--green); margin-top: 2px; }

#ticker { margin-top: 8px; }
.tick {
  background: rgba(18,22,28,.85); border: 1px solid var(--edge); border-left: 3px solid var(--accent);
  padding: 5px 9px; margin-bottom: 5px; border-radius: 6px; font-size: 0.74rem;
  animation: tickin .25s ease-out; transition: opacity .6s;
}
.tick.bonus { border-left-color: var(--green); color: var(--green); }
.tick.frac { border-left-color: var(--red); color: #f0a08f; }
@keyframes tickin { from { transform: translateX(30px); opacity: 0; } }

#banner {
  position: fixed; left: 50%; top: 18%; transform: translateX(-50%);
  z-index: 20; text-align: center; pointer-events: none;
  font-size: 1.6rem; font-weight: 800; letter-spacing: 2px; color: var(--accent);
  text-shadow: 0 2px 12px #000;
}
#banner .small { display: block; font-size: 0.85rem; color: var(--txt); font-weight: 400; margin-top: 6px; }

#help {
  position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%);
  font-size: 0.72rem; color: var(--dim); z-index: 10;
  background: rgba(18,22,28,.7); padding: 5px 12px; border-radius: 14px;
}

#loading {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 100; color: var(--dim); letter-spacing: 2px;
}
.hidden { display: none !important; }

@media (max-width: 760px) {
  #ui-left { width: 205px; }
  #ui-right { width: 150px; }
}
