:root { --ink: #fff6e8; --soft: #c9bdf0; --panel: rgba(22, 15, 52, 0.82); --line: rgba(190, 170, 255, 0.35); --gold: #ffcf4d; --mint: #7dffe0;
  --top: env(safe-area-inset-top, 0px); --bottom: env(safe-area-inset-bottom, 0px); --left: env(safe-area-inset-left, 0px); --right: env(safe-area-inset-right, 0px); }
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #150f30; color: var(--ink); font: 15px/1.4 system-ui, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#boot { position: fixed; inset: 0; display: grid; place-items: center; background: #150f30; z-index: 30; font-size: 18px; }
button { font: inherit; color: var(--ink); background: rgba(120, 96, 220, 0.35); border: 1px solid var(--line); border-radius: 12px; padding: 9px 14px; min-height: 42px; cursor: pointer; }
button:hover { background: rgba(140, 112, 245, 0.5); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; }
button.primary { background: linear-gradient(180deg, #ffd96a, #ff9f43); color: #2a1236; border-color: transparent; font-weight: 700; }
button[aria-pressed="true"] { background: var(--mint); color: #12203a; border-color: transparent; font-weight: 700; }

#hud { position: fixed; z-index: 5; top: calc(8px + var(--top)); left: calc(8px + var(--left)); right: calc(8px + var(--right)); display: flex; gap: 6px; align-items: center; pointer-events: none; }
#hud .chip { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
#hud .label { color: var(--soft); font-size: 13px; }
#hud b { color: var(--gold); }
#btnMenu { margin-left: auto; pointer-events: auto; background: var(--panel); border-radius: 999px; min-height: 38px; padding: 6px 14px; }
#hint { position: fixed; z-index: 4; top: calc(56px + var(--top)); left: 50%; transform: translateX(-50%); width: max-content; max-width: min(560px, calc(100% - 20px)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 14px; text-align: center; font-size: 14px; pointer-events: none; }
#pointer { position: fixed; z-index: 5; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
#pointer i { position: absolute; left: -17px; top: -17px; width: 34px; height: 34px; display: grid; place-items: center; font-style: normal; font-size: 17px; color: #12203a; background: var(--mint); border-radius: 50%; box-shadow: 0 0 14px rgba(125, 255, 224, 0.8); }
#pointer.gold i { background: var(--gold); box-shadow: 0 0 14px rgba(255, 207, 77, 0.8); }
#pointer b { position: absolute; left: -30px; top: 18px; width: 60px; text-align: center; font-size: 12px; text-shadow: 0 0 4px #000, 0 0 4px #000; }
#stats { position: fixed; z-index: 6; right: calc(8px + var(--right)); top: calc(128px + var(--top)); font: 12px/1.45 ui-monospace, Consolas, monospace; background: rgba(0, 0, 0, 0.55); border-radius: 8px; padding: 5px 9px; text-align: right; white-space: pre-wrap; max-width: calc(100% - 16px); pointer-events: none; }

#legend { position: fixed; z-index: 4; left: calc(10px + var(--left)); bottom: calc(10px + var(--bottom)); width: 330px; max-width: calc(100% - 20px); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; font-size: 13px; }
#legend h2 { font-size: 13px; color: var(--gold); margin-bottom: 4px; }
#legend dl { display: grid; grid-template-columns: max-content 1fr; gap: 1px 12px; }
#legend dt { font-weight: 700; white-space: nowrap; }
#legend dd { color: var(--soft); }
#legend p { color: var(--soft); margin: 5px 0; }
#legend button { min-height: 30px; padding: 3px 10px; font-size: 12px; }

.screen { position: fixed; inset: 0; z-index: 10; display: flex; overflow: auto; padding: calc(12px + var(--top)) 12px calc(12px + var(--bottom)); touch-action: pan-y; }
#levels { background: rgba(14, 10, 36, 0.86); }
.pick { margin: auto; width: min(980px, 100%); display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.pick h2 { color: var(--gold); font-size: 26px; }
#levelList { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; width: 100%; }
.level { border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: linear-gradient(180deg, #3a2a78, #1c1440); }
.level.theme-grotte { background: linear-gradient(180deg, #14606a, #0c2434); }
.level.theme-wipfel { background: linear-gradient(180deg, #3c78b8, #223a68); }
.level.locked { filter: saturate(0.25) brightness(0.75); }
.level h3 { font-size: 21px; color: var(--gold); }
.level .quiet { color: var(--ink); opacity: 0.85; min-height: 38px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; text-align: left; margin-top: auto; }
.facts dt { opacity: 0.75; }
.facts dd { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.level .row button { flex-basis: 120px; }
button:disabled { opacity: 0.55; cursor: default; }
#lightChip b { letter-spacing: 2px; }
#hint b { color: var(--gold); margin-right: 4px; }
#hint { transition: opacity 0.25s; }
#hint.air { opacity: 0.4; }
#hint.done { border-color: var(--mint); }
#hint.done b { color: var(--mint); }
@media (max-width: 760px) { #levelList { grid-template-columns: 1fr; max-width: 420px; } .level .quiet { min-height: 0; } .level { padding: 10px 12px; gap: 5px; } }
@media (max-height: 460px) and (min-width: 600px) { #levelList { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: none; } .level { padding: 8px 10px; gap: 4px; } .level .quiet { display: none; } .pick { gap: 6px; } .pick h2 { font-size: 20px; } .level h3 { font-size: 17px; } }
#start { background: radial-gradient(ellipse at 50% 45%, rgba(21, 15, 48, 0.55), rgba(21, 15, 48, 0.82)); }
#menu { background: rgba(10, 7, 28, 0.55); }
.card { margin: auto; width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; text-align: center; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45); }
.kicker { color: var(--mint); letter-spacing: 0.14em; text-transform: uppercase; font-size: 12px; }
h1 { font-size: clamp(34px, 9vw, 52px); line-height: 1; color: var(--gold); text-shadow: 0 0 24px rgba(255, 170, 60, 0.55); }
h1 small { display: block; font-size: 0.42em; color: var(--ink); text-shadow: none; margin-top: 4px; }
.card h2 { color: var(--gold); }
.quiet { color: var(--soft); font-size: 13px; }
.quiet:empty { display: none; }
fieldset { border: 0; }
fieldset legend { color: var(--soft); font-size: 13px; margin: 0 auto 4px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button { padding: 8px 2px; font-size: 14px; }
label { display: flex; gap: 10px; align-items: center; text-align: left; min-height: 34px; cursor: pointer; }
input[type="checkbox"] { width: 20px; height: 20px; flex: none; accent-color: var(--mint); }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.row button { flex: 1 1 150px; }
body.has-touch .desk { display: none; }
#finish { position: fixed; z-index: 8; left: 50%; top: 22%; transform: translateX(-50%); width: min(420px, calc(100% - 24px)); background: var(--panel); border: 2px solid var(--gold); border-radius: 18px; padding: 14px 18px; text-align: center; display: flex; flex-direction: column; gap: 10px; }
#finish h2 { color: var(--gold); font-size: 20px; }
body[data-screen="menu"] #finish { display: none; }

/* Fingersteuerung */
#touch { position: fixed; inset: 0; z-index: 3; pointer-events: none; touch-action: none; }
#stickZone { position: absolute; left: var(--left); bottom: var(--bottom); width: 50%; height: 48%; pointer-events: auto; touch-action: none; }
#stickBase { position: absolute; left: 14px; bottom: 18px; width: 112px; height: 112px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); background: rgba(30, 20, 70, 0.3); display: grid; place-items: center; }
#stickBase.on { bottom: auto; border-color: var(--mint); }
#stickKnob { width: 52px; height: 52px; border-radius: 50%; background: rgba(255, 246, 232, 0.65); }
#actions { position: absolute; right: calc(12px + var(--right)); bottom: calc(18px + var(--bottom)); width: 170px; height: 140px; }
.act { position: absolute; border-radius: 50%; width: 84px; height: 84px; font-weight: 800; font-size: 14px; pointer-events: auto; touch-action: none; padding: 0; border: 2px solid rgba(255, 255, 255, 0.5); }
#act-jump { right: 0; bottom: 0; background: rgba(255, 159, 67, 0.55); }
#act-arm { left: 0; bottom: 46px; width: 76px; height: 76px; background: rgba(255, 95, 168, 0.5); }
.act.on { filter: brightness(1.5); transform: scale(0.94); }

#gpuTrouble { position: fixed; inset: 0; z-index: 40; background: #150f30; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; text-align: center; padding: 20px; }
#gpuTrouble p { max-width: 480px; }

/* Große Bildschirme: Erklärung unten, damit oben nichts verdeckt wird */
@media (min-width: 1100px) and (min-height: 560px) {
  body:not(.has-touch) #hint { top: auto; bottom: 14px; }
}

@media (max-width: 520px) {
  #hud { gap: 4px; }
  #hud .chip { padding: 4px 8px; font-size: 13px; }
  #hud .label { display: none; }
  #hud .chip:nth-child(1) b::before { content: "Samen "; color: var(--soft); font-weight: 400; }
  #hud .chip:nth-child(2) b::before { content: "Verst. "; color: var(--soft); font-weight: 400; }
  #stats { top: calc(160px + var(--top)); }
  #btnMenu { padding: 6px 10px; font-size: 13px; }
  #hint { top: calc(52px + var(--top)); font-size: 13px; }
}
/* Sehr schmal: Zeichen statt Wörter, damit alles in eine Zeile passt */
@media (max-width: 420px) {
  #hud { gap: 3px; }
  #hud .chip { padding: 4px 7px; }
  #hud .chip:nth-child(1) b::before { content: "♪ "; }
  #hud .chip:nth-child(2) b::before { content: "★ "; }
  #lightChip b { letter-spacing: 0; }
  #btnMenu { padding: 6px 8px; }
}
@media (max-width: 340px) {
  #hud .chip { padding: 4px 6px; font-size: 12px; }
  #actions { width: 148px; right: calc(8px + var(--right)); }
  #act-jump { width: 76px; height: 76px; }
  #act-arm { width: 68px; height: 68px; }
  #stickBase { width: 100px; height: 100px; left: 10px; }
}
@media (max-height: 460px) {
  .card { padding: 10px 16px; gap: 6px; }
  h1 { font-size: 32px; }
  #menu .card { width: min(560px, 100%); }
  #menu label { min-height: 28px; }
  #hint { top: calc(48px + var(--top)); font-size: 12px; max-width: min(520px, calc(100% - 20px)); }
  #stats { top: calc(108px + var(--top)); }
  #menu button { min-height: 36px; padding-top: 4px; padding-bottom: 4px; }
  #stickBase { bottom: 12px; }
  #finish { top: 14%; }
}
@media (prefers-reduced-motion: reduce) { .act.on { transform: none; } }
