/* Regelkarten-Tisch – Sandbox */

:root {
  --warn: #e0a200;
  --paper: #f6f1e7;
  --paper-2: #efe8da;
  --mat: #fffdf8;
  --ink: #2b2a33;
  --ink-soft: #6f6c7a;
  --line: #e3dccd;
  --beat-a: #fff6ea;
  --beat-b: #eef7f2;
  --rule: #6b5b95;
  --rule-soft: #ece7f7;
  --accent: #ff7a1a;
  --accent-ink: #fff;
  --good: #2fb37a;
  --bad: #e0503a;
  --card: clamp(58px, 7.2vw, 84px);
  --tray-card: clamp(54px, calc((100vw - 290px) / 18), 84px);
  --radius: 18px;
  --shadow: 0 6px 18px rgba(40, 30, 10, .12), 0 1px 3px rgba(40, 30, 10, .08);
  --font: 'Nunito', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
button, input { font: inherit; }
.hidden { display: none !important; }
.ico { width: 22px; height: 22px; flex: none; }

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  min-height: 58px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: .2px; white-space: nowrap; }
.brand-dot { width: 14px; height: 14px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #ffb347); box-shadow: 0 0 0 4px rgba(255, 122, 26, .18); }
.tempo { display: flex; align-items: center; gap: 8px; margin-left: 10px; color: var(--ink-soft); }
.tempo input[type=range] { width: clamp(90px, 14vw, 170px); accent-color: var(--accent); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 14px;
  border: 0; border-radius: 999px;
  background: #fff; color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.chip:active { transform: translateY(1px); }
.chip-ghost { background: transparent; box-shadow: none; color: var(--ink-soft); }
.chip-play { width: 44px; padding: 0; justify-content: center; background: var(--ink); color: #fff; margin-left: 4px; }
.chip-play .ico { width: 22px; height: 22px; }
.chip-play .ico-pause, .chip-play.playing .ico-play { display: none; }
.chip-play.playing .ico-pause { display: block; }
.chip-play.playing { background: var(--accent); }
.chip-accent { background: var(--accent); color: var(--accent-ink); }
.chip-accent.active { background: var(--ink); }
.badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--ink); color: #fff; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.chip-accent .badge { background: rgba(255,255,255,.3); }

/* ---------- Bühne ---------- */
.stage { flex: 1; position: relative; display: flex; min-height: 0; padding: 4px 16px 10px; }

.mat {
  position: relative;
  flex: 1;
  border-radius: 24px;
  background: var(--mat);
  box-shadow: inset 0 0 0 2px var(--line), var(--shadow);
  overflow: visible;
}
.mat-grid {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: repeat(16, 1fr);
  border-radius: 24px; overflow: hidden;
}
.mat-grid > div { border-right: 1px dashed rgba(0,0,0,.06); }
.mat-grid > div:nth-child(16) { border-right: 0; }
.mat-grid > div.beat-a { background: var(--beat-a); }
.mat-grid > div.beat-b { background: var(--beat-b); }
.mat-grid > div.step-now { background: rgba(255, 122, 26, .13); }
.mat-beats {
  position: absolute; left: 0; right: 0; top: 8px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  pointer-events: none;
}
.mat-beats span { text-align: left; padding-left: 12px; font-size: 13px; color: var(--ink-soft); opacity: .7; }

.links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.links line { stroke: var(--rule); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 2 10; opacity: .55; }

.playhead {
  position: absolute; top: 0; bottom: 0; width: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(255,122,26,.6);
  border-radius: 2px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s;
}
.playhead.on { opacity: .9; }

.empty-hint {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 18px; align-items: center; justify-content: center;
  color: var(--ink-soft); pointer-events: none;
}
.empty-text { font-size: clamp(18px, 2.6vw, 28px); opacity: .55; }
.scenes { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; pointer-events: auto; }
.scenes-label { font-size: 14px; opacity: .7; margin-right: 4px; }
.scene { font: inherit; font-weight: 800; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; box-shadow: var(--shadow); }
.scene:active { transform: translateY(1px); }
.camera-mode .scenes { display: none; }

/* ---------- Muster-Zeilen ---------- */
.rows { position: absolute; inset: 0; pointer-events: none; }
.row {
  position: absolute; left: 0; right: 0; height: 18px; margin-top: -9px;
  display: grid; grid-template-columns: repeat(16, 1fr);
  align-items: center;
}
.row .dot {
  justify-self: center;
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(0,0,0,.07);
  transition: transform .08s, background .12s;
}
.row .dot.on { background: var(--vc); width: 14px; height: 14px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--vc) 25%, transparent); }
.row .dot.ghost { background: transparent; border: 2px solid color-mix(in srgb, var(--vc) 45%, transparent); width: 12px; height: 12px; }
.row .dot.dropped { background: transparent; border: 2px dashed var(--bad); width: 12px; height: 12px; opacity: .7; }
.row .dot.now.on { transform: scale(1.5); }
.row.mimic { margin-top: 14px; }
.row.mimic .dot.on { background: transparent; border: 3px solid var(--vc); width: 13px; height: 13px; }

/* ---------- Karten ---------- */
.cards { position: absolute; inset: 0; }
.card {
  position: absolute;
  width: var(--card); height: var(--card);
  margin: calc(var(--card) / -2) 0 0 calc(var(--card) / -2);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow), inset 0 0 0 4px var(--cc);
  color: var(--cc);
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
  will-change: transform;
  transition: box-shadow .15s;
}
.card .face { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 100%; height: 100%; pointer-events: none; }
.card .icon { width: 46%; height: 46%; transform: rotate(var(--rot, 0deg)); transition: transform .08s; }
.card .name { font-size: clamp(10px, 1.15vw, 13px); font-weight: 800; color: var(--ink); line-height: 1; white-space: nowrap; }
.card .name.long { font-size: clamp(8.5px, .95vw, 11px); }
.card .live { font-size: 11px; color: var(--ink-soft); line-height: 1; min-height: 11px; white-space: nowrap; }
.card.rule { background: var(--rule-soft); box-shadow: var(--shadow), inset 0 0 0 3px var(--cc); border: 2px dashed var(--cc); --cc: var(--rule); }
.card.rule.inactive { opacity: .55; }
.card.rule.inactive::after {
  content: '?'; position: absolute; right: -8px; top: -8px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--ink-soft); color: #fff; font-size: 15px; display: flex; align-items: center; justify-content: center;
}
.card.hit { animation: hit .16s ease-out; }
.card.seen { animation: seen .5s ease-out; }
@keyframes seen { 0% { box-shadow: 0 0 0 0 rgba(255,122,26,.9), var(--shadow), inset 0 0 0 4px var(--cc); } 100% { box-shadow: 0 0 0 22px rgba(255,122,26,0), var(--shadow), inset 0 0 0 4px var(--cc); } }
@keyframes hit { 0% { transform: var(--tf) scale(1); } 40% { transform: var(--tf) scale(1.14); } 100% { transform: var(--tf) scale(1); } }
.card.selected { box-shadow: 0 0 0 4px var(--accent), var(--shadow), inset 0 0 0 4px var(--cc); z-index: 5; }
.card.rule.selected { box-shadow: 0 0 0 4px var(--accent), var(--shadow), inset 0 0 0 3px var(--cc); }
.card.dragging { z-index: 10; cursor: grabbing; box-shadow: 0 14px 30px rgba(40,30,10,.25), inset 0 0 0 4px var(--cc); }
.card.masked .face { opacity: .45; }

.card .remove {
  position: absolute; left: -12px; top: -12px; width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: var(--ink); color: #fff; display: none; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: var(--shadow);
}
.card .remove .ico { width: 16px; height: 16px; }
.card.selected .remove { display: flex; }

.card .flipbtn {
  position: absolute; right: -12px; top: -12px; width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: #fff; color: var(--cc); display: none; align-items: center; justify-content: center;
  box-shadow: var(--shadow), inset 0 0 0 2px var(--cc); cursor: pointer;
}
.card .flipbtn .ico { width: 18px; height: 18px; }
.card.selected .flipbtn { display: flex; }
.card.back { background: var(--cc); color: #fff; }
.card.back .name { color: #fff; }
.card.back .live { color: rgba(255,255,255,.85); }
.card .wildbtn {
  position: absolute; right: -14px; bottom: -12px; height: 28px; padding: 0 10px; border-radius: 14px;
  border: 0; background: #fff; color: var(--rule); font: inherit; font-size: 12px; font-weight: 800;
  display: none; align-items: center; box-shadow: var(--shadow), inset 0 0 0 2px var(--rule); cursor: pointer;
}
.card.selected .wildbtn { display: flex; }
.card.wild .wildbtn { background: var(--accent); color: #fff; box-shadow: var(--shadow), inset 0 0 0 2px var(--accent); }
.card.wild { border-color: var(--accent); --cc: var(--accent); }

.ring {
  position: absolute; width: calc(var(--card) * 1.9); height: calc(var(--card) * 1.9);
  margin: calc(var(--card) * -0.95) 0 0 calc(var(--card) * -0.95);
  border-radius: 50%;
  border: 3px dashed var(--accent);
  pointer-events: none;
  z-index: 4;
}
.ring .knob {
  position: absolute; left: 50%; top: 0;
  width: 40px; height: 40px; margin: -20px 0 0 -20px;
  border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  pointer-events: auto; cursor: grab; touch-action: none;
}
.ring .knob .ico { width: 20px; height: 20px; }

/* Euklid-Kreis auf der Karte */
.necklace { width: 58%; height: 58%; }
.necklace .pt { fill: rgba(0,0,0,.13); }
.necklace .pt.on { fill: var(--cc); }
.necklace .pt.now { fill: var(--accent); }
/* Würfel */
.dice-face { transition: color .1s; }
.card.dice-yes { --cc: var(--good); }
.card.dice-no { --cc: var(--bad); }
/* Jeder 3. */
.counter { display: flex; gap: 4px; }
.counter i { width: 9px; height: 9px; border-radius: 50%; background: rgba(0,0,0,.12); display: block; }
.counter i.on { background: var(--cc); }
.counter i.now { box-shadow: 0 0 0 2px var(--accent); }
/* ---------- Raetsel ---------- */
.puzzle {
  position: absolute; right: 16px; top: 4px; bottom: 10px; width: min(380px, 70vw); z-index: 15;
  background: #1e1b2e; color: #f5f2ff; border-radius: 24px; box-shadow: 0 20px 50px rgba(0,0,0,.3);
  display: flex; flex-direction: column; padding: 16px 18px; gap: 8px;
}
.puzzle-head { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.puzzle-head .iconbtn { margin-left: auto; }
.puzzle-sub { font-size: 13px; opacity: .7; }
.puzzle-code { flex: 0 1 auto; max-height: 45%; padding: 8px 0; }
.pz { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.pz li { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 10px; background: rgba(255,255,255,.06); }
.pz li::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.3); flex: none; }
.pz .pz-ok::before { background: var(--good); }
.pz .pz-differs::before { background: var(--warn, #e0a200); }
.pz .pz-missing::before { background: rgba(255,255,255,.25); }
.pz .pz-extra::before { background: var(--bad); }
.pz .pz-ok { opacity: .8; }
.puzzle-actions { display: flex; gap: 8px; margin-top: auto; }
.btn-ghost { background: rgba(255,255,255,.08); }

/* ---------- Dein Stueck (Streifen) ---------- */
.piece { padding: 0 16px 6px; }
.piece-head { display: flex; align-items: center; gap: 10px; min-height: 34px; flex-wrap: wrap; }
.piece-title { font-weight: 800; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
.piece-title .badge { background: var(--rule); }
.piece.playing .piece-title .badge { background: var(--accent); }
.chip-small { min-height: 32px; padding: 0 12px; font-size: 13px; gap: 6px; }
.chip-small .ico { width: 16px; height: 16px; }
.chip-small.chip-accent.playing { background: var(--ink); }
#btn-repeat.off { color: var(--ink); background: #fff; box-shadow: var(--shadow); }
.piece-hint { color: var(--ink-soft); font-size: 12px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.piece-lane { position: relative; overflow-x: auto; overflow-y: hidden; padding: 6px 2px 8px; }
.piece-tiles { display: flex; gap: 8px; min-height: 72px; }
.tile {
  position: relative; flex: none; height: 72px; border-radius: 12px;
  background: #fff; box-shadow: var(--shadow); border: 2px solid transparent;
  display: flex; flex-direction: column; overflow: hidden; cursor: pointer; user-select: none; touch-action: none;
}
.tile.now { border-color: var(--accent); }
.tile.dragging { opacity: .85; z-index: 3; box-shadow: 0 10px 24px rgba(40,30,10,.25); cursor: grabbing; }
.tile-pic { position: relative; flex: 1; background: var(--mat); border-bottom: 1px solid rgba(0,0,0,.06); }
.tile-pic i { position: absolute; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--cc, #888); }
.tile-pic i.rule { border-radius: 2px; background: var(--rule); }
.tile-pic i.mood { width: 6px; height: 6px; box-shadow: 0 0 0 1.5px #fff; }
.tile-foot { display: flex; align-items: center; gap: 6px; padding: 2px 6px 2px 8px; font-size: 12px; font-weight: 800; }
.tile-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-loops { border: 0; border-radius: 999px; background: var(--rule-soft); color: var(--rule); font: inherit; font-size: 12px; font-weight: 800; padding: 2px 8px; cursor: pointer; }
.tile-name { border: 0; background: transparent; font: inherit; font-weight: 800; padding: 2px 4px 2px 0; cursor: pointer; text-align: left; color: var(--ink); }
.tile-name::after { content: ' ▾'; color: var(--ink-soft); font-size: 10px; }
.tile.menu-open { border-color: var(--rule); }
.tile-trans { position: absolute; right: 0; top: 0; bottom: 26px; width: 14px; background: repeating-linear-gradient(135deg, var(--accent) 0 3px, transparent 3px 7px); opacity: .75; pointer-events: none; }
.tile-trans.rest { background: rgba(0,0,0,.18); }
.tile-trans::after { content: attr(data-t); position: absolute; right: 16px; top: 4px; font-size: 10px; font-weight: 800; color: var(--accent); white-space: nowrap; background: rgba(255,255,255,.85); padding: 0 4px; border-radius: 6px; }
.tile-trans.rest::after { color: var(--ink-soft); }
.piece { position: relative; }
.tile-menu {
  position: absolute; z-index: 16; bottom: calc(100% - 40px); left: 16px; width: min(440px, calc(100vw - 32px));
  background: #1e1b2e; color: #f5f2ff; border-radius: 18px; padding: 12px 14px; box-shadow: 0 20px 50px rgba(0,0,0,.3);
  display: flex; flex-direction: column; gap: 8px; font-size: 13px;
}
.tile-menu::after { content: ''; position: absolute; left: var(--arrow-x, 40px); bottom: -8px; width: 16px; height: 16px; background: #1e1b2e; transform: rotate(45deg); margin-left: -8px; }
.tm-head { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.tm-sub { color: rgba(255,255,255,.55); font-size: 12px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-head .iconbtn { margin-left: auto; }
.tm-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tm-label { width: 52px; color: rgba(255,255,255,.6); font-weight: 800; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.tm-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.tm-chips button { border: 0; border-radius: 999px; padding: 5px 10px; font: inherit; font-size: 12px; font-weight: 800; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; }
.tm-chips button.on { background: var(--accent); }
.tm-input { font: inherit; font-size: 13px; border: 0; border-radius: 999px; padding: 6px 10px; width: 120px; background: rgba(255,255,255,.12); color: #fff; }
.tm-input::placeholder { color: rgba(255,255,255,.45); }
.tm-note { color: rgba(255,255,255,.55); font-size: 12px; }
.tile-menu .btn.small { min-height: 32px; padding: 0 12px; font-size: 12px; background: rgba(255,255,255,.12); color: #fff; gap: 6px; }
.tile-menu .btn.small .ico { width: 14px; height: 14px; }
.tile-menu .tm-danger { color: #ffb4a8; }
.tm-actions { padding-top: 4px; border-top: 1px solid rgba(255,255,255,.1); }
.tile.born { animation: born .45s cubic-bezier(.2,.9,.3,1.2); }
@keyframes born { 0% { transform: translateY(-46px) scale(.55); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; opacity: 1; } }
.mat.snap::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: #fff; pointer-events: none; z-index: 20; animation: snap .45s ease-out forwards; }
@keyframes snap { 0% { opacity: .9; } 100% { opacity: 0; } }
.piece-playhead { position: absolute; top: 4px; bottom: 6px; left: 0; width: 3px; background: var(--accent); border-radius: 2px; box-shadow: 0 0 0 1px #fff; display: none; pointer-events: none; }
.piece.playing .piece-playhead { display: block; }
.camera-mode .piece-hint { display: none; }
.piece-from-cards .tile { cursor: default; }
.tile-note { align-self: center; color: var(--ink-soft); font-size: 13px; padding: 0 8px; }
.relay-status { font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.relay-status.ok { color: #2a9d5c; }
#btn-relay.active { background: var(--ink); color: #fff; }
.ghosts { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.ghost-card {
  position: absolute; left: 0; top: 0; width: var(--card); height: var(--card); margin: calc(var(--card) * -0.5) 0 0 calc(var(--card) * -0.5);
  border-radius: 18px; border: 3px dashed rgba(255,255,255,.9); background: rgba(255,255,255,.18);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #fff; font-size: 11px; font-weight: 800; text-shadow: 0 1px 3px rgba(0,0,0,.8);
  box-shadow: 0 0 0 2px rgba(0,0,0,.35);
}
.ghost-card .icon { width: 40%; height: 40%; transform: rotate(var(--rot, 0deg)); }
.ghost-card.mood { border-radius: 50%; }
.ghost-card.ok { border-style: solid; border-color: #3ddc84; background: rgba(61,220,132,.25); }
.ghost-card.near { border-color: var(--accent); }
.ghost-card.ok::after { content: '✓'; position: absolute; right: -8px; top: -8px; width: 22px; height: 22px; border-radius: 50%; background: #3ddc84; color: #053; font-size: 14px; line-height: 22px; text-align: center; text-shadow: none; }
.ghost-card .arrow { position: absolute; left: 50%; top: -9px; width: 0; height: 0; margin-left: -6px; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 9px solid var(--accent); transform-origin: 6px calc(var(--card) * 0.5 + 9px); transform: rotate(var(--rot, 0deg)); }
.playback .cam-wrap { opacity: .35; }
.playback .empty-hint { display: none; }
@media (max-width: 1100px) { .piece-hint { display: none; } }

/* ---------- Aufgabe ---------- */
.task {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 8;
  display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: #fff; padding: 10px 12px 10px 16px; border-radius: 999px;
  box-shadow: var(--shadow); font-size: 16px; font-weight: 800; max-width: min(90%, 640px);
}
.task .ico { color: var(--accent); }
.task .iconbtn.small { width: 30px; height: 30px; background: rgba(255,255,255,.15); }
.task .iconbtn.small .ico { width: 16px; height: 16px; color: #fff; }

/* ---------- Kamera-Modus ---------- */
.cam-wrap { display: none; position: absolute; inset: 0; overflow: hidden; border-radius: 24px; z-index: 0; pointer-events: none; }
.cam { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.cam.mirrored { transform: scaleX(-1); }
.camera-mode .cam-wrap { display: block; }
.camera-mode .mat { flex: none; margin: 0 auto; background: #222; }
.camera-mode .mat-grid > div { background: transparent; border-right-color: rgba(255,255,255,.25); }
.camera-mode .mat-grid > div.step-now { background: rgba(255,122,26,.22); }
.camera-mode .mat-beats span { color: #fff; opacity: 1; }
.camera-mode .mat-beats span::before { content: ''; }
.camera-mode .mat-beats span { padding-left: 0; margin-left: 10px; }
.camera-mode .mat-beats span { display: inline-block; width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 11px; background: rgba(0,0,0,.45); font-size: 12px; }
.camera-mode .empty-hint { color: #fff; opacity: 1; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.camera-mode .row .dot { background: rgba(0,0,0,.25); box-shadow: 0 0 0 1px rgba(255,255,255,.6); }
.camera-mode .tray { display: none; }
.camera-mode .card .remove { display: none !important; }
.camera-mode .card { cursor: pointer; }
.camera-mode .links line { stroke: var(--accent); opacity: .9; }
.camera-mode .links .ballpath { stroke: var(--accent); opacity: .6; }
.camera-mode .links .ballhit { stroke: var(--accent); opacity: .8; }
.camera-mode .ball { background: var(--accent); }
.cam-status { font-size: 12px; color: var(--ink-soft); white-space: nowrap; max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1280px) { .camera-mode .brand span:last-child { display: none; } }
.chip.active { background: var(--ink); color: #fff; }

/* ---------- Kugel ---------- */
.ball {
  position: absolute; left: 0; top: 0; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 3px #fff, 0 4px 10px rgba(0,0,0,.25);
  pointer-events: none; z-index: 3;
}
.ball.bounce { animation: bounce .22s ease-out; }
@keyframes bounce { 0% { box-shadow: 0 0 0 3px #fff, 0 0 0 0 rgba(255,122,26,.6); } 100% { box-shadow: 0 0 0 3px #fff, 0 0 0 16px rgba(255,122,26,0); } }
.links .ballpath { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 6 8; opacity: .25; stroke-linejoin: round; }
.links .ballpath.strong { opacity: .7; stroke: var(--accent); stroke-width: 3; }
.links .ballhit { fill: #fff; stroke: var(--ink); stroke-width: 2; opacity: .35; }
.links .ballhit.strong { opacity: 1; stroke: var(--accent); }
.links .ballhit.hit-card { fill: var(--accent); stroke: #fff; }
.edgeflash {
  position: absolute; left: 0; top: 0; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%; border: 3px solid var(--accent); pointer-events: none; z-index: 3;
  animation: edgeflash .32s ease-out forwards;
}
@keyframes edgeflash { 0% { opacity: 1; scale: .5; } 100% { opacity: 0; scale: 2.6; } }
.bhs { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.bh { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: rgba(0,0,0,.06); color: var(--ink-soft); }
.bh.bh-card { background: var(--rule-soft); color: var(--rule); font-weight: 800; }
.bh.done { opacity: .45; }
.bh.next { outline: 2px solid var(--accent); color: var(--ink); }

/* ---------- Erklär-Blase ---------- */
.explain {
  position: absolute; z-index: 6;
  background: #fff; color: var(--ink);
  border-radius: 16px; padding: 12px 14px;
  box-shadow: 0 12px 30px rgba(40,30,10,.18), 0 0 0 2px var(--rule-soft);
  pointer-events: none;
  font-size: 13px; line-height: 1.35;
}
.explain::before {
  content: ''; position: absolute; width: 16px; height: 16px;
  background: #fff; transform: rotate(45deg);
}
.explain.below::before { left: var(--arrow-x, 50%); top: -8px; margin-left: -8px; box-shadow: -2px -2px 0 var(--rule-soft); }
.explain.above::before { left: var(--arrow-x, 50%); bottom: -8px; margin-left: -8px; box-shadow: 2px 2px 0 var(--rule-soft); }
.explain.right::before { left: -8px; top: 50%; margin-top: -8px; box-shadow: -2px 2px 0 var(--rule-soft); }
.explain.left::before { right: -8px; top: 50%; margin-top: -8px; box-shadow: 2px -2px 0 var(--rule-soft); }
.ex-title { font-weight: 800; font-size: 15px; color: var(--rule); margin-bottom: 6px; }
.ex-text { color: var(--ink-soft); }
.ex-text b { color: var(--ink); }
.ex-list { margin: 6px 0 0; padding-left: 18px; color: var(--ink-soft); }
.ex-list li { margin: 2px 0; }
.ex-list b { color: var(--ink); }
.ex-row { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.ex-necklace { width: 84px; height: 84px; flex: none; color: var(--rule); transition: transform .15s; }
.ex-necklace .pt { fill: rgba(0,0,0,.12); }
.ex-necklace .pt.on { fill: var(--rule); }
.ex-necklace .pt.now { fill: var(--accent); }
.strip { display: grid; grid-template-columns: repeat(16, 1fr); gap: 3px; margin: 6px 0; }
.strip i { display: block; height: 12px; border-radius: 4px; background: rgba(0,0,0,.08); }
.strip i.on { background: var(--rule); }
.strip i.now { outline: 2px solid var(--accent); outline-offset: 1px; }
.dice-strip i.yes { background: var(--good); }
.dice-strip i.no { background: var(--bad); opacity: .7; }
.ex-text .yes { color: var(--good); font-weight: 800; }
.ex-text .no { color: var(--bad); font-weight: 800; }
.ex-count { display: flex; gap: 8px; margin: 4px 0 8px; }
.ex-count b { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.06); color: var(--ink-soft); }
.ex-count b.plays { background: var(--rule-soft); color: var(--rule); }
.ex-count b.now { box-shadow: 0 0 0 3px var(--accent); }
.mk { display: flex; flex-direction: column; gap: 5px; margin: 8px 0; }
.mk-head { font-size: 11px; color: var(--ink-soft); margin-bottom: 2px; }
.mk-row { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; padding: 3px 6px; border-radius: 8px; }
.mk-row.now { background: rgba(255,122,26,.14); }
.mk-ctx { font-weight: 800; letter-spacing: 1px; font-size: 14px; }
.mk-bar { height: 10px; border-radius: 5px; background: rgba(0,0,0,.08); position: relative; overflow: hidden; }
.mk-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--rule); display: block; }
.mk-txt { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }

/* ---------- Hinweiszeile ---------- */
.hint {
  min-height: 26px; padding: 2px 22px; text-align: center;
  color: var(--ink-soft); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Kartenbox ---------- */
.tray {
  display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap;
  padding: 8px 16px 14px;
}
.tray::-webkit-scrollbar { display: none; }
.tray-group {
  position: relative;
  display: flex; gap: clamp(5px, .8vw, 10px); align-items: center;
  padding: 20px 12px 10px;
  border-radius: 22px;
  background: var(--paper-2);
}
.tray-group::before {
  content: attr(data-label);
  position: absolute; left: 14px; top: 4px;
  font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .08em;
}
.tray-group.tray-rules { background: #e9e4f4; }
.tray-group.tray-moods { background: #f3e6de; }
.card.mood { background: #fff; border-radius: 50%; box-shadow: var(--shadow), inset 0 0 0 4px var(--cc); }
.card.mood .name { font-style: italic; }
.tempo-out { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 3ch; }
.tray .card {
  position: relative; margin: 0;
  flex: none;
  width: var(--tray-card); height: var(--tray-card);
}
.tray .card .name { font-size: clamp(9px, 1.05vw, 12px); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tray .card.used { opacity: .95; }

/* ---------- Geist beim Ziehen ---------- */
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 50;
  pointer-events: none;
  transform-origin: center;
}
.drag-ghost .card { position: relative; margin: 0; box-shadow: 0 14px 30px rgba(40,30,10,.3), inset 0 0 0 4px var(--cc); }

/* ---------- Programm-Panel ---------- */
.code-panel {
  position: absolute; right: 16px; top: 4px; bottom: 10px;
  width: min(420px, 80vw);
  background: #1e1b2e; color: #f5f2ff;
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
  display: flex; flex-direction: column;
  transform: translateX(calc(100% + 32px));
  transition: transform .28s cubic-bezier(.2,.8,.2,1);
  z-index: 20;
}
.code-panel.open { transform: none; }
.code-head { display: flex; align-items: flex-start; gap: 10px; padding: 18px 18px 8px; }
.code-title { font-weight: 800; font-size: 17px; }
.code-sub { font-size: 13px; opacity: .7; margin-top: 2px; }
.iconbtn { margin-left: auto; border: 0; background: rgba(255,255,255,.1); color: #fff; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.code {
  flex: 1; margin: 0; padding: 8px 18px; overflow: auto;
  font: 13px/1.55 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  white-space: pre; color: #e8e3ff;
  -webkit-user-select: text; user-select: text;
}
.code .c { color: #8f88b5; }
.code .s { color: #ffd479; }
.code .f { color: #7ee0c3; }
.code .n { color: #ff9e6b; }
.code-actions { display: flex; gap: 10px; padding: 12px 18px 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 999px; border: 0;
  background: rgba(255,255,255,.12); color: #fff; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--accent); flex: 1; }
.btn-big { font-size: 20px; min-height: 64px; padding: 0 34px; background: var(--accent); color: #fff; box-shadow: var(--shadow); }
.btn-big .ico { width: 26px; height: 26px; }

/* ---------- Start ---------- */
.start {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(246, 241, 231, .92);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.start-card { text-align: center; padding: 30px; max-width: 520px; }
.start-title { font-size: clamp(30px, 5vw, 48px); font-weight: 800; margin-bottom: 10px; }
.start-text { color: var(--ink-soft); font-size: clamp(16px, 2.2vw, 20px); margin-bottom: 26px; line-height: 1.4; }

/* ---------- Links zu den anderen Seiten ---------- */
.start-links { display: flex; gap: 6px 18px; justify-content: center; flex-wrap: wrap; margin-top: 22px; font-size: 14px; }
.start-links a, .morelinks a { color: var(--ink-soft); text-decoration: none; font-weight: 800; border-bottom: 2px solid transparent; padding: 2px 0; }
.start-links a:hover, .morelinks a:hover, .start-links a:focus-visible, .morelinks a:focus-visible { color: var(--accent); border-bottom-color: var(--accent); outline: none; }
.morelinks { display: flex; gap: 6px 18px; justify-content: center; flex-wrap: wrap; padding: 0 16px 10px; font-size: 12px; }
.camera-mode .morelinks { display: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 160px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow); z-index: 60; font-size: 14px;
  animation: toast 2s forwards;
}
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px); } 12% { opacity: 1; transform: translate(-50%, 0); } 80% { opacity: 1; } 100% { opacity: 0; } }

@media (max-width: 1240px) {
  .topbar .chip span:not(.badge) { display: none; }
  .topbar .chip { padding: 0 12px; }
}
@media (max-width: 1100px) {
  .brand span:last-child { display: none; }
  .tempo input[type=range] { width: 90px; }
}
@media (max-height: 560px) {
  :root { --card: 52px; }
  .tray { padding-bottom: 8px; }
  .tray-group { padding-top: 16px; }
}
