:root {
  color-scheme: light dark;
  --bg: #081a2b;
  --panel: #102a43;
  --panel-2: #173e5f;
  --text: #fffaf0;
  --muted: #bfd5e5;
  --accent: #ffd23f;
  --accent-text: #1d2630;
  --danger: #ff6b6b;
  --success: #62d394;
  font-family: Inter, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  /* dvh statt vh: sonst springt das Layout, wenn die Adressleiste am Handy
     ein- und ausfährt. */
  min-height: 100dvh;
  /* Der Schimmer oben nimmt die Akzentfarbe der Version auf – so sieht jede
     Fassung anders aus, statt immer im selben Gold zu leuchten. */
  background:
    radial-gradient(circle at top, color-mix(in srgb, var(--accent) 22%, transparent), transparent 35rem),
    linear-gradient(160deg, color-mix(in srgb, var(--bg) 70%, #000), var(--bg));
  color: var(--text);
}

main {
  width: min(680px, calc(100% - 32px));
  margin: 0 auto;
  /* Unten Luft, damit der schwebende Regeln-Knopf nichts überdeckt. */
  padding: 32px 0 112px;
}

/* Sichtbarer Fokus – ohne den weiß man bei Tastaturbedienung nicht, wo man ist. */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Wer Bewegung reduziert haben will, bekommt keine Wackel- und Flugeffekte. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.panel {
  /* Über --panel, damit die Version (Malle/Mittelalter) auch die Kästen färbt. */
  background: var(--panel);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  padding: 24px;
  margin: 16px 0;
}

h1, h2 {
  margin-top: 0;
}

p {
  line-height: 1.55;
}

.muted {
  color: var(--muted);
}

.status {
  min-height: 1.5em;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.status.success {
  color: var(--success);
}

button,
a.button,
select,
input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 14px 16px;
  font: inherit;
}

select,
input {
  background: var(--panel-2);
  color: var(--text);
  margin: 8px 0 16px;
}

button,
a.button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  text-align: center;
  font-weight: 700;
  cursor: pointer;
  margin: 6px 0;
}

button.secondary {
  background: var(--panel-2);
  color: var(--text);
}

button.danger {
  background: var(--danger);
  color: #1b1212;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.big-ready {
  text-align: center;
  padding: 36px 16px;
}

.big-ready .emoji {
  font-size: 64px;
}

.pin {
  font-size: 44px;
  letter-spacing: 0.2em;
  font-weight: 800;
  text-align: center;
}

.reveal {
  text-align: center;
}

.reveal .year {
  font-size: 72px;
  font-weight: 900;
  color: var(--accent);
  margin: 8px 0;
}

/* Hilfsklasse, die gewinnen MUSS. Ohne !important schlägt jede spätere Regel
   mit gleicher Spezifität sie (z. B. `.nudge-banner { display: flex }`) – dann
   bleibt ein „verstecktes" Overlay stehen und schluckt alle Taps. */
.hidden {
  display: none !important;
}

ul.rules,
ol.rules {
  margin: 0;
  padding-left: 1.3em;
}

ul.rules li,
ol.rules li {
  line-height: 1.55;
  margin: 8px 0;
}

.shot-rule {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid var(--accent);
  font-weight: 700;
}

.shot-rule .shot-emoji {
  font-size: 32px;
  line-height: 1;
}

.shot-rule small {
  display: block;
  font-weight: 400;
  color: var(--muted);
}

.fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  width: auto;
  margin: 0;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.fab:hover {
  filter: brightness(1.05);
}

.rules-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
  padding: 12px 0;
  background: linear-gradient(160deg, color-mix(in srgb, var(--bg) 70%, #000), var(--bg));
}

.rules-nav a {
  width: auto;
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.18);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.rules-nav a:hover {
  background: var(--accent);
  color: var(--accent-text);
}

.panel[id] {
  scroll-margin-top: 64px;
}

.explainer {
  margin-top: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: var(--panel-2);
  padding: 4px 16px;
}

.explainer summary {
  cursor: pointer;
  font-weight: 700;
  padding: 12px 0;
  list-style: none;
}

.explainer summary::before {
  content: "▸ ";
  color: var(--accent);
}

.explainer[open] summary::before {
  content: "▾ ";
}

.explainer summary::-webkit-details-marker {
  display: none;
}

.explainer .rules {
  padding-bottom: 12px;
}

.player-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 12px;
  margin: 6px 0;
  background: var(--panel-2);
}

.player-row.active {
  border: 1px solid var(--accent);
}

.player-row .count {
  font-weight: 800;
  color: var(--accent);
}

.turn-line {
  font-weight: 700;
  text-align: center;
}

/* Umbrechen statt seitlich scrollen: bei zehn Karten will man alles auf einen
   Blick sehen, nicht wischen. Gelesen wird wie Text – zeilenweise von links. */
.timeline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 4px;
  margin: 12px 0;
}

.timeline > * {
  flex: 0 0 auto;
}

.timeline-wrap {
  position: relative;
}

/* Fester Platz für die Aktionsknöpfe: die Reihenfolge bleibt gleich, egal was
   gerade sichtbar ist – sonst wandert der Knopf unter dem Finger weg. */
.action-area {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 12px 0;
}

/* Schritte in der Lobby – Erledigtes darf zusammenklappen. */
.step {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 4px 16px;
  margin: 12px 0;
  background: var(--panel-2);
}

.step > summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 12px 0;
  list-style: none;
}

.step > summary::-webkit-details-marker {
  display: none;
}

.step > summary::before {
  content: "▸ ";
  color: var(--accent);
}

.step[open] > summary::before {
  content: "▾ ";
}

.step .step-state {
  float: right;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.9rem;
}

.step .step-state.done {
  color: var(--success);
}

/* Zeitleisten der anderen Tische – klein, nur zum Mitschauen. */
.mini-timelines .mini-row {
  margin: 10px 0;
}

.mini-timelines .mini-head {
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.mini-timelines .mini-years {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.mini-timelines .mini-year {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 0.85rem;
  font-weight: 700;
}

.mini-timelines .mini-row.is-turn .mini-head {
  color: var(--accent);
}

.conn-lost {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 150;
  padding: 10px 14px;
  text-align: center;
  font-weight: 700;
  background: var(--danger);
  color: #1b1212;
}

.timeline .year-chip {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-2);
  font-weight: 800;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.timeline .slot {
  width: auto;
  margin: 0;
  padding: 8px 9px;
  border-radius: 10px;
  border: 1px dashed var(--accent);
  background: transparent;
  color: var(--accent);
  font-weight: 800;
  font-size: 0.95rem;
  /* Tippfläche bleibt fingerfreundlich, auch wenn der Rahmen klein ist. */
  min-width: 34px;
}

.timeline .slot:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-text);
}

/* Nur zum Zuschauen: die Lücken zwischen den Jahren brauchen keine Tippfläche.
   Schmal gehalten passt die ganze Zeitleiste in deutlich weniger Zeilen. */
.timeline .slot:disabled {
  min-width: 0;
  padding: 8px 3px;
  border-color: transparent;
  opacity: 0.45;
}

/* Passiv = ein anderer Tisch ist dran. Die Seite geht sichtbar in den
   Hintergrund, damit man ohne Lesen erkennt, ob man handeln muss. */
body.passive {
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.05), transparent 35rem),
    linear-gradient(160deg, #0c0e10, #17191c);
}

body.passive main {
  filter: grayscale(0.85);
}

/* Farbig bleibt, was auch im passiven Zustand zählt: der Zug-Hinweis (er sagt,
   worauf man wartet) und vor allem der Konter – anzweifeln darf man ja GERADE
   dann, wenn ein anderer Tisch dran ist. Grau hieße hier „geht nicht". */
body.passive .turn-line,
body.passive .shot-rule,
body.passive #challengeBox,
body.passive #challengeSlotBox {
  filter: grayscale(0);
}

/* Und er soll auch auffallen, nicht nur farbig sein. */
body.passive #challengeBtn {
  animation: challenge-pulse 2.4s ease-in-out infinite;
}

@keyframes challenge-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.03); }
}

.turn-line.mine {
  color: var(--accent-text);
  background: var(--accent);
  border-radius: 12px;
  padding: 10px 14px;
}

.turn-line.waiting {
  opacity: 0.85;
}

/* Große Wartemeldung – soll man quer durchs Zimmer sehen. */
.nudge-banner {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: rgba(7, 19, 31, 0.94);
  color: var(--text);
  font-size: clamp(1.6rem, 7vw, 3rem);
  font-weight: 900;
  line-height: 1.25;
  animation: nudge-pop 0.25s ease-out;
}

.nudge-banner .nudge-emoji {
  font-size: clamp(3rem, 14vw, 6rem);
  animation: nudge-shake 0.6s ease-in-out 3;
}

.nudge-banner .nudge-from {
  font-size: 1rem;
  font-weight: 400;
  color: var(--muted);
}

@keyframes nudge-pop {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes nudge-shake {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-12deg); }
  75%      { transform: rotate(12deg); }
}

.timeline .slot.challenged {
  background: var(--danger);
  color: #1b1212;
  border-style: solid;
}

.timeline .slot.chosen {
  background: var(--accent);
  color: var(--accent-text);
  outline: 2px solid var(--text);
}

.confirm-bar {
  margin: 12px 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid var(--accent);
  text-align: center;
}

.confirm-bar p {
  margin: 4px 0 10px;
  font-weight: 700;
}

.confirm-bar .confirm-hint {
  font-weight: 400;
  font-size: 0.9rem;
}

/* Reveal-Animationen im Digital-Modus */
@keyframes blink-green {
  0%, 100% { background: var(--success); color: var(--accent-text); }
  50%      { background: transparent; color: var(--text); }
}

@keyframes flash-red {
  0%, 100% { background: var(--danger); color: #1b1212; }
  50%      { background: transparent; color: var(--text); }
}

.timeline .slot.correct-blink {
  border-style: solid;
  animation: blink-green 0.4s ease-in-out 3;
}

.timeline .slot.wrong-flash {
  border-style: solid;
  animation: flash-red 0.3s ease-in-out 2;
}

.ghost-wrong {
  position: fixed;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 1.1rem;
  background: var(--danger);
  color: #1b1212;
  pointer-events: none;
  transition: left 0.9s ease, top 0.9s ease, opacity 0.4s ease 0.9s;
}

.chip-remove {
  width: auto;
  margin: 0 0 0 10px;
  padding: 2px 10px;
}

#nameList li {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@media (max-width: 520px) {
  .actions {
    grid-template-columns: 1fr;
  }
}

/* Jubel bei einer richtigen Karte – siehe celebrate.js. Liegt über allem,
   fängt aber keine Klicks ab und beeinflusst kein Layout. */
.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  font-size: 30px;
  line-height: 1;
  will-change: transform, opacity;
  animation: confetti-fly 1.6s cubic-bezier(0.15, 0.6, 0.35, 1) forwards;
}

@keyframes confetti-fly {
  0% {
    transform: translate(-50%, -50%) scale(0.4) rotate(0deg);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1) rotate(var(--spin));
    opacity: 0;
  }
}

/* Zeigt auf einen Blick, welche Version läuft und wie hier gerufen wird. */
.theme-strip {
  display: inline-block;
  margin: 0 0 16px;
  padding: 8px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

.theme-strip:empty {
  display: none;
}
