/* Schriften liegen bei der App (kein Abruf bei Google Fonts) */
@font-face {
  font-family: 'Patrick Hand';
  font-weight: 400;
  font-display: swap;
  src: url(fonts/patrick-hand-latin-400-normal.woff2) format('woff2');
}
@font-face {
  font-family: 'Rubik Wet Paint';
  font-weight: 400;
  font-display: swap;
  src: url(fonts/rubik-wet-paint-latin-400-normal.woff2) format('woff2');
}

/* Layout: Vollbild-Spiel; Startseite wie die Bleistiftskizze, Knöpfe unten links, Kreatur unten rechts */
:root {
  --ink: #0d0d0f;       /* Graphit, fast schwarz */
  --graphite: #2a2a2e;  /* Schraffur */
  --lead: #66666c;      /* heller Bleistift */
  --paper: #dddcd4;     /* Papier */
  --paper-dim: #a6a59d;
  --blood: #8e1414;
  --font-display: 'Rubik Wet Paint', 'Patrick Hand', 'Comic Sans MS', cursive;
  --font-hand: 'Patrick Hand', 'Comic Sans MS', 'Segoe Print', cursive;
  color-scheme: dark;
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-hand);
  font-size: 18px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

[hidden] { display: none !important; }

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#touch {
  position: fixed;
  inset: 0;
  z-index: 2;
  touch-action: none;
}

#vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(90, 0, 0, 0.55) 72%, rgba(20, 0, 0, 0.95) 100%);
  transition: opacity 0.2s linear;
}

/* ---- Joystick ---- */
#stick {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 3;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px dashed rgba(221, 220, 212, 0.45);
  background: rgba(221, 220, 212, 0.06);
  pointer-events: none;
}
#knob {
  position: absolute;
  left: 38px;
  top: 38px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(221, 220, 212, 0.55);
  border: 2px solid var(--ink);
}

/* ---- Startseite ---- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 5;
}

#forest {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.title {
  position: absolute;
  margin: 0;
  top: calc(env(safe-area-inset-top, 0px) + 6vh);
  left: max(28px, calc(env(safe-area-inset-left, 0px) + 20px));
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.6rem, 11vmin, 5.5rem);
  line-height: 1;
  color: var(--paper);
  transform: rotate(-2.5deg);
  text-shadow: 3px 3px 0 var(--ink);
  letter-spacing: 0.02em;
}

.menu {
  position: absolute;
  left: max(28px, calc(env(safe-area-inset-left, 0px) + 20px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12vh);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.btn {
  font-family: var(--font-hand);
  font-size: clamp(1.5rem, 5.2vmin, 2rem);
  line-height: 1.1;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 4px 9px 5px 8px / 8px 4px 9px 5px;
  padding: 0.25em 0.9em 0.3em;
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
  transform: rotate(-1.5deg);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn + .btn { transform: rotate(1deg); }
.btn:active {
  transform: translate(3px, 3px) rotate(-1deg);
  box-shadow: 1px 1px 0 var(--ink);
}
.btn:focus-visible {
  outline: 3px dashed var(--paper);
  outline-offset: 5px;
}
.btn.ghost {
  background: transparent;
  color: var(--paper);
  border-color: var(--paper-dim);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
}

#peek {
  position: absolute;
  right: env(safe-area-inset-right, 0px);
  bottom: 0;
  width: clamp(150px, 44vmin, 320px);
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 0 22px rgba(0, 0, 0, 0.9));
}
#pk-creature {
  transition: transform 1.6s cubic-bezier(0.3, 0, 0.2, 1);
}
#pk-creature.hide {
  transform: translateX(130px);
  transition: transform 0.28s ease-in;
}
#pk-head {
  transform-box: view-box;
  transform-origin: 120px 240px;
  transition: transform 0.12s steps(2);
}
#pk-head.twitch { transform: rotate(13deg); }
#pk-head.twitch-l { transform: rotate(-9deg) translateX(-3px); }
#pk-hand { transition: opacity 0.4s ease; }
#pk-hand.hide { opacity: 0; transition: opacity 0.15s ease; }
#peek .eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 6.5s infinite;
}
#peek .eye + .eye { animation-delay: 0.05s; }

@keyframes blink {
  0%, 93%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.08); }
}

/* ---- Panels (Zeiten, Pause, Ende) ---- */
.panel-screen, .overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-block: calc(env(safe-area-inset-top, 0px) + 16px) calc(env(safe-area-inset-bottom, 0px) + 16px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  box-sizing: border-box;
}
.panel-screen {
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.35) 0 3px, transparent 3px 11px),
    var(--graphite);
}
.overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  background: rgba(5, 5, 6, 0.72);
  pointer-events: auto;
}

.panel {
  width: min(440px, 100%);
  max-height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 6px 12px 8px 10px / 10px 6px 12px 8px;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.75);
  padding: 22px 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  transform: rotate(-0.6deg);
  touch-action: pan-y;
}
.panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2rem, 8vmin, 2.8rem);
  line-height: 1;
}
.panel .sub { margin: 0; color: #3c3c40; }
.panel .btn { box-shadow: 4px 4px 0 var(--ink); }
.panel .btn.ghost { color: var(--ink); border-color: var(--ink); box-shadow: none; }
.row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }

.eaten { color: var(--blood); }
.big-time {
  margin: 0;
  font-size: clamp(2.8rem, 13vmin, 4rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.note { margin: 0; min-height: 1.2em; }
.note.record { color: var(--blood); font-weight: 700; }

#score-list {
  list-style: none;
  margin: 4px 0 6px;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#score-list li {
  display: grid;
  grid-template-columns: 2.2em 1fr auto;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1.5px dashed rgba(13, 13, 15, 0.3);
  font-variant-numeric: tabular-nums;
}
#score-list li:first-child .time { color: var(--blood); }
#score-list .rank { color: #55555a; }
#score-list .time { font-size: 1.35rem; }
#score-list .date { color: #55555a; font-size: 0.95rem; }
#score-list li.empty { display: block; border: 0; color: #3c3c40; }

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
}
.hud-info { display: flex; flex-direction: column; gap: 6px; }
.hud-time { display: flex; flex-direction: column; text-shadow: 2px 2px 0 var(--ink); }
#timer { font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; }
#level { font-size: 1rem; color: var(--paper-dim); letter-spacing: 0.04em; }
#btn-pause {
  pointer-events: auto;
  position: relative;
  z-index: 6;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--paper-dim);
  background: rgba(13, 13, 15, 0.55);
  color: var(--paper);
  display: grid;
  place-items: center;
  cursor: pointer;
}
#btn-pause svg { width: 22px; height: 22px; fill: currentColor; }
#btn-pause:focus-visible, #btn-sprint:focus-visible, .item-btn:focus-visible, #minimap:focus-visible {
  outline: 3px dashed var(--paper);
  outline-offset: 3px;
}

#effects { display: flex; flex-direction: column; gap: 4px; }
.effect {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  padding: 2px 10px 2px 6px;
  border-radius: 999px;
  background: rgba(13, 13, 15, 0.7);
  border: 2px solid currentColor;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.effect svg { width: 20px; height: 20px; }

/* Karte oben rechts */
#minimap {
  pointer-events: auto;
  position: absolute;
  z-index: 6;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: max(16px, env(safe-area-inset-right, 0px));
  width: clamp(112px, 30vmin, 150px);
  height: clamp(112px, 30vmin, 150px);
  border-radius: 50%;
  border: 3px solid var(--paper-dim);
  box-shadow: 0 0 0 2px var(--ink), 0 4px 18px rgba(0, 0, 0, 0.7);
  background: var(--ink);
  opacity: 0.92;
  cursor: pointer;
  transition: width 0.2s ease, height 0.2s ease;
}
#minimap.big {
  top: 50%;
  right: 50%;
  transform: translate(50%, -50%);
  width: min(78vmin, 340px);
  height: min(78vmin, 340px);
  opacity: 0.96;
  z-index: 7;
}

/* Sprint-Knopf und Items unten rechts, für den rechten Daumen */
#btn-sprint {
  pointer-events: auto;
  position: absolute;
  z-index: 6;
  right: max(20px, calc(env(safe-area-inset-right, 0px) + 12px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 0;
  background: rgba(13, 13, 15, 0.6);
  color: var(--paper);
  font-family: var(--font-hand);
  font-size: 1.15rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#btn-sprint span { position: relative; }
#btn-sprint .ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
#btn-sprint .ring circle { fill: none; stroke-width: 7; }
#btn-sprint .ring-bg { stroke: rgba(221, 220, 212, 0.18); }
#btn-sprint .ring-fg {
  stroke: var(--paper);
  stroke-linecap: round;
  stroke-dasharray: 282.7;
  stroke-dashoffset: 0;
}
#btn-sprint.held { background: rgba(221, 220, 212, 0.25); transform: scale(0.95); }
#btn-sprint.tired .ring-fg { stroke: #c0392b; }
#btn-sprint.tired span { color: #e8a39a; }
#btn-sprint.boost .ring-fg { stroke: #ffd84a; }

#item-bar {
  position: absolute;
  z-index: 6;
  right: max(28px, calc(env(safe-area-inset-right, 0px) + 20px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 128px);
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
}
.item-btn {
  pointer-events: auto;
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 14px;
  border: 3px solid currentColor;
  background: rgba(13, 13, 15, 0.72);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 0 16px currentColor;
  animation: item-in 0.35s ease;
}
.item-btn svg { width: 34px; height: 34px; }
.item-btn .count {
  position: absolute;
  right: -8px;
  top: -8px;
  min-width: 24px;
  height: 24px;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-hand);
  font-size: 1rem;
  line-height: 24px;
  text-align: center;
  border: 2px solid var(--ink);
}
.item-btn:active { transform: scale(0.92); }
@keyframes item-in {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#frost {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(143, 214, 255, 0.25) 75%, rgba(200, 236, 255, 0.6) 100%);
}
#frost.on { opacity: 1; }

#banner {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translate(-50%, 0) rotate(-1.5deg);
  max-width: calc(100% - 32px);
  text-align: center;
  font-size: clamp(1.3rem, 5vmin, 2rem);
  color: var(--paper);
  text-shadow: 2px 2px 0 var(--ink), 0 0 18px rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
}
#banner.show { animation: banner 2.8s ease forwards; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, 10px) rotate(-1.5deg); }
  12%, 80% { opacity: 1; transform: translate(-50%, 0) rotate(-1.5deg); }
  100% { opacity: 0; transform: translate(-50%, -6px) rotate(-1.5deg); }
}

#hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 5vh);
  display: flex;
  justify-content: center;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(130px, calc(env(safe-area-inset-right, 0px) + 120px));
  transition: opacity 0.8s ease;
}
#hint.fade { opacity: 0; }
.hint-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 22px;
  max-width: 520px;
  background: rgba(13, 13, 15, 0.72);
  border: 2px dashed var(--paper-dim);
  border-radius: 10px;
  padding: 10px 16px;
  color: var(--paper);
}
.hint-side { display: flex; align-items: center; gap: 10px; }
.hint-card svg { width: 54px; height: 54px; flex: none; }
.hint-card p { margin: 0; line-height: 1.2; }
.hint-dot { animation: drag 2.2s ease-in-out infinite; }
.hint-swipe { animation: swipe 1.8s ease-in-out infinite; }
@keyframes drag {
  0%, 100% { transform: translate(0, 0); }
  35% { transform: translate(0, -26px); }
  65% { transform: translate(24px, -10px); }
}
@keyframes swipe {
  0%, 100% { transform: translateX(-28px); }
  50% { transform: translateX(28px); }
}

@media (prefers-reduced-motion: reduce) {
  #peek .eye, .hint-dot, .hint-swipe { animation: none; }
  #pk-creature, #pk-head { transition: none; }
  #banner.show { animation-duration: 0.01s; opacity: 1; }
}

/* ---- Mehr Horror auf der Startseite ---- */
.title {
  color: #a3110f;
  text-shadow: 3px 3px 0 var(--ink), 0 0 24px rgba(160, 10, 10, 0.45);
  animation: glitch 7s infinite steps(1);
}
@keyframes glitch {
  0%, 91%, 100% { transform: rotate(-2.5deg); filter: none; }
  92% { transform: rotate(-2.5deg) translate(4px, -2px) skewX(8deg); filter: blur(0.6px); }
  93% { transform: rotate(-2.5deg) translate(-5px, 1px); }
  94% { transform: rotate(-2.5deg) translate(2px, 0) skewX(-6deg); }
}
#flicker {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
#lurkers { position: absolute; inset: 0; pointer-events: none; }
.lurker {
  position: absolute;
  display: flex;
  gap: 9px;
  opacity: 0;
  transition: opacity 1.4s ease;
}
.lurker.on { opacity: 1; }
.lurker i {
  display: block;
  width: 9px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, #ff3b2a 0 35%, rgba(255, 40, 20, 0.35) 60%, transparent 70%);
  box-shadow: 0 0 10px 3px rgba(255, 30, 10, 0.35);
  animation: blink 4.5s infinite;
}
.fog {
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: -5%;
  height: 45%;
  pointer-events: none;
  background:
    radial-gradient(ellipse 40% 50% at 20% 80%, rgba(170, 170, 165, 0.16), transparent 70%),
    radial-gradient(ellipse 35% 45% at 60% 90%, rgba(170, 170, 165, 0.12), transparent 70%),
    radial-gradient(ellipse 30% 40% at 85% 75%, rgba(170, 170, 165, 0.1), transparent 70%);
  animation: drift 26s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translateX(-6%); }
  to { transform: translateX(6%); }
}
#pk-mouth {
  transform-box: view-box;
  transform-origin: 120px 186px;
  transition: transform 0.6s cubic-bezier(0.5, 0, 0.2, 1.4);
}
#pk-mouth.open { transform: scaleY(1.9) scaleX(1.08); }

/* ---- Mehrspieler ---- */
.lobby-panel { width: min(580px, 100%); }
.divider {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #55555a;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  border-top: 1.5px dashed rgba(13, 13, 15, 0.35);
}
#code-input {
  width: 8.5ch;
  font-family: var(--font-hand);
  font-size: 1.8rem;
  letter-spacing: 0.25em;
  padding: 0.1em 0.3em;
  border: 3px solid var(--ink);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  -webkit-user-select: text;
  user-select: text;
}
#code-input:focus-visible { outline: 3px dashed var(--ink); outline-offset: 3px; }
.note.error { color: var(--blood); font-weight: 700; }
.invite-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin-top: 6px;
}
#qr, .qr {
  flex: none;
  width: 168px;
  height: 168px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 6px;
  padding: 6px;
  box-sizing: border-box;
}
#qr svg, #qr img, .qr svg { width: 100%; height: 100%; display: block; }
.invite-actions { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.btn.wa { background: #2f9e57; color: #fff; text-decoration: none; text-align: center; }
.small { font-size: 0.95rem; }
.code { letter-spacing: 0.15em; font-variant-numeric: tabular-nums; }
.btn.big { font-size: clamp(1.6rem, 6vmin, 2.2rem); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ready { background: #2f9e57; color: #fff; }
#team-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
#team-list li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1.5px dashed rgba(13, 13, 15, 0.3); padding: 3px 0; }

#countdown {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(5, 5, 6, 0.85);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: clamp(5rem, 30vmin, 12rem);
}

/* ---- Tot stellen ---- */
#btn-dead {
  pointer-events: auto;
  position: absolute;
  z-index: 6;
  right: max(128px, calc(env(safe-area-inset-right, 0px) + 120px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 0;
  background: rgba(13, 13, 15, 0.6);
  color: var(--paper);
  font-family: var(--font-hand);
  font-size: 0.98rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: none;
}
#btn-dead span { position: relative; text-align: center; }
#btn-dead .ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
#btn-dead .ring circle { fill: none; stroke-width: 7; }
#btn-dead .ring-bg { stroke: rgba(221, 220, 212, 0.18); }
#btn-dead .ring-fg { stroke: #b9a6e8; stroke-linecap: round; stroke-dasharray: 282.7; stroke-dashoffset: 0; }
#btn-dead.cooling { color: var(--paper-dim); }
#btn-dead.cooling .ring-fg { stroke: var(--paper-dim); }
#btn-dead.active { background: rgba(185, 166, 232, 0.3); }
#btn-dead:focus-visible { outline: 3px dashed var(--paper); outline-offset: 3px; }
#hint { padding-right: max(220px, calc(env(safe-area-inset-right, 0px) + 210px)); }

#deadfx {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.2) 20%, rgba(0, 0, 0, 0.92) 85%);
  -webkit-backdrop-filter: blur(3px) grayscale(0.7);
  backdrop-filter: blur(3px) grayscale(0.7);
}
#deadfx.on { opacity: 1; }
#flicker, .lurker i { will-change: opacity; }
@media (prefers-reduced-motion: reduce) {
  .title, .fog, .lurker i { animation: none; }
  #pk-mouth { transition: none; }
}

/* Querformat mit wenig Höhe: Fenster kompakter, Warteraum zweispaltig */
@media (max-height: 520px) {
  .panel { padding: 14px 20px 16px; gap: 6px; }
  .panel h2 { font-size: 1.9rem; }
  .panel .btn { font-size: 1.3rem; }
  #mp .panel { width: min(640px, 100%); display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; align-items: start; }
  #mp .panel > h2, #mp .panel > p.sub { grid-column: 1 / -1; }
  #mp .panel > *, .lobby-panel > * { justify-self: start; }
  #mp .divider { display: none; }
  #mp #btn-invite { grid-column: 1; grid-row: 3 / span 2; align-self: center; }
  #mp label { grid-row: 3; }
  #mp .row { grid-row: 4; }
  #mp label, #mp .row, #mp #mp-error { grid-column: 2; }
  #mp #btn-mp-back { grid-column: 1; }
  .lobby-panel { width: min(720px, 100%); display: grid; grid-template-columns: auto 1fr; column-gap: 20px; align-items: start; }
  .lobby-panel > h2, .lobby-panel > #lobby-status { grid-column: 2; }
  .lobby-panel > #invite { grid-column: 1; grid-row: 1 / span 5; }
  .lobby-panel > #invite > .sub { display: none; }
  .lobby-panel > .row, .lobby-panel > #team-list, .lobby-panel > #btn-lobby-leave { grid-column: 2; }
  .lobby-panel > #invite[hidden] + .row { grid-column: 1 / -1; }
  #qr { width: 132px; height: 132px; }
  .invite-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .invite-actions .btn { font-size: 1.1rem; }
}

/* Kratzer und Blut auf dem Bildschirm */
#fxcanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}
/* Schalter für Blut auf der Startseite */
.toggle {
  position: absolute;
  z-index: 4;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: max(16px, env(safe-area-inset-right, 0px));
  font-family: var(--font-hand);
  font-size: 1.05rem;
  color: var(--paper);
  background: rgba(13, 13, 15, 0.6);
  border: 2px solid var(--paper-dim);
  border-radius: 999px;
  padding: 4px 14px;
  cursor: pointer;
}
.toggle[aria-pressed="true"] { border-color: #a3110f; color: #f0b0a8; }
.toggle:focus-visible { outline: 3px dashed var(--paper); outline-offset: 3px; }
/* Während der Todesszene nur das Bild zeigen */
#hud.cinematic > :not(#banner) { visibility: hidden; }

/* Flackern verdunkelt nur den Hintergrund; Titel, Knöpfe und rote Augen bleiben darüber */
#flicker { z-index: 2; }
#lurkers { z-index: 3; }
.title, .menu, .toggle { z-index: 4; }
.menu .btn { box-shadow: 4px 4px 0 var(--ink), 0 0 18px rgba(221, 220, 212, 0.18); }

/* ---- Anmeldung, Konto, Betreiber, Teilen ---- */
.gate {
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-block: calc(env(safe-area-inset-top, 0px) + 16px) calc(env(safe-area-inset-bottom, 0px) + 16px);
  padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
  box-sizing: border-box;
  background:
    radial-gradient(ellipse at 50% 120%, rgba(142, 20, 20, 0.35), transparent 60%),
    repeating-linear-gradient(80deg, rgba(0, 0, 0, 0.4) 0 3px, transparent 3px 10px),
    #121214;
}
.gate-panel { width: min(420px, 100%); }
.gate-title { color: var(--blood); font-size: clamp(2.4rem, 10vmin, 3.4rem) !important; }
.gate-state { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; width: 100%; }
.gate-state .row { margin-top: 2px; }
.btn.google {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  font-size: clamp(1.25rem, 4.6vmin, 1.6rem);
}
.btn.google svg { width: 1.2em; height: 1.2em; flex: none; }
.chip {
  margin: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  background: rgba(13, 13, 15, 0.08);
  border: 2px dashed rgba(13, 13, 15, 0.4);
  border-radius: 999px;
  padding: 2px 14px;
  font-size: 1.05rem;
}
.link { color: #3c3c40; }
.panel .link { align-self: flex-start; }
.toggle.konto {
  top: calc(env(safe-area-inset-top, 0px) + 58px);
  max-width: 44vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.url { overflow-wrap: anywhere; }
.btn.pdf { text-decoration: none; font-size: clamp(1.1rem, 4vmin, 1.35rem); }
.btn.mini { font-size: 1.1rem; padding: 0.15em 0.7em 0.2em; box-shadow: 3px 3px 0 var(--ink); }
.btn.ok { background: #2f9e57; color: #fff; }

.admin-panel { width: min(560px, 100%); }
.share-panel { width: min(580px, 100%); }
.admin-panel h3 { margin: 8px 0 0; font-size: 1.3rem; font-weight: 700; }
.adm-list { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 8px; }
.adm-list li { overflow-wrap: anywhere; }
.adm-card, .adm-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  border: 2px solid rgba(13, 13, 15, 0.5);
  border-radius: 8px 5px 9px 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.45);
}
.adm-card { border-color: var(--blood); }
.adm-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.adm-who img, .adm-face { width: 40px; height: 40px; border-radius: 50%; flex: none; border: 2px solid var(--ink); object-fit: cover; }
.adm-who .adm-face { display: grid; place-items: center; background: var(--paper-dim); font-weight: 700; }
.adm-card b, .adm-row b { display: block; }
.adm-row b { display: inline; }
.adm-card span, .adm-row span, .adm-card small, .adm-row small { display: block; color: #3c3c40; }
.adm-card small, .adm-row small { font-size: 0.9rem; }
.adm-row em { font-style: normal; font-size: 0.85rem; background: var(--ink); color: var(--paper); border-radius: 999px; padding: 0 8px; }
.adm-actions { display: flex; gap: 10px; }
.adm-empty { color: #55555a; font-size: 1rem; }
.adm-add { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.adm-add input {
  flex: 1 1 180px;
  min-width: 0;
  font-family: var(--font-hand);
  font-size: 1.15rem;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  -webkit-user-select: text;
  user-select: text;
}
#adm-msg.error { color: var(--blood); font-weight: 700; }
.panel input, .panel textarea { touch-action: manipulation; }

@media (max-height: 520px) {
  .gate-title { font-size: 2rem !important; }
  .share-panel { width: min(720px, 100%); display: grid; grid-template-columns: auto 1fr; column-gap: 22px; row-gap: 6px; align-items: start; }
  .share-panel > .invite-row { display: contents; }
  .share-panel .qr { grid-column: 1; grid-row: 1 / span 5; width: 150px; height: 150px; }
  .share-panel > h2, .share-panel > .sub, .share-panel .invite-actions, .share-panel > .pdf, .share-panel > #btn-share-back { grid-column: 2; justify-self: start; }
  .share-panel .invite-actions { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
  .share-panel .invite-actions .btn { font-size: 1.1rem; }
  .share-panel .invite-actions .sub { flex-basis: 100%; }
  .share-panel > .sub { font-size: 1rem; }
}

/* Schmale Handys hochkant: Titel unter die Schalter oben rechts */
@media (orientation: portrait) and (max-width: 430px) {
  .title { top: calc(env(safe-area-inset-top, 0px) + 104px); }
}

/* ---- VR-Modus ---- */
body.vr #hud, body.vr #touch, body.vr #stick { visibility: hidden !important; }
/* Blut, Eis und rote Ränder zeichnet im VR-Modus der Vollbild-Durchgang je Auge */
body.vr #vignette, body.vr #frost, body.vr #deadfx, body.vr #fxcanvas { visibility: hidden; }
#vr-ui { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.vr-eye {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  color: var(--paper);
  text-shadow: 2px 2px 0 #000, 0 0 14px #000;
}
.vr-count { font-family: var(--font-display); font-size: min(34vh, calc(var(--vrw, 30vw) * 0.5)); line-height: 1; color: #fff; }
.vr-count:empty, .vr-text:empty { display: none; }
.vr-text { font-size: clamp(0.95rem, 4.4vh, 1.5rem); line-height: 1.2; white-space: pre-line; }
.vr-msg { font-size: clamp(0.95rem, 4.4vh, 1.4rem); line-height: 1.2; opacity: 0; transition: opacity 0.3s ease; }
.vr-msg.show { opacity: 1; }
#btn-vr-close {
  pointer-events: auto;
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: max(8px, env(safe-area-inset-right, 0px));
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--paper-dim);
  background: rgba(13, 13, 15, 0.75);
  color: var(--paper);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}
#btn-vr-close:focus-visible { outline: 3px dashed var(--paper); outline-offset: 3px; }

/* ---- VR-Brille einstellen ---- */
#brille { background: #000; z-index: 35; }
#brille-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.brille-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: system-ui, sans-serif;
  font-size: 13px;
  color: #cfd3d8;
}
.brille-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 5px; padding: 0 6px; }
.brille-row span { margin-left: 6px; }
.brille-row button {
  min-width: 38px;
  min-height: 34px;
  padding: 2px 9px;
  font: inherit;
  font-size: 14px;
  color: #fff;
  background: #2a2d33;
  border: 1px solid #5a606a;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}
.brille-row button.primary { background: #2f9e57; border-color: #2f9e57; font-weight: 700; }
.brille-row button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
#brille-werte { margin: 0; font-variant-numeric: tabular-nums; }

/* ---- Controller ---- */
.pad-hint {
  position: absolute;
  z-index: 4;
  left: max(28px, calc(env(safe-area-inset-left, 0px) + 20px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 6px);
  margin: 0;
  max-width: 70vw;
  font-size: 1rem;
  color: var(--paper-dim);
  text-shadow: 1px 1px 0 #000;
}
.pad-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  text-align: left;
  color: var(--ink);
  border: 2px solid rgba(13, 13, 15, 0.5);
  border-radius: 8px 5px 9px 6px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
}
.pad-row b { background: var(--ink); color: var(--paper); border-radius: 999px; padding: 0 12px; white-space: nowrap; }
.pad-row.wait { border-color: var(--blood); }
.pad-row.wait b { background: var(--blood); }
.pad-row:focus-visible { outline: 3px dashed var(--ink); outline-offset: 2px; }

/* Querformat mit wenig Höhe: Startmenü zweispaltig, damit alle Knöpfe passen */
@media (max-height: 520px) {
  .menu { display: grid; grid-template-columns: auto auto; gap: 12px 18px; bottom: calc(env(safe-area-inset-bottom, 0px) + 9vh); }
  .menu .btn { font-size: 1.35rem; justify-self: start; }
}
