/* Sand v2 – Oberfläche */
:root {
  --bg: #0a0d13;
  --panel: rgba(19, 23, 32, 0.94);
  --panel-2: #1a2030;
  --panel-3: #222a3c;
  --line: #283146;
  --line-2: #354057;
  --text: #ecebe6;
  --muted: #9ba4b8;
  --accent: #f2c45a;
  --accent-2: #ffd98a;
  --accent-ink: #1d1505;
  --ok: #62d995;
  --danger: #ff8077;
  --focus: 0 0 0 3px rgba(242, 196, 90, 0.65);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  min-height: 100vh;
  color: var(--text);
  font: 400 14px/1.45 var(--font);
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(242, 196, 90, 0.07), transparent 60%),
    radial-gradient(900px 600px at 0% 110%, rgba(70, 130, 200, 0.08), transparent 60%),
    var(--bg);
  -webkit-tap-highlight-color: transparent;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 20px; height: 20px; flex: none; }
button { font: inherit; color: inherit; }
button, select, input { touch-action: manipulation; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }

/* ---------------- App-Rahmen ---------------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 540px;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
  min-height: 56px;
}
.brand { display: flex; align-items: baseline; gap: 8px; user-select: none; }
.brand-logo { display: inline-grid; grid-template-columns: repeat(3, 6px); grid-template-rows: 6px 6px; gap: 1px; align-self: center; }
.brand-logo i { display: block; width: 6px; height: 6px; border-radius: 1.5px; background: var(--accent); }
.brand-logo i:nth-child(1) { grid-column: 2; grid-row: 1; background: #ffdf8f; }
.brand-logo i:nth-child(2) { grid-column: 1; grid-row: 2; background: #d9ae52; }
.brand-logo i:nth-child(3) { grid-column: 3; grid-row: 2; background: #3a8ade; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: 3px; text-transform: uppercase; color: var(--accent); }
.brand-sub { color: var(--muted); font-size: 12.5px; letter-spacing: 0.4px; }
.tb-actions { margin-left: auto; display: flex; gap: 4px; align-items: center; }

/* Icon-Buttons */
.ib {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0;
  border-radius: 11px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.ib:hover { background: var(--panel-3); border-color: var(--line-2); }
.ib:active { transform: scale(0.95); }
.ib[aria-pressed="true"] { border-color: rgba(242, 196, 90, 0.6); color: var(--accent-2); }
.ib.ib-accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.ib.ib-accent:hover { background: var(--accent-2); }
.ib-sm { width: 30px; height: 30px; border-radius: 9px; }
.ib-sm svg { width: 17px; height: 17px; }

/* Text-Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 38px; padding: 8px 12px;
  border-radius: 11px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
  font-weight: 600; font-size: 13.5px; text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.btn:hover { background: var(--panel-3); border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; color: var(--accent); }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: 13px; justify-content: center; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary svg { color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger svg { color: var(--danger); }
.btn-danger:hover { border-color: rgba(255, 128, 119, 0.55); }
.btn-big { min-height: 48px; padding: 10px 16px; font-size: 15px; border-radius: 13px; }
.btn[disabled], .ib[disabled] { opacity: 0.45; cursor: not-allowed; }
.linkbtn { background: none; border: 0; color: var(--accent-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 6px; font-size: 13.5px; }

/* ---------------- Arbeitsfläche ---------------- */
.work {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr) 282px;
  gap: 10px;
  padding: 0 10px 10px;
}
.side {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.sec { display: flex; flex-direction: column; gap: 8px; }
.side-right { overflow: hidden; }
.sec-mats { flex: 1 1 auto; min-height: 120px; overflow: auto; overscroll-behavior: contain; margin: -2px -6px 0 0; padding: 2px 6px 4px 0; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.sec-mats .sec-h { position: sticky; top: -2px; z-index: 1; background: #141924; padding: 2px 0 4px; }
.sec-info { flex: none; max-height: 46%; overflow: auto; }
.sec-h {
  margin: 0; display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; font-weight: 700; letter-spacing: 1.8px; text-transform: uppercase; color: var(--muted);
}
.row-label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.row-label output { color: var(--accent-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
select {
  width: 100%; min-height: 34px; padding: 4px 8px; border-radius: 9px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); font: inherit;
}

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--panel-3); border: 1px solid var(--line); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--panel-3); border: 1px solid var(--line); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; margin-top: -7px;
  border-radius: 50%; background: var(--accent); border: 2px solid #11141b; box-shadow: 0 0 10px rgba(242, 196, 90, 0.45);
}
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid #11141b; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; }
.seg button {
  min-height: 30px; padding: 4px 6px; border: 0; border-radius: 8px; background: transparent; color: var(--muted);
  font-size: 12.5px; font-weight: 650; cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.sim-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.scene-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.scene-btns .btn { width: 100%; min-height: 50px; flex-direction: column; justify-content: center; gap: 3px; padding: 6px 4px; font-size: 11.5px; text-align: center; line-height: 1.15; }
.scene-btns .btn svg { width: 19px; height: 19px; }
.disc-count { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 99px; background: rgba(242, 196, 90, 0.16); color: var(--accent-2); font-size: 11.5px; }

/* Werkzeuge */
.tool-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.tool-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 43px; padding: 3px 2px;
  border-radius: 11px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  cursor: pointer; font-size: 9.5px; font-weight: 650; letter-spacing: 0.2px;
  transition: background 0.15s, border-color 0.15s;
}
.tool-btn svg { width: 21px; height: 21px; }
.tool-btn:hover { background: var(--panel-3); }
.tool-btn[aria-checked="true"] { border-color: var(--accent); background: rgba(242, 196, 90, 0.12); color: var(--accent-2); box-shadow: inset 0 0 0 1px var(--accent); }
.tool-btn[disabled] { opacity: 0.28; cursor: not-allowed; }
.tool-btn .tk { position: absolute; top: 2px; right: 4px; font-size: 8.5px; color: var(--muted); font-weight: 600; }
.opts-toggle { display: none; }

/* Materialien */
.mats { display: flex; flex-direction: column; gap: 4px; }
.mat-cat { margin: 6px 0 1px; font-size: 10.5px; letter-spacing: 1.4px; text-transform: uppercase; color: #7f889c; font-weight: 700; }
.mat-cat:first-child { margin-top: 0; }
.mat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.mat {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 3px 5px;
  border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  cursor: pointer; font-size: 11.5px; font-weight: 600; text-align: left; line-height: 1.08;
  transition: background 0.12s, border-color 0.12s;
  overflow: hidden;
}
.mat:hover { background: var(--panel-3); border-color: var(--line-2); }
.mat[aria-checked="true"] { border-color: var(--accent); background: rgba(242, 196, 90, 0.12); box-shadow: inset 0 0 0 1px var(--accent); }
.mat[disabled] { opacity: 0.25; cursor: not-allowed; }
.mat .sw { flex: none; width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, 0.18); box-shadow: inset 0 -3px 5px rgba(0, 0, 0, 0.25); }
.mat .sw.glow { box-shadow: 0 0 9px 1px var(--glow, #ff8a2a); }
.mat .nm { overflow: hidden; hyphens: manual; -webkit-hyphens: manual; overflow-wrap: normal; }
.mat .mk { position: absolute; top: 1px; right: 3px; font-size: 8.5px; color: var(--muted); }

.sec-info { padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); gap: 6px; }
.mi-head { display: flex; align-items: center; gap: 10px; }
.mi-sw { width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.18); flex: none; }
.mi-name { font-weight: 750; font-size: 15px; }
.mi-cat { font-size: 11.5px; color: var(--muted); }
.mi-desc { margin: 0; color: #d4d6dd; font-size: 13px; }
.mi-q { margin: 2px 0 0; font-size: 12px; font-weight: 700; color: var(--accent-2); }
.mi-facts { margin: 0; padding-left: 18px; color: #c3c8d4; font-size: 12.5px; }
.mi-facts li { margin: 2px 0; }

/* ---------------- Spielfeld ---------------- */
.stage-col { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0b0e15;
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
#view {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none; cursor: crosshair;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#view:focus-visible { box-shadow: inset 0 0 0 3px rgba(242, 196, 90, 0.6); }
.statusbar {
  flex: none; display: flex; justify-content: space-between; gap: 10px;
  padding: 0 4px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden;
}
.sb-cell { overflow: hidden; text-overflow: ellipsis; }
.sb-info { display: none; align-items: center; gap: 5px; min-width: 0; padding: 2px 4px; border: 0; background: none; color: var(--muted); font-size: 11.5px; cursor: pointer; text-align: left; }
.sb-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-info b { color: var(--text); }
.sb-info svg { width: 15px; height: 15px; color: var(--accent-2); }
@media (pointer: coarse), (max-width: 899px) {
  .sb-cell { display: none; }
  .sb-info { display: flex; }
}
.sb-right { display: flex; gap: 12px; }
.paused-badge {
  position: absolute; right: 10px; top: 10px; z-index: 4;
  padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
  background: rgba(242, 196, 90, 0.92); color: var(--accent-ink); pointer-events: none;
}

/* Startbildschirm */
.start {
  position: absolute; inset: 0; z-index: 8;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(8, 10, 16, 0.45), rgba(8, 10, 16, 0.78));
}
.start-card {
  width: min(460px, 100%);
  max-height: 100%; overflow: auto;
  padding: 22px 22px 16px; border-radius: 20px; text-align: center;
  background: rgba(17, 21, 30, 0.86); border: 1px solid var(--line-2);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.start-title {
  margin: 0; font-size: 58px; line-height: 1; font-weight: 900; letter-spacing: 10px; text-transform: uppercase;
}
.start-title span {
  background: linear-gradient(180deg, #ffe7a6 0%, #f2c45a 45%, #c9913a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 rgba(120, 80, 20, 0.6));
}
.start-sub { margin: 10px 0 16px; color: #c8ccd6; font-size: 14px; }
.start-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.start-btns .btn { justify-content: center; }
.start-btns .btn-primary { grid-column: 1 / -1; }
.start-tip { margin: 6px 0 0; font-size: 12px; color: var(--muted); }

/* Herausforderungs-HUD */
.hud {
  position: absolute; left: 10px; top: 10px; z-index: 5;
  width: min(330px, calc(100% - 20px));
  padding: 10px 12px; border-radius: 14px;
  background: rgba(15, 19, 28, 0.86); border: 1px solid var(--line-2);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex; flex-direction: column; gap: 6px;
}
.hud-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.hud-title { font-weight: 750; font-size: 14px; color: var(--accent-2); }
.hud-time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }
.hud-goal { font-size: 12.5px; color: #cdd2dc; }
.hud-bar { height: 8px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
.hud-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #62d995, #f2c45a); transition: width 0.25s; }
.hud-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hud-label { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hud-btns { display: flex; gap: 4px; }
.hud.compact .hud-goal { display: none; }
.hud { cursor: pointer; }

/* Toasts */
.toasts { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 9; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; width: max-content; max-width: calc(100% - 20px); }
.toast {
  padding: 7px 14px; border-radius: 99px; font-size: 13px; font-weight: 600;
  background: rgba(16, 20, 29, 0.92); border: 1px solid var(--line-2); color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.22s ease-out;
  text-align: center;
}
.toast.toast-disc { border-color: rgba(242, 196, 90, 0.7); }
.toast.toast-disc b { color: var(--accent-2); }
.toast.out { opacity: 0; transition: opacity 0.4s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Tooltip */
.tip {
  position: fixed; z-index: 60; width: 270px; pointer-events: none;
  padding: 10px 12px; border-radius: 12px;
  background: rgba(16, 20, 29, 0.97); border: 1px solid var(--line-2); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  font-size: 12.5px; color: #d3d7e0;
}
.tip b { color: var(--text); font-size: 14px; }
.tip .tp-q { margin: 6px 0 2px; color: var(--accent-2); font-weight: 700; font-size: 12px; }
.tip ul { margin: 0; padding-left: 16px; }
.tip .tp-k { float: right; color: var(--muted); font-size: 11px; }

/* Optionen-Popover (nur mobil sichtbar als Popover) */
.opts { display: flex; flex-direction: column; gap: 12px; }
.opts-head { display: none; }

/* ---------------- Modal ---------------- */
.modal { position: fixed; inset: 0; z-index: 2147483100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-back { position: absolute; inset: 0; background: rgba(5, 7, 11, 0.66); }
.modal-card {
  position: relative; width: min(760px, 100%); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  background: #141926; border: 1px solid var(--line-2); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: popIn 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.modal-card.narrow { width: min(460px, 100%); }
.modal-card:focus { outline: none; }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 14px 16px 16px; overflow: auto; overscroll-behavior: contain; }
.modal-body p { margin: 0 0 10px; color: #cfd3dc; }
.modal-body h3 { margin: 14px 0 6px; font-size: 14px; color: var(--accent-2); }
.modal-body h3:first-child { margin-top: 0; }
.modal-body ul { margin: 0 0 8px; padding-left: 18px; color: #cfd3dc; }
.modal-body li { margin: 3px 0; }
.modal-body kbd {
  display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 5px; text-align: center;
  font: 600 11.5px/1.6 var(--font); background: #0d1017; border: 1px solid var(--line-2); border-bottom-width: 2px; color: var(--text);
}

.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.menu-grid .btn { min-height: 52px; }
.menu-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.card {
  display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--line); text-align: left; cursor: pointer; color: var(--text);
  transition: border-color 0.15s, transform 0.1s, background 0.15s;
}
.card:hover { border-color: var(--accent); background: var(--panel-3); }
.card:active { transform: scale(0.99); }
.card canvas, .card img { width: 100%; aspect-ratio: 16 / 10; border-radius: 9px; background: #0b0e15; image-rendering: pixelated; object-fit: cover; }
.card b { font-size: 14px; }
.card small { color: var(--muted); font-size: 12px; line-height: 1.35; }

.ch-list { display: flex; flex-direction: column; gap: 8px; }
.ch {
  display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 13px; background: var(--panel-2); border: 1px solid var(--line);
  cursor: pointer; text-align: left; color: var(--text);
}
.ch:hover { border-color: var(--accent); background: var(--panel-3); }
.ch-num { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-weight: 800; background: #0e121b; color: var(--accent-2); border: 1px solid var(--line-2); }
.ch.done .ch-num { background: rgba(98, 217, 149, 0.15); color: var(--ok); border-color: rgba(98, 217, 149, 0.5); }
.ch-t b { display: block; font-size: 14px; }
.ch-t small { color: var(--muted); font-size: 12.5px; }
.ch-r { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }
.stars { display: inline-flex; gap: 1px; color: #3a4359; }
.stars svg { width: 15px; height: 15px; }
.stars .on { color: var(--accent); }
.big-stars { display: flex; justify-content: center; gap: 6px; margin: 4px 0 10px; color: #3a4359; }
.big-stars svg { width: 40px; height: 40px; }
.big-stars .on { color: var(--accent); filter: drop-shadow(0 0 10px rgba(242, 196, 90, 0.55)); animation: starPop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.4) both; }
.big-stars .on:nth-child(2) { animation-delay: 0.15s; }
.big-stars .on:nth-child(3) { animation-delay: 0.3s; }
@keyframes starPop { from { transform: scale(0.2); opacity: 0; } to { transform: none; opacity: 1; } }
.result-big { text-align: center; font-size: 15px; }
.result-big strong { font-size: 26px; display: block; margin-bottom: 4px; color: var(--accent-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; }
.chip i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.slots { display: flex; flex-direction: column; gap: 8px; }
.slot { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; padding: 8px; border-radius: 13px; background: var(--panel-2); border: 1px solid var(--line); }
.slot img { width: 96px; height: 60px; border-radius: 8px; object-fit: cover; image-rendering: pixelated; background: #0b0e15; }
.slot-t b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-t small { color: var(--muted); font-size: 12px; }
.slot-b { display: flex; gap: 6px; }
.save-row { display: flex; gap: 8px; margin-bottom: 12px; }
.save-row input {
  flex: 1; min-width: 0; min-height: 40px; padding: 6px 10px; border-radius: 11px; border: 1px solid var(--line);
  background: #0e121b; color: var(--text); font: inherit;
}
.empty-note { padding: 14px; border-radius: 12px; border: 1px dashed var(--line-2); color: var(--muted); text-align: center; }

.set-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.set-item { display: flex; flex-direction: column; gap: 6px; }
.set-item > span { font-size: 13px; color: var(--muted); }
.set-item .seg { max-width: 100%; }

.disc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.disc { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
.disc b { display: block; font-size: 13.5px; }
.disc small { color: var(--muted); font-size: 12px; }
.disc.got { border-color: rgba(242, 196, 90, 0.55); background: rgba(242, 196, 90, 0.07); }
.disc.got b { color: var(--accent-2); }
.disc:not(.got) b { color: #6f788c; }

.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
.react-list { display: grid; grid-template-columns: 1fr; gap: 4px; margin: 0; padding: 0; list-style: none; }
.react-list li { font-size: 13px; color: #cfd3dc; }

/* ---------------- Footer-Abstand ---------------- */
.s05-footer { margin-top: 0; }

/* ======================================================================
   Kompakter Desktop (schmale Seitenleisten)
   ====================================================================== */
@media (max-width: 1180px) and (min-width: 900px) {
  .work { grid-template-columns: 214px minmax(0, 1fr) 236px; }
  .mat-grid { grid-template-columns: repeat(2, 1fr); }
  .brand-sub { display: none; }
}

/* ======================================================================
   Handy / Tablet hochkant
   ====================================================================== */
@media (max-width: 899px) and (min-height: 561px), (max-width: 560px) {
  .app { min-height: 480px; }
  .topbar { gap: 8px; padding: calc(6px + env(safe-area-inset-top, 0px)) 8px 6px; min-height: 48px; }
  .brand { display: none; }
  .hide-sm { display: none; }
  .ib { width: 36px; height: 36px; }
  .work { display: flex; flex-direction: column; gap: 6px; padding: 0 6px calc(6px + env(safe-area-inset-bottom, 0px)); }
  .stage-col { order: 1; flex: 1; gap: 4px; }
  .stage { border-radius: 12px; }
  .side { background: none; border: 0; padding: 0; overflow: visible; gap: 0; }
  .side-left { order: 2; flex: none; }
  .side-right { order: 3; flex: none; }
  .sec-scene, .sec-info { display: none; }
  .sec-tools .sec-h, .sec-mats .sec-h { display: none; }
  .sec-tools { flex-direction: row; gap: 6px; }
  .tool-grid {
    flex: 1; display: flex; gap: 5px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    touch-action: pan-x; padding-bottom: 1px;
  }
  .tool-grid::-webkit-scrollbar { display: none; }
  .tool-btn { flex: none; width: 50px; min-height: 46px; }
  .tool-btn .tk { display: none; }
  .opts-toggle { display: flex; flex: none; width: 52px; background: var(--panel-3); border-color: var(--line-2); }
  .opts-size { font-size: 11px; font-weight: 800; color: var(--accent-2); }
  .opts {
    display: none;
    position: fixed; left: 8px; right: 8px; bottom: calc(118px + env(safe-area-inset-bottom, 0px)); z-index: 40;
    max-height: calc(100dvh - 190px); overflow: auto;
    padding: 12px 14px 14px; border-radius: 16px;
    background: rgba(18, 22, 32, 0.97); border: 1px solid var(--line-2); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  }
  .opts.open { display: flex; }
  .opts-head { display: flex; align-items: center; justify-content: space-between; }
  .mats {
    flex-direction: row; gap: 5px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    touch-action: pan-x; padding: 1px 0;
  }
  .mats::-webkit-scrollbar { display: none; }
  .mats { align-items: center; }
  .mat-cat {
    flex: none; writing-mode: vertical-rl; transform: rotate(180deg); margin: 0 1px; padding: 0 1px;
    height: 52px; display: flex; align-items: center; justify-content: center; overflow: hidden;
    font-size: 8.5px; letter-spacing: 0.8px; text-align: center; color: #6c7488;
    border-left: 1px solid var(--line);
  }
  .mat-cat::after { content: attr(data-short); }
  .mat-cat { font-size: 0; }
  .mat-cat::after { font-size: 8.5px; }
  .mat-grid { display: flex; gap: 5px; }
  .mat { flex: none; flex-direction: column; justify-content: center; gap: 3px; width: 58px; min-height: 52px; padding: 5px 3px; font-size: 10px; text-align: center; }
  .mat .sw { width: 20px; height: 20px; border-radius: 5px; }
  .mat .nm { max-width: 100%; }
  .mat .mk { display: none; }
  .sec-mats { position: relative; overflow: visible; min-height: 0; margin: 0; padding: 0; flex: none; }
  .statusbar { font-size: 11px; }
  #sbFps { display: none; }
  .start-title { font-size: 46px; letter-spacing: 7px; }
  .start-card { padding: 18px 16px 12px; }
  .start-sub { font-size: 13px; margin: 8px 0 12px; }
  .btn-big { min-height: 44px; font-size: 14px; padding: 8px 10px; }
  .hud { left: 6px; top: 6px; width: calc(100% - 12px); padding: 8px 10px; gap: 4px; }
  .hud-goal { font-size: 12px; }
  .toast { font-size: 12px; padding: 6px 12px; max-width: calc(100vw - 40px); }
  .toasts .toast:nth-last-child(n+3) { display: none; }
  .modal { align-items: flex-end; padding: 0; }
  .modal-card { width: 100%; max-height: 90dvh; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); animation: sheetIn 0.24s cubic-bezier(0.2, 0.9, 0.3, 1); }
  .modal-card.narrow { width: 100%; }
  @keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .help-grid { grid-template-columns: 1fr; }
  .slot { grid-template-columns: 72px 1fr; }
  .slot img { width: 72px; height: 46px; }
  .slot-b { grid-column: 1 / -1; justify-content: flex-end; }
}

/* ======================================================================
   Handy quer (wenig Höhe)
   ====================================================================== */
@media (max-height: 560px) and (min-width: 561px) and (max-width: 1100px) {
  .app { min-height: 300px; }
  .topbar { min-height: 42px; padding: calc(4px + env(safe-area-inset-top, 0px)) 8px 4px; }
  .brand { display: none; }
  .hide-sm { display: none; }
  .ib { width: 34px; height: 34px; }
  .work {
    display: grid; grid-template-columns: minmax(0, 1fr) 196px; grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "stage tools" "stage mats"; gap: 6px; padding: 0 6px calc(4px + env(safe-area-inset-bottom, 0px));
  }
  .stage-col { grid-area: stage; order: 0; gap: 2px; }
  .side { background: none; border: 0; padding: 0; gap: 0; overflow: visible; }
  .side-left { grid-area: tools; order: 0; }
  .side-right { grid-area: mats; order: 0; overflow: auto; min-height: 0; padding-left: 3px; }
  .sec-mats { overflow: visible; min-height: 0; margin: 0; padding: 0; flex: none; }
  .sec-scene, .sec-info, .sec-tools .sec-h, .sec-mats .sec-h { display: none; }
  .sec-tools { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .tool-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; flex: 1 1 100%; }
  .tool-btn { min-height: 34px; font-size: 0; gap: 0; border-radius: 9px; }
  .tool-btn svg { width: 18px; height: 18px; }
  .tool-btn .tk { display: none; }
  .opts-toggle { display: flex; flex-direction: row; gap: 6px; width: 100%; min-height: 30px; font-size: 11px; }
  .opts {
    display: none; position: fixed; right: 210px; top: 50px; bottom: 8px; width: min(320px, 50vw); z-index: 40; overflow: auto;
    padding: 12px; border-radius: 16px; background: rgba(18, 22, 32, 0.97); border: 1px solid var(--line-2); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  }
  .opts.open { display: flex; }
  .opts-head { display: flex; align-items: center; justify-content: space-between; }
  .mats { gap: 3px; }
  .mat-cat { margin: 4px 0 0; font-size: 9px; }
  .mat-grid { grid-template-columns: repeat(2, 1fr); gap: 3px; }
  .mat { min-height: 28px; font-size: 10.5px; padding: 3px 5px; }
  .mat .sw { width: 13px; height: 13px; }
  .mat .mk { display: none; }
  .statusbar { display: none; }
  .start-card { padding: 12px 14px 8px; }
  .start-title { font-size: 34px; letter-spacing: 6px; }
  .start-sub { font-size: 12.5px; margin: 6px 0 10px; }
  .btn-big { min-height: 38px; font-size: 13px; padding: 6px 10px; }
  .hud { width: min(300px, calc(100% - 12px)); left: 6px; top: 6px; padding: 7px 9px; gap: 3px; }
  .hud-goal { display: none; }
  .modal { align-items: center; padding: 8px; }
  .modal-card { max-height: calc(100dvh - 16px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
html.rm *, html.rm *::before, html.rm *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
