/* CoupleDraw — Druckregister-Design
   Leitidee: zwei Platten, ein Motiv. Passt es nicht, gibt's ein Geisterbild. */

:root {
  --ink-black: #12111a;
  --ink-black-2: #1b1926;
  --ink-black-3: #262330;
  --paper: #f7f3e8;
  --paper-dim: #cfc9b8;
  --cyan: #00c8d7;
  --magenta: #ff2e88;
  --yellow: #ffd400;
  --line: rgba(247, 243, 232, 0.14);
  --danger: #ff4d4d;

  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Cascadia Mono", "Roboto Mono", "Courier New", monospace;

  --radius: 4px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--ink-black);
  color: var(--paper);
}

body {
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(20px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  max-width: 480px;
  margin: 0 auto;
}

.screen {
  display: none;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}
.screen.active { display: flex; }

/* Typographie */
h1, h2, .eyebrow, .brand-title { font-family: var(--font-display); }

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper-dim);
  margin: 0;
}

.brand { text-align: center; margin-top: 8vh; }
.brand-title {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin: 0;
  line-height: 0.95;
}
.brand-title span { color: var(--cyan); }
.brand-sub {
  color: var(--paper-dim);
  font-size: 14px;
  margin: 10px 0 0;
}

/* Karten & Formulare */
.card-stack { display: flex; flex-direction: column; gap: 14px; margin-top: 8vh; }
.card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.hidden { display: none !important; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-dim);
}
input[type="text"] {
  background: var(--ink-black-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 22px;
  letter-spacing: 0.08em;
  padding: 14px 16px;
  outline: none;
}
input[type="text"]:focus { border-color: var(--cyan); }
#input-room-code { text-align: center; text-transform: uppercase; font-size: 32px; }

/* Buttons */
.btn {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius);
  padding: 16px 20px;
  border: 1px solid transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--paper);
  color: var(--ink-black);
}
.btn-primary:disabled {
  background: var(--ink-black-3);
  color: var(--paper-dim);
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--paper);
  border-color: var(--line);
}
.btn-link {
  background: transparent;
  color: var(--paper-dim);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
  padding: 8px;
}

/* Lobby */
.lobby-head { text-align: center; margin-top: 4vh; }
.room-code {
  font-family: var(--font-mono);
  font-size: 56px;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin: 4px 0;
}
.team-name { color: var(--paper-dim); margin: 0; }

.qr-wrap { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.qr-wrap img {
  background: var(--paper);
  padding: 12px;
  border-radius: var(--radius);
  width: 176px;
  height: 176px;
}
.hint { color: var(--paper-dim); font-size: 13px; max-width: 30ch; margin: 0; }

.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.player-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ink-black-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 14px;
}
.player-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.player-list .status { margin-left: auto; font-size: 11px; color: var(--paper-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.player-list .offline { color: var(--danger); }
.lobby-note { color: var(--paper-dim); font-size: 13px; text-align: center; min-height: 1em; margin: 0; }

/* Runde */
.round-head { text-align: center; }
.round-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--paper-dim);
}
.timer { font-size: 22px; color: var(--paper); font-weight: 700; }
.timer.low { color: var(--magenta); }
.word {
  font-size: 30px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  margin: 6px 0 10px;
}
.timer-bar { height: 3px; background: var(--ink-black-3); border-radius: 2px; overflow: hidden; }
.timer-bar-fill {
  height: 100%;
  width: 100%;
  background: var(--cyan);
  transform-origin: left;
  transition: width 1s linear, background-color 0.4s;
}
.timer-bar-fill.low { background: var(--magenta); }

.canvas-wrap {
  display: flex;
  justify-content: center;
}
#draw-canvas {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 420px;
  background: var(--paper);
  border-radius: var(--radius);
  touch-action: none;
  box-shadow: 0 0 0 1px var(--line);
}
#draw-canvas.locked { opacity: 0.55; }
.draw-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas: "undo clear" "submit submit";
  gap: 10px;
}
#btn-undo { grid-area: undo; }
#btn-clear { grid-area: clear; }
.btn-tool-primary { grid-area: submit; }
.btn-tool {
  background: var(--ink-black-2);
  color: var(--paper);
  border-color: var(--line);
}
.peer-status {
  text-align: center;
  font-size: 13px;
  color: var(--paper-dim);
  min-height: 1em;
  margin: 0;
}

/* Reveal */
.plates-frame {
  position: relative;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.regmark {
  position: absolute;
  width: 16px;
  height: 16px;
  opacity: 0.6;
}
.regmark::before, .regmark::after {
  content: "";
  position: absolute;
  background: var(--paper-dim);
}
.regmark::before { width: 100%; height: 1px; top: 50%; left: 0; }
.regmark::after { width: 1px; height: 100%; left: 50%; top: 0; }
.regmark-tl { top: 6px; left: 6px; }
.regmark-tr { top: 6px; right: 6px; }
.regmark-bl { bottom: 6px; left: 6px; }
.regmark-br { bottom: 6px; right: 6px; }

.plates-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
  overflow-x: auto;
  padding-bottom: 2px;
}
.plate-panel {
  flex: 1 1 0;
  min-width: 84px;
  max-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.plate-panel canvas {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--paper);
  border-radius: 2px;
  display: block;
}
.plate-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--paper-dim);
  margin: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.composite-panel .plate-label { color: var(--paper); font-weight: 700; }
.composite-panel { max-width: 190px; }

.plate-panel.enter-left { transform: translateX(-160%); opacity: 0; }
.plate-panel.enter-right { transform: translateX(160%); opacity: 0; }
.plates-row.enter .plate-panel.enter-left,
.plates-row.enter .plate-panel.enter-right {
  transform: translateX(0);
  opacity: 1;
  transition: transform 0.7s cubic-bezier(0.16, 0.9, 0.2, 1.05), opacity 0.4s ease;
}
.composite-panel {
  opacity: 0;
  transform: scale(0.82);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.plates-row.settled .composite-panel { opacity: 1; transform: scale(1); }

.reveal-score { text-align: center; }
.score-round {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 700;
  color: var(--yellow);
  margin: 0;
}
.score-total {
  font-family: var(--font-mono);
  color: var(--paper-dim);
  margin: 4px 0 0;
}
.reveal-next { text-align: center; color: var(--paper-dim); font-size: 13px; margin: 0; }

.solo-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

/* Final */
.final-head { text-align: center; margin-top: 3vh; }
.final-score {
  font-family: var(--font-mono);
  font-size: 64px;
  font-weight: 800;
  margin: 6px 0;
  color: var(--paper);
}
.final-team { color: var(--paper-dim); margin: 0; }

.round-breakdown {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.round-breakdown li {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--ink-black-2);
  border-radius: var(--radius);
}
.round-breakdown .rb-word { color: var(--paper-dim); }

.leaderboard { margin-top: 8px; }
.leaderboard h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--paper-dim);
  margin: 0 0 10px;
}
.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.leaderboard-list li {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.leaderboard-list .lb-rank { color: var(--paper-dim); width: 2ch; }
.leaderboard-list .lb-team { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-list .lb-score { color: var(--yellow); }

/* Toast */
.toast {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-120px);
  opacity: 0;
  visibility: hidden;
  background: var(--magenta);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  z-index: 100;
  transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s;
  max-width: calc(100% - 40px);
  text-align: center;
}
.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
  .plates-row.enter .plate-panel.enter-left,
  .plates-row.enter .plate-panel.enter-right,
  .composite-panel,
  .timer-bar-fill {
    transition: none !important;
  }
}
