:root {
  --bg: #f6f1e8;
  --panel: #fffaf1;
  --text: #241c18;
  --muted: #6f6259;
  --line: #d8cab7;
  --accent: #2f5f6d;
  --accent-dark: #1f424c;
  --danger: #8c3d35;
  --shadow: 0 18px 45px rgba(41, 30, 20, 0.13);
  --pointer-height: clamp(30px, 5vw, 52px);
  --pointer-half-width: clamp(15px, 2.7vw, 28px);
  --pointer-gap: clamp(6px, 0.8vw, 12px);
  --pointer-overlap: clamp(8px, 1.1vw, 16px);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #fff8dc, var(--bg) 40%, #eadfce);
  color: var(--text);
}

button, textarea, input { font: inherit; }

button, .file-button, .button-link {
  border: 0;
  background: var(--accent);
  color: white;
  padding: 0.85rem 1rem;
  border-radius: 999px;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(31, 66, 76, 0.18);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover, .file-button:hover, .button-link:hover { background: var(--accent-dark); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.secondary {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--line);
  box-shadow: none;
}
.secondary:hover { background: #fffaf1; }

.app { width: min(1540px, 100%); margin: 0 auto; padding: 24px; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 22px;
}

.top-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 5vw, 4rem); line-height: 0.9; margin-bottom: 0.4rem; }
h2 { font-size: 1.3rem; }
h3 { margin-top: 1.4rem; margin-bottom: 0.5rem; color: var(--muted); font-size: 1rem; }
.topbar p, .status-card p, .hint { color: var(--muted); margin-bottom: 0; }

.layout { display: grid; gap: 22px; align-items: start; }
.admin-layout { grid-template-columns: minmax(250px, 330px) minmax(420px, 1fr) minmax(250px, 330px); }

.panel {
  background: rgba(255, 250, 241, 0.9);
  border: 1px solid rgba(216, 202, 183, 0.9);
  border-radius: 28px;
  padding: 22px;
  box-shadow: var(--shadow);
}

label { display: block; font-weight: 700; margin-bottom: 0.5rem; }

textarea {
  width: 100%; min-height: 280px; resize: vertical;
  border-radius: 18px; border: 1px solid var(--line);
  background: #fffdf8; color: var(--text); padding: 14px; line-height: 1.45;
}

.button-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.options { display: grid; gap: 0.65rem; margin-top: 18px; }
.options label { display: flex; gap: 0.55rem; align-items: center; margin: 0; font-weight: 650; }

.status-card { margin-top: 18px; padding: 14px; border-radius: 18px; border: 1px dashed var(--line); background: rgba(255, 255, 255, 0.45); }

.wheel-column { display: grid; gap: 10px; }

.wheel-stage { display: grid; place-items: center; min-width: 0; }
.admin-stage { padding: 6px 0 0; }

.wheel-shell {
  width: min(72vw, 72vh, 760px);
  max-width: 100%;
  position: relative;
  padding-top: calc(var(--pointer-height) - var(--pointer-overlap));
}

.canvas-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; z-index: 1; }

#wheelCanvas {
  width: 100%; height: 100%; aspect-ratio: 1 / 1; display: block;
  filter: drop-shadow(0 25px 35px rgba(41, 30, 20, 0.20));
}

.pointer {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  width: 0;
  height: 0;
  border-left: var(--pointer-half-width) solid transparent;
  border-right: var(--pointer-half-width) solid transparent;
  border-top: var(--pointer-height) solid var(--danger);
  filter: drop-shadow(0 4px 3px rgba(0,0,0,0.25));
  pointer-events: none;
}

.spin-button {
  position: absolute;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: clamp(105px, 17vw, 155px); height: clamp(105px, 17vw, 155px);
  border-radius: 50%; font-size: clamp(1rem, 2.8vw, 1.45rem); letter-spacing: 0.04em;
  border: 8px solid #fff8ef;
  z-index: 6;
}

.winner-box {
  min-height: 90px; display: grid; place-items: center; text-align: center;
  border-radius: 22px; background: #fffdf8; border: 1px solid var(--line);
  padding: 18px; font-size: 1.35rem; font-weight: 800;
}

.continue-button {
  margin-top: 12px;
  width: 100%;
}

.continue-button[hidden] { display: none; }

.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.export-button {
  width: 100%;
  padding-inline: 0.75rem;
}

.export-button:disabled {
  opacity: 0.45;
}
.compact-list { margin: 0; padding-left: 1.25rem; color: var(--text); }
.compact-list li { padding: 0.22rem 0; word-break: break-word; }

/* Publikum */
body[data-page="display"] {
  overflow: hidden;
  background: radial-gradient(circle at 50% 0%, #fff8dc, #f2ebdd 48%, #e4d5c0);
}

.display-app {
  height: 100dvh;
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(8px, 1.2vw, 18px);
}

.display-header {
  position: fixed;
  top: clamp(8px, 1.2vw, 18px);
  left: clamp(10px, 1.4vw, 24px);
  right: clamp(10px, 1.4vw, 24px);
  z-index: 8;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  pointer-events: none;
}

.display-header h1 {
  font-size: clamp(1.65rem, 3.15vw, 3.9rem);
  line-height: 0.9;
  margin-bottom: 0.05em;
}

.display-header p {
  color: var(--muted);
  margin: 0;
  font-size: clamp(0.82rem, 1.05vw, 1.05rem);
}

.display-count {
  font-size: clamp(1.05rem, 2vw, 2.15rem);
  font-weight: 900;
  color: var(--accent-dark);
  white-space: nowrap;
  padding-top: 0.2rem;
}

.display-stage {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0;
  transform: translateY(calc(clamp(10px, 2.5vh, 28px) - 10px));
}

.display-shell {
  width: min(96vw, calc(100dvh - 74px));
  margin-inline: auto;
}

.display-spin-button {
  width: clamp(120px, 16vw, 205px);
  height: clamp(120px, 16vw, 205px);
  font-size: clamp(1.1rem, 2.4vw, 2rem);
}

.display-footer {
  position: fixed;
  right: clamp(14px, 1.6vw, 28px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 7;
  width: min(320px, 22vw);
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.display-winner {
  min-height: 78px;
  padding: 16px 18px;
  border-radius: 20px;
  font-size: clamp(1.35rem, 2.35vw, 3rem);
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 45px rgba(41, 30, 20, 0.12);
}

.display-continue {
  pointer-events: auto;
  font-size: clamp(1rem, 1.25vw, 1.25rem);
  padding: 1rem 1.2rem;
}

.drawn-strip {
  list-style: none;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  max-height: 92px;
  overflow: hidden;
  justify-content: flex-start;
}

.drawn-strip li {
  background: rgba(255,255,255,0.74);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.62rem;
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .display-shell { width: min(94vw, calc(100dvh - 130px)); }
  .display-footer {
    left: clamp(10px, 1.35vw, 20px);
    right: clamp(10px, 1.35vw, 20px);
    top: auto;
    bottom: clamp(8px, 1.2vw, 16px);
    transform: none;
    width: auto;
  }
  .display-winner { min-height: 52px; padding: 9px 16px; }
  .drawn-strip { max-height: 36px; flex-wrap: nowrap; }
}

@media (max-width: 1120px) {
  .admin-layout { grid-template-columns: 1fr; }
  .wheel-column { order: -1; }
  textarea { min-height: 190px; }
}

@media (max-width: 620px) {
  .app { padding: 16px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .top-actions { justify-content: stretch; }
  .top-actions > * { flex: 1; }
  .panel { border-radius: 22px; }
  .display-header { align-items: flex-start; }
}

@media (max-height: 720px) and (min-width: 1121px) {
  body:not([data-page="display"]) .wheel-shell { width: min(62vw, 62vh, 680px); }
  body[data-page="display"] .display-shell { width: min(96vw, calc(100dvh - 68px)); }
}

.spin-button.next-mode {
  background: #7f2f2f;
  letter-spacing: 0.08em;
}


.display-admin-link {
  position: fixed;
  left: clamp(10px, 1.4vw, 24px);
  bottom: clamp(10px, 1.4vw, 24px);
  z-index: 20;
  color: rgba(36, 28, 24, 0.58);
  background: rgba(255, 253, 248, 0.54);
  border: 1px solid rgba(216, 202, 183, 0.72);
  border-radius: 999px;
  padding: 0.44rem 0.72rem;
  text-decoration: none;
  font-weight: 750;
  font-size: clamp(0.78rem, 0.9vw, 0.95rem);
  backdrop-filter: blur(8px);
}

.display-admin-link:hover {
  color: var(--accent-dark);
  background: rgba(255, 253, 248, 0.86);
}

.spin-button.done-mode {
  background: #6f6259;
  letter-spacing: 0.07em;
}


.final-overlay {
  position: absolute;
  inset: calc(var(--pointer-height) - var(--pointer-overlap)) 0 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: clamp(14px, 3vw, 34px);
  background: radial-gradient(circle at 50% 30%, rgba(255, 253, 248, 0.96), rgba(255, 250, 241, 0.90) 62%, rgba(36, 28, 24, 0.08));
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(216, 202, 183, 0.60), 0 18px 45px rgba(41, 30, 20, 0.16);
  text-align: center;
}

.final-overlay[hidden] { display: none; }

.final-card {
  width: min(82%, 560px);
  max-height: 82%;
  overflow: auto;
  border-radius: 28px;
  padding: clamp(18px, 3vw, 34px);
  background: rgba(255, 253, 248, 0.90);
  border: 1px solid rgba(216, 202, 183, 0.92);
  box-shadow: 0 18px 45px rgba(41, 30, 20, 0.14);
}

.final-kicker {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: clamp(0.72rem, 1.2vw, 0.95rem);
}

.final-card h2 {
  margin: 0 0 0.8rem;
  font-size: clamp(1.8rem, 4vw, 4.2rem);
  line-height: 0.95;
}

.final-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: clamp(6px, 1vw, 12px);
}

.final-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: center;
  text-align: left;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(216, 202, 183, 0.82);
  padding: clamp(6px, 1vw, 12px) clamp(10px, 1.4vw, 18px);
  font-size: clamp(1rem, 2vw, 2rem);
  font-weight: 850;
}

.result-rank {
  display: inline-grid;
  place-items: center;
  width: clamp(28px, 3vw, 46px);
  height: clamp(28px, 3vw, 46px);
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.display-final-overlay {
  background: radial-gradient(circle at 50% 30%, rgba(255, 253, 248, 0.98), rgba(255, 250, 241, 0.94) 64%, rgba(36, 28, 24, 0.10));
}

.display-final-overlay .final-card {
  width: min(84%, 760px);
}

body[data-page="display"]:has(.final-overlay:not([hidden])) .display-footer {
  display: none;
}

body[data-page="display"]:has(.final-overlay:not([hidden])) .display-count {
  opacity: 0.25;
}

@media (max-width: 980px) {
  .final-overlay { border-radius: 34px; }
  .final-card { width: min(94%, 620px); max-height: 88%; }
}
