:root {
  --bg: #0d0b24;
  --panel: #161338;
  --panel-2: #1d1947;
  --ink: #ece6ff;
  --muted: #a39ccc;
  --gold: #d4af5a;
  --gold-soft: rgba(212, 175, 90, 0.35);
  --ratio: 0.575;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #241f5c 0%, var(--bg) 60%);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
.top { padding: 24px 28px 8px; }
h1 { margin: 0 0 4px; font-weight: 600; font-size: 1.5rem; letter-spacing: 0.02em; }
h1 .muted { font-weight: 400; }
.hint { margin: 0; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.4fr);
  gap: 20px;
  padding: 16px 28px 28px;
}
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid rgba(212, 175, 90, 0.18);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.controls { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.field select {
  font: inherit; color: var(--ink); background: #0f0d2a; border: 1px solid rgba(212, 175, 90, 0.4);
  border-radius: 8px; padding: 8px 10px; min-width: 200px;
}
.check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--muted); }
.check input { accent-color: var(--gold); width: 18px; height: 18px; }

/* Walze: Karten laufen offen auf einem Bogen (Halbkreis) vorbei, Bogenmittelpunkt liegt unterhalb der Bühne */
.reel {
  position: relative; height: 300px; margin: 14px 0 16px;
  border-radius: 14px; overflow: hidden; cursor: pointer;
  background:
    radial-gradient(ellipse 70% 55% at 50% 0%, rgba(212, 175, 90, 0.14), transparent 70%),
    linear-gradient(180deg, #0a0820 0%, #0e0b2c 100%);
  border: 1px solid rgba(212, 175, 90, 0.2);
}
.reel-track { position: absolute; inset: 0; }
.reel-track .reel-card {
  position: absolute; left: 50%; top: var(--arc-cy, 50%);
  height: var(--card-h, 150px); aspect-ratio: var(--ratio);
  border-radius: 6px; overflow: hidden;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.6);
  will-change: transform, opacity;
}
.reel-track .reel-card.card-back {          /* Rückseitenmuster behalten, Schlagschatten dazu */
  box-shadow: inset 0 0 0 5px #151238, inset 0 0 0 6px var(--gold-soft), 0 8px 22px rgba(0, 0, 0, 0.6);
}
.reel-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reel-card.reversed img { transform: rotate(180deg); }
.reel-marker {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  height: 180px; aspect-ratio: var(--ratio);
  border-radius: 8px; pointer-events: none;
  box-shadow: 0 0 0 2px var(--gold), 0 0 28px 6px rgba(212, 175, 90, 0.45);
  z-index: 400;
}
.reel.spinning .reel-marker { animation: breathe 1.2s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 2px var(--gold), 0 0 22px 4px rgba(212, 175, 90, 0.35); }
  50% { box-shadow: 0 0 0 2px #f1d38a, 0 0 36px 10px rgba(212, 175, 90, 0.6); }
}

/* Kartenrücken (CSS, eigenes Design) */
.card-back {
  background:
    radial-gradient(circle at 50% 50%, rgba(212, 175, 90, 0.18) 0 18%, transparent 19%),
    repeating-radial-gradient(circle at 50% 50%, transparent 0 9px, rgba(212, 175, 90, 0.08) 9px 10px),
    radial-gradient(circle at 50% 45%, #2b2570 0%, #151238 70%);
  border: 2px solid var(--gold);
  box-shadow: inset 0 0 0 5px #151238, inset 0 0 0 6px var(--gold-soft);
  position: relative; overflow: hidden;
}
.card-back::after {
  content: "✦"; position: absolute; inset: 0; display: grid; place-items: center;
  color: #e9cf85; font-size: 1.9rem; text-shadow: 0 0 12px rgba(233, 207, 133, 0.7);
}

.actions { display: flex; gap: 12px; flex-wrap: wrap; }
button {
  font: inherit; cursor: pointer; border-radius: 999px; border: 1px solid transparent;
  padding: 12px 22px; transition: transform 0.08s ease, box-shadow 0.2s ease, background 0.2s ease;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: default; }
.primary {
  flex: 1 1 220px; font-size: 1.15rem; font-weight: 600; letter-spacing: 0.04em;
  background: linear-gradient(180deg, #e6c475, #c69b42); color: #1a1430;
  box-shadow: 0 6px 20px rgba(212, 175, 90, 0.35);
}
.primary.halt {
  background: linear-gradient(180deg, #ff8a7a, #d9453a); color: #fff;
  box-shadow: 0 6px 24px rgba(217, 69, 58, 0.5);
  animation: pulse 0.9s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }
.secondary { background: transparent; color: var(--muted); border-color: rgba(163, 156, 204, 0.4); }
.secondary:hover { color: var(--ink); border-color: var(--gold); }
.status { min-height: 1.5em; margin: 12px 0 4px; }

/* Brett */
.board {
  position: relative; width: 100%; aspect-ratio: 3 / 2;
  border-radius: 12px;
  background: radial-gradient(ellipse at 50% 40%, rgba(212, 175, 90, 0.08), transparent 60%), #0e0c28;
  border: 1px solid rgba(212, 175, 90, 0.15);
}
.slot { position: absolute; transform: translate(-50%, -50%); }
.slot-card {
  height: 100%; aspect-ratio: var(--ratio); border-radius: 8px;
  border: 1px dashed rgba(212, 175, 90, 0.45); background: rgba(255, 255, 255, 0.02);
  transform: rotate(var(--rot, 0deg)); transition: box-shadow 0.3s ease;
}
.slot.active .slot-card {
  border-style: solid; box-shadow: 0 0 0 2px var(--gold), 0 0 24px rgba(212, 175, 90, 0.6);
  animation: breathe 1.2s ease-in-out infinite;
}
.slot.filled .slot-card { border: 1px solid rgba(212, 175, 90, 0.5); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); }
.slot-card img { width: 100%; height: 100%; object-fit: cover; border-radius: 7px; display: block; }
img.reversed { transform: rotate(180deg); }
.slot-label {
  position: absolute; top: calc(100% + 4px); left: 50%; transform: translateX(calc(-50% + var(--shift, 0px)));
  font-size: 0.72rem; line-height: 1.2; color: var(--muted); white-space: nowrap; text-align: center;
}
.slot-num { color: var(--gold); font-weight: 600; }
.slot.label-above .slot-label { top: auto; bottom: calc(100% + 4px); }

/* Fliegende Karte (Flip + Flug) */
.fly { position: fixed; z-index: 1000; perspective: 1200px; pointer-events: none; }
.fly-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.7s cubic-bezier(.4, 0, .2, 1); }
.fly.flipped .fly-inner { transform: rotateY(180deg); }
.fly-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 8px; overflow: hidden; }
.fly-front { transform: rotateY(180deg); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); }
.fly-front img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fly.reversed .fly-front img { transform: rotate(180deg); }
body.reduce .fly-inner, .fly.instant .fly-inner { transition: none; }

/* Ergebnisliste */
.results { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.result { display: flex; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.03); }
.result img { width: 44px; aspect-ratio: var(--ratio); object-fit: cover; border-radius: 4px; flex: none; }
.result-pos { font-size: 0.75rem; color: var(--gold); letter-spacing: 0.04em; text-transform: uppercase; }
.result-name { font-weight: 600; }
.result-kw { color: var(--muted); font-size: 0.9rem; }
.badge { display: inline-block; font-size: 0.7rem; padding: 1px 8px; border-radius: 999px; background: rgba(217, 69, 58, 0.25); color: #ffb3aa; vertical-align: middle; margin-left: 6px; }

footer { padding: 0 28px 24px; }

/* Deutungstexte in der Ergebnisliste */
.result { align-items: flex-start; }
.result img { width: 64px; }
.result-text { min-width: 0; }
.result-frage { margin-top: 6px; font-style: italic; color: var(--gold); font-size: 0.9rem; }
.result-deutung { margin: 6px 0 0; line-height: 1.5; }
.result-rat { margin: 6px 0 0; font-weight: 600; }
.result-tendenz { margin: 6px 0 0; }
.result-more { margin-top: 8px; font-size: 0.9rem; color: var(--muted); }
.result-more summary { cursor: pointer; color: var(--gold); }
.result-more p { margin: 6px 0 0; }
.result-more strong { color: var(--ink); font-weight: 600; }

/* Ziehart wählen */
.mode { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.mode-opt {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; cursor: pointer;
  border: 1px solid rgba(212, 175, 90, 0.25); border-radius: 12px; background: rgba(255, 255, 255, 0.02);
}
.mode-opt:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold-soft); background: rgba(212, 175, 90, 0.08); }
.mode-opt input { accent-color: var(--gold); margin-top: 3px; flex: none; }
.mode-opt strong { display: block; font-weight: 600; }
.mode-opt small { display: block; color: var(--muted); font-size: 0.8rem; line-height: 1.3; }
@media (max-width: 520px) { .mode { grid-template-columns: 1fr; } }
.reel[hidden] { display: none; }

/* Kreis */
.ring {
  position: relative; width: 100%; max-width: 520px; aspect-ratio: 1 / 1; margin: 14px auto 16px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 90, 0.12), rgba(212, 175, 90, 0.03) 55%, transparent 72%);
}
.ring[hidden] { display: none; }
.ring-inner { position: absolute; inset: 0; }
.ring-slot { position: absolute; left: 50%; top: 50%; aspect-ratio: var(--ratio); }
.ring-slot:hover, .ring-slot:focus-visible { z-index: 500; outline: none; }
.ring-card {
  width: 100%; height: 100%; border-radius: 5px; border-width: 1px;
  box-shadow: inset 0 0 0 2px #151238, inset 0 0 0 3px var(--gold-soft);
  transition: transform 0.18s ease, filter 0.18s ease; cursor: default;
}
.ring-card.card-back::after { font-size: 0.8rem; }
.ring.choosing .ring-card { cursor: pointer; }
.ring:not(.choosing) .ring-card { opacity: 0.7; }
.ring.choosing .ring-slot:hover .ring-card, .ring.choosing .ring-slot:focus-visible .ring-card {
  transform: scale(1.3); filter: brightness(1.35) drop-shadow(0 0 10px rgba(212, 175, 90, 0.85));
}
.ring-slot.taken { visibility: hidden; }
.ring-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 34%;
  text-align: center; color: var(--gold); font-size: 0.9rem; line-height: 1.3; pointer-events: none;
}

/* Bewegung reduziert: auch die pulsierenden Hinweise ruhig stellen (die Walze selbst läuft, sie ist die Mechanik) */
@media (prefers-reduced-motion: reduce) {
  .primary.halt, .reel.spinning .reel-marker, .slot.active .slot-card { animation: none; }
}

/* Eingebettet als iframe (app.js setzt html.framed): keine Kopfzeile, keine Mindesthöhe (sonst wächst der Rahmen mit
   jeder Höhenmeldung), schmale Ränder, kein eigener Scrollbalken; die Elternseite stellt die Höhe per postMessage ein. */
html.framed { overflow: hidden; }
html.framed body { min-height: 0; border-radius: 16px; }
html.framed .top { display: none; }
html.framed .layout { padding: 12px; gap: 14px; }
html.framed footer { padding: 0 14px 12px; }
@media (max-width: 520px) {
  .top { padding: 18px 16px 6px; }
  .layout { padding: 12px 12px 20px; gap: 14px; }
  .panel { padding: 12px; }
  footer { padding: 0 16px 18px; }
  html.framed .layout { padding: 0 0 10px; }
  html.framed footer { padding: 0 4px 8px; }
}

/* Legung als PDF (07.11.2026) */
.pdf-box { margin-top: 18px; padding: 16px 18px; border: 1px solid rgba(212, 175, 90, 0.28); border-radius: 12px; background: rgba(212, 175, 90, 0.06); text-align: center; }
.pdf-box p { margin: 8px 0 0; }
.pdf-btn { min-width: 260px; }
.pdf-btn::before { content: '\2726\00a0'; color: var(--gold); }
#pdf-status:empty { display: none; }
