/* ------------------------------------------------------------------
   Two Rooms and a Boom – Rundenmusik
   Mobile first, dunkel, grosse Flaechen fuer hektische Spieleabende.
   ------------------------------------------------------------------ */

:root {
  --bg: #0d1014;
  --bg-soft: #161b22;
  --bg-card: #171d26;
  --line: #262e3a;
  --fg: #eef2f7;
  --fg-dim: #97a3b4;
  --accent: #ff5a3c;
  --accent-soft: #ff8a72;
  --ok: #3ddc84;
  --warn: #ffc93c;
  --bad: #ff5f56;
  --blue: #4aa8ff;
  --radius: 14px;
  --tap: 52px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  min-height: 100svh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 48px;
}

h1, h2, h3 { line-height: 1.15; margin: 0 0 12px; }

h1 {
  font-size: 26px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 800;
}
h1 .boom { color: var(--accent); display: block; }

h2 { font-size: 15px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-dim); font-weight: 700; }

p { margin: 0 0 12px; }
.lead { color: var(--fg-dim); }
.hint { font-size: 14px; color: var(--fg-dim); }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Karten ---------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 14px;
}
.card.tight { padding: 12px 14px; }

/* ---------- Buttons ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0d09;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  min-height: 64px;
}
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: #5c2a28; color: var(--bad); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.btn-small { min-height: 42px; font-size: 15px; padding: 8px 12px; }

/* ---------- Eingaben ---------- */

input[type="text"], select {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--fg);
  font: inherit;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--fg-dim) 50%), linear-gradient(135deg, var(--fg-dim) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 40px; }

.code-input {
  text-align: center;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  padding-left: 0.35em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-dim); margin-bottom: 6px; }

/* ---------- Kopfzeile Raum ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 16, 20, .92);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}
.topbar .title { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--fg-dim); white-space: nowrap; }
/* Auf schmalen Geraeten wuerde der Name die Kopfzeile auf drei Zeilen
   aufblaehen - dort zaehlt nur der Raumcode. */
@media (max-width: 420px) {
  .topbar .title { display: none; }
}
.topbar .room-code { font-size: 24px; font-weight: 800; letter-spacing: .22em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.topbar-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.topbar-row { display: flex; align-items: center; gap: 6px; }
.sync-info { font-size: 11px; color: var(--fg-dim); }

/* Kleine Schaltflaechen oben rechts */
.icon-btn {
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}
.icon-btn:active { transform: scale(.96); }
.icon-btn[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #06131f; }
.icon-btn.danger { border-color: #6b2f2c; background: #2a1514; color: #ffb4ad; }
.icon-btn.tiny { min-height: 24px; padding: 2px 7px; font-size: 12px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  white-space: nowrap;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--fg-dim); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.idle { background: #4b5563; }

/* ---------- Geraeteliste ---------- */

.devices { list-style: none; margin: 0; padding: 0; }
.devices li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.devices li:last-child { border-bottom: 0; }
.devices .name { flex: 1; font-weight: 600; }
.devices .state { font-size: 13px; color: var(--fg-dim); }
.devices .you { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--blue); }
.devices .host-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-soft); }

/* ---------- Rundendauer ---------- */

.durations { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.durations button {
  min-height: 58px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--fg);
  font: inherit;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.durations button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0d09;
}

/* ---------- Rundenansicht ---------- */

/* Die Runde fuellt den Bildschirm: die Uhr ist das Einzige, was zaehlt. */
.round-stage {
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100svh - 190px);
  padding: 4px 0;
}
.round-state {
  font-size: 13px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 2px;
}
.round-timer {
  font-size: clamp(64px, 27vw, 170px);
  font-weight: 800;
  line-height: .95;
  letter-spacing: -0.02em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin: 2px 0 20px;
}
.round-bars { margin-bottom: 4px; }
.round-theme { color: var(--fg-dim); margin-top: 20px; font-size: 15px; }
.round-next { font-size: 14px; color: var(--fg-dim); margin-top: 6px; font-variant-numeric: tabular-nums; }

/* Fortschrittsbalken: kraeftig, mit Marken an der richtigen Stelle */
.progress {
  position: relative;
  height: 26px;
  border-radius: 999px;
  background: #10151d;
  overflow: hidden;
  border: 1px solid #39465a;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .55);
}
.progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff4726, var(--accent-soft));
  box-shadow: 0 0 14px rgba(255, 90, 60, .55);
  transition: width .2s linear;
}
.progress.is-end .progress-fill {
  background: linear-gradient(90deg, #ffc93c, #ff5a3c);
  box-shadow: 0 0 16px rgba(255, 201, 60, .6);
}
.progress .ticks { position: absolute; inset: 0; pointer-events: none; }
.progress .ticks i {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, .5);
}
.progress .ticks i.end { width: 3px; background: rgba(255, 255, 255, .85); }

/* Beschriftung exakt unter der jeweiligen Marke */
.scale {
  position: relative;
  height: 18px;
  margin-top: 7px;
  font-size: 12px;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}
.scale span { position: absolute; top: 0; white-space: nowrap; }
.scale span.mid { transform: translateX(-50%); }
.scale span.last { color: var(--warn); }

/* Grossflaechige Zustaende */
.banner {
  border-radius: var(--radius);
  padding: 26px 16px;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.banner.switch { background: #4a1b12; color: #ffd9cf; animation: pulse 1s ease-in-out infinite; }
.banner.done { background: #13291d; color: #b7f5cf; }
.banner.pre { background: #16233a; color: #cfe4ff; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) {
  .banner.switch { animation: none; }
  .progress > span { transition: none; }
}

.countdown {
  font-size: clamp(56px, 22vw, 96px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ---------- Schwebendes Player-Fenster ---------- */

.player-dock {
  position: fixed;
  top: calc(84px + env(safe-area-inset-top));
  right: 10px;
  width: 186px;
  z-index: 40;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .55);
}
.dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--fg-dim);
  padding: 0 2px 5px;
}
.dock-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.dock-slots .slot {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}
.dock-slots .slot iframe { width: 100%; height: 100%; border: 0; display: block; }
.dock-slots .slot .tag {
  position: absolute;
  left: 5px;
  top: 4px;
  font-size: 9px;
  letter-spacing: .1em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, .65);
  padding: 1px 5px;
  border-radius: 5px;
  color: var(--fg-dim);
  pointer-events: none;
}

/*
  Verborgen heisst: auf 2 Pixel geschrumpft und durchsichtig, aber weiterhin
  im Layout. display:none oder visibility:hidden wuerde die Wiedergabe auf
  iOS abwuergen.
*/
.player-dock.is-hidden {
  top: auto;
  bottom: 0;
  right: 0;
  width: 2px;
  height: 2px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}
.player-dock.is-hidden .dock-head { display: none; }

/* ---------- Meldungen ---------- */

.notice {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}
.notice.error { border-color: #5c2a28; background: #2a1514; color: #ffc9c4; }
.notice.warn { border-color: #5c4c1f; background: #2a2413; color: #ffe9b0; }
.notice.info { border-color: #1f3d5c; background: #131f2a; color: #cfe4ff; }

.hidden { display: none !important; }

.footer-note { text-align: center; font-size: 12px; color: #5c6875; margin-top: 22px; }

.list-plain { list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--fg-dim); }
.list-plain li { padding: 3px 0; }

.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--fg-dim); padding: 3px 0; }
.kv b { color: var(--fg); font-weight: 600; }
