:root {
  --bg: #0b0d10;
  --card: #14181d;
  --card2: #1b2027;
  --line: #2a313a;
  --text: #e8ebef;
  --muted: #8d97a3;
  --accent: #ffb020;
  --ok: #3ddc84;
  --bad: #ff4d5e;
  --blue: #3d8bff;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 50% -200px, rgba(255,176,32,.10), transparent 70%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.015) 0 1px, transparent 1px 3px),
    var(--bg);
}
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(11,13,16,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font: 700 13px/1 var(--mono); letter-spacing: .14em; color: var(--accent); white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); margin-right: 6px; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.progress { display: flex; gap: 5px; }
.progress i { width: 22px; height: 6px; border-radius: 3px; background: var(--line); }
.progress i.done { background: var(--ok); }
.progress i.now { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

main { max-width: 680px; margin: 0 auto; padding: 18px 14px 80px; }
.card {
  background: linear-gradient(180deg, var(--card2), var(--card));
  border: 1px solid var(--line); border-radius: 16px; padding: 20px;
  margin-bottom: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.35);
  animation: rise .35s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.center { text-align: center; }
.kicker { font: 600 12px/1 var(--mono); letter-spacing: .16em; color: var(--accent); text-transform: uppercase; }
h1 { font-size: 26px; margin: 8px 0 10px; line-height: 1.2; }
h2 { font-size: 19px; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.story { color: #c9d0d8; }

button, .btn {
  font: 600 16px/1 system-ui, sans-serif; color: #111; background: var(--accent);
  border: 0; border-radius: 12px; padding: 14px 20px; cursor: pointer;
  transition: transform .08s, filter .15s; touch-action: manipulation;
}
button:active { transform: scale(.97); }
button:disabled { filter: grayscale(1) brightness(.6); cursor: not-allowed; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.small { padding: 9px 13px; font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.full { width: 100%; }

input[type=text] {
  width: 100%; font: 600 18px/1.2 var(--mono); color: var(--text); background: #0d1014;
  border: 1px solid var(--line); border-radius: 12px; padding: 14px; outline: none; letter-spacing: .06em;
}
input[type=text]:focus { border-color: var(--accent); }

.msg { min-height: 24px; margin-top: 10px; font-weight: 600; }
.msg.bad { color: var(--bad); }
.msg.ok { color: var(--ok); }
.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }

.hint { margin-top: 14px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 12px; font-size: 14px; color: var(--muted); }
.hint b { color: var(--accent); }

/* Stufe 1: Tresor */
.qlist { margin: 0 0 16px; padding: 0; list-style: none; counter-reset: q; }
.qlist li { counter-increment: q; position: relative; padding: 10px 0 10px 40px; border-bottom: 1px solid var(--line); }
.qlist li::before {
  content: counter(q); position: absolute; left: 0; top: 9px; width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; font: 700 14px var(--mono); background: #0d1014; color: var(--accent); border: 1px solid var(--line);
}
.safe { display: flex; justify-content: center; gap: 10px; margin: 18px 0; }
.wheel { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.wheel button { width: 62px; padding: 8px 0; background: var(--card2); color: var(--muted); border: 1px solid var(--line); font-size: 14px; }
.wheel .digit {
  width: 62px; height: 78px; display: grid; place-items: center; font: 700 40px var(--mono);
  background: #07090b; border: 2px solid #3a434e; border-radius: 10px; color: var(--accent);
  text-shadow: 0 0 12px rgba(255,176,32,.5);
}

/* Stufe 2: Okarina */
.staff {
  position: relative; height: 120px; margin: 14px 0 18px; border-radius: 12px; background: #0d1014; border: 1px solid var(--line);
  overflow: hidden;
}
.staff .line { position: absolute; left: 10px; right: 10px; height: 1px; background: #2c3540; }
.staff .note {
  position: absolute; width: 34px; height: 34px; margin-left: -17px; border-radius: 50%;
  display: grid; place-items: center; font: 700 16px var(--mono); color: #111; animation: pop .2s;
}
@keyframes pop { from { transform: scale(.3); } }
.oca { display: grid; grid-template-columns: repeat(3, 72px); grid-template-rows: repeat(3, 64px); gap: 8px; justify-content: center; }
.oca button { border-radius: 50%; width: 64px; height: 64px; padding: 0; font-size: 22px; justify-self: center; }
.oca .a { background: var(--blue); color: #fff; grid-column: 1; grid-row: 3; }
.oca .c { background: #f2c94c; }
.oca .up { grid-column: 2; grid-row: 1; }
.oca .left { grid-column: 1; grid-row: 2; }
.oca .right { grid-column: 3; grid-row: 2; }
.oca .down { grid-column: 2; grid-row: 3; }

/* Stufe 3: Funkspruch */
.radio {
  font: 700 18px/1.7 var(--mono); letter-spacing: .12em; word-spacing: .3em;
  background: #06120b; color: #6dff9e; border: 1px solid #1b3a26; border-radius: 12px;
  padding: 16px; margin: 12px 0 16px; text-shadow: 0 0 8px rgba(109,255,158,.45);
}
.abc { font: 13px/1.6 var(--mono); color: var(--muted); overflow-x: auto; white-space: nowrap; margin-bottom: 14px; }

/* Stufe 4: G-Code */
pre.gcode {
  font: 13px/1.5 var(--mono); background: #07090b; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; max-height: 300px; overflow: auto; margin: 10px 0 14px; color: #cfd6de;
}
pre.gcode .c { color: #5f6b78; }
pre.gcode .g { color: var(--accent); }
.bed { width: 100%; height: auto; background: #101418; border: 1px solid var(--line); border-radius: 12px; touch-action: manipulation; }
.bed .grid { stroke: #222a33; stroke-width: .3; }
.bed .axis { fill: #7d8894; font: 600 4px var(--mono); }
.bed .pt { fill: #3a4450; cursor: pointer; }
.bed .pt:hover { fill: var(--accent); }
.bed .hit { fill: transparent; cursor: pointer; }
.bed .seg { stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; }
.bed .cur { fill: var(--ok); }

/* Stufe 5: Stack */
canvas.stack { display: block; width: 100%; max-width: 360px; margin: 10px auto; border-radius: 12px; border: 1px solid var(--line); background: #0d1014; touch-action: manipulation; }

/* Ende */
.big { font: 800 44px/1.1 var(--mono); color: var(--ok); text-shadow: 0 0 22px rgba(61,220,132,.5); margin: 10px 0; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10;
  background: var(--ok); color: #062; font-weight: 700; padding: 12px 18px; border-radius: 999px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); animation: rise .25s;
}
.confetti { position: fixed; top: -10px; width: 8px; height: 14px; z-index: 20; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
