/* =========================================================
   Drehrad – Grundlayout
   Farben, Schriften und Formen kommen aus Variablen, die in
   designs.css je Design überschrieben werden. Die Werte hier
   sind zugleich das Design „Klar“.
   ========================================================= */

:root {
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font-body);
  --font-wheel: var(--font-body);

  --bg: #f2f4f8;
  --ink: #1b2233;
  --ink-muted: #667085;
  --line: #e5e9f1;
  --focus: #4f46e5;

  --panel-bg: #ffffff;
  --panel-border: 1px solid #e5e9f1;
  --panel-radius: 18px;
  --panel-shadow: 0 12px 32px -14px rgba(27, 34, 51, .2);

  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-hover: #4338ca;

  --field-bg: #ffffff;
  --field-border: #cdd4e2;
  --btn-bg: #edf0f6;
  --btn-bg-hover: #e1e6f0;
  --btn-ink: #1b2233;
  --btn-border: transparent;
  --btn-radius: 10px;
  --btn-shadow: none;

  --item-bg: #f5f7fa;
  --item-border: transparent;
  --item-radius: 10px;

  /* angewählte Objekte: leicht grün */
  --ok-bg: #ddf4e2;
  --ok-border: #a3dab1;
  --ok-mark: #1f9d55;
  --ok-mark-ink: #ffffff;
  --danger: #d92d20;
  --danger-ink: #ffffff;

  --wheel-rim: #1b2233;
  --wheel-back: #1b2233;
  --wheel-sep: #ffffff;
  --wheel-sep-w: 1.2;
  --wheel-shadow: drop-shadow(0 8px 14px rgba(27, 34, 51, .22));
  --hub: #ffffff;
  --hub-stroke: #1b2233;
  --hub-dot: #1b2233;
  --pointer: #1b2233;
  --pointer-stroke: #ffffff;
  --label-weight: 600;

  --slice-ink: #ffffff;
  --s1: #4f46e5;
  --s2: #0e9fd8;
  --s3: #12a37a;
  --s4: #f2a41c;  --s4-ink: #2b1d00;
  --s5: #e5484d;
  --s6: #8b5cf6;
  --s7: #0fa3a3;
  --s8: #e0559b;
}

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ol, ul { margin: 0; padding: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Seitenaufbau: Anleitung | Rad | Liste ---------- */

.app {
  display: grid;
  grid-template-columns: clamp(240px, 24vw, 340px) minmax(0, 1fr) clamp(240px, 24vw, 340px);
  gap: clamp(16px, 2.2vw, 32px);
  height: 100vh;
  height: 100dvh;
  padding: clamp(16px, 2.2vw, 32px);
}

/* ---------- Seitenkästen ---------- */

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel-bg);
  border: var(--panel-border);
  border-radius: var(--panel-radius);
  box-shadow: var(--panel-shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
}

.count {
  font-size: .8rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 20px;
}

.panel-foot {
  display: flex;
  gap: 8px;
  padding: 12px 20px 14px;
  border-top: 1px solid var(--line);
}

.panel-foot .btn { flex: 1; }

/* Einstellungen (Design, Sprache, Drehdauer) im Fuß der Anleitung */
.settings { flex-wrap: wrap; }
.pick {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding-left: 9px;
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--btn-radius);
  color: var(--ink-muted);
}
.pick svg { flex: none; width: 15px; height: 15px; }
.pick-wide { flex-basis: 100%; }
.pick-label { flex: none; margin-right: 4px; font-size: .82rem; }
.pick-range {
  flex: 1;
  min-width: 0;
  margin: 0 4px;
  accent-color: var(--accent);
  cursor: pointer;
}
.pick-range:focus-visible { outline: none; }
.pick-value {
  flex: none;
  min-width: 3.4em;
  padding-right: 10px;
  text-align: right;
  color: var(--ink);
  font-size: .82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pick select {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 2px;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: inherit;
  font-size: .82rem;
  font-weight: 600;
  text-overflow: ellipsis;
  cursor: pointer;
}
.pick select:focus-visible { outline: none; }
.pick:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Anleitung ---------- */

.steps {
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 40px;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 0;
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--step-bg, var(--btn-bg));
  color: var(--step-ink, var(--accent));
  border: var(--step-border, 0);
  font-family: var(--font-display);
  font-size: .82rem;
  font-weight: 700;
}

.steps h3 {
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 700;
  line-height: 26px;
}

.steps p {
  margin-top: 2px;
  font-size: .86rem;
  color: var(--ink-muted);
}

.steps b { color: var(--ink); font-weight: 600; }

/* ---------- Anleitung einklappen ---------- */

.panel-help { position: relative; }
.panel-help .panel-head { align-items: center; }
.panel-help .panel-head h2 { min-width: 0; overflow: hidden; white-space: nowrap; }
/* beim Aufklappen wird der Inhalt abgeschnitten statt gequetscht */
.panel-help .panel-body,
.panel-help .panel-foot { min-width: 240px; }

.help-toggle {
  flex: none;
  width: 30px; height: 30px;
  margin: -4px -6px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: var(--btn-radius);
  color: var(--ink-muted);
  transition: background-color .15s, color .15s;
}
.help-toggle:hover { background: var(--btn-bg-hover); color: var(--ink); }
.help-toggle svg { width: 18px; height: 18px; transition: transform .25s; }

[data-help="zu"] .panel-help .panel-head { border-bottom: 0; }
[data-help="zu"] .panel-help .panel-body,
[data-help="zu"] .panel-help .panel-foot { display: none; }

/* Breite Fenster: eingeklappt bleibt eine schmale Leiste mit senkrechtem Titel */
@media (min-width: 901px) {
  /* nur beim Umschalten animieren, nicht bei jeder Änderung der Fenstergröße */
  .app.is-toggling-help { transition: grid-template-columns .25s ease; }
  [data-help="zu"] .app { grid-template-columns: 56px minmax(0, 1fr) clamp(240px, 24vw, 340px); }
  [data-help="zu"] .panel-help .panel-head {
    flex: 1;
    flex-direction: column;
    justify-content: flex-start;
    padding: 62px 0 16px;
  }
  [data-help="zu"] .panel-help .panel-head h2 {
    position: relative;     /* über dem Knopf, damit dessen Hover-Fläche den Titel nicht verdeckt */
    z-index: 1;
    pointer-events: none;
    writing-mode: vertical-rl;
  }
  /* die ganze Leiste ist der Knopf */
  [data-help="zu"] .help-toggle {
    position: absolute;
    inset: 0;
    width: auto; height: auto;
    margin: 0;
    padding-top: 18px;
    place-items: start center;
    border-radius: inherit;
  }
  [data-help="zu"] .help-toggle:focus-visible { outline-offset: -4px; }
  [data-help="zu"] .help-toggle svg { transform: rotate(180deg); }
}

/* Schmale Fenster: Pfeil nach oben (zuklappen) oder unten (aufklappen) */
@media (max-width: 900px) {
  .help-toggle svg { transform: rotate(90deg); }
  [data-help="zu"] .help-toggle svg { transform: rotate(-90deg); }
}

/* ---------- Knöpfe und Felder ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  border: 1px solid var(--btn-border);
  border-radius: var(--btn-radius);
  box-shadow: var(--btn-shadow);
  font-weight: 600;
  font-size: .9rem;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, transform .08s, box-shadow .08s;
}

.btn:hover:not(:disabled) { background: var(--btn-bg-hover); }
.btn:disabled { opacity: .45; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-small { min-height: 32px; padding: 0 10px; font-size: .82rem; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent-border, transparent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-danger {
  background: var(--danger);
  color: var(--danger-ink);
  border-color: var(--accent-border, transparent);
}
.btn-danger:hover:not(:disabled) { background: var(--danger); filter: brightness(.92); }

.icon-btn {
  flex: none;
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
  background: var(--btn-bg);
  color: var(--btn-ink);
  border: 1px solid var(--btn-border);
  border-radius: var(--btn-radius);
  box-shadow: var(--btn-shadow);
  transition: background-color .15s, color .15s, transform .08s, box-shadow .08s;
}
.icon-btn:hover { background: var(--btn-bg-hover); }
.icon-btn-danger:hover { color: var(--danger); }
.icon-btn svg { width: 17px; height: 17px; }

.field {
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  background: var(--field-bg);
  color: var(--ink);
  border: 1px solid var(--field-border);
  border-radius: var(--btn-radius);
}
.field::placeholder { color: var(--ink-muted); opacity: .8; }
select.field { padding-right: 6px; text-overflow: ellipsis; cursor: pointer; }

/* ---------- Liste der Objekte ---------- */

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px 12px;
}

.list-bar { display: flex; gap: 6px; }
.list-bar select { flex: 1; font-weight: 600; }

.add-row { display: flex; flex-wrap: wrap; gap: 6px; }
.add-row input { flex: 1 1 140px; }
.add-row .btn { flex: 1 0 auto; }

.bulk-row { display: flex; gap: 6px; }
.bulk-row .btn { flex: 1; }

.items {
  list-style: none;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 20px 16px;
  scrollbar-width: thin;
}

.item {
  flex: none;
  display: flex;
  align-items: stretch;
  background: var(--item-bg);
  border: 1px solid var(--item-border);
  border-radius: var(--item-radius);
  transition: background-color .15s, border-color .15s;
}

.item.is-selected {
  background: var(--ok-bg);
  border-color: var(--ok-border);
}

.item-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px 9px 12px;
  background: none;
  border: 0;
  border-radius: inherit;
  text-align: left;
}

.item-check {
  flex: none;
  width: 18px; height: 18px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--field-border);
  border-radius: 50%;
  color: transparent;
  transition: background-color .15s, border-color .15s;
}
.item-check svg { width: 11px; height: 11px; }

.item.is-selected .item-check {
  background: var(--ok-mark);
  border-color: var(--ok-mark);
  color: var(--ok-mark-ink);
}

.item-text { min-width: 0; overflow-wrap: anywhere; }
.item:not(.is-selected) .item-text { color: var(--ink-muted); }

.item-delete {
  flex: none;
  width: 38px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: inherit;
  color: var(--ink-muted);
  opacity: .75;
  transition: color .15s, opacity .15s;
}
.item-delete:hover, .item-delete:focus-visible { color: var(--danger); opacity: 1; }
.item-delete svg { width: 17px; height: 17px; }

.items-empty {
  padding: 22px 8px;
  text-align: center;
  font-size: .88rem;
  color: var(--ink-muted);
}

.panel-list.is-locked { opacity: .6; }
.panel-list { transition: opacity .2s; }

/* ---------- Mitte: Gewinner, Rad, Knopf ---------- */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1.8vh, 18px);
  min-width: 0;
  min-height: 0;
}

.winner {
  width: 100%;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.winner-label {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.winner-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.2vw, 2.5rem);
  font-weight: 800;
  line-height: 1.25;
}

.winner[data-state="idle"] .winner-name,
.winner[data-state="spinning"] .winner-name { color: var(--ink-muted); }
.winner[data-state="done"] .winner-label { color: var(--winner-accent, var(--accent)); }

.winner.pop .winner-name { animation: winner-pop .5s cubic-bezier(.2, 1.5, .4, 1); }

@keyframes winner-pop {
  from { transform: scale(.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.wheel-wrap {
  position: relative;
  flex: 1 1 0;
  width: 100%;
  min-height: 0;
}

.wheel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.wheel-rim { fill: var(--wheel-rim); filter: var(--wheel-shadow); }
.wheel-back { fill: var(--wheel-back); }

.slice > :first-child {
  fill: var(--s1);
  stroke: var(--wheel-sep);
  stroke-width: var(--wheel-sep-w);
  stroke-linejoin: round;
}
.slice text {
  fill: var(--slice-ink);
  font-family: var(--font-wheel);
  font-weight: var(--label-weight);
  text-anchor: end;
  pointer-events: none;
}
.slice { transition: opacity .35s; }

.slice.c1 > :first-child { fill: var(--s1); }  .slice.c1 text { fill: var(--s1-ink, var(--slice-ink)); }
.slice.c2 > :first-child { fill: var(--s2); }  .slice.c2 text { fill: var(--s2-ink, var(--slice-ink)); }
.slice.c3 > :first-child { fill: var(--s3); }  .slice.c3 text { fill: var(--s3-ink, var(--slice-ink)); }
.slice.c4 > :first-child { fill: var(--s4); }  .slice.c4 text { fill: var(--s4-ink, var(--slice-ink)); }
.slice.c5 > :first-child { fill: var(--s5); }  .slice.c5 text { fill: var(--s5-ink, var(--slice-ink)); }
.slice.c6 > :first-child { fill: var(--s6); }  .slice.c6 text { fill: var(--s6-ink, var(--slice-ink)); }
.slice.c7 > :first-child { fill: var(--s7); }  .slice.c7 text { fill: var(--s7-ink, var(--slice-ink)); }
.slice.c8 > :first-child { fill: var(--s8); }  .slice.c8 text { fill: var(--s8-ink, var(--slice-ink)); }

/* nach dem Drehen treten die anderen Felder zurück */
.wheel.has-winner .slice:not(.is-winner) { opacity: .38; }

.wheel-empty circle {
  fill: var(--panel-bg);
  stroke: var(--field-border);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.wheel-empty text {
  fill: var(--ink-muted);
  font-family: var(--font-body);
  font-size: 8px;
}

.bulbs { display: none; }

.wheel-hub { fill: var(--hub); stroke: var(--hub-stroke); stroke-width: 2.5; }
.wheel-hub-dot { fill: var(--hub-dot); }

.pointer {
  fill: var(--pointer);
  stroke: var(--pointer-stroke);
  stroke-width: 1.6;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, .3));
}

.spin-btn {
  flex: none;
  min-width: 190px;
  height: 56px;
  padding: 0 36px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent-border, transparent);
  border-radius: var(--spin-radius, 999px);
  box-shadow: var(--spin-shadow, 0 10px 22px -10px var(--accent));
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: .04em;
  transition: background-color .15s, transform .08s, box-shadow .08s, opacity .15s;
}
.spin-btn:hover:not(:disabled) { background: var(--accent-hover); }
.spin-btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.spin-btn:disabled { opacity: .45; box-shadow: none; }

/* ---------- Dialog ---------- */

.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 22px;
  background: var(--panel-bg);
  color: var(--ink);
  border: var(--panel-border);
  border-radius: var(--panel-radius);
  box-shadow: var(--dialog-shadow, 0 30px 70px -20px rgba(0, 0, 0, .45));
}
.dialog::backdrop { background: rgba(12, 14, 22, .5); }
.dialog h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.dialog p { margin-top: 8px; color: var(--ink-muted); overflow-wrap: anywhere; }
.dialog .field { width: 100%; margin-top: 14px; }
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.dialog-actions .btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: inline-block; line-height: 36px; }

/* ---------- Hinweis-Einblendung ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: 18px;
  z-index: 20;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 600;
  opacity: 0;
  transform: translate(-50%, -16px);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Schmale Seitenkästen: Listen-Knöpfe in eigene Zeile ---------- */

@media (min-width: 901px) and (max-width: 1250px) {
  .list-bar { flex-wrap: wrap; }
  .list-bar select { flex: 1 1 100%; }
  .list-bar .icon-btn { flex: 1; width: auto; }
}

/* ---------- Schmale Fenster: untereinander ---------- */

@media (max-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    padding: 16px;
  }
  .stage { order: 1; }
  .panel-list { order: 2; }
  .panel-help { order: 3; }
  .wheel-wrap {
    flex: none;
    width: min(100%, 520px);
    aspect-ratio: 1;
  }
  .items { max-height: 55vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
