:root {
  --bg: #0a1430;
  --card: rgba(8, 13, 28, 0.72);
  --line: rgba(120, 150, 200, 0.16);
  --text: #e8edf5;
  --muted: #8592a8;
  --signal: #5ee0ff;
  --win: #ffb347;
  --font: ui-sans-serif, -apple-system, "SF Pro Display", "Inter", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hud { position: fixed; inset: 0; pointer-events: none; transition: opacity 0.4s; }
.hud > * { pointer-events: auto; }
body.clean .hud { opacity: 0; }
body.clean .hud > * { pointer-events: none; }

.title { position: absolute; top: 28px; left: 32px; max-width: 520px; pointer-events: none; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--signal);
}

h1 { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; margin-top: 6px; }

.meta { color: var(--muted); font-size: 13px; margin-top: 6px; }

.caption { margin-top: 18px; font-size: 16px; font-weight: 500; color: #d4dbe6; min-height: 22px; }

.progress { margin-top: 8px; width: 240px; height: 2px; background: rgba(255, 255, 255, 0.08); }
#progress-bar { height: 100%; width: 0; background: var(--signal); }

.card {
  position: absolute;
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.controls-card { left: 32px; bottom: 32px; width: 252px; display: flex; flex-direction: column; gap: 12px; }

.pad-wrap { position: relative; }

#pad {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: crosshair;
  touch-action: none;
}

.pad-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #3a4456;
  font-size: 14px;
  pointer-events: none;
  transition: opacity 0.2s;
}
.pad-hint.hidden { opacity: 0; }

.controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

button {
  background: rgba(20, 28, 46, 0.9);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 0;
  font: 500 12px var(--font);
  cursor: pointer;
}
button:hover { border-color: rgba(150, 180, 230, 0.35); }
button.active { border-color: var(--signal); color: var(--signal); background: rgba(94, 224, 255, 0.1); }
button.active kbd { color: var(--signal); }

kbd { font-family: var(--mono); font-size: 9px; color: var(--muted); margin-left: 3px; }

.speed {
  display: grid;
  grid-template-columns: auto 1fr 36px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.speed input { accent-color: var(--signal); }
.speed output { font-family: var(--mono); color: var(--text); text-align: right; }

.result-card { right: 32px; bottom: 32px; width: 240px; }

.result-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.result-row { display: flex; align-items: center; gap: 14px; margin-top: 6px; }

.result-digit {
  font-family: var(--mono);
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  color: #2a3345;
  min-width: 40px;
  transition: color 0.3s, text-shadow 0.3s;
}
.result-digit.live { color: var(--win); text-shadow: 0 0 24px rgba(255, 179, 71, 0.5); }

.result-conf { font-size: 15px; font-weight: 550; }
.result-note { font-size: 12px; color: var(--muted); margin-top: 3px; min-height: 16px; }

.bars { list-style: none; padding: 0; margin-top: 14px; display: grid; gap: 5px; }
.bars li { display: grid; grid-template-columns: 14px 1fr 44px; gap: 8px; align-items: center; font: 11px var(--mono); color: var(--muted); }
.bars .track { height: 4px; background: rgba(255, 255, 255, 0.06); border-radius: 2px; overflow: hidden; }
.bars .fill { height: 100%; width: 0; background: var(--signal); }
.bars .pct { text-align: right; }
.bars li.win { color: var(--win); }
.bars li.win .fill { background: var(--win); }

.unhide {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font: 11px var(--mono);
  color: rgba(255, 255, 255, 0.3);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}
body.clean .unhide { opacity: 1; animation: fade 3s 1.5s forwards; }
@keyframes fade { to { opacity: 0; } }

/* Mono theme */
:root[data-theme="mono"] {
  --bg: #000;
  --card: rgba(8, 8, 8, 0.72);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f2f2f2;
  --muted: #8a8a8a;
  --signal: #ffffff;
  --win: #ffb84d;
}
:root[data-theme="mono"] .eyebrow { color: #9a9a9a; }
:root[data-theme="mono"] button { background: #111; }
:root[data-theme="mono"] button:hover { border-color: #3a3a3a; background: #161616; }
:root[data-theme="mono"] button.active { background: rgba(255, 255, 255, 0.08); }
:root[data-theme="mono"] .result-digit { color: #222; }
:root[data-theme="mono"] .result-digit.live { color: var(--win); text-shadow: 0 0 24px rgba(255, 184, 77, 0.45); }

/* Nebula theme */
:root[data-theme="nebula"] {
  --bg: #06050f;
  --card: rgba(10, 8, 24, 0.72);
  --line: rgba(160, 140, 255, 0.16);
  --text: #ecebf7;
  --muted: #8f8bb3;
  --signal: #3ce8dc;
  --win: #ffc850;
}
:root[data-theme="nebula"] .eyebrow { background: linear-gradient(90deg, #3ce8dc, #a46cff, #ff3d8f); -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme="nebula"] #progress-bar { background: linear-gradient(90deg, #3ce8dc, #8a4dff, #ff3d8f, #ffc850); }
:root[data-theme="nebula"] button { background: rgba(18, 16, 42, 0.9); }
:root[data-theme="nebula"] button.active { background: rgba(60, 232, 220, 0.1); }
:root[data-theme="nebula"] .result-digit { color: #24203f; }
:root[data-theme="nebula"] .result-digit.live { color: var(--win); text-shadow: 0 0 24px rgba(255, 200, 80, 0.5); }

/* Teal & orange theme */
:root[data-theme="teal-orange"] {
  --bg: #07262b;
  --card: rgba(4, 22, 25, 0.72);
  --line: rgba(110, 200, 190, 0.16);
  --text: #eaf2f0;
  --muted: #86a3a1;
  --signal: #ff8a3d;
  --win: #ffd68c;
}
:root[data-theme="teal-orange"] button { background: rgba(10, 36, 40, 0.9); }
:root[data-theme="teal-orange"] button.active { background: rgba(255, 138, 61, 0.12); }
:root[data-theme="teal-orange"] .caption { color: #d9e8e5; }
:root[data-theme="teal-orange"] .result-digit { color: #1d3b3d; }
:root[data-theme="teal-orange"] .result-digit.live { color: var(--win); text-shadow: 0 0 24px rgba(255, 170, 80, 0.5); }

@media (max-width: 760px) {
  .title { left: 16px; right: 16px; top: 16px; }
  h1 { font-size: 22px; }
  .controls-card { left: 16px; bottom: 16px; width: 200px; }
  .result-card { right: 16px; bottom: 16px; width: 150px; }
  .bars { display: none; }
}
