:root {
  --bg: #f5ecd9;
  --paper: #fffaf0;
  --ink: #2b1d14;
  --muted: #7a6656;
  --blue: #2a4fbf;
  --blue-d: #1c3787;
  --brown: #a0663a;
  --brown-d: #6b4429;
  --green: #4f9a35;
  --green-d: #36701f;
  --red: #c0392b;
  --gold: #f1c40f;
  --pink: #e86fa8;
  --line: #2b1d14;
  --shadow: 0 4px 0 var(--line);
  --pixel: 'Press Start 2P', ui-monospace, monospace;
  --body: 'Nunito', system-ui, sans-serif;
  /* von app.js (Layout) gesetzt */
  --sw: min(100vw, calc(100dvh * 16 / 9));
  --sh: calc(var(--sw) * 9 / 16);
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
  --ease-out: cubic-bezier(0.2, 0.9, 0.25, 1.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }
body {
  background: var(--bg);
  background-image: radial-gradient(#e8dcc2 1px, transparent 1px);
  background-size: 12px 12px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; touch-action: manipulation; color: inherit; }
h1, h2, h3 { font-family: var(--pixel); font-weight: 400; letter-spacing: 0.5px; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ── Grundgerüst: Bühne so groß wie möglich ────────────── */
.app {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: var(--sa-t) var(--sa-r) var(--sa-b) var(--sa-l);
  transition: transform 0.35s var(--ease-out);
}
.stage-box { flex: none; width: var(--sw); height: var(--sh); position: relative; transition: transform 0.35s var(--ease-out); }
.stage {
  position: absolute; inset: 0; border: 4px solid var(--line); border-radius: 8px;
  overflow: hidden; background: #6a8fb5; box-shadow: 0 6px 0 var(--line);
}
.stage canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: manipulation; }
body.mode-over .stage { border: none; border-radius: 0; box-shadow: none; }
body.mode-over { background: #1d140e; }
body.mode-side .app { flex-direction: row; }

/* Kopfzeile (nur wenn oben Platz ist) */
.topbar {
  flex: none; width: var(--sw); display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 0 2px;
}
body:not(.mode-stack) .topbar { display: none; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { image-rendering: pixelated; flex: none; filter: drop-shadow(2px 2px 0 rgba(43, 29, 20, 0.35)); }
.brand h1 { margin: 0; font-size: 16px; color: var(--blue); text-shadow: 2px 2px 0 #fff, 3px 3px 0 var(--line); }
.brand .sub { font-size: 13px; color: var(--muted); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.brand-mini .brand .sub { display: none; }
body.brand-mini .brand h1 { font-size: 12px; }
body.brand-tiny .brand > div { display: none; }

/* Pixel-Plättchen: Grundform für alle HUD-Teile */
.chip, .coins, .ini-box, .dock-nav button, .drawer-close, .drawer-tabs button, .hud-fold, .testbar-tab {
  border: 3px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink);
  box-shadow: inset -3px -3px 0 rgba(43, 29, 20, 0.12), inset 3px 3px 0 #fff, 0 4px 0 var(--line);
}

.wallet { display: flex; align-items: center; gap: 8px; flex: none; }
.ini-box { display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 4px 0 10px; font-family: var(--pixel); font-size: 9px; cursor: text; }
.ini-box input {
  width: 4.6em; height: 32px; padding: 0 2px; text-align: center; font-family: var(--pixel); font-size: 16px; text-transform: uppercase;
  border: 2px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink); letter-spacing: 1px;
}
.ini-box input::placeholder { color: #c9b9a1; }
.coins {
  display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 12px; font-family: var(--pixel); font-size: 13px; white-space: nowrap;
  background: #eaf8d8;
}
.coins.bump { animation: bump 0.5s; }
@keyframes bump { 30% { transform: scale(1.2); } }

.btn {
  min-height: 44px; padding: 9px 14px; border: 3px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink);
  font-weight: 900; box-shadow: var(--shadow); transition: transform 0.05s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.btn-primary { background: var(--gold); }
.btn-green { background: #7ed957; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Dock: Menüknöpfe ──────────────────────────────────── */
.dock { flex: none; display: flex; align-items: center; justify-content: center; gap: 10px; z-index: 30; }
.dock-nav { display: flex; gap: 8px; }
.dock-nav button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-width: 48px; min-height: 48px; padding: 6px 8px 5px; transition: transform 0.08s, background 0.15s;
}
.dock-nav button i { font-style: normal; font-size: 22px; line-height: 1; }
.dock-nav button span { font-family: var(--pixel); font-size: 8px; line-height: 1; white-space: nowrap; }
.dock-nav button:active { transform: translateY(3px); box-shadow: inset -3px -3px 0 rgba(43, 29, 20, 0.12), inset 3px 3px 0 #fff, 0 1px 0 var(--line); }
.dock-nav button.cta { background: var(--gold); box-shadow: inset -3px -3px 0 #c9a10a, inset 3px 3px 0 #fff3a8, 0 4px 0 var(--line); }
.dock-nav button.active { background: var(--blue); color: #fff; box-shadow: inset -3px -3px 0 var(--blue-d), inset 3px 3px 0 #5a7ae0, 0 4px 0 var(--line); }
.dot {
  position: absolute; top: -6px; right: -6px; width: 14px; height: 14px; border-radius: 50%; background: var(--red); border: 3px solid var(--line);
  animation: blink 1.2s steps(2) infinite;
}
@keyframes blink { 50% { transform: scale(0.75); } }
body.dock-compact .dock-nav button span { display: none; }
body.dock-compact .dock-nav { gap: 6px; }

/* Stack (Hochformat/genug Platz): Dock unter dem Bild */
body.mode-stack .dock { width: var(--sw); justify-content: center; }
/* Seite (Breitbild): Dock senkrecht rechts */
body.mode-side .dock { flex-direction: column; align-self: center; }
body.mode-side .dock-nav { flex-direction: column; }
body.mode-side .wallet { flex-direction: column; }
body.mode-side .ini-box { padding: 0 6px; }
/* Über dem Bild (wenig Platz): Dock schwebt am unteren Bildrand */
body.mode-over .dock {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--sa-b) + 8px);
  padding: 6px 8px 10px; background: rgba(43, 29, 20, 0.55); border-radius: 12px;
}
body.mode-over .dock-nav button { opacity: 0.96; }

/* Infozeile unter dem Bild (kleine Bildschirme im Hochformat): Werte wandern aus dem Bild hierher */
.infobar { display: none; }
body.has-infobar .infobar { display: flex; flex: none; width: var(--sw); gap: 8px; align-items: stretch; padding: 0 2px; }
.infobar .hud { position: static; transform: none; font-size: 13px; min-width: 0; }
.infobar .hud-left { flex: 1; display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; }
.infobar .hud-left #hud-stats { display: contents; }
.infobar .hud-left .name, .infobar .hud-left .status-line { grid-column: 1 / -1; }
.infobar .hud-right { flex: none; display: flex; flex-direction: column; justify-content: center; }
.infobar .hud-fold { display: none; }

/* ── HUD im Bild ───────────────────────────────────────── */
.overlay { position: absolute; inset: 0; pointer-events: none; font-size: clamp(10px, calc(var(--sw) * 0.0135), 18px); }
.hud {
  position: absolute; background: rgba(255, 250, 240, 0.93); border: 3px solid var(--line); border-radius: 6px;
  padding: 0.45em 0.7em; font-weight: 800; font-size: 0.85em; box-shadow: 0 3px 0 rgba(43, 29, 20, 0.45);
}
.hud-left { left: 1%; top: 2%; min-width: 11em; max-width: 15em; pointer-events: auto; padding-right: 2.2em; }
.hud-left .name { font-family: var(--pixel); font-size: 0.75em; margin-bottom: 0.4em; line-height: 1.3; }
.status-line { font-size: 0.85em; color: var(--muted); font-weight: 800; line-height: 1.25; margin-top: 0.3em; }
.status-line:empty { display: none; }
.hud-fold {
  position: absolute; right: -3px; top: -3px; width: 2em; height: 2em; padding: 0;
  font-size: 1em; line-height: 1; box-shadow: none; border-radius: 0 6px 0 6px; background: #f1e4c8;
}
.hud-fold::after { content: ''; position: absolute; inset: -10px -10px -6px -6px; } /* größere Tippfläche */
.hud-fold::before { content: '–'; font-family: var(--pixel); font-size: 0.8em; }
.hud-left.folded { min-width: 0; padding-right: 2.6em; }
.hud-left.folded .hud-fold::before { content: '+'; }
.hud-left.folded .bar, .hud-left.folded .status-line { display: none; }
.hud-left.folded .name { margin: 0; }
.hud-left .mini { display: none; }
.hud-left.folded .mini { display: inline; margin-left: 0.4em; font-family: var(--body); font-size: 1.2em; }
.bar { display: flex; align-items: center; gap: 0.4em; margin: 0.15em 0; }
.bar span { width: 1.4em; text-align: center; }
.bar i { flex: 1; height: 0.6em; background: #e5d7bd; border: 2px solid var(--line); border-radius: 3px; position: relative; overflow: hidden; }
.bar i b { position: absolute; inset: 0 auto 0 0; background: var(--green); transition: width 1s; }
.bar i b.low { background: var(--red); }
.bar i b.mid { background: var(--gold); }
.hud-right { right: 1%; top: 2%; text-align: right; }
.hud-right .big { font-size: 1.4em; line-height: 1.1; }
.hud-teams { left: 50%; top: 2%; transform: translateX(-50%); display: flex; align-items: center; gap: 0.5em; padding: 0.3em 0.6em; }
.hud-teams .tbar { width: 12em; height: 0.8em; display: flex; border: 2px solid var(--line); border-radius: 3px; overflow: hidden; }
.hud-teams .tbar .w { background: var(--brown); }
.hud-teams .tbar .f { background: #a8e6cf; }
.hud-teams .tbar .h { background: var(--pink); }
body.testmode .hud-teams { top: 11%; }

.bubble {
  position: absolute; transform: translate(-50%, calc(-100% - 6px)) scale(0.6); opacity: 0; transition: opacity 0.2s, transform 0.2s;
  max-width: 16em; padding: 0.45em 0.7em; background: #fff; border: 3px solid var(--line); border-radius: 10px;
  font-weight: 800; font-size: 0.95em; line-height: 1.25; text-align: center;
}
.bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%);
  border: 7px solid transparent; border-top-color: var(--line);
}
.bubble.show { opacity: 1; transform: translate(-50%, calc(-100% - 6px)) scale(1); }
.bubble-hessi { background: #fde7f1; }
.bubble-prop { background: #fff8dc; font-size: 0.85em; }

.pip {
  position: absolute; right: 1.5%; bottom: 4%; width: 22%; background: var(--paper); border: 3px solid var(--line); border-radius: 6px;
  padding: 0.3em; opacity: 0; transform: translateY(20px); transition: all 0.3s;
}
.pip.show { opacity: 1; transform: none; }
.pip canvas { width: 100%; image-rendering: pixelated; display: block; border: 2px solid var(--line); }
.pip-title { font-size: 0.7em; font-weight: 900; margin-bottom: 0.2em; }
.pip-say { font-size: 0.75em; font-weight: 700; margin-top: 0.2em; min-height: 1.2em; }
body.mode-over .pip { bottom: 16%; }

.gift-drop { position: absolute; transform: translate(-50%, -100%); animation: drop 4.2s forwards; text-align: center; }
.gift-icon { display: block; font-size: 2.2em; filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.4)); }
.gift-ini { display: inline-block; font-family: var(--pixel); font-size: 0.65em; background: var(--gold); border: 2px solid var(--line); padding: 0.2em 0.35em; border-radius: 3px; }
@keyframes drop {
  0% { margin-top: -12em; opacity: 0; } 10% { opacity: 1; }
  30% { margin-top: 0; } 38% { margin-top: -1.2em; } 46% { margin-top: 0; }
  85% { opacity: 1; } 100% { opacity: 0; margin-top: -2em; }
}

.announce {
  position: absolute; left: 50%; top: 18%; transform: translateX(-50%); width: min(70%, 34em); pointer-events: auto;
  display: flex; gap: 0.8em; align-items: center; background: var(--paper); border: 4px solid var(--line); border-radius: 10px;
  padding: 0.8em 2.6em 0.8em 0.8em; box-shadow: 0 6px 0 var(--line); animation: pop 0.4s var(--ease-out);
}
.announce img { width: 5.5em; image-rendering: pixelated; }
.announce h2 { font-size: 0.85em; margin: 0 0 0.4em; color: var(--blue); line-height: 1.4; }
.announce p { margin: 0; font-weight: 700; font-size: 0.9em; }
.announce-close {
  position: absolute; right: 0; top: 0; min-width: 44px; min-height: 44px; background: none; border: none; font-size: 1.6em; line-height: 1; color: var(--muted);
}
@keyframes pop { from { transform: translateX(-50%) scale(0.7); opacity: 0; } }

.kiosk-ticker, .kiosk-qr, .kiosk-scores { display: none; }

/* ── Schublade (Panels) ────────────────────────────────── */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 38; background: rgba(29, 20, 14, 0.42); opacity: 0; visibility: hidden;
  transition: opacity 0.25s, visibility 0s 0.25s;
}
.drawer {
  position: fixed; z-index: 40; display: flex; flex-direction: column; background: var(--paper);
  border: 4px solid var(--line); visibility: hidden;
  transition: transform 0.32s var(--ease-out), visibility 0s 0.32s;
}
body.drawer-open .drawer-backdrop { opacity: 1; visibility: visible; transition: opacity 0.25s; }
body.drawer-open .drawer { visibility: visible; transform: none; transition: transform 0.32s var(--ease-out); }
/* rechts herausfahrend */
body.drawer-side .drawer {
  top: calc(var(--sa-t) + 10px); bottom: calc(var(--sa-b) + 10px); right: calc(var(--sa-r) + 10px);
  width: min(640px, calc(100vw - var(--sa-l) - var(--sa-r) - 20px));
  border-radius: 12px; box-shadow: -6px 6px 0 rgba(43, 29, 20, 0.55); transform: translateX(calc(100% + 30px));
}
/* von unten herausfahrend (Hochformat): das Bild rutscht nach oben und bleibt sichtbar */
body.drawer-sheet .drawer {
  left: var(--sa-l); right: var(--sa-r); bottom: 0; top: var(--sheet-top, 35dvh);
  border-bottom: none; border-radius: 16px 16px 0 0; box-shadow: 0 -6px 0 rgba(43, 29, 20, 0.35); transform: translateY(105%);
  padding-bottom: var(--sa-b);
}
body.drawer-open.drawer-side .drawer, body.drawer-open.drawer-sheet .drawer { transform: none; }
body.drawer-sheet.drawer-open .app { transform: translateY(calc(-1 * var(--lift, 0px))); }
body.drawer-sheet .drawer-backdrop { background: rgba(29, 20, 14, 0.28); }
.drawer-head {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px;
  background: var(--blue); color: #fff; border-bottom: 4px solid var(--line); border-radius: 8px 8px 0 0;
}
body.drawer-sheet .drawer-head { border-radius: 12px 12px 0 0; padding-top: 14px; position: relative; }
body.drawer-sheet .drawer-head::before {
  content: ''; position: absolute; left: 50%; top: 4px; width: 44px; height: 5px; transform: translateX(-50%); border-radius: 3px; background: rgba(255, 255, 255, 0.45);
}
.drawer-head h2 { flex: 1; margin: 0; font-size: 13px; line-height: 1.4; display: flex; align-items: center; gap: 10px; text-shadow: 2px 2px 0 var(--blue-d); min-width: 0; }
.drawer-head h2 i { font-style: normal; font-size: 24px; text-shadow: none; }
.drawer-head h2 span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coins-mini { height: 40px; font-size: 11px; padding: 0 10px; }
.drawer-close { flex: none; width: 44px; height: 44px; padding: 0; font-family: var(--pixel); font-size: 18px; line-height: 1; }
.drawer-close:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.drawer-tabs {
  flex: none; display: flex; gap: 6px; padding: 8px 12px 10px; background: #e4d5b8; border-bottom: 3px solid var(--line);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.drawer-tabs::-webkit-scrollbar { display: none; }
.drawer-tabs button {
  position: relative; flex: 1 0 auto; min-width: 44px; height: 44px; padding: 0 8px; font-size: 20px; line-height: 1;
  box-shadow: inset -2px -2px 0 rgba(43, 29, 20, 0.12), inset 2px 2px 0 #fff, 0 3px 0 var(--line);
}
.drawer-tabs button.active { background: var(--blue); box-shadow: inset -2px -2px 0 var(--blue-d), inset 2px 2px 0 #5a7ae0, 0 3px 0 var(--line); }
.drawer-tabs .dot { top: -5px; right: -5px; width: 12px; height: 12px; }
.drawer-body {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  container-type: inline-size; touch-action: pan-y;
}
.panel { padding: 16px 18px 26px; animation: panelin 0.25s ease-out; }
@keyframes panelin { from { opacity: 0; transform: translateY(8px); } }
.panel h2 { font-size: 12px; margin: 0 0 12px; color: var(--blue); line-height: 1.5; }
.panel h3 { font-size: 11px; margin: 18px 0 8px; line-height: 1.5; }
.muted { color: var(--muted); }
.lead { font-weight: 700; margin: 0 0 14px; }
@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer-backdrop, .app, .stage-box { transition: none !important; }
  .panel, .dot { animation: none; }
}

/* Neuigkeiten */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 10px 4px; border-bottom: 2px dashed #e4d5b8; align-items: flex-start; }
.feed .ic { font-size: 22px; width: 30px; text-align: center; flex: none; }
.feed .tx { flex: 1; }
.feed .ts { font-size: 12px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.feed li.k-story .tx, .feed li.k-bau .tx { font-weight: 800; }
.feed li.k-gift { font-size: 14px; color: var(--muted); padding: 5px 4px; }
.gift-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.gift-chip { flex: none; padding: 4px 8px; background: #fff3cd; border: 2px solid var(--line); border-radius: 14px; font-size: 13px; font-weight: 800; }
.cols { display: grid; grid-template-columns: 1fr; gap: 6px 18px; }
@container (min-width: 600px) { .cols { grid-template-columns: 3fr 2fr; } }
.cols > div > h2:not(:first-child) { margin-top: 18px; }

/* Laden */
.filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filter button { min-height: 40px; padding: 6px 12px; border: 2px solid var(--line); border-radius: 14px; background: #fff; font-weight: 800; font-size: 14px; }
.filter button.active { background: var(--blue); color: #fff; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.item {
  display: flex; flex-direction: column; gap: 4px; padding: 12px; background: #fff; border: 3px solid var(--line); border-radius: 8px;
  box-shadow: 0 3px 0 var(--line); text-align: left;
}
@media (hover: hover) { .item:hover { background: #fff8e1; } .mail-list button:hover { background: #fff3cd; } }
.item:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.item .ic { font-size: 30px; }
.item .nm { font-weight: 900; line-height: 1.2; }
.item .fx { font-size: 12px; color: var(--muted); font-weight: 700; min-height: 1.2em; }
.item .pr { margin-top: auto; font-family: var(--pixel); font-size: 11px; display: flex; align-items: center; justify-content: space-between; }
.item.too-expensive { opacity: 0.55; }
.item .cd, .modal-box .cd { font-size: 12px; font-weight: 700; color: #8a5a00; }
.item .own { font-size: 11px; background: #d4f4c4; border: 2px solid var(--line); border-radius: 8px; padding: 1px 6px; font-family: var(--body); font-weight: 900; }
.item.side-wombat { background: #f6e6d6; }
.item.side-hessi { background: #fde7f1; }
.item.side-frieden { background: #e3f7ee; }
.target-toggle { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; align-items: center; font-weight: 800; }

/* Spiele */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.game-card { padding: 14px; background: #fff; border: 3px solid var(--line); border-radius: 8px; box-shadow: 0 3px 0 var(--line); display: flex; flex-direction: column; gap: 8px; }
.game-card .gh { display: flex; align-items: center; gap: 10px; }
.game-card .gh .ic { font-size: 30px; }
.game-card h3 { margin: 0; font-size: 11px; }
.game-card p { margin: 0; font-size: 14px; }
/* Kopf, Text, Bestenliste und Knopf stehen in allen Karten einer Reihe auf gleicher Höhe */
.game-card .btn { margin-top: auto; }
@supports (grid-template-rows: subgrid) {
  .game-card { display: grid; grid-row: span 4; grid-template-rows: subgrid; row-gap: 8px; }
  .game-card .scores { align-self: start; }
  .game-card .btn { margin-top: 0; align-self: end; }
}
.scores { list-style: none; margin: 0; padding: 0; font-family: var(--pixel); font-size: 10px; }
.scores li { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dotted #ccc; }
.scores li:first-child { color: #b8860b; }

/* Bauen */
.project { padding: 14px; background: #fff; border: 3px solid var(--line); border-radius: 8px; margin-bottom: 12px; }
.project.done { background: #eef9e6; }
.project .ph { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.project h3 { margin: 0 0 6px; }
.project p { margin: 0 0 10px; font-size: 14px; }
.res { display: grid; grid-template-columns: minmax(80px, 110px) 1fr 64px; gap: 8px; align-items: center; font-size: 14px; font-weight: 800; margin: 4px 0; }
.res .track { height: 14px; background: #eee3cf; border: 2px solid var(--line); border-radius: 4px; position: relative; overflow: hidden; }
.res .track .p { position: absolute; inset: 0 auto 0 0; background: var(--green); }
.res .track .s { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(45deg, #f1c40f 0 4px, #f7dc6f 4px 8px); }
.res .num { text-align: right; font-family: var(--pixel); font-size: 9px; }
.legend { font-size: 13px; color: var(--muted); font-weight: 700; display: flex; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 10px; border: 2px solid var(--line); vertical-align: middle; margin-right: 4px; }

/* Abstimmungen & Post */
.poll { padding: 14px; background: #fff; border: 3px solid var(--line); border-radius: 8px; margin-bottom: 12px; }
.poll h3 { margin-top: 0; font-family: var(--body); font-size: 17px; font-weight: 900; }
.opt { display: block; width: 100%; min-height: 44px; text-align: left; margin: 6px 0; padding: 10px 12px; background: #fff; border: 2px solid var(--line); border-radius: 6px; position: relative; overflow: hidden; font-weight: 800; }
.opt .fill { position: absolute; inset: 0 auto 0 0; background: #d6e4ff; z-index: 0; transition: width 0.5s; }
.opt span { position: relative; z-index: 1; }
.opt .cnt { float: right; font-family: var(--pixel); font-size: 10px; }
.opt.mine { border-color: var(--blue); box-shadow: inset 0 0 0 2px var(--blue); }
.mail-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.mail-list button { text-align: left; min-height: 44px; padding: 10px; border: 2px solid var(--line); border-radius: 6px; background: #fff; font-weight: 700; }

/* Fundbüro & Freunde */
.finds { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.find { display: flex; gap: 10px; padding: 10px; background: #fff; border: 2px solid var(--line); border-radius: 8px; align-items: center; }
.find img { width: 56px; image-rendering: pixelated; flex: none; }
.find b { display: block; }
.find small { color: var(--muted); font-weight: 700; }
.friends { list-style: none; padding: 0; margin: 0; counter-reset: f; }
.friends li { display: flex; gap: 12px; align-items: center; padding: 8px; border-bottom: 2px dashed #e4d5b8; font-weight: 800; }
.friends li::before { counter-increment: f; content: counter(f); font-family: var(--pixel); font-size: 11px; width: 26px; color: var(--muted); }
.friends .ini { font-family: var(--pixel); font-size: 13px; background: var(--gold); border: 2px solid var(--line); padding: 3px 6px; border-radius: 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.stat { background: #fff; border: 2px solid var(--line); border-radius: 8px; padding: 10px; text-align: center; font-weight: 800; }
.stat b { display: block; font-family: var(--pixel); font-size: 16px; margin-bottom: 6px; color: var(--blue); }

/* ── Modal ─────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(30, 20, 10, 0.55); display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: calc(var(--sa-t) + 16px) calc(var(--sa-r) + 16px) calc(var(--sa-b) + 16px) calc(var(--sa-l) + 16px);
  animation: fadein 0.2s;
}
.modal-box {
  background: var(--paper); border: 4px solid var(--line); border-radius: 10px; padding: 20px; width: min(440px, 100%); box-shadow: 0 6px 0 var(--line);
  max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; animation: modalin 0.28s var(--ease-out);
}
@keyframes fadein { from { opacity: 0; } }
@keyframes modalin { from { transform: translateY(16px) scale(0.94); opacity: 0; } }
.modal-box h2 { font-size: 13px; margin: 0 0 12px; line-height: 1.5; }
.modal-box .big-ic { font-size: 48px; text-align: center; }
.modal-box input.ini {
  width: 100%; padding: 10px; font-family: var(--pixel); font-size: 22px; text-align: center; text-transform: uppercase; letter-spacing: 8px;
  border: 3px solid var(--line); border-radius: 6px; margin: 8px 0 12px;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.err { color: var(--red); font-weight: 800; min-height: 1.3em; }

/* ── Arcade ────────────────────────────────────────────── */
.arcade {
  position: fixed; inset: 0; background: rgba(10, 8, 20, 0.92); z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: calc(var(--sa-t) + 10px) calc(var(--sa-r) + 10px) calc(var(--sa-b) + 10px) calc(var(--sa-l) + 10px);
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: manipulation;
}
.arcade-cabinet { margin: auto; width: min(720px, 100%, calc((100dvh - var(--sa-t) - var(--sa-b) - 110px) * 4 / 3)); background: #2b2440; border: 4px solid #000; border-radius: 14px; padding: 12px; box-shadow: 0 0 0 4px #5b4b8a, 0 10px 30px rgba(0,0,0,0.6); }
.arcade-head { display: flex; align-items: center; gap: 12px; color: #ffe66d; font-family: var(--pixel); font-size: 12px; margin-bottom: 10px; }
.arcade-head #arcade-title { flex: 1; }
.arcade-head button { background: none; border: 2px solid #ffe66d; color: #ffe66d; border-radius: 6px; width: 44px; height: 40px; font-size: 18px; }
.arcade-screen { position: relative; aspect-ratio: 4 / 3; background: #000; border: 4px solid #000; border-radius: 6px; overflow: hidden; }
.arcade-screen canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.arcade-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #fff; text-align: center; font-family: var(--pixel); font-size: clamp(9px, 2vw, 14px); line-height: 1.8; padding: 20px; pointer-events: none; }
.arcade-msg:empty { display: none; }
.arcade-msg .panel-in { pointer-events: auto; background: rgba(20, 16, 36, 0.92); border: 3px solid #ffe66d; border-radius: 8px; padding: 16px 20px; max-width: 92%; }
.arcade-msg input { font-family: var(--pixel); font-size: 20px; width: 6em; text-align: center; text-transform: uppercase; letter-spacing: 6px; padding: 6px; border: 3px solid #ffe66d; background: #000; color: #ffe66d; border-radius: 4px; }
.arcade-msg button { font-family: var(--pixel); font-size: 11px; padding: 10px 12px; margin: 4px; border: 3px solid #000; border-radius: 6px; background: #ffe66d; color: #000; }
.arcade-msg ol { text-align: left; margin: 8px 0; padding-left: 2.2em; font-size: 0.85em; }
.arcade-help { color: #c9bff2; font-size: 13px; text-align: center; margin-top: 8px; }
.pad { display: none; justify-content: space-between; align-items: center; margin-top: 12px; user-select: none; -webkit-user-select: none; touch-action: none; }
.dpad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 50px); gap: 4px; }
.dpad button, .ab button { background: #5b4b8a; color: #fff; border: 3px solid #000; border-radius: 10px; font-size: 18px; touch-action: none; }
.dpad button[data-k=up] { grid-column: 2; grid-row: 1; }
.dpad button[data-k=left] { grid-column: 1; grid-row: 2; }
.dpad button[data-k=right] { grid-column: 3; grid-row: 2; }
.dpad button[data-k=down] { grid-column: 2; grid-row: 3; }
.ab { display: flex; gap: 14px; }
.ab button { width: 66px; height: 66px; border-radius: 50%; font-family: var(--pixel); background: #c0392b; }
.dpad button.on, .ab button.on { filter: brightness(1.5); }
@media (pointer: coarse) {
  .pad { display: flex; } .arcade-help { display: none; }
  .arcade-cabinet { width: min(720px, 100%, max(300px, calc((100dvh - var(--sa-t) - var(--sa-b) - 300px) * 4 / 3))); }
}
/* Handy quer: Steuerkreuz links, A/B rechts neben dem Bildschirm */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 620px) {
  .arcade { padding-top: calc(var(--sa-t) + 6px); padding-bottom: calc(var(--sa-b) + 6px); }
  .arcade-cabinet {
    width: min(100%, calc((100dvh - var(--sa-t) - var(--sa-b) - 84px) * 4 / 3 + 296px));
    display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: 'head head head' 'dpad screen ab'; align-items: center; column-gap: 14px; padding: 8px 12px;
  }
  .arcade-head { grid-area: head; margin-bottom: 6px; }
  .arcade-screen { grid-area: screen; }
  .pad { display: contents; }
  .dpad { grid-area: dpad; }
  .ab { grid-area: ab; flex-direction: column-reverse; }
}

/* ── Toasts ────────────────────────────────────────────── */
.toasts {
  position: fixed; right: var(--toast-r, 12px); bottom: var(--toast-b, 12px); display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  z-index: 70; pointer-events: none; max-width: min(360px, calc(100vw - 24px));
}
.toast {
  background: var(--paper); border: 3px solid var(--line); border-radius: 8px; padding: 10px 14px; font-weight: 800;
  box-shadow: 0 4px 0 var(--line); animation: slidein 0.35s var(--ease-out); max-width: 100%; font-size: 15px;
}
.toast.err { background: #ffe0dc; }
.toast.out { transition: opacity 0.3s, transform 0.3s; opacity: 0; transform: translateX(30px); }
@keyframes slidein { from { transform: translateX(120%); } }
/* Während eines Spiels: Hinweise klein oben in der Mitte, nie über den Knöpfen */
body.game-open .toasts { right: auto; bottom: auto; left: 50%; transform: translateX(-50%); align-items: center; top: calc(var(--sa-t) + 4px); }
body.game-open .toast { font-size: 13px; padding: 6px 10px; opacity: 0.92; }
body.game-open .dock, body.game-open .testbar { visibility: hidden; }

@media (max-width: 760px) {
  .res { grid-template-columns: 76px 1fr 56px; }
  .panel { padding: 14px 12px 24px; }
}
/* kleines Bild: HUD im Bild etwas schmaler */
body.stage-small .hud-left { min-width: 0; font-size: 0.78em; }
body.stage-small .hud-right { font-size: 0.75em; }
body.stage-small .hud-teams { top: auto; bottom: 2%; }
body.stage-small .announce { width: 92%; top: 10%; font-size: 0.85em; }
body.stage-small .pip { width: 34%; }

/* ── Kiosk (Schulbildschirm) ───────────────────────────── */
body.kiosk { background: #000; }
body.kiosk .topbar, body.kiosk .dock, body.kiosk .infobar, body.kiosk .drawer, body.kiosk .drawer-backdrop, body.kiosk .status-line, body.kiosk .hud-fold { display: none !important; }
body.kiosk .app { padding: 0; }
body.kiosk .stage { border: none; border-radius: 0; box-shadow: none; }
body.kiosk .hud-left { pointer-events: none; padding-right: 0.7em; }
body.kiosk .overlay { font-size: calc(var(--sw) * 0.0125); }
body.kiosk .announce-close { display: none; }
body.kiosk .kiosk-ticker {
  display: block; position: absolute; left: 0; right: 0; bottom: 0; background: rgba(43, 29, 20, 0.85); color: #fff;
  padding: 0.5em 1em; font-weight: 800; font-size: 1.05em; white-space: nowrap; overflow: hidden;
}
body.kiosk .kiosk-ticker span { display: inline-block; padding-left: 100%; animation: tick 60s linear infinite; }
@keyframes tick { to { transform: translateX(-100%); } }
body.kiosk .kiosk-qr {
  display: flex; gap: 0.6em; align-items: center; position: absolute; right: 1%; bottom: 3.2em; background: rgba(255, 250, 240, 0.95);
  border: 3px solid var(--line); border-radius: 8px; padding: 0.5em 0.7em; font-weight: 800;
}
body.kiosk .kiosk-qr img { width: 5em; image-rendering: pixelated; }
body.kiosk .kiosk-qr div { display: flex; flex-direction: column; }
body.kiosk .kiosk-qr b { font-family: var(--pixel); font-size: 0.7em; margin-bottom: 0.3em; }
body.kiosk .kiosk-scores {
  display: block; position: absolute; left: 1%; bottom: 3.2em; background: rgba(255, 250, 240, 0.95); border: 3px solid var(--line);
  border-radius: 8px; padding: 0.5em 0.7em; font-weight: 800; min-width: 12em; font-size: 0.85em;
}
body.kiosk .kiosk-scores h4 { margin: 0 0 0.3em; font-family: var(--pixel); font-size: 0.75em; }
body.kiosk .kiosk-scores ol { margin: 0; padding-left: 1.6em; font-family: var(--pixel); font-size: 0.7em; line-height: 1.8; }
body.kiosk .pip { bottom: auto; top: 20%; }

/* ── Testmodus: einklappbare Leiste oben ───────────────── */
.testbar { position: fixed; z-index: 36; top: var(--sa-t); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; max-width: calc(100vw - 16px); }
.testbar-tab {
  min-height: 32px; padding: 4px 12px; border-top: none; border-radius: 0 0 8px 8px; font-weight: 900; font-size: 13px;
  background: repeating-linear-gradient(45deg, #ffd93d, #ffd93d 10px, #fff1a8 10px, #fff1a8 20px);
}
.testbar-tab .tb-offset { margin-left: 6px; }
.testbar-body {
  display: none; margin-top: 6px; padding: 8px 10px; border: 3px solid #111; border-radius: 8px; text-align: center; font-weight: 900;
  background: repeating-linear-gradient(45deg, #ffd93d, #ffd93d 14px, #2b2b2b 14px, #2b2b2b 28px); box-shadow: 0 4px 0 #111;
  max-height: calc(100dvh - 80px); overflow-y: auto;
}
.testbar.open .testbar-body { display: block; animation: modalin 0.22s var(--ease-out); }
.testbar-body, .testbar-body > * { color: #111; }
.testbar-body span, .testbar-body .btn { background: #fff; padding: 2px 8px; border-radius: 6px; border: 2px solid #111; }
.testbar-body .btn { font-size: 13px; min-height: 36px; box-shadow: 0 2px 0 #111; }
.testbar .tb-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; }
.testbar .tb-row + .tb-row { margin-top: 6px; }
.testbar label { background: #fff; padding: 2px 8px; border-radius: 6px; border: 2px solid #111; font-size: 13px; }
.testbar select { font: inherit; font-size: 16px; font-weight: 700; margin-left: 4px; }
.testbar.traveling .testbar-tab, .testbar.traveling .tb-offset { background: #ffd0ea; }

.linkish { display: inline; padding: 0 2px; border: none; background: none; color: var(--blue); font-weight: 900; text-decoration: underline; text-underline-offset: 3px; }
