@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/space-grotesk-latin.woff2") format("woff2");
}

:root {
  --bg: #0e0f12;
  --surface: #17191e;
  --surface-2: #1d2026;
  --border: #2a2e36;
  --text: #eceef2;
  --muted: #8b919c;
  --accent: #d6ef5a;
  --accent-ink: #151709;
  --danger: #ff5a5f;
  --radius: 14px;
  --font: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:focus-visible, .input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.screen { flex: 1; display: flex; flex-direction: column; gap: 24px; }
.stack { display: flex; flex-direction: column; gap: 22px; }
.field { display: flex; flex-direction: column; gap: 10px; }
.muted { margin: 0; color: var(--muted); }

.label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Setup */

.brand h1 {
  margin: 28px 0 6px;
  font-size: 46px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.brand h1::after { content: "."; color: var(--accent); }

.input {
  width: 100%;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 18px;
}
.input:focus { outline: none; border-color: var(--accent); }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.info {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  overflow-wrap: anywhere;
  user-select: all;
}

.stepper {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.stepper button { height: 56px; font-size: 24px; }
.stepper button:active { background: var(--surface-2); }
.stepper output {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.picker button {
  aspect-ratio: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.picker button[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.field-head { display: flex; justify-content: space-between; align-items: baseline; }
.label-sub { margin-top: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}
.chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-color: var(--accent);
  color: var(--text);
}
.chip:active { transform: scale(0.97); }

.toggle { display: flex; align-items: center; gap: 12px; }
.toggle input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }

.error { margin: 0; color: var(--danger); font-size: 14px; }

.primary {
  padding: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 700;
}
.ghost {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.primary:active, .ghost:active, .picker button:active { transform: scale(0.98); }

.small { padding: 10px 14px; font-size: 14px; }

/* Kompakte Raum-Zusammenfassung */

.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.summary-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.summary-code { font-size: 28px; font-weight: 700; }
.summary-details { color: var(--muted); font-size: 14px; }

/* Game */

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
}

.round { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.round-main { display: flex; align-items: baseline; gap: 14px; }
.round-facts { display: flex; gap: 20px; margin: 0; }
.round-facts div { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.round-facts dd { margin: 0; font-size: 17px; font-weight: 700; }
.mono { font-family: var(--mono); letter-spacing: 0.08em; }
.round-button {
  padding: 0 4px;
  margin: 0 -4px;
  border-radius: 10px;
  border-bottom: 2px dotted var(--border);
}
.round-button:active { background: var(--surface); }

.dialog {
  width: min(360px, calc(100vw - 40px));
  padding: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog[open] { animation: pop-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }
.dialog form { padding: 22px; }
.dialog-text { font-size: 14px; line-height: 1.4; }
.dialog .input { font-size: 28px; text-align: center; }

.round-number {
  display: inline-block;
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

/* Karte: Vorder- und Rueckseite, dreht sich beim Gedrueckthalten um */

.card {
  flex: 1;
  display: flex;
  min-height: 280px;
  perspective: 1200px;
  cursor: pointer;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
.card-inner {
  position: relative;
  flex: 1;
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.card.is-revealed .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  border-radius: 22px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.card-front {
  background:
    repeating-linear-gradient(135deg, transparent 0 14px, rgba(255, 255, 255, 0.018) 14px 15px),
    var(--surface);
  border: 1px solid var(--border);
}
.card-back {
  transform: rotateY(180deg);
  background: var(--surface-2);
  border: 1px solid var(--accent);
}
.card.is-imposter .card-back { border-color: var(--danger); }
.card.is-imposter .card-word { color: var(--danger); }
.card:focus-visible .card-front { border-color: var(--accent); }

.card-ring {
  width: 56px;
  height: 56px;
  border: 2px solid var(--border);
  border-radius: 50%;
  transition: transform 0.2s, border-color 0.2s;
}
.card:active .card-ring { transform: scale(0.9); border-color: var(--accent); }
.card-hint { color: var(--muted); }

.card-word {
  font-size: clamp(32px, 10vw, 48px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.panel {
  flex: 1;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 22px;
}

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .wide { grid-column: 1 / -1; }
.ghost[data-armed] { border-color: var(--danger); color: var(--danger); }

.footnote { text-align: center; font-family: var(--mono); font-size: 12px; }

/* Einblenden von Screens und Panels */

.screen:not([hidden]) { animation: fade-in 0.25s ease-out; }
.panel:not([hidden]) { animation: pop-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* Fester Aktionsbereich im Setup */

.setup-actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 0 12px;
  margin-top: -8px;
  background: linear-gradient(to bottom, transparent, var(--bg) 20px);
}
.setup-actions .info { margin: 0; }

.link {
  align-self: center;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Eigene Spielernummer */

.topbar-left { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.player-badge { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.player-badge-number {
  color: var(--accent);
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* Dialoge */

.dialog-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.guide {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}
.guide strong { color: var(--text); font-weight: 600; }
.guide li::marker { color: var(--accent); font-weight: 700; }

/* Aufloesung: erst das Wort, kurz danach der Imposter */

.solution-divider { width: 40px; height: 1px; background: var(--border); margin: 6px 0; }
.solution-imposter { color: var(--danger); font-size: 32px; font-weight: 700; line-height: 1.1; }

/* Hilfswort fuer den Imposter: dezent unter dem Wort */
.card-helpword {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}
.card-helpword strong { color: var(--text); font-size: 22px; font-weight: 600; }
.solution:not([hidden]) .reveal-1 { animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.solution:not([hidden]) .reveal-2 { animation: rise 0.45s 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* Imposter: kurzer roter Lichtring beim Aufdecken */

.card.is-revealed.is-imposter .card-back { animation: imposter-pulse 0.9s ease-out; }

@keyframes imposter-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 90, 95, 0); }
  30% { box-shadow: 0 0 0 5px rgba(255, 90, 95, 0.22); }
  100% { box-shadow: 0 0 0 14px rgba(255, 90, 95, 0); }
}

button:disabled { cursor: default; opacity: 0.55; }

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