/* Muss, Soll, Kann – Schüleransicht */

:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #57534e;
  --line: #e7e5e4;
  --amber: #b45309;
  --amber-2: #f59e0b;
  --grad: linear-gradient(45deg, #ff6036 0%, #fd267a 100%);
  --grad-text: linear-gradient(45deg, #ff6036, #fd267a);
  --muss: #dc2626;
  --soll: #2563eb;
  --kann: #16a34a;
  --radius: 12px;
  --shadow-card: 0 10px 30px rgba(28, 25, 23, 0.16), 0 2px 6px rgba(28, 25, 23, 0.08);
  --shadow-btn: 0 6px 18px rgba(28, 25, 23, 0.14), 0 1px 3px rgba(28, 25, 23, 0.1);
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --script: "Snell Roundhand", "Segoe Script", "Brush Script MT", "URW Chancery L", cursive;
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

.screen {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
}

/* ---------- Buttons ---------- */
.btn-primary {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 14px 24px;
  border: 0;
  border-radius: 999px;
  background: var(--grad);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  box-shadow: 0 6px 16px rgba(253, 38, 122, 0.3);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.7; cursor: progress; }

.link-btn {
  display: block;
  margin: 8px auto 0;
  min-height: 48px;
  padding: 10px 20px;
  border: 0;
  background: none;
  color: var(--amber);
  font-size: 18px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

/* ---------- Startseite ---------- */
.start { display: flex; flex-direction: column; background: var(--bg); }
.hero {
  background: var(--grad);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 56px) 24px 64px;
  text-align: center;
}
.brand-big {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  position: relative;
  font-size: 64px;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  --mark-fill: #fff;
}
.mark-big { width: 58px; height: 58px; }
.hero-sub {
  margin: 16px auto 0;
  max-width: 20em;
  font-size: 19px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.sheet {
  flex: 1;
  margin-top: -28px;
  padding: 28px 20px calc(env(safe-area-inset-bottom) + 32px);
  background: var(--bg);
  border-radius: 28px 28px 0 0;
}
.join { display: grid; gap: 10px; }
.join-label { font-weight: 800; font-size: 18px; text-align: center; }
.code-input {
  width: 100%;
  min-height: 72px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  text-align: center;
  text-transform: uppercase;
}
.code-input::placeholder { color: #a8a29e; }
.code-input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 4px rgba(180, 83, 9, 0.18); }
.join-msg { min-height: 1.45em; margin: 0; text-align: center; color: var(--muted); font-size: 18px; }
.join-msg.error { color: #b91c1c; font-weight: 600; }

.explain { display: grid; gap: 12px; margin-top: 24px; }
.explain-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--cat);
  border-radius: 14px;
}
.explain-card h2 { margin: 0; font-size: 20px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.explain-card h2 small { font-size: 16px; font-weight: 600; color: var(--muted); }
.explain-card p { margin: 2px 0 0; }
.explain-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-btn);
  color: var(--cat);
}
.explain-icon svg { width: 26px; height: 26px; }
.test {
  margin: 20px 0 0;
  padding: 16px 18px;
  border-radius: 14px;
  background: #fef3c7;
  color: #451a03;
  font-size: 19px;
  text-align: center;
}

/* ---------- Spiel-Layout ---------- */
.game {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  background: none;
  color: #a8a29e;
  border-radius: 50%;
  cursor: pointer;
}
.topbar-btn svg { width: 28px; height: 28px; }
button.topbar-btn { color: #78716c; }
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.06em;
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.mark { width: 30px; height: 30px; margin-right: -2px; }

.notice {
  flex: none;
  margin: 8px auto 0;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  background: #f5f5f4;
  color: var(--muted);
  text-align: center;
}
.notice:empty { display: none; }
.notice.online { background: #dcfce7; color: #14532d; }

.deck-area {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0 6px;
}
.deck {
  position: relative;
  width: 92%;
  height: min(68dvh, 100%);
}

/* ---------- Karte ---------- */
.card {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  background: #1c1917;
  color: #fff;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  will-change: transform;
}
.card.dragging { cursor: grabbing; }
.card.is-next {
  transform: scale(0.95);
  pointer-events: none;
}
.card.is-next .edge,
.card.is-next .progress { opacity: 0; }

.scene {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% 0%, var(--a) 0%, var(--b) 75%);
  overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(34px);
  opacity: 0.75;
}
.blob.b1 { width: 70%; height: 45%; left: -18%; top: 8%; background: var(--c); }
.blob.b2 { width: 60%; height: 40%; right: -20%; top: 30%; background: var(--d); opacity: 0.55; }
.stripe {
  position: absolute;
  left: -20%;
  right: -20%;
  top: 44%;
  height: 22%;
  transform: rotate(-12deg);
  background: rgba(255, 255, 255, 0.07);
}
.scene-icon {
  position: absolute;
  left: 50%;
  top: 36%;
  width: 46%;
  max-width: 190px;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.92);
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.3));
}
.shade {
  position: absolute;
  inset: 45% 0 0 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.75) 62%, rgba(0, 0, 0, 0.82) 100%);
}
.tint {
  position: absolute;
  inset: 0;
  background: var(--tint, transparent);
  opacity: 0;
}

.progress {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
}
.progress i {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.3);
}
.progress i.done { background: rgba(255, 255, 255, 0.6); }
.progress i.current { background: #fff; }

.edge {
  position: absolute;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.38);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
  opacity: var(--edge, 1);
}
.edge-top { top: 22px; left: 50%; transform: translateX(-50%); }
.edge-left,
.edge-right {
  top: 40%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px 10px;
  transform: translateY(-50%);
}
.edge-left { left: 6px; }
.edge-right { right: 6px; }
.edge b { font-size: 16px; line-height: 1; }
.edge-left span { writing-mode: vertical-rl; transform: rotate(180deg); }
.edge-right span { writing-mode: vertical-rl; }

.stamp {
  position: absolute;
  padding: 2px 12px;
  border: 6px solid currentColor;
  border-radius: 10px;
  font-size: 46px;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.1;
  opacity: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.12);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.15);
}
.stamp-muss { top: 54px; right: 26px; color: #ef4444; transform: rotate(20deg); }
.stamp-kann { top: 54px; left: 26px; color: #22c55e; transform: rotate(-20deg); }
.stamp-soll { bottom: 42%; left: 50%; color: #3b82f6; transform: translateX(-50%); }

.card-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 20px 22px;
}
.card-title {
  margin: 0;
  font-size: clamp(26px, 7.6vw, 31px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  hyphens: manual;
  text-wrap: balance;
}
.card-role {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0;
  font-size: 18px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.92);
}
.card-role svg { width: 20px; height: 20px; flex: none; }

/* ---------- Runde Aktions-Buttons ---------- */
.actions {
  flex: none;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 26px;
  padding: 6px 0 8px;
}
.action { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.action span { font-size: 16px; font-weight: 700; color: var(--muted); }
.round-btn {
  --c: var(--muss);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--c);
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  transition: transform 0.18s var(--ease-spring), background-color 0.18s ease, color 0.18s ease;
}
.round-btn[data-cat="soll"] { --c: var(--soll); margin-top: 6px; }
.round-btn[data-cat="kann"] { --c: var(--kann); }
.round-btn.big { width: 64px; height: 64px; }
.round-btn.small { width: 52px; height: 52px; }
.round-btn.big svg { width: 32px; height: 32px; }
.round-btn.small svg { width: 26px; height: 26px; }
.round-btn[data-cat="kann"] svg,
.explain-icon[data-icon="kann"] svg { fill: currentColor; }
.round-btn:active,
.round-btn.pop { transform: scale(1.15); background: var(--c); color: #fff; }
.round-btn:disabled { cursor: default; }
.round-btn:disabled:not(.pop) { opacity: 0.55; }

/* ---------- Tab-Leiste ---------- */
.tabbar {
  flex: none;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff;
  border-top: 1px solid var(--line);
}
.tab {
  display: grid;
  place-items: center;
  width: 56px;
  height: 48px;
  border: 0;
  background: none;
  color: #a8a29e;
  --mark-fill: #a8a29e;
}
.tab svg { width: 28px; height: 28px; }
button.tab { cursor: pointer; }
.tab.active { --mark-fill: url(#brandGrad); }

/* ---------- Match-Overlay ---------- */
.match {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(12, 10, 9, 0.93);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.match.show { opacity: 1; }
.match-inner {
  width: 100%;
  max-width: 420px;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.35s var(--ease-spring);
}
.match.show .match-inner { transform: scale(1); }
.match-title {
  margin: 0;
  font-family: var(--script);
  font-size: 60px;
  font-weight: 700;
  font-style: italic;
  line-height: 1.1;
  background: linear-gradient(90deg, #fbbf24, #f59e0b 50%, #fcd34d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  transform: rotate(-4deg);
  padding: 0 8px 6px;
}
.match.wrong .match-title { background: linear-gradient(90deg, #e7e5e4, #d6d3d1); -webkit-background-clip: text; background-clip: text; }
.match-avatars {
  display: flex;
  justify-content: center;
  margin: 26px 0 20px;
}
.avatar {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.avatar svg { width: 54%; height: 54%; }
#match-a {
  background: radial-gradient(120% 90% at 30% 20%, var(--c, #666), var(--b, #222));
  color: #fff;
  transform: rotate(-8deg) translateX(10px);
}
#match-b {
  background: #fff;
  color: var(--cat);
  transform: rotate(8deg) translateX(-10px);
}
#match-b svg { width: 50%; height: 50%; }
#match-b[data-cat="kann"] svg { fill: currentColor; }
.match-card { margin: 0; font-size: 20px; font-weight: 700; }
.match-result { margin: 14px 0 0; font-size: 19px; }
.chip {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--cat);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.match-why {
  margin: 14px 0 26px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 19px;
}
.match-why strong { color: #fcd34d; }

/* ---------- Info-Sheet ---------- */
.info-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(12, 10, 9, 0.5);
}
.info-sheet {
  width: 100%;
  max-width: 480px;
  padding: 24px 20px calc(env(safe-area-inset-bottom) + 24px);
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  animation: sheet-up 0.3s var(--ease-spring);
}
.info-sheet h2 { margin: 0 0 12px; font-size: 24px; }
.info-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.info-list li {
  padding: 12px 14px;
  border-left: 6px solid var(--cat);
  border-radius: 12px;
  background: #fff;
}
.info-list li span { display: block; font-size: 16px; font-weight: 700; color: var(--muted); }
.info-sheet .btn-primary { margin-top: 18px; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- Abschlussseite ---------- */
.end {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 12px 20px 28px;
  -webkit-overflow-scrolling: touch;
}
.end-head { text-align: center; padding: 12px 0 6px; }
.end-score {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.2;
}
.end-score b {
  display: block;
  font-size: 84px;
  line-height: 1;
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.end-sub { margin: 4px 0 0; font-size: 20px; color: var(--muted); font-weight: 600; }
.end h3 { margin: 26px 0 10px; font-size: 20px; }
.tiles { display: grid; gap: 12px; }
.tile {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
}
.tile-thumb {
  display: grid;
  place-items: center;
  width: 56px;
  height: 72px;
  border-radius: 8px;
  background: radial-gradient(120% 90% at 30% 20%, var(--c), var(--b));
  color: #fff;
}
.tile-thumb svg { width: 30px; height: 30px; }
.tile h4 { margin: 0; font-size: 18px; line-height: 1.3; }
.tile p { margin: 6px 0 0; font-size: 18px; }
.tile .choice { color: var(--muted); }
.tile .choice s { text-decoration-thickness: 2px; }
.all-right {
  margin: 22px 0 0;
  padding: 16px;
  border-radius: 14px;
  background: #dcfce7;
  color: #14532d;
  text-align: center;
  font-weight: 700;
}
.merksatz {
  margin: 24px 0 20px;
  padding: 18px;
  border-radius: 16px;
  background: #fef3c7;
  color: #451a03;
  border-left: 6px solid var(--amber);
}
.merksatz strong { display: block; font-size: 16px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber); }
.merksatz p { margin: 6px 0 0; font-size: 20px; font-weight: 700; }

/* ---------- Kleine Displays ---------- */
@media (max-height: 700px) {
  .actions { gap: 22px; padding: 4px 0 4px; }
  .action span { display: none; }
  .card-title { font-size: 24px; }
  .scene-icon { width: 38%; }
  .stamp { font-size: 38px; }
}

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

/* ---------- BFSU-Sticker & Hinweis ---------- */
.brand { position: relative; }
.sticker {
  position: absolute;
  top: -10px;
  right: -34px;
  padding: 3px 9px;
  border-radius: 8px;
  background: #fff;
  color: #1c1917;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.2;
  transform: rotate(12deg);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
  border: 2px dashed #fd267a;
  -webkit-text-fill-color: #1c1917;
}
.sticker.small {
  top: 1px;
  right: -32px;
  padding: 1px 6px;
  font-size: 12px;
  border-radius: 6px;
  border-width: 1.5px;
}
.disclaimer { margin: 18px 0 0; font-size: 15px; color: #78716c; text-align: center; }
