:root {
  --bg: #0f1220;
  --bg-elevated: #171b2e;
  --card: #1d2238;
  --text: #f2f3f7;
  --text-muted: #a4a8bd;
  --accent: #ff6b6b;
  --accent-2: #4ecdc4;
  --border: #2c3150;
  --radius: 14px;
  --max-width: 680px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 18, 32, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 0;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.brand {
  display: block;
  font-weight: 800;
  font-size: 1.2rem;
  padding-bottom: 10px;
}
.brand .dot { color: var(--accent-2); }

.tabbar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }

.tabbar a {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  border: 1px solid transparent;
}

.tabbar a.active {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}

.ad-slot {
  max-width: var(--max-width);
  margin: 12px auto;
  padding: 14px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
}

h1 {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  margin: 8px 0 4px;
}

.lead {
  color: var(--text-muted);
  margin: 0 0 20px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.eyebrow {
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 800;
}

.tool-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

select, textarea, input[type="number"] {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
}

textarea { resize: vertical; }

.btn-primary, .btn-secondary {
  border: none;
  border-radius: 999px;
  padding: 13px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #ff8e53);
  color: #1a0f0f;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-primary:active, .btn-secondary:active { transform: scale(0.97); }

.action-row {
  display: flex;
  gap: 8px;
}
.action-row button { flex: 1; }

.result-box {
  min-height: 60px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 1.05rem;
  line-height: 1.5;
  white-space: pre-line;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
}
.chip {
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.85rem;
  cursor: pointer;
}
.chip.active {
  background: var(--card);
  color: var(--text);
  border-color: var(--accent-2);
}

.wheel-wrap {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 12px auto;
  display: flex;
  justify-content: center;
}

.wheel-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.6rem;
  color: var(--accent);
  z-index: 2;
}

#rad-canvas {
  max-width: 100%;
  height: auto;
  border-radius: 50%;
  border: 3px solid var(--border);
  transition: transform 6s cubic-bezier(0.15, 0.85, 0.2, 1.05);
}

.hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.45;
  margin: 0 0 4px;
}

.dice-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 40px auto;
  padding: 24px 0;
  width: 100%;
}

/* Würfelgeometrie 1:1 aus der verifizierten Sandbox (dice-lab/index.html)
   übernommen — kein iframe mehr, der Würfel ist ein zusammenhängender
   Inline-Block im PickDay-DOM. Keine transform:scale/container-query auf
   einem Vorfahren des Würfels (das hat den 3D-Effekt in ein 2D-Abbild
   flachgedrückt) — stattdessen feste, untereinander konsistente
   Geometriewerte (Bühne, Würfel, Face, translateZ, Perspektive), die auf
   dem PickDay-Panel-Breitenbereich zuverlässig passen.
*/
.dice-wrap .scene {
  perspective: 900px;
  perspective-origin: 50% 50%;
  width: 220px;
  height: 220px;
  flex-shrink: 0;
}

.dice-wrap .cube {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 30px auto;
  transform-style: preserve-3d;
  --idle-transform: rotateX(-20deg) rotateY(30deg) rotateZ(0deg);
  --roll-duration: 1600ms;
  transform: var(--idle-transform);
}

.dice-wrap .cube.rolling {
  animation-name: dice-roll;
  animation-duration: var(--roll-duration);
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

/* filter darf NIRGENDS im Vorfahren-Pfad des Würfels sitzen: auch auf
   .scene (Elternelement von .cube) angewendet, flacht ein filter die
   preserve-3d-Unterstruktur ab (in der Praxis flatten mehrere Browser
   jeden Nachfahren mit transform-style:preserve-3d, sobald irgendein
   Vorfahre einen filter trägt - nicht nur das Element mit preserve-3d
   selbst). box-shadow ist keine "grouping property" und flacht daher
   auch auf einem Vorfahren nichts ab.
*/
.dice-wrap .scene {
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.28);
}

@keyframes dice-roll {
  from {
    transform: var(--idle-transform);
  }
  to {
    transform: rotateX(700deg) rotateY(760deg) rotateZ(180deg);
  }
}

.dice-wrap .face {
  position: absolute;
  width: 160px;
  height: 160px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 20px;
  background: #f5f0e6;
  border: 3px solid rgba(0, 0, 0, 0.25);
  border-radius: 14px;
  backface-visibility: hidden;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.12);
}

.dice-wrap .pip {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #444, #111 70%);
  justify-self: center;
  align-self: center;
}

.dice-wrap .p-tl { grid-column: 1; grid-row: 1; }
.dice-wrap .p-tr { grid-column: 3; grid-row: 1; }
.dice-wrap .p-ml { grid-column: 1; grid-row: 2; }
.dice-wrap .p-mc { grid-column: 2; grid-row: 2; }
.dice-wrap .p-mr { grid-column: 3; grid-row: 2; }
.dice-wrap .p-bl { grid-column: 1; grid-row: 3; }
.dice-wrap .p-br { grid-column: 3; grid-row: 3; }

.dice-wrap .face-1 { transform: rotateY(0deg) translateZ(80px); }
.dice-wrap .face-6 { transform: rotateY(180deg) translateZ(80px); }
.dice-wrap .face-3 { transform: rotateY(90deg) translateZ(80px); }
.dice-wrap .face-4 { transform: rotateY(-90deg) translateZ(80px); }
.dice-wrap .face-5 { transform: rotateX(90deg) translateZ(80px); }
.dice-wrap .face-2 { transform: rotateX(-90deg) translateZ(80px); }

.coin-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0;
  perspective: 600px;
}
.coin {
  position: relative;
  width: 84px;
  height: 84px;
  transform-style: preserve-3d;
}
.coin-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffe66d, #ffb020);
  color: #141414;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  backface-visibility: hidden;
  border: 3px solid var(--border);
}
.coin-back { transform: rotateY(180deg); }

.coin.flip-ja { animation: coin-flip-ja 1.1s ease-out forwards; }
.coin.flip-nein { animation: coin-flip-nein 1.1s ease-out forwards; }

@keyframes coin-flip-ja {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(1800deg); }
}
@keyframes coin-flip-nein {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(1980deg); }
}

@media (prefers-reduced-motion: reduce) {
  .coin.flip-ja, .coin.flip-nein {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.character-banner {
  margin: 20px auto 24px;
  max-width: 260px;
  text-align: center;
}
.character-banner img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.character-banner figcaption {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
@media (min-width: 560px) {
  .character-banner { max-width: 340px; }
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.stat strong { color: var(--text); font-size: 1.05rem; }

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 24px;
}
@media (min-width: 560px) {
  .cards { grid-template-columns: 1fr 1fr; }
}
.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card span { font-size: 1.6rem; }
.card h2 { font-size: 1.05rem; margin: 8px 0 4px; }
.card p { margin: 0; color: var(--text-muted); font-size: 0.88rem; line-height: 1.45; }

.section-title { font-size: 1.2rem; margin: 32px 0 4px; }

.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
  text-align: center;
}

.footer-links {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--accent-2);
  margin-bottom: 8px;
}

.footer-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.5;
}

.legal main {
  max-width: 760px;
}
.legal .box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text-muted);
  line-height: 1.6;
}
.legal .box h2 { color: var(--text); font-size: 1.05rem; margin-top: 28px; }
.legal .box h2:first-child { margin-top: 0; }
.legal .todo {
  border-left: 4px solid #ffb020;
  background: rgba(255, 176, 32, 0.1);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  margin: 8px 0;
  font-size: 0.9rem;
}
.legal a { color: var(--accent-2); }
