:root {
  --asphalt: #10161a;
  --edge: #33413f;
  --paper: #edeae2;
  --muted: #7f8d88;
  --guide: #f2c230;
  --signal: #16b978;
  --danger: #ff5a3c;
  --heart: #ff5d7a;
  --shield: #7dd8ff;
  --minus: #a68cff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--asphalt);
  color: var(--paper);
  font-family: 'IBM Plex Sans KR', sans-serif;
  overflow: hidden;
  touch-action: none;
}

.stage {
  max-width: 470px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.strip {
  flex: none;
  padding: 8px 12px;
  background: var(--asphalt);
  border-bottom: 1px solid var(--edge);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
}

.brand {
  font-family: 'Black Han Sans', sans-serif;
  font-size: 20px;
  line-height: 1;
  color: var(--guide);
  white-space: nowrap;
}
.brand small { font-size: 12px; color: var(--paper); margin-left: 2px; }

.levelbox { display: flex; flex-direction: column; gap: 2px; }
.levelhead {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--muted);
}
.track {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.fill {
  height: 100%;
  width: 0%;
  background: var(--signal);
  border-radius: 3px;
  transition: width 0.15s ease-out;
}

.readout { text-align: right; }
.score-row {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}
#goal { font-size: 12px; color: var(--muted); margin-left: 2px; font-weight: 500; }
.subrow {
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  font-size: 11px; color: var(--muted); margin-top: 2px;
}
.powtag b { color: var(--guide); }
.shieldtag {
  background: var(--shield);
  color: var(--asphalt);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 10px;
}

.shield-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
}
.shield-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--shield);
  clip-path: polygon(50% 0%, 100% 30%, 85% 100%, 50% 85%, 15% 100%, 0% 30%);
  border-radius: 2px;
}
.shield-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: var(--asphalt);
  clip-path: polygon(20% 0%, 80% 0%, 80% 30%, 100% 30%, 100% 70%, 80% 70%, 80% 100%, 20% 100%, 20% 70%, 0% 70%, 0% 30%, 20% 30%);
}
.lives { display: flex; gap: 3px; }
.life-pip {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
}
.life-pip.off { background: rgba(255,255,255,0.12); }

.board {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#cv {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 470px;
  height: 100%;
  touch-action: none;
}

.overlay {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  width: 100%;
  max-width: 470px;
  height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
  background: rgba(16,22,26,0.55);
  z-index: 10;
  padding: 20px;
  text-align: center;
}
.overlay[hidden] { display: none !important; }

.title {
  font-family: 'Black Han Sans', sans-serif;
  font-size: 42px; color: var(--guide); line-height: 1.1;
}
.title small { font-size: 16px; color: var(--paper); display: block; margin-top: 4px; }
.rules { text-align: left; font-size: 13px; color: var(--muted); line-height: 1.7; margin: 8px 0; }

.btn {
  appearance: none; border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-family: 'IBM Plex Sans KR', sans-serif;
  font-weight: 700; font-size: 15px;
  cursor: pointer;
  background: var(--edge);
  color: var(--paper);
  transition: transform 0.05s, opacity 0.15s;
}
.btn:active { transform: scale(0.96); }
.btn.primary { background: var(--signal); color: #fff; }

.clear-title { font-family: 'Black Han Sans', sans-serif; font-size: 32px; color: var(--guide); }
.clear-sub { font-size: 18px; color: var(--paper); }
.clear-next { font-size: 14px; color: var(--muted); }
.clear-speed { font-size: 13px; color: var(--signal); }
.clear-heal { font-size: 13px; color: var(--heart); }

.end-title { font-family: 'Black Han Sans', sans-serif; font-size: 36px; color: var(--danger); }
.end-stats { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.end-stats b { color: var(--paper); font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; }
.end-best { color: var(--guide); font-weight: 700; }

.pause-title { font-family: 'Black Han Sans', sans-serif; font-size: 32px; color: var(--paper); }

.controls {
  flex: none;
  display: flex; justify-content: center; gap: 8px;
  padding: 8px 12px 12px;
  background: var(--asphalt);
  border-top: 1px solid var(--edge);
}
.ctrl-btn {
  appearance: none; border: none;
  min-width: 48px; min-height: 44px;
  border-radius: 8px;
  font-family: 'IBM Plex Sans KR', sans-serif;
  font-weight: 700; font-size: 13px;
  cursor: pointer;
  background: var(--edge);
  color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
.ctrl-btn.primary { background: var(--guide); color: var(--asphalt); }
.ctrl-btn:active { transform: scale(0.95); }
.dash-wrap { position: relative; }
.dash-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px; background: rgba(255,255,255,0.25);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}
.dash-bar::after {
  content: '';
  display: block; height: 100%; width: 0%;
  background: var(--signal);
  border-radius: 0 0 8px 8px;
}

.keyhint {
  flex: none;
  text-align: center;
  font-size: 11px; color: var(--muted);
  padding: 4px 12px 8px;
  background: var(--asphalt);
}

@media (pointer: coarse) {
  .keyhint { display: none; }
  .controls { display: flex; }
}
@media (pointer: fine) {
  .controls { display: none; }
  .keyhint { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .fill { transition: none; }
  .btn, .ctrl-btn { transition: none; }
}
