:root {
  --bg-1: #1b1033;
  --bg-2: #2d1b4e;
  --bg-3: #3a1f5c;
  --card: rgba(255, 255, 255, 0.06);
  --card-hover: rgba(255, 255, 255, 0.12);
  --stroke: rgba(255, 255, 255, 0.12);
  --text: #f4eefb;
  --text-dim: #b9a9d4;
  --accent: #ffb347;
  --accent-2: #ff6f91;
  --accent-3: #59d0c0;
  --accent-4: #7c9cff;
  --good: #59d08a;
  --radius: 20px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body {
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 15% -10%, #4a2a7a 0%, transparent 55%),
    radial-gradient(900px 600px at 110% 10%, #7a2a5a 0%, transparent 50%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(14px, 4vw, 32px);
  background: rgba(20, 12, 38, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--stroke);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.2px;
  cursor: pointer;
  padding: 4px;
}
.brand-mark { font-size: 1.5rem; }

.lang-switch {
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 4px;
}
.lang-btn {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.lang-btn.active {
  background: var(--accent);
  color: #2a1500;
  box-shadow: 0 4px 14px rgba(255, 179, 71, 0.35);
}

/* ---------- Layout ---------- */
.app {
  flex: 1;
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 36px) clamp(14px, 4vw, 32px) 60px;
  animation: fade 0.35s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 18px;
  border-top: 1px solid var(--stroke);
}

/* ---------- Home ---------- */
.hero {
  text-align: center;
  margin-bottom: 26px;
}
.hero h1 {
  font-size: clamp(1.9rem, 6vw, 3rem);
  margin: 0 0 8px;
  line-height: 1.05;
}
.hero p {
  color: var(--text-dim);
  font-size: clamp(0.95rem, 3vw, 1.1rem);
  margin: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 14px;
}
@media (min-width: 620px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

.card {
  position: relative;
  text-align: left;
  border: 1px solid var(--stroke);
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.card:hover, .card:focus-visible {
  transform: translateY(-4px);
  background: var(--card-hover);
  border-color: rgba(255, 255, 255, 0.28);
  outline: none;
}
.card .icon {
  font-size: 2.2rem;
  line-height: 1;
}
.card h3 {
  margin: 14px 0 4px;
  font-size: 1.05rem;
}
.card .tag {
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #12232f;
  background: var(--accent-3);
  padding: 3px 8px;
  border-radius: 999px;
  margin-top: 8px;
}
.card .num {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-dim);
  opacity: 0.6;
}

/* ---------- Detail ---------- */
.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke);
  color: var(--text);
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  margin-bottom: 20px;
  font-size: 0.9rem;
}
.back:hover { background: var(--card-hover); }

.detail-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}
.detail-head .icon { font-size: 2.6rem; }
.detail-head h1 { margin: 0; font-size: clamp(1.6rem, 5vw, 2.4rem); }

.scene {
  margin: 18px 0 24px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  padding: 10px;
  overflow: hidden;
}
.scene svg { display: block; width: 100%; height: auto; }

.panel {
  border: 1px solid var(--stroke);
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
}
.material {
  color: var(--text-dim);
  font-size: 1rem;
  margin: 0;
}
.rules {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: step;
}
.rules li {
  position: relative;
  padding: 10px 0 10px 44px;
  border-bottom: 1px dashed var(--stroke);
  line-height: 1.45;
}
.rules li:last-child { border-bottom: 0; }
.rules li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 8px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-2);
  color: #2a0012;
  font-weight: 800;
  font-size: 0.9rem;
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #2a1500;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 15px 24px;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  width: 100%;
  justify-content: center;
}
.cta:hover { filter: brightness(1.05); }
.cta.secondary {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid var(--stroke);
  box-shadow: none;
}

/* ---------- Draw / Display mode ---------- */
.stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.pair-info {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.qr-box {
  background: #fff;
  padding: 14px;
  border-radius: 16px;
  display: grid;
  place-items: center;
}
.qr-box canvas, .qr-box img { display: block; }
.code-pill {
  font-size: clamp(1.8rem, 8vw, 3rem);
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--accent);
  background: rgba(0,0,0,0.25);
  padding: 8px 22px;
  border-radius: 14px;
  border: 1px dashed var(--accent);
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--stroke);
}
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent-2); }
.status.connected .dot { background: var(--good); box-shadow: 0 0 10px var(--good); }

.canvas-wrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid var(--stroke);
  background: #fbf7ff;
  touch-action: none;
  width: 100%;
}
canvas.draw { display: block; width: 100%; height: auto; background: #fbf7ff; touch-action: none; }

.term-banner {
  text-align: center;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(120deg, var(--accent-4), var(--accent-3));
  color: #0d1b2a;
}
.term-banner .label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; opacity: 0.8; }
.term-banner .word { font-size: clamp(1.6rem, 7vw, 2.6rem); font-weight: 900; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}
.swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 0;
}
.swatch.active { border-color: #fff; transform: scale(1.15); box-shadow: 0 0 0 3px rgba(255,255,255,0.25); }
.tool-btn {
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
}
.tool-btn:hover { background: var(--card-hover); }

.hint {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
  line-height: 1.5;
}
.hint code {
  background: rgba(0,0,0,0.3);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--accent);
  font-weight: 700;
}

.join-form {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}
.join-form input {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 6px;
  text-align: center;
  text-transform: uppercase;
  width: 160px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.25);
  color: var(--text);
}

.notice {
  border: 1px solid var(--accent);
  background: rgba(255,179,71,0.1);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 0.9rem;
  text-align: center;
}

/* ---------- Wer bin ich? (Host) ---------- */
.wa-stage { text-align: center; }
.wa-list { max-width: 520px; margin: 16px auto; display: flex; flex-direction: column; gap: 8px; }
.wa-row { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--stroke); background: var(--card); }
.wa-row.turn { border-color: var(--accent-2); background: rgba(255,111,145,0.14); }
.wa-row.done { opacity: 0.5; }
.wa-name { font-weight: 700; }
.wa-word { color: var(--accent); font-weight: 700; }

/* ---------- Partner-Quiz (Host) ---------- */
.cp-setup { text-align: center; }
.cp-pool { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 14px 0; }
.cp-chip { padding: 10px 18px; border-radius: 999px; border: 1px solid var(--stroke);
  background: var(--card); color: var(--text); font-weight: 700; font-size: 1rem; cursor: pointer; }
.cp-chip.sel { border-color: var(--accent-2); background: rgba(255,111,145,0.25); transform: scale(1.05); }
.cp-pairs { max-width: 480px; margin: 8px auto; }
.cp-pair { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: 12px; border: 1px solid var(--stroke); background: var(--card); margin: 6px 0; }
.cp-x { border: none; background: rgba(255,77,77,0.2); color: var(--text); border-radius: 8px; padding: 4px 10px; cursor: pointer; }
.cp-opts { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
.cp-opt { padding: 12px 20px; border-radius: 14px; border: 1px solid var(--stroke); background: var(--card); min-width: 120px; }
.cp-opt b { display: block; font-size: 1.1rem; }
.cp-opt span { color: var(--text-dim); font-size: 0.9rem; }
.cp-rlist { max-width: 560px; margin: 14px auto; display: flex; flex-direction: column; gap: 8px; }
.cp-rrow { display: grid; grid-template-columns: 1fr auto 28px; gap: 10px; align-items: center;
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--stroke); background: var(--card); text-align: left; }
.cp-rrow.match { border-color: var(--good); background: rgba(89,208,138,0.14); }
.cp-rnames { font-weight: 700; }
.cp-rvals { color: var(--text-dim); font-size: 0.9rem; }
.cp-rmark { font-size: 1.2rem; text-align: center; }
