/* Seitenspezifische Stile des Quiz-Bretts. Tokens/Resets siehe shared.css. */

body {
  overflow: hidden;            /* keine Scrollbalken auf dem Beamer */
  user-select: none;           /* verhindert versehentliches Markieren */
  -webkit-user-select: none;
}

/* ============================================================================
   APP-RAHMEN
   ============================================================================ */
#app { height: 100vh; display: flex; flex-direction: column; }

/* ----------------------------------------------------------------------
   TIMER-OVERLAY  (das Signatur-Element)
   WAS: eine vollflächige, farbige Ebene HINTER der Frage-Karte.
   WIE: per JavaScript wird clip-path inset() von 0% -> 50% animiert.
        Dadurch schrumpft die farbige Fläche von aussen nach innen zur
        Mitte – man sieht auf einen Blick, wie viel Zeit noch übrig ist.
   WARUM hinter der Karte: die Frage bleibt jederzeit gut lesbar.
   pointer-events:none -> die Ebene fängt keine Klicks ab.
   ---------------------------------------------------------------------- */
#timer-overlay {
  position: fixed; inset: 0;
  z-index: 1;
  pointer-events: none;
  background: var(--team-1);   /* Startfarbe = aktives Team (per JS gesetzt) */
  clip-path: inset(0% round 0px);
  transition: background-color .35s ease;
  opacity: 0;                  /* nur während einer Frage sichtbar */
}

/* ============================================================================
   KOPFLEISTE (immer sichtbar: Punktestände + Kontext in der Mitte)
   ============================================================================ */
#topbar {
  position: relative; z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;   /* Team1 | Mitte | Team2 */
  align-items: start;
  gap: 12px;
  padding: 14px;
}

/* Punkte-Box eines Teams (die farbigen Ecken oben) */
.team-box {
  justify-self: start;
  min-width: 96px;
  padding: 8px 16px 12px;
  border-radius: 0 0 16px 0;             /* nur unten-rechts gerundet (Ecke) */
  line-height: 1;
  transition: box-shadow .25s ease, transform .25s ease;
}
.team-box.right { justify-self: end; border-radius: 0 0 0 16px; text-align: right; }
.team-box.t1 { background: var(--team-1); }
.team-box.t2 { background: var(--team-2); }

.team-box .score {
  font-size: clamp(34px, 5.5vw, 64px);
  font-weight: 800;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;    /* Ziffern springen beim Zählen nicht */
}
.team-box .team-name {
  font-size: clamp(11px, 1.4vw, 15px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  opacity: .92;
  margin-top: 2px;
}

/* Markierung des Teams, das gerade an der Reihe ist (leuchtender Ring) */
.team-box.active {
  box-shadow: 0 0 0 4px rgba(255,255,255,.9), 0 0 28px 4px rgba(255,255,255,.35);
  transform: translateY(2px);
}
/* kurzes Aufleuchten, wenn ein Team Punkte bekommt */
.team-box.flash { animation: flash .7s ease; }
@keyframes flash {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,.0); }
  30%  { box-shadow: 0 0 0 10px rgba(255,255,255,.0), 0 0 50px 14px rgba(255,255,255,.9); transform: scale(1.06); }
  100% { box-shadow: none; transform: scale(1); }
}

/* Mittlerer Bereich der Kopfleiste (Titel bzw. Timer/Status) */
#topbar-center { text-align: center; padding-top: 4px; min-width: 0; }
#board-title {
  font-size: clamp(15px, 2.2vw, 24px);
  font-weight: 800; letter-spacing: -.01em;
}
#turn-label {
  margin-top: 4px;
  font-size: clamp(12px, 1.6vw, 17px);
  font-weight: 600; opacity: .85;
}
/* grosse Timer-Zahl (während einer Frage) */
#timer-num {
  font-size: clamp(40px, 7vw, 84px);
  font-weight: 800; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
#timer-num.urgent { color: #ffd0c2; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
#status-line {
  margin-top: 2px;
  font-size: clamp(13px, 1.8vw, 20px);
  font-weight: 700;
  min-height: 1.2em;
}

/* ============================================================================
   HAUPTBEREICH (wechselt zwischen Brett und Frage)
   ============================================================================ */
#main { position: relative; z-index: 3; flex: 1; min-height: 0; }

/* ---------- BRETT (Fragenauswahl) ---------- */
#board {
  height: 100%;
  display: grid;
  /* Spaltenzahl wird per JS gesetzt (--cols = Anzahl Kategorien) */
  grid-template-columns: repeat(var(--cols, 5), 1fr);
  gap: 14px;                                       /* wird per JS feinjustiert */
  padding: clamp(6px, 1.2vw, 16px) clamp(12px, 2.6vw, 40px) clamp(6px, 1.2vw, 14px);
  align-content: start;
  overflow: hidden;          /* fitBoard() sorgt dafür, dass alles passt – nie scrollen */
}

.category { display: flex; flex-direction: column; gap: var(--cat-gap, 12px); min-width: 0; }

.cat-name {
  text-align: center;
  font-size: clamp(13px, 1.7vw, 23px);
  font-weight: 800;
  letter-spacing: .01em;
  margin-bottom: 0;          /* Abstand kommt allein über --cat-gap (fitBoard rechnet damit) */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Das eigentliche Sticky-Note (anklickbarer Button)
   Grösse kommt aus --note-size, das JavaScript passend zum Bildschirm berechnet. */
.note {
  position: relative;
  width: var(--note-size, 110px);
  height: var(--note-size, 110px);
  margin: 0 auto;
  border-radius: 3px;
  /* zwei Verläufe = leichte Papier-Anmutung mit Glanz oben links */
  background:
    radial-gradient(120% 90% at 15% 10%, var(--note-hi) 0%, var(--note) 55%);
  color: var(--note-ink);
  font-size: calc(var(--note-size, 110px) * 0.4);
  font-weight: 800;
  display: grid; place-items: center;
  box-shadow: var(--shadow-note);
  transition: transform .14s ease, box-shadow .14s ease, opacity .4s ease;
  will-change: transform;
}
/* leicht zufällige Drehung pro Position -> wirkt handgeklebt/tactil */
.note.r0 { transform: rotate(-2.2deg); }
.note.r1 { transform: rotate(1.6deg); }
.note.r2 { transform: rotate(-1deg); }
.note.r3 { transform: rotate(2.4deg); }
.note.r4 { transform: rotate(-1.7deg); }

.note:hover, .note:focus-visible {
  transform: rotate(0deg) translateY(-4px) scale(1.05);
  box-shadow: 0 14px 28px rgba(0,0,0,.55);
  outline: none;
}
.note:focus-visible { box-shadow: 0 0 0 4px #fff, var(--shadow-note); }

/* Bereits gespielter Zettel: verschwindet, Platz bleibt aber erhalten,
   damit die Spalten nicht verrutschen. */
.note.used {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(.6) rotate(8deg);
}

/* ---------- FRAGE-ANSICHT ---------- */
#question {
  position: absolute; inset: 0;   /* legt sich ÜBER das sichtbare Brett */
  z-index: 4;                      /* über den Notes, unter Topbar/Steuerung */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 60px);
}

/* Während einer Frage tritt das Brett dezent in den Hintergrund (Karte im Fokus). */
body.question-open #board { filter: brightness(.42); transition: filter .3s ease; }
/* Zeit abgelaufen: zusätzlich entsättigt (entspricht deinem zweiten Mockup). */
body.question-open.phase-open #board { filter: grayscale(.6) brightness(.38); }

/* Die weisse Frage-Karte in der Mitte (das «Papier auf der Bühne») */
#question-card {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: clamp(28px, 5vw, 72px);
  max-width: min(1100px, 88vw);
  width: 100%;
  text-align: center;
  transform-origin: center;
}
/* sanftes Hereinzoomen beim Öffnen einer Frage */
#question-card.enter { animation: cardIn .32s cubic-bezier(.2,.8,.2,1); }
@keyframes cardIn {
  from { transform: scale(.82); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

#q-meta {
  font-size: clamp(13px, 1.8vw, 22px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: clamp(14px, 2.5vw, 28px);
}
#q-text {
  font-size: clamp(26px, 4.4vw, 58px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -.01em;
}
/* Lösung – erst sichtbar, wenn die Lehrperson sie einblendet */
#q-answer {
  margin-top: clamp(18px, 3vw, 36px);
  padding-top: clamp(16px, 2.5vw, 28px);
  border-top: 2px dashed rgba(0,0,0,.18);
  font-size: clamp(19px, 3vw, 38px);
  font-weight: 700;
  color: var(--good-dark);
}
#q-answer .label {
  display: block;
  font-size: clamp(11px, 1.4vw, 15px);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 6px;
  font-weight: 800;
}

/* ============================================================================
   STEUER-LEISTEN (Buttons unten)
   ============================================================================ */
.controls {
  position: relative; z-index: 6;
  display: flex; flex-wrap: wrap;
  gap: 10px; justify-content: center; align-items: center;
  padding: 10px clamp(14px, 3vw, 40px) 12px;
}
/* kompakte Leiste während einer Frage (nimmt wenig Höhe weg) */
.controls.compact { gap: 8px; padding: 8px clamp(12px, 2.5vw, 36px) 10px; }

.btn {
  border-radius: 10px;
  padding: 10px 16px;
  font-size: clamp(13px, 1.5vw, 16px);
  font-weight: 700;
  color: #fff;
  background: rgba(255,255,255,.10);
  transition: transform .12s ease, filter .12s ease, background .12s ease;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.btn:disabled { opacity: .35; cursor: not-allowed; transform: none; filter: none; }

/* kleine Bedien-Buttons (untere Leiste) */
.btn.small { padding: 7px 12px; font-size: clamp(12px, 1.3vw, 14px); border-radius: 9px; }
/* grosse Buttons nur für Setup-/End-Bildschirm */
.btn.big { padding: 16px 28px; font-size: clamp(16px, 2.1vw, 23px); }
.btn.t1   { background: var(--team-1); }
.btn.t1:hover { background: var(--team-1-dark); }
.btn.t2   { background: var(--team-2); }
.btn.t2:hover { background: var(--team-2-dark); }
.btn.good { background: var(--good); }
.btn.good:hover { background: var(--good-dark); }
.btn.ghost { background: rgba(255,255,255,.08); }
.btn.ghost:hover { background: rgba(255,255,255,.16); }
.btn.muted { background: var(--muted); }

/* kleine Tastatur-Hinweise unter den Buttons */
.hint {
  width: 100%; text-align: center;
  font-size: 12px; opacity: .5; margin-top: 4px;
}
kbd {
  background: rgba(255,255,255,.14);
  border-radius: 5px; padding: 1px 7px;
  font-family: inherit; font-size: .9em; font-weight: 700;
}

/* ============================================================================
   EINSTELLUNGS-MODAL (sammelt selten gebrauchte Funktionen)
   ============================================================================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(8,9,13,.72);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.modal {
  width: min(360px, 92vw);
  background: var(--stage-2);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  padding: 22px;
  display: flex; flex-direction: column; gap: 10px;
}
.modal h3 { margin: 0 0 6px; text-align: center; font-size: 21px; }
.modal .btn { width: 100%; text-align: center; }
.modal .modal-hint { font-size: 12px; opacity: .55; text-align: center; margin-top: 4px; line-height: 1.5; }

/* ============================================================================
   GRUPPEN-AUSLOSUNG (eigene Vollbild-Ansicht, beamer-tauglich)
   WARUM eine ganze Seite statt eines Modals: die Auslosung bleibt eine
   OPTION aus dem Setup, soll aber - einmal gestartet - durchgehend gross
   projizierbar sein: Auslosung, Teamnamen, Bedenkzeit und Start auf
   derselben Fläche, ohne zwischen kleiner Box und Setup-Karte zu wechseln.
   ============================================================================ */
#groups-screen {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  overflow-y: auto;
  background: radial-gradient(120% 120% at 50% 0%, var(--stage-2) 0%, var(--stage) 60%);
}
.groups-stage {
  width: min(760px, 94vw);
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 20px;
  padding: clamp(26px, 4vw, 44px);
  text-align: center;
}
.groups-stage h1 { font-size: clamp(28px, 5vw, 44px); margin: 0 0 18px; letter-spacing: -.02em; }
.groups-stage .btn { margin-top: 14px; }

.groups-label {
  display: block; text-align: left; opacity: .75; margin: 0 0 8px; font-size: 14px;
}

#groups-input {
  width: 100%;
  min-height: 110px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.25);
  color: #fff;
  resize: vertical;
}
#groups-input:focus { outline: 2px solid var(--note); border-color: transparent; }

#groups-error {
  color: #ff9b8a; font-weight: 700; min-height: 1.2em; font-size: 13px; text-align: center;
  margin-top: 6px;
}

#groups-result { margin-top: 28px; text-align: left; }

.groups-cols { display: flex; gap: 16px; }
.groups-col {
  flex: 1; min-width: 0;
  background: rgba(255,255,255,.05);
  border-radius: 14px;
  padding: 16px 18px;
}
.groups-col-title {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: clamp(14px, 1.8vw, 19px);
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 2px solid rgba(255,255,255,.15);
}
.groups-col-title.t1 { color: var(--team-1); }
.groups-col-title.t2 { color: var(--team-2); }
.groups-col ul {
  list-style: none; margin: 0; padding: 0;
  font-size: clamp(16px, 2.2vw, 22px); line-height: 1.8;
  max-height: 38vh; overflow-y: auto;
}

#groups-result .field-row { margin-top: 24px; }

/* ============================================================================
   SETUP-BILDSCHIRM (Start: JSON laden)
   ============================================================================ */
#setup {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(120% 120% at 50% 0%, var(--stage-2) 0%, var(--stage) 60%);
}
.setup-card {
  width: min(640px, 94vw);
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 20px;
  padding: clamp(26px, 4vw, 44px);
  text-align: center;
}
.setup-card h1 { font-size: clamp(28px, 5vw, 44px); margin: 0 0 6px; letter-spacing: -.02em; }
.setup-card .sub { opacity: .7; margin: 0 0 26px; font-size: clamp(14px, 2vw, 18px); }

/* Drag&Drop-Zone bzw. Klickfläche für die Dateiauswahl */
#dropzone {
  border: 2px dashed rgba(255,255,255,.28);
  border-radius: 16px;
  padding: clamp(26px, 5vw, 44px) 20px;
  transition: border-color .15s ease, background .15s ease;
  cursor: pointer;
}
#dropzone:hover, #dropzone.drag { border-color: var(--note); background: rgba(255,223,107,.07); }
#dropzone .big-text { font-size: clamp(17px, 2.4vw, 22px); font-weight: 700; }
#dropzone .small-text { opacity: .6; margin-top: 6px; font-size: 14px; }

#file-error {
  color: #ff9b8a; font-weight: 700; margin-top: 14px; min-height: 1.2em;
  font-size: 15px;
}

/* Block, der NACH erfolgreichem Laden erscheint (Namen, Timer, Start) */
#setup-loaded { margin-top: 22px; text-align: left; }
#loaded-summary {
  background: rgba(52,179,107,.12);
  border: 1px solid rgba(52,179,107,.4);
  border-radius: 12px; padding: 12px 16px;
  font-weight: 600; margin-bottom: 18px; text-align: center;
}
.field-row { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.field { flex: 1 1 180px; }
.field label {
  display: block; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; opacity: .7; margin-bottom: 6px;
}
.field input {
  width: 100%; padding: 12px 14px; font-size: 16px; font-family: inherit;
  border-radius: 10px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.25); color: #fff;
}
.field input:focus { outline: 2px solid var(--note); border-color: transparent; }

/* Button «letzte Sitzung fortsetzen» (nur wenn gespeicherter Stand da ist) */
#resume-row { margin-bottom: 22px; }
.or-sep { opacity: .4; font-size: 13px; margin: 14px 0; letter-spacing: .1em; }

/* Kleine Navigation zurück zur Startseite / in den Editor */
.setup-nav {
  margin-top: 24px;
  display: flex; justify-content: center; gap: 10px;
  font-size: 13px; opacity: .55;
}
.setup-nav a { color: inherit; text-decoration: none; }
.setup-nav a:hover { opacity: .85; text-decoration: underline; }

/* ============================================================================
   END-BILDSCHIRM (alle Fragen gespielt)
   ============================================================================ */
#endscreen {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,9,13,.92);
  backdrop-filter: blur(4px);
}
.end-card { text-align: center; padding: 40px; }
.end-card h2 { font-size: clamp(30px, 6vw, 60px); margin: 0 0 8px; }
#winner-line { font-size: clamp(20px, 3.5vw, 34px); font-weight: 800; margin: 18px 0 26px; }
.end-scores { display: flex; gap: 24px; justify-content: center; margin-bottom: 30px; flex-wrap: wrap; }
.end-score { padding: 18px 30px; border-radius: 16px; min-width: 160px; }
.end-score.t1 { background: var(--team-1); }
.end-score.t2 { background: var(--team-2); }
.end-score .n { font-size: 16px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .9; }
.end-score .v { font-size: clamp(40px, 7vw, 72px); font-weight: 800; }

/* ============================================================================
   KONFETTI (kleiner, dezenter Effekt bei richtiger Antwort)
   ============================================================================ */
#confetti { position: fixed; inset: 0; z-index: 45; pointer-events: none; overflow: hidden; }
.confetti-piece {
  position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(105vh) rotate(640deg); opacity: 0; }
}
