:root {
  --bg: #0b1230; --ink: #1d2340; --muted: #5d6585; --card: #fbfaf6; --line: #e2e0d8;
  --ok: #18a058; --bad: #e0464e; --accent: #ffb020; --focus: #3b82f6;
  --b0: #f5a524; --b1: #22c3ee; --b2: #a78bfa; --b3: #34d399; --b4: #fb7185;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: #fff; font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; overflow: hidden; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
body.no3d { background: radial-gradient(circle at 30% 20%, #234 0, var(--bg) 60%); }
#labels { position: fixed; inset: 0; pointer-events: none; }
.islabel { position: absolute; left: 0; top: 0; pointer-events: auto; border: 2px solid var(--c); background: rgba(11, 18, 48, .78); color: #fff; font: 600 14px/1 inherit; font-family: inherit; padding: 6px 10px; border-radius: 99px; cursor: pointer; white-space: nowrap; transition: background .2s; }
.islabel span { margin-right: 5px; }
.islabel:hover, .islabel.active { background: var(--c); color: #111; }
body.labels-off .islabel { pointer-events: none; opacity: .75; }

#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; pointer-events: none; z-index: 5; }
.brand { font-weight: 800; font-size: 20px; text-shadow: 0 2px 8px #000; }
.stats { display: flex; gap: 10px; }
.stats span { background: rgba(0, 0, 0, .45); padding: 6px 12px; border-radius: 99px; font-size: 16px; }
.stats .pop { animation: pop .5s; display: inline-block; }
@keyframes pop { 40% { transform: scale(1.6); color: var(--accent); } }

main { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
.panel { pointer-events: auto; position: absolute; top: 62px; bottom: 16px; overflow-y: auto; border-radius: 18px; }
.hidden { display: none !important; }

#menu { left: 16px; width: min(500px, calc(100% - 32px)); background: rgba(11, 18, 48, .86); backdrop-filter: blur(6px); padding: 18px 20px; border: 1px solid rgba(255, 255, 255, .12); }
#menu h1 { margin: 0 0 6px; font-size: 24px; }
#menu h2 { font-size: 17px; margin: 18px 0 8px; }
#menu h2 small { font-weight: 400; opacity: .7; }
.sub { margin: 0 0 12px; opacity: .85; line-height: 1.4; }
.name { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.name input { font: inherit; font-size: 18px; padding: 9px 12px; border-radius: 10px; border: 2px solid #3a4470; background: #121a40; color: #fff; }
.name input:focus { outline: none; border-color: var(--accent); }
.big-modes { display: grid; gap: 8px; margin-top: 14px; }
.mode { display: grid; grid-template-columns: 42px 1fr; grid-template-rows: auto auto; text-align: left; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid #3a4470; background: #18224f; color: #fff; cursor: pointer; font: inherit; }
.mode span { grid-row: span 2; font-size: 28px; }
.mode small { opacity: .75; }
.mode:hover { background: #22306b; }
.mode.exam { background: linear-gradient(135deg, #ff9f1c, #ff5e62); border: 0; color: #1a1020; }
.mode.exam small { opacity: .85; }
.topics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tcard { text-align: left; border-radius: 12px; padding: 10px; border: 2px solid var(--c); background: #121a40; color: #fff; cursor: pointer; font: inherit; }
.tcard:hover { background: #1b2559; }
.tcard b { display: block; font-size: 15px; }
.tcard small { display: block; opacity: .7; margin-top: 3px; line-height: 1.3; font-size: 12px; }
.tcard .acc { height: 6px; background: #2b3463; border-radius: 6px; margin-top: 8px; overflow: hidden; }
.tcard .acc i { display: block; height: 100%; background: var(--c); }
.foot { margin-top: 18px; font-size: 13px; opacity: .7; }
.foot a { color: #9ecbff; }

.card { bottom: auto; max-height: calc(100% - 78px); right: 16px; width: min(600px, calc(100% - 32px)); background: var(--card); color: var(--ink); padding: 16px 20px 20px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.qhead { display: flex; align-items: center; gap: 10px; }
.chip { background: var(--tc, #ddd); color: #111; font-weight: 700; padding: 4px 10px; border-radius: 99px; font-size: 13px; }
#qProg { color: var(--muted); font-size: 14px; margin-left: auto; }
.ghost { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.bar { height: 6px; background: #e8e5dc; border-radius: 6px; margin: 10px 0 14px; overflow: hidden; }
.bar div { height: 100%; background: var(--tc, var(--accent)); transition: width .4s; }
.qtext { font-size: 19px; line-height: 1.5; }
.qtext .big, .big { font-size: 28px; font-weight: 700; margin: 12px 0 4px; text-align: center; }
.qtext small { color: var(--muted); }
.hl { background: #ffe58a; padding: 0 4px; border-radius: 4px; }
.visual { margin: 10px 0; }
.visual:empty { display: none; }
.visual svg { width: 100%; height: auto; display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.visual svg.coord { max-width: 400px; margin: 0 auto; }
svg .grid { stroke: #e3e6ef; stroke-width: 1; }
svg .axis { stroke: #333; stroke-width: 2; }
svg .arrow { fill: #333; }
svg .tick { font-size: 13px; fill: #333; }
svg .tick.sm { font-size: 10px; fill: #666; }
svg .lab { font-size: 13px; fill: #222; font-weight: 600; }
svg .axl { font-size: 15px; font-style: italic; font-weight: 700; }
svg .pt { fill: #e0464e; stroke: #fff; stroke-width: 2; }
svg .ptl { font-size: 16px; font-weight: 800; fill: #c02030; }
svg .sb.b0 { fill: var(--b0); } svg .sb.b1 { fill: var(--b1); } svg .sb.b2 { fill: var(--b2); } svg .sb.b3 { fill: var(--b3); } svg .sb.b4 { fill: var(--b4); }

.fr { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .82em; line-height: 1.1; margin: 0 2px; }
.fr span:first-child { border-bottom: 2px solid currentColor; padding: 0 3px; }
.tbl { border-collapse: collapse; margin: 10px 0; font-size: 17px; }
.tbl th, .tbl td { border: 1px solid #c9c5b8; padding: 5px 12px; text-align: center; }
.tbl th { background: #f0ede3; }

.inrow { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.inrow input { flex: 1; min-width: 0; font-size: 24px; padding: 10px 14px; border: 2px solid #c9c5b8; border-radius: 12px; font-family: inherit; }
.inrow input:focus { outline: none; border-color: var(--focus); }
.inrow .unit { font-size: 20px; color: var(--muted); }
.coordrow { font-size: 24px; font-weight: 700; justify-content: center; }
.coordrow input { flex: 0 0 90px; text-align: center; }
.btn { font: inherit; font-weight: 700; font-size: 18px; padding: 11px 18px; border-radius: 12px; border: 0; background: var(--ink); color: #fff; cursor: pointer; }
.btn:disabled { opacity: .35; cursor: default; }
.btn.alt { background: #e8e5dc; color: var(--ink); }
.keys { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.keys button { font: inherit; font-size: 20px; min-width: 48px; padding: 6px 10px; border-radius: 10px; border: 1px solid #c9c5b8; background: #fff; cursor: pointer; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 10px; }
.choices.sym { grid-template-columns: repeat(3, 1fr); }
.choices.sym button { font-size: 32px; }
.choices button { font: inherit; font-size: 18px; padding: 14px 10px; border-radius: 12px; border: 2px solid #c9c5b8; background: #fff; cursor: pointer; color: var(--ink); }
.choices button:hover:not(:disabled) { border-color: var(--focus); }
.choices button.right { background: #d8f5e4; border-color: var(--ok); }
.choices button.wrong { background: #fde0e1; border-color: var(--bad); }
.pool, .slots { display: flex; flex-wrap: wrap; gap: 8px; min-height: 54px; padding: 8px; border-radius: 12px; }
.pool { background: #f0ede3; margin-top: 10px; }
.slots { border: 2px dashed #c9c5b8; margin-top: 8px; align-items: center; }
.slots:empty::before { content: 'Hier entsteht deine Reihenfolge …'; color: var(--muted); font-size: 14px; }
.pchip { font: inherit; font-size: 20px; font-weight: 600; padding: 8px 14px; border-radius: 10px; border: 2px solid #c9c5b8; background: #fff; cursor: pointer; color: var(--ink); }
.pchip.used { visibility: hidden; }
.slots .pchip { cursor: default; background: #e6f0ff; border-color: #9ec0f5; }
.slots .sep { color: var(--muted); font-weight: 700; }
.row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.msg { color: var(--bad); font-weight: 600; min-height: 1em; margin-top: 8px; }
.feedback { margin-top: 12px; padding: 14px; border-radius: 14px; }
.feedback.ok { background: #e3f8eb; border: 2px solid var(--ok); }
.feedback.bad { background: #fdecec; border: 2px solid var(--bad); }
.feedback h3 { margin: 0 0 6px; font-size: 21px; }
.feedback .sol { background: #fff; border-radius: 10px; padding: 10px 12px; margin-top: 8px; line-height: 1.7; }
.feedback details summary { cursor: pointer; color: var(--muted); margin-top: 6px; }

#result h2 { margin: 4px 0; font-size: 26px; }
.res-top { display: flex; align-items: center; gap: 16px; }
.res-top .emo { font-size: 64px; }
.grade { display: inline-block; margin-top: 4px; background: var(--ink); color: #fff; padding: 4px 12px; border-radius: 99px; font-weight: 700; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.kpis div { background: #f0ede3; border-radius: 12px; padding: 10px; text-align: center; }
.kpis b { display: block; font-size: 22px; }
.kpis small { color: var(--muted); }
table.subs { width: 100%; border-collapse: collapse; font-size: 15px; }
table.subs td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.subs td:last-child { text-align: right; white-space: nowrap; font-weight: 700; }
.wbox { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; background: #fff; }
.wbox .q { font-weight: 600; }
.wbox .a { margin-top: 6px; font-size: 15px; }
.wbox .a .x { color: var(--bad); font-weight: 700; }
.wbox .a .y { color: var(--ok); font-weight: 700; }
.wbox .sol { color: #333; font-size: 15px; margin-top: 6px; line-height: 1.6; }
.wbox svg { max-width: 320px; width: 100%; height: auto; }

.toast { position: fixed; left: 50%; top: 70px; transform: translate(-50%, -20px); background: var(--accent); color: #111; font-weight: 800; padding: 10px 18px; border-radius: 99px; opacity: 0; transition: .3s; z-index: 10; pointer-events: none; font-size: 18px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .brand { font-size: 16px; }
  .stats span { padding: 4px 8px; font-size: 14px; }
  #menu { top: auto; max-height: 72%; left: 8px; width: calc(100% - 16px); bottom: 8px; }
  .card { top: auto; max-height: 78%; bottom: 8px; right: 8px; width: calc(100% - 16px); bottom: 8px; padding: 12px 14px 16px; }
  .qtext { font-size: 17px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
