/* Grundlayout. Farben, Schriften und Formen kommen aus den Theme-Tokens (themes.css). */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--font); font-weight: var(--fw); font-size: var(--fs); color: var(--ink);
  background: var(--bg); background-color: var(--bgc); background-attachment: fixed;
}
a { color: inherit; }
p { margin: 0; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: var(--ink); }
.h { margin: 0; font-family: var(--fontH); font-weight: var(--hw); line-height: 1.05; overflow-wrap: break-word; hyphens: auto; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.small { font-size: .85em; }
.center { text-align: center; }
.panel { background: var(--panel); border: var(--pb); border-radius: var(--pr); box-shadow: var(--ps); }
.btn { -webkit-tap-highlight-color: transparent; display: inline-flex; align-items: center; justify-content: center; gap: 10px; font: inherit; color: var(--ink); background: var(--panel); border: var(--pb); border-radius: var(--pr); box-shadow: var(--ps); padding: 10px 16px; text-decoration: none; cursor: pointer; user-select: none; }
.btn:hover { filter: brightness(1.04); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.pri { background: var(--accent); color: var(--on); }
.btn.sm { padding: 5px 12px; }
.btn.left { justify-content: flex-start; text-align: left; }
.btn.block { display: flex; width: 100%; }
.kbd { display: inline-block; min-width: 30px; padding: 1px 8px; border: var(--pb); border-radius: 6px; text-align: center; background: var(--panel); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; background: var(--accent); color: var(--on); font-size: .85em; white-space: nowrap; }
.badge.alt { background: transparent; border: var(--pb); color: var(--ink); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--good); }
.dot.off { background: var(--bad); }
.rule { height: 0; border-top: 1.5px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 4px 12px; border: var(--pb); border-radius: 999px; background: transparent; color: var(--ink); font: inherit; white-space: nowrap; cursor: pointer; text-decoration: none; }
.chip.on { background: var(--ink); color: var(--bgc); }
.tchip { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px; font: inherit; color: var(--ink); background: var(--panel); border: var(--pb); border-radius: var(--pr); box-shadow: var(--ps); cursor: pointer; text-align: left; }
.tchip.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.sw { display: flex; gap: 3px; align-items: center; width: 100%; height: 26px; padding: 0 6px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); }
.sw i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: inherit; color: var(--muted); padding: 6px 10px; border-bottom: 1.5px solid var(--line); }
.tbl th.num { text-align: right; }
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
.tbl tr.me td { background: var(--accent); color: var(--on); font-weight: 700; }
/* Eigene Zeile: alles in der Kontrastfarbe, auch gedämpfte Texte und Knöpfe (sonst hell auf hell, z. B. Kreidetafel) */
.tbl tr.me td .muted, .tbl tr.me td.muted { color: var(--on); opacity: .85; }
.tbl tr.me .btn { color: var(--on); background: transparent; border-color: var(--on); box-shadow: none; }
.tbl tr.sel td { outline: 2px solid var(--acc2); outline-offset: -2px; }
.tbl tr.click { cursor: pointer; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sw2 { width: 44px; height: 24px; border-radius: 999px; border: var(--pb); background: var(--panel); position: relative; flex: none; cursor: pointer; padding: 0; }
.sw2::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); }
.sw2.on { background: var(--accent); }
.sw2.on::after { left: auto; right: 3px; background: var(--on); }
.inp { display: flex; align-items: center; gap: 8px; width: 100%; border: var(--pb); border-radius: var(--pr); background: var(--panel); padding: 10px 12px; min-height: 46px; }
.inp input, .inp textarea, .inp select { border: 0; background: transparent; outline: none; width: 100%; padding: 0; }
.lab { font-size: .85em; color: var(--muted); margin-bottom: 4px; display: block; }
.row { display: flex; gap: 10px; align-items: flex-start; }
.row.mid { align-items: center; }
.cb { width: 22px; height: 22px; flex: none; accent-color: var(--accent); margin: 2px 0 0; }
.err { color: var(--bad); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.spr { display: block; overflow: visible; flex: none; }

/* Seitenrahmen */
.page { max-width: 1200px; margin: 0 auto; padding: max(22px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 18px; }
.page.narrow { max-width: 460px; }
.topbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar .h { font-size: clamp(28px, 8.5vw, 40px); min-width: 0; }
.scroll-x { overflow-x: auto; }

/* Raum: native 370×320, per --k skaliert, damit Theme-Hintergründe immer passen */
.stage { position: relative; width: 100%; aspect-ratio: 370 / 320; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage > .room { position: absolute; left: 0; top: 0; transform-origin: 0 0; transform: scale(var(--k, 1)); }
.room { position: relative; width: 370px; height: 320px; }
.walls { position: absolute; left: 0; top: 0; }
.cell { position: absolute; width: 25px; height: 25px; }
.cell svg { display: block; overflow: visible; }
.ent { position: absolute; left: 0; top: 0; width: 25px; height: 25px; transition: transform .11s linear; z-index: 2; }
.ent.robot { transition-duration: .3s; }
.ent.owl { transition-duration: .05s; }
.ent svg { display: block; overflow: visible; }
.ent.flip svg { transform: scaleX(-1); }
.ent.mouse { z-index: 3; }
.ent.dying { animation: blink .4s steps(2) 3; }
.ghost { opacity: .35; }
.fx { position: absolute; z-index: 4; pointer-events: none; font-family: var(--fontH); font-size: 13px; padding: 1px 6px; border-radius: 999px; background: var(--ink); color: var(--bgc); white-space: nowrap; animation: rise 1s ease-out forwards; }
@keyframes rise { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-22px); } }
@keyframes blink { 50% { opacity: .2; } }
.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(1.6); opacity: .3; } 100% { transform: scale(1); opacity: 1; } }

/* Effekte aus: keine SVG-Filter (schwache Geräte) */
.fx-off .wash, .fx-off .line, .fx-off .line2, .fx-off .wall { filter: none !important; }
.reduce-motion .ent, .reduce-motion .fx, .reduce-motion .pop { transition: none !important; animation: none !important; }

/* Spielbildschirm (Handy): alles passt immer in den Bildschirm, nichts scrollt.
   Der Raum nimmt den Platz, der zwischen Kopfzeile und Steuerung übrig bleibt (Container-Query auf .stagebox). */
body:has(.game) { overflow: hidden; overscroll-behavior: none; }
.game { --pad: clamp(42px, 7.6dvh, 62px); display: flex; flex-direction: column; gap: 8px; max-width: 520px; margin: 0 auto;
  height: 100dvh; overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
.game > .head { flex: none; }
.game > .head .h { white-space: nowrap; }
.game .main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.game .hud { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; flex: none; }
.game .stagebox { flex: 1 1 auto; min-height: 0; container-type: size; display: flex; align-items: center; justify-content: center; }
.game .stagebox .stage { width: min(100cqw, 100cqh * 1.15625); }
.game .roomline { flex: none; }
.stat { display: flex; flex-direction: column; align-items: center; padding: 3px 0; background: var(--panel); border: var(--pb); border-radius: var(--pr); box-shadow: var(--ps); }
.stat .lbl { font-size: .72em; color: var(--muted); }
.stat .val { font-family: var(--fontH); font-size: 1.35em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat.low .val { color: var(--bad); }
.controls { flex: none; display: flex; justify-content: space-between; align-items: center; padding: 0 8px; gap: 12px; }
.controls.left { flex-direction: row-reverse; }
.dpad { display: grid; grid-template-columns: repeat(3, var(--pad)); grid-template-rows: repeat(3, var(--pad)); gap: 4px; touch-action: none; }
.pad { width: var(--pad); height: var(--pad); border: var(--pb); border-radius: var(--pr); background: var(--panel); box-shadow: var(--ps); display: flex; align-items: center; justify-content: center; padding: 0; touch-action: none; -webkit-tap-highlight-color: transparent; }
.pad.down { background: var(--acc2); }
.bombbtn { width: calc(var(--pad) * 1.65); height: calc(var(--pad) * 1.65); border: var(--pb); border-radius: 50%; background: var(--accent); color: var(--on); font-family: var(--fontH); font-size: calc(var(--pad) * .34); touch-action: none; box-shadow: var(--ps); -webkit-tap-highlight-color: transparent; }
.side { display: none; }
.keys { display: none; }
/* Sehr niedrige Bildschirme: Raumname ausblenden, Platz für den Raum */
@media (max-height: 600px) { .game .roomline { display: none; } }
/* Handy quer: Raum links, Steuerung rechts */
@media (orientation: landscape) and (max-height: 560px) {
  .game { --pad: clamp(38px, 13dvh, 58px); max-width: none; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); column-gap: 14px; }
  .game > .head { grid-column: 1 / -1; }
  .game .main { grid-column: 1; grid-row: 2; }
  .game .controls { grid-column: 2; grid-row: 2; flex-direction: column-reverse; justify-content: center; padding: 0; }
  .game .roomline { display: none; }
}
@media (min-width: 1000px) and (pointer: fine) {
  body:has(.game) { overflow: auto; }
  .game { max-width: 1440px; height: auto; min-height: 100dvh; overflow: visible; display: grid; grid-template-columns: 280px minmax(0, 760px) 300px; grid-template-rows: auto auto; justify-content: center; align-items: start; gap: 24px; padding: 18px 28px; }
  .game .stagebox { container-type: normal; display: block; }
  .game .stagebox .stage { width: 100%; }
  .game .roomline { display: flex; }
  .game > .head { grid-column: 1 / -1; }
  .game .hud { display: none; }
  .game .side { display: flex; flex-direction: column; gap: 14px; }
  .game .controls { display: none; }
  .game .keys { display: flex; grid-column: 1 / -1; gap: 24px; justify-content: center; flex-wrap: wrap; }
  .game .main { grid-column: 2; grid-row: 2; }
}
.toast { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 50; padding: 8px 16px; background: var(--ink); color: var(--bgc); border-radius: 999px; font-family: var(--fontH); font-size: 1.1em; animation: rise2 2.4s ease-out forwards; pointer-events: none; white-space: nowrap; }
@keyframes rise2 { 0% { opacity: 0; transform: translate(-50%, -10px); } 10%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* Dialoge */
.ov { position: fixed; inset: 0; background: rgba(25,18,12,.55); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal { background: var(--bgc); border: var(--pb); border-radius: var(--pr); box-shadow: 0 20px 60px rgba(0,0,0,.35); padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; }
.codeboxes { display: flex; gap: 8px; justify-content: center; }
.codeinput { font-family: var(--fontH) !important; font-size: 34px !important; letter-spacing: .3em; text-align: center; text-transform: uppercase; }
.hero-room { transform: rotate(-2deg); }
.herorow .spr { max-width: 23vw; height: auto; }
.footer { display: flex; flex-wrap: wrap; gap: 8px 22px; justify-content: center; padding: 22px 16px 30px; color: var(--muted); font-size: .9em; }
.footer a { text-decoration: none; }
.legal h2 { font-family: var(--fontH); font-weight: var(--hw); margin: 18px 0 6px; }
.legal p, .legal li { line-height: 1.5; }
.flag { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
@media (max-width: 700px) { .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .hide-m { display: none !important; } }
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; padding: 10px 16px; background: var(--accent); color: var(--on); }
#blazor-error-ui .reload { color: var(--on); margin-left: 10px; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* Admin-Bereich: nüchtern, unabhängig vom Theme */
.adm { --font: system-ui, 'Segoe UI', Roboto, sans-serif; --fontH: system-ui, 'Segoe UI', Roboto, sans-serif; --fw: 400; --hw: 650; --fs: 14px; --ink: #1f2328; --muted: #656d76; --bgc: #f6f8fa; --bg: none; --panel: #fff; --pb: 1px solid #d0d7de; --pr: 8px; --ps: none; --accent: #cf222e; --on: #fff; --acc2: #0969da; --good: #1a7f37; --bad: #cf222e; --line: #d8dee4;
  display: flex; min-height: 100vh; font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--bgc); }
.adm .h { letter-spacing: -.01em; }
.adm .btn { padding: 6px 12px; font-size: 14px; gap: 6px; }
.adm .btn.blue { background: #0969da; color: #fff; border-color: #0969da; }
.adm .btn.green { background: #1a7f37; color: #fff; border-color: #1a7f37; }
.adm .tbl td, .adm .tbl th { padding: 8px 10px; }
.adm .tbl tr.sel td { background: #ddf4ff; }
.adm .inp { min-height: 34px; padding: 5px 10px; }
.adm-nav { width: 232px; flex: none; background: #24292f; color: #e6edf3; display: flex; flex-direction: column; gap: 2px; padding: 16px 10px; }
.adm-nav a { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 6px; color: #c9d1d9; text-decoration: none; }
.adm-nav a.active { background: #3b434b; color: #fff; }
.adm-nav b { font-weight: 600; background: #cf222e; color: #fff; border-radius: 999px; padding: 0 8px; font-size: 12px; line-height: 20px; }
.adm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.adm-head { display: flex; align-items: center; gap: 16px; padding: 16px 24px; border-bottom: 1px solid #d0d7de; background: #fff; flex-wrap: wrap; }
.adm-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 18px; }
.st { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid currentColor; white-space: nowrap; }
.st.r { color: #cf222e; } .st.g { color: #1a7f37; } .st.y { color: #9a6700; } .st.b { color: #0969da; } .st.n { color: #656d76; }
@media (max-width: 800px) { .adm { flex-direction: column; } .adm-nav { width: auto; flex-direction: row; flex-wrap: wrap; } }
/* Tabellen als Karten auf schmalen Handys (z. B. Meine Runs) */
@media (max-width: 560px) {
  .tbl.cards thead { display: none; }
  .tbl.cards, .tbl.cards tbody { display: block; }
  .tbl.cards tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
  .tbl.cards td { padding: 0; border: 0; }
  .tbl.cards td.num { text-align: right; }
}

/* Sammelsachen (Käse, Keks, Knaller) heben sich vom Raster ab: warmer Schein, etwas größer, leichtes Wippen.
   Löcher: dunkler Rand, damit man sie nicht übersieht. --glow kommt aus dem Theme. */
.room { --glow: rgba(255, 196, 60, .7); }
.t3 .room { --glow: rgba(250, 240, 170, .38); }
.t5 .room { --glow: rgba(217, 162, 58, .40); }
.t2 .room, .t4 .room, .t6 .room { --glow: rgba(255, 196, 60, .45); }
.cell.pick::before { content: ''; position: absolute; inset: -4px; border-radius: 50%; background: radial-gradient(circle, var(--glow) 0%, var(--glow) 35%, transparent 70%); pointer-events: none; }
.cell.pick svg { position: relative; transform-origin: 50% 70%; animation: bob 1.6s ease-in-out infinite; animation-delay: calc(var(--i, 0) * -0.19s); filter: drop-shadow(0 1.2px 0 rgba(0, 0, 0, .28)); }
@keyframes bob { 0%, 100% { transform: translateY(0) scale(1.14); } 50% { transform: translateY(-1.6px) scale(1.14); } }
.cell.sp-H svg { transform: scale(1.12); filter: drop-shadow(0 0 1.2px rgba(0, 0, 0, .55)); }
.reduce-motion .cell.pick svg { animation: none; transform: scale(1.14); }
.fx-off .cell.pick svg, .fx-off .cell.sp-H svg { filter: none; }
.t3 .cell.sp-H svg { filter: drop-shadow(0 0 1.6px rgba(255, 255, 255, .75)); }
/* Todespause: kurzer, deutlicher Hinweis über dem Raum */
.deathov { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: rgba(25, 18, 12, .45); color: #fff8ef; text-align: center; animation: deathin .25s ease-out; pointer-events: none; }
.deathov .h { font-size: 54px; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.deathov p:last-child { font-size: 20px; font-weight: 700; }
@keyframes deathin { from { opacity: 0; transform: scale(1.08); } to { opacity: 1; transform: none; } }
/* Admin: Tages-Seed-Ansicht (Hauskarte) */
.dmap { display: grid; grid-template-columns: repeat(var(--ww, 10), minmax(0, 1fr)); gap: 3px; }
.dmap-room { position: relative; padding: 2px; border: 2px solid transparent; border-radius: 4px; background: #eaeef2; cursor: pointer; line-height: 0; }
.dmap-room.start { border-color: #2da44e; }
.dmap-room.end { border-color: #d4a72c; }
.dmap-room.locked { opacity: .55; }
.dmap-room.sel { outline: 3px solid #0969da; outline-offset: 1px; }
.dmap-room .tag { position: absolute; top: 1px; left: 2px; font-size: 10px; line-height: 14px; padding: 0 3px; border-radius: 3px; color: #fff; background: #2da44e; }
.dmap-room.end .tag { background: #d4a72c; }
.dmini { display: block; width: 100%; height: auto; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
