:root { color-scheme: light; }
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #2b2b2b;
  color: #eee;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}
main { padding: 16px; }
h1 { font-size: 1.2rem; margin: 4px 0 8px; font-weight: 600; }
.hint { font-size: 0.85rem; color: #bbb; margin: 0 0 12px; }
.screen-wrap { overflow-x: auto; }
/* Bühne: Spielfeld (Canvas) mit Dialogschicht darüber. Seitenverhältnis 640:400 = 8:5. Die Bühne
   passt sich der Fensterbreite und -höhe an (höchstens 1280 CSS-Pixel breit); alle Dialogmaße sind
   in cqw, skalieren also mit. */
.stage {
  position: relative;
  width: min(calc(100vw - 32px), calc((100vh - 32px) * 1.6));
  aspect-ratio: 8 / 5;
  margin: 0 auto;
  border-radius: 14px;
  background: #e0f2fe;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  container-type: inline-size;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}
/* Zeiger des Online-Spiels (Hand mit Zeigefinger): Fingerspitze (8/24, 1.5/24 der Grafik) liegt auf dem Klickpunkt */
.zeiger {
  position: absolute;
  width: 3cqw;
  transform: translate(-33.33%, -6.25%);
  pointer-events: none;
  z-index: 100;
  /* weißer Halo: die Hand bleibt auf dunklem Berg und hellem Himmel gleich gut erkennbar */
  filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff);
}
.zeiger[hidden] { display: none; }
.zeiger svg { display: block; width: 100%; height: auto; }
/* Umrandung der Hand in der Farbe des Spielers: links blau, rechts rot */
.zeiger.links path { stroke: #2563eb; }
.zeiger.rechts path { stroke: #dc2626; }
/* Grafik „Klassik“ (Menü Desk, Einstellungen): die ganze Bühne, also Spielfeld, Dialoge und Menüs,
   wird in Graustufen dargestellt, und zwar in nur 10 Grautönen (Filter #grau10 in index.html).
   Der helle Himmel (#f2f2f2) landet im hellsten Ton, der Berg (#323232) im zweitdunkelsten Ton (dunkler als die Dächer). */
.stage.grau { filter: url(#grau10); background: #f2f2f2; }
.stage.grau .dlg-flag { background: #f2f2f2; }   /* ohne Verlauf */
.stage.grau .dlg-panel, .stage.grau .menu-drop { box-shadow: none; }   /* keine Schatten hinter Dialogen und Menüs */
#screen {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
/* Dialoge: Maße in cqw, damit sie mit der Bühne skalieren */
.dialogs {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-family: 'Menlo', 'Consolas', 'Courier New', monospace;
  /* 16 Zeichen = 128 Originalpixel = 20cqw: Menlo ist 0,602 em breit, daher höchstens 2,07cqw */
  font-size: 2.07cqw;
  line-height: 2.5cqw;
  color: #111;
}
.dialogs > * { position: absolute; box-sizing: border-box; margin: 0; }
.dlg-panel {
  background: #f7f6f1;
  border: 0.25cqw solid #222;
  border-radius: 1cqw;
  box-shadow: 0 1cqw 3cqw rgba(0, 0, 0, 0.35);
}
.dlg-box { border: 0.2cqw solid #222; border-radius: 0.6cqw; }
.dlg-text {
  display: flex;
  align-items: center;
  white-space: pre;
  pointer-events: none;
  overflow: hidden;
}
/* Haken eines markierten Eintrags: 5 Originalpixel rechts von der Textspalte (5 * 100 / 640 cqw) */
.dlg-check { position: absolute; left: 0.78125cqw; top: 0; bottom: 0; display: flex; align-items: center; }
.dlg-title { font-weight: bold; }
.dlg-opt { display: flex; align-items: center; white-space: pre; pointer-events: auto; cursor: pointer; border-radius: 0.5cqw; }
.dlg-opt:hover { background: #e8eef9; }
.dlg-btn {
  pointer-events: auto;
  font: inherit;
  white-space: pre;
  padding: 0;
  color: #111;
  background: #fff;
  border: 0.2cqw solid #333;
  border-radius: 0.8cqw;
  cursor: pointer;
}
.dlg-btn.def { border-width: 0.45cqw; border-color: #111; }
.dlg-btn:hover { background: #e8eef9; }
/* Knopf ohne Hover-Hinweis (noHover im Objektbaum): nur Anzeige, kein Farbwechsel */
.dlg-btn.nohover, .dlg-btn.nohover:hover { background: #fff; cursor: default; }
/* Spielerkarte: kleinere Schrift, damit Name, Windwert und „Fertig“ in ihre Rahmen passen */
#card { font-size: 1.44cqw; }
/* Beschriftung eines Knopfes: Block; auf der Karte zentriert sie Text und Pfeile (Flexbox) */
.dlg-label { display: block; }
/* Knopf nur mit Pfeilen (Winkel, Pulver): Dreiecke nebeneinander, horizontal und vertikal mittig */
.dlg-label.dlg-chevs { display: flex; align-items: center; justify-content: center; gap: 0.5cqw; height: 100%; }
/* Knöpfe der Karte zentrieren ihren Inhalt (Text und Pfeile) vertikal und horizontal */
#card .dlg-btn { display: flex; align-items: center; justify-content: center; }
#card .dlg-label { display: flex; align-items: center; justify-content: center; }
/* Pfeile des Windwerts: Dreiecke aus Rahmenkanten, damit sie mittig im Feld sitzen */
.dlg-arrow { flex: none; width: 0; height: 0; border-style: solid; border-color: transparent; }
.dlg-arrow.left { border-width: 0.4em 0.55em 0.4em 0; border-right-color: #111; }
.dlg-arrow.right { border-width: 0.4em 0 0.4em 0.55em; border-left-color: #111; }
/* Spielerkarte: Knöpfe ohne Funktion sind reine Anzeige; der Windkasten trägt die Fahne als Canvas */
.dlg-btn.static { pointer-events: none; cursor: default; }
.dlg-btn.static:hover { background: #fff; }
/* Pfeile in Kästen (Steuern, Burgauswahl): Dreieck aus Rahmenkanten, etwa 13 Originalpixel hoch, mittig im Kasten */
.dlg-chev { flex: none; width: 0; height: 0; border-style: solid; border-color: transparent; }
.dlg-chev.left { border-width: 0.65cqw 0.75cqw 0.65cqw 0; border-right-color: #111; }
.dlg-chev.right { border-width: 0.65cqw 0 0.65cqw 0.75cqw; border-left-color: #111; }
/* Windkasten: das Canvas deckt den ganzen Kasten ab (Koordinaten wie im Raster). Der Rahmen liegt
   als Overlay darüber, damit die Zeichnung nicht um die Rahmenbreite verschoben oder gestreckt wird. */
.dlg-flag { background: linear-gradient(#bae6fd, #f0f9ff); overflow: hidden; border: 0; border-radius: 0.8cqw; }
.dlg-flag canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.dlg-flag::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 0.2cqw solid #222;
  border-radius: inherit;
  pointer-events: none;
}
/* Grafikfläche über dem Dialog (z. B. Winkel-Dial): deckt den Dialog ab, Klicks gehen durch */
.dlg-gfx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.dlg-input {
  pointer-events: auto;
  font: inherit;
  color: #111;
  background: #fff;
  border: 0;
  border-radius: 0.6cqw;
  padding: 0 0.8cqw;
  outline: none;
  min-width: 0;
}
/* Fokus innen am Feld (inset), damit er nicht über den Rahmen des Kastens hinausragt */
.dlg-input:focus { box-shadow: inset 0 0 0 0.3cqw rgba(37, 99, 235, 0.6); }
.dlg-input::placeholder { color: #999; }
/* Vorspann vor dem Eingabefeld (z. B. „Spieler 1:“): 2 Originalpixel nach rechts (2 * 100 / 640 cqw) */
.dlg-pre { padding-left: 0.3125cqw; }
.on { background: #111 !important; color: #fff !important; }
.dis { opacity: 0.35; }
/* Menüleiste und Dropdowns: nur Anzeige, Klicks gehen über die Bühne an die Ereignisschleife */
.menu-bar { background: #fff; }
.menu-title { white-space: pre; }
.menu-drop {
  background: #fff;
  border: 0.15cqw solid #111;
  box-shadow: 0 1cqw 3cqw rgba(0, 0, 0, 0.35);
}
/* Vollbild-Knopf rechts in der Menüleiste (menu-view.js); als einziges Element der Schicht klickbar */
.menu-fs {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: #fff;
  color: #111;
  cursor: pointer;
  pointer-events: auto;
}
.menu-fs svg { width: 70%; height: 70%; }
.menu-fs:hover { background: #111; color: #fff; }
.menu-fs:focus-visible { outline: 0.2cqw solid #2563eb; outline-offset: -0.2cqw; }
.menu-item { white-space: pre; }
/* Hover-Hervorhebung wie AES: invertiert (wird von menu-view.js per Klasse gesetzt) */
.menu-item.hov { background: #111; color: #fff; }
/* Trennlinie zwischen Einträgen */
.menu-item.sep { background: linear-gradient(#111, #111) center / 100% 0.15cqw no-repeat; }
/* Ergebnistabelle */
.tab-dialog { overflow: hidden; display: flex; flex-direction: column; }
/* 5 Originalpixel Rand um die Tabelle (5 * 100 / 640 cqw) */
.tab-body { flex: 1 1 0; min-height: 0; margin: 0.78125cqw; }
.tab-table {
  width: 100%;
  height: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
  font: inherit;
}
.tab-table th, .tab-table td {
  border: 0.12cqw solid #111;
  padding: 0 0.6cqw;
  white-space: nowrap;
  overflow: hidden;
  font-weight: normal;
}
.tab-table th.name { text-align: left; }
.tab-table thead th.name { text-align: center; }
.tab-table td { text-align: right; }
.tab-table tr.sum th, .tab-table tr.sum td { border-top-width: 0.35cqw; }
.tab-table td.diag { box-shadow: inset 0 0 0 0.25cqw #111; background: #b5b5b5; }
/* Ecke der Kopfzeile mit Diagonale von oben links nach unten rechts */
.tab-table th.corner {
  position: relative;
  width: 16.5%;
  background: linear-gradient(to top right, transparent calc(50% - 0.1cqw), #111 calc(50% - 0.1cqw), #111 calc(50% + 0.1cqw), transparent calc(50% + 0.1cqw));
}
.tab-table .lbl-gew, .tab-table .lbl-verl {
  position: absolute;
  font-size: 1.4cqw;
  line-height: 1.5cqw;
}
.tab-table .lbl-gew { top: 0.2cqw; right: 0.5cqw; }
.tab-table .lbl-verl { bottom: 0.2cqw; left: 0.5cqw; }
/* Statistik: lange Beschriftungen in der breiten ersten Spalte, je Spieler eine Spalte für Name und Werte (bei 500 px Dialogbreite reicht das für Namen bis etwa 11 Zeichen) */
.stat-table th:first-child { width: 60%; }
.stat-table td { width: 20%; }
/* Hinweis unten im Fenster, unter der Tabelle (kein eigener Kasten) */
.tab-hint {
  flex: 0 0 auto;
  justify-content: center;
  height: 3.2cqw;
  font-size: 1.6cqw;
  line-height: 3.2cqw;
  color: #111;
}

/* ---------------------------------------------------------------- Anmeldung des Hosts (Atari-Stil) */
.login {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #8c8c8c;
  font-family: 'Menlo', 'Consolas', 'Courier New', monospace;
  color: #111;
}
.login[hidden] { display: none; }
.login-box {
  width: min(92vw, 360px);
  background: #f7f6f1;
  border: 3px solid #111;
  box-shadow: 6px 6px 0 #111;
  padding: 18px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-box h1 { margin: 0 0 4px; font-size: 20px; text-align: center; }
.login-box label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.login-box input {
  font: inherit;
  font-size: 15px;
  padding: 6px 8px;
  border: 2px solid #111;
  background: #fff;
}
.login-box button {
  font: inherit;
  font-size: 15px;
  padding: 7px;
  margin-top: 4px;
  border: 2px solid #111;
  background: #fff;
  cursor: pointer;
}
.login-box button:hover { background: #111; color: #fff; }
.login-box button:disabled { color: #888; border-color: #888; cursor: default; }
.login-fehler { min-height: 1.3em; margin: 0; font-size: 13px; color: #b91c1c; }

/* ---------------------------------------------------------------- online - online (Host) */
/* Menüleiste ausgeblendet: das Spiel läuft über die Tasten Strg+C/P/N/S/F/B */
.stage.online #menu { display: none; }
/* Statusstreifen an Stelle der Menüleiste (16 von 400 Zeilen): Verbindung der beiden Handys */
.online-status {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4%;
  z-index: 15;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.2cqw;
  background: #fff;
  border-bottom: 0.15cqw solid #111;
  font-family: 'Menlo', 'Consolas', 'Courier New', monospace;
  font-size: 2.07cqw;
  white-space: pre;
  pointer-events: none;
}
.stage.online .online-status { display: flex; }
.online-status .unterbrochen { background: #b3261e; color: #fff; padding: 0 0.6cqw; }
.online-status .verbunden { color: #111; }
/* Lobby: Codes, Anmeldung, Bereitschaft und Countdown am Hauptbildschirm */
.lobby {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2cqw;
  background: #f7f6f1;   /* deckend: Spielfeld und Dialoge darunter bleiben verborgen */
  font-family: 'Menlo', 'Consolas', 'Courier New', monospace;
  color: #111;
  font-size: 2.6cqw;
}
.lobby[hidden] { display: none; }
.lobby h2 { margin: 0 0 2cqw; font-size: 4.2cqw; }
.lobby-qr { width: 16cqw; height: 16cqw; background: #fff; }
.lobby-qr svg { display: block; width: 100%; height: 100%; }
.lobby-zeile { display: flex; gap: 1cqw; align-items: baseline; flex-wrap: wrap; justify-content: center; }
.lobby-zeile b { font-size: 4.6cqw; letter-spacing: 0.4cqw; }
.lobby-status { font-size: 2.2cqw; color: #444; }
.lobby-hinweis { margin: 2cqw 0 0; font-size: 1.7cqw; color: #444; text-align: center; max-width: 84%; line-height: 2.4cqw; }
/* Schwarzer Hauptbildschirm (Strg+B, nur ohne laufendes Spiel) */
.stage.schwarz { background: #000; }
.stage.schwarz > * { display: none; }
