:root {
  --night: #17132f;
  --panel: rgba(27, 22, 58, 0.78);
  --panel-line: rgba(243, 213, 138, 0.35);
  --gold: #f3d58a;
  --gold-deep: #d9b45c;
  --text: #f5f2ff;
  --muted: #c2bbe0;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --st: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--text);
  font-family: var(--sans); font-size: 16px;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none; touch-action: none;
}
body { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#touch { position: absolute; inset: 0; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
h1, h2 { font-family: var(--serif); font-weight: 600; margin: 0; text-wrap: balance; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: none; }
#hud button { pointer-events: auto; }
#topbar { position: absolute; top: calc(var(--st) + 10px); left: calc(var(--sl) + 14px); display: flex; align-items: center; gap: 8px; }
#shards { display: flex; gap: 5px; padding: 6px 10px; border-radius: 999px; background: rgba(23, 19, 47, 0.55); border: 1px solid rgba(255, 255, 255, 0.14); }
#shards svg { width: 20px; height: 24px; display: block; }
#shards .off path { fill: rgba(255, 255, 255, 0.12); stroke: rgba(255, 255, 255, 0.45); }
#shards .on path { stroke: rgba(255, 255, 255, 0.9); filter: drop-shadow(0 0 4px currentColor); fill: currentColor; }
#shards .pop { animation: pop 0.7s ease-out; }
@keyframes pop { 0% { transform: scale(0.4); } 55% { transform: scale(1.55); } 100% { transform: scale(1); } }
.chip { display: flex; align-items: center; gap: 5px; padding: 6px 11px; border-radius: 999px; background: rgba(23, 19, 47, 0.55); border: 1px solid rgba(255, 255, 255, 0.14); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.chip svg { width: 17px; height: 17px; fill: #fff1a8; stroke: #fff1a8; }
#sparkcount svg { fill: #ffe9a0; stroke: #ffe9a0; }
#sparkcount.pop { animation: pop 0.35s ease-out; }
.round { position: absolute; top: calc(var(--st) + 10px); right: calc(var(--sr) + 14px); width: 44px; height: 44px; border-radius: 50%; background: rgba(23, 19, 47, 0.55); border: 1px solid rgba(255, 255, 255, 0.2); display: grid; place-items: center; }
.round svg { width: 20px; height: 20px; fill: var(--text); }
#hint { position: absolute; top: calc(var(--st) + 58px); left: 50%; transform: translateX(-50%); max-width: min(64vw, 560px); padding: 8px 16px; border-radius: 14px; background: rgba(23, 19, 47, 0.62); border: 1px solid var(--panel-line); font-size: 15px; line-height: 1.35; text-align: center; text-wrap: balance; }
#toast { z-index: 30; pointer-events: none; position: absolute; top: 34%; left: 50%; transform: translateX(-50%); padding: 10px 22px; border-radius: 999px; background: rgba(23, 19, 47, 0.72); border: 1px solid var(--gold); color: var(--gold); font-family: var(--serif); font-size: 21px; white-space: nowrap; animation: toast 3.2s ease forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 12px) scale(0.92); } 10%, 80% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -10px); } }
#stick { position: absolute; width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; background: rgba(255, 255, 255, 0.1); border: 1.5px solid rgba(255, 255, 255, 0.35); opacity: 0; transition: opacity 0.15s; left: 110px; top: 70%; }
#stick.on { opacity: 1; }
#knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; border-radius: 50%; background: rgba(255, 255, 255, 0.55); transform: translate(-50%, -50%); box-shadow: 0 0 14px rgba(255, 255, 255, 0.35); }
.action { position: absolute; border-radius: 50%; display: grid; place-items: center; background: rgba(23, 19, 47, 0.5); border: 2px solid rgba(255, 255, 255, 0.55); transition: transform 0.08s, background 0.08s; }
.action svg { width: 46%; height: 46%; fill: #fff; }
.action.down { transform: scale(0.9); background: rgba(243, 213, 138, 0.45); }
#btnJump { width: 82px; height: 82px; right: calc(var(--sr) + 22px); bottom: calc(var(--sb) + 20px); }
#btnHorn { width: 72px; height: 72px; right: calc(var(--sr) + 116px); bottom: calc(var(--sb) + 52px); border-color: var(--gold); }
#btnHorn svg { fill: var(--gold); }
#keys { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); font-size: 13px; color: rgba(255, 255, 255, 0.85); background: rgba(23, 19, 47, 0.5); padding: 6px 14px; border-radius: 999px; white-space: nowrap; }
body.desktop .action { display: none; }
body.desktop #keys { display: block !important; }

/* ---------- Bildschirme ---------- */
#screens { position: absolute; inset: 0; pointer-events: none; }
.screen { position: absolute; inset: 0; display: flex; padding: calc(var(--st) + 14px) calc(var(--sr) + 18px) calc(var(--sb) + 14px) calc(var(--sl) + 18px); pointer-events: auto; animation: fadein 0.35s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.screen.center { align-items: center; justify-content: center; }
.screen.right { align-items: stretch; justify-content: flex-end; pointer-events: none; }
.screen.right .panel { pointer-events: auto; }
.panel { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 20px; padding: 20px 24px; max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); width: min(420px, 100%); box-shadow: 0 12px 40px rgba(8, 5, 30, 0.45); }
.panel.wide { width: min(760px, 100%); }
.panel.side { width: min(440px, 54vw); padding: 12px 18px; }
.side .field { display: grid; grid-template-columns: 78px minmax(0, 1fr); align-items: center; gap: 8px; margin: 6px 0; }
.side .field > span:first-child { margin: 0; font-size: 11px; }
.side .fine { margin: 4px 0 0; }
.side .row { margin-top: 8px; }
.panel.story { width: min(560px, 100%); text-align: center; }
.panel h2 { font-size: 26px; color: var(--gold); margin-bottom: 12px; }
.panel.side h2 { font-size: 22px; margin-bottom: 8px; }
.story p { font-family: var(--serif); font-size: 20px; line-height: 1.5; margin: 6px 0 16px; text-wrap: pretty; }
.story .kicker { font-family: var(--sans); font-size: 13px; margin-bottom: 4px; }
.story .stats { font-family: var(--sans); font-size: 15px; color: var(--muted); }
.titlebox { text-align: center; padding: 10px 20px 0; text-shadow: 0 2px 18px rgba(15, 10, 45, 0.85); }
.titlebox h1 { font-size: clamp(54px, 13vh + 2vw, 104px); letter-spacing: 0.04em; line-height: 1; color: #fff; background: linear-gradient(180deg, #fff 30%, var(--gold) 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; text-shadow: none; filter: drop-shadow(0 3px 16px rgba(20, 12, 60, 0.7)); padding-bottom: 0.08em; }
.kicker { text-transform: uppercase; letter-spacing: 0.22em; font-size: 13px; color: var(--gold); margin: 0 0 6px; }
.lead { font-family: var(--serif); font-size: 19px; margin: 10px auto 20px; max-width: 30ch; text-wrap: balance; }
.primary { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: #2a1f4d; font-weight: 700; padding: 12px 30px; border-radius: 999px; font-size: 17px; min-height: 46px; box-shadow: 0 4px 18px rgba(243, 213, 138, 0.35); }
.primary:active { transform: scale(0.96); }
.ghost { padding: 11px 20px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.35); color: var(--text); min-height: 44px; font-size: 16px; }
.ghost:active { background: rgba(255, 255, 255, 0.12); }
.ghost.small { padding: 6px 12px; min-height: 36px; font-size: 14px; }
.ghost.warn { border-color: #ff9d9d; color: #ffc9c9; }
.row { display: flex; gap: 12px; justify-content: space-between; align-items: center; margin-top: 12px; }
.stack { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stack .primary { grid-column: 1 / -1; }
.stack .ghost { padding: 10px 12px; font-size: 15px; }
.fine { font-size: 13px; color: var(--muted); margin: 8px 0 0; line-height: 1.4; }
.field { display: block; margin: 8px 0; }
.field > span:first-child { display: block; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.namerow { display: flex; gap: 8px; min-width: 0; }
.namerow button { flex: none; }
input[type="text"] { flex: 1; min-width: 0; font: inherit; font-size: 17px; color: var(--text); background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 12px; padding: 7px 12px; -webkit-user-select: text; user-select: text; }
input[type="text"]:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
input::placeholder { color: rgba(255, 255, 255, 0.45); }
.swatches { display: flex; gap: 9px; flex-wrap: wrap; }
.swatch { width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); padding: 0; }
.swatch.sel { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(243, 213, 138, 0.45); transform: scale(1.08); }
.modes { display: flex; gap: 8px; }
.mode { flex: 1; padding: 8px 6px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.3); font-size: 15px; min-height: 40px; }
.mode.sel { background: rgba(243, 213, 138, 0.2); border-color: var(--gold); color: var(--gold); font-weight: 600; }
#slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.slot { position: relative; border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.28); padding: 14px 12px; text-align: center; min-height: 124px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: rgba(255, 255, 255, 0.05); }
.slot:active { background: rgba(255, 255, 255, 0.12); }
.slot .nm { font-family: var(--serif); font-size: 21px; color: var(--text); overflow-wrap: anywhere; }
.slot .sub { font-size: 13px; color: var(--muted); }
.slot .chips { display: flex; gap: 4px; }
.slot .chips i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.5); display: block; }
.slot .plus { font-size: 34px; line-height: 1; color: var(--gold); font-family: var(--serif); }
.slot .del { position: absolute; top: 4px; right: 4px; width: 34px; height: 34px; border-radius: 50%; font-size: 13px; color: var(--muted); }
.slot .del.sure { width: auto; padding: 0 10px; color: #ffc9c9; border: 1px solid #ff9d9d; background: rgba(60, 10, 30, 0.6); }
.dots { display: flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.3); }
.dots i.on { background: var(--gold); }

#rotate { position: absolute; inset: 0; background: var(--night); display: grid; place-items: center; text-align: center; z-index: 50; font-family: var(--serif); font-size: 20px; padding: 30px; }
#rotate svg { width: 84px; height: 84px; color: var(--gold); animation: tilt 2.4s ease-in-out infinite; }
@keyframes tilt { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
#fader { position: absolute; inset: 0; background: var(--night); opacity: 0; pointer-events: none; transition: opacity 0.35s ease; z-index: 40; }
#fader.on { opacity: 1; }
#fatal { position: absolute; inset: 0; background: var(--night); display: grid; place-items: center; text-align: center; padding: 30px; font-size: 17px; line-height: 1.5; z-index: 60; }

@media (max-height: 430px) {
  .panel { padding: 14px 18px; border-radius: 16px; }
  .panel h2 { font-size: 21px; margin-bottom: 8px; }
  .story p { font-size: 17px; margin: 4px 0 10px; }
  .lead { font-size: 16px; margin: 6px auto 12px; }
  .slot { min-height: 104px; padding: 10px; }
  .field { margin: 6px 0; }
  .swatch { width: 33px; height: 33px; }
  .side .field { margin: 5px 0; }
  .panel.side h2 { font-size: 20px; margin-bottom: 4px; }
  .mode { min-height: 36px; padding: 6px; }
  #hint { font-size: 14px; padding: 6px 14px; }
  .stack { gap: 8px; margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .screen, #toast, #rotate svg, #shards .pop { animation: none; }
}

/* ---------- Version 0.2: neue Bildschirme ---------- */
.titlelinks { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.titlelinks .ghost { background: rgba(23, 19, 47, 0.45); position: relative; text-shadow: none; }
.dot { position: absolute; top: -3px; right: -3px; width: 12px; height: 12px; border-radius: 50%; background: #ff7eb6; border: 2px solid var(--night); display: block; }
.ver { font-size: 12px; color: rgba(255, 255, 255, 0.75); margin: 10px 0 0; letter-spacing: 0.06em; }
.row.end { justify-content: flex-end; }
.panel.pause { width: min(520px, 100%); }
.field.inline { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 10px; }
.field.inline > span:first-child { margin: 0; }
.slider { position: relative; height: 40px; border-radius: 999px; touch-action: none; cursor: pointer; }
.slider::before { content: ""; position: absolute; left: 0; right: 0; top: 16px; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.18); }
.slider i { position: absolute; left: 0; top: 16px; height: 8px; border-radius: 999px; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); display: block; pointer-events: none; }
.slider b { position: absolute; top: 7px; width: 26px; height: 26px; margin-left: -13px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(8, 5, 30, 0.5); display: block; pointer-events: none; }
.swatch { position: relative; }
.swatch.locked { opacity: 0.55; }
.swatch.locked::after { content: ""; position: absolute; inset: 0; margin: auto; width: 14px; height: 12px; border-radius: 3px; background: #17132f; box-shadow: 0 -7px 0 -3px #17132f, 0 0 0 1.5px rgba(255, 255, 255, 0.8); }
.swatch.fresh { animation: pop 0.7s ease-out; }
.locknote { min-height: 1.4em; color: var(--gold); margin: 2px 0 0 86px; }
.locknote:empty { display: none; }
#chapters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.chapter { border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.28); padding: 14px 16px; text-align: left; background: rgba(255, 255, 255, 0.05); display: flex; flex-direction: column; gap: 5px; min-height: 118px; color: var(--text); }
.chapter:active { background: rgba(255, 255, 255, 0.12); }
.chapter .k { font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); }
.chapter .n { font-family: var(--serif); font-size: 22px; }
.chapter .s { font-size: 13px; color: var(--muted); line-height: 1.4; }
.chapter.here { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(243, 213, 138, 0.3); }
.chapter.locked { opacity: 0.55; }
.news { display: flex; flex-direction: column; }
#newsList { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; flex: 1; min-height: 0; padding-right: 6px; -webkit-user-select: text; user-select: text; }
.panel.news { overflow: hidden; }
.rel { margin: 0 0 14px; }
.rel h3 { font-family: var(--serif); font-size: 18px; margin: 0 0 2px; color: var(--text); font-weight: 600; }
.rel .when { font-size: 12px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 6px; }
.rel ul { margin: 0; padding-left: 20px; }
.rel li { font-size: 15px; line-height: 1.45; margin: 3px 0; }
#scrFinale .row { justify-content: center; flex-wrap: wrap; }
@media (max-height: 430px) {
  .stack { gap: 7px; margin-top: 8px; }
  .stack .ghost { padding: 7px 10px; min-height: 38px; }
  .stack .primary { min-height: 40px; padding: 8px 20px; }
  .slider { height: 34px; }
  .slider::before, .slider i { top: 13px; }
  .slider b { top: 4px; }
  .chapter { min-height: 96px; padding: 10px 14px; }
  .titlelinks { margin-top: 8px; }
  .ver { margin-top: 6px; }
  .side .swatch { width: 30px; height: 30px; }
  .side .swatches { gap: 7px; }
}
