/*
 * Aussehen des HTML-Overlays ueber der 3D-Ansicht (siehe `src/overlay.ts`).
 *
 * Zwei Dinge sind hier keine Geschmacksfrage:
 *
 * 1. `pointer-events`. Die Flaechen des Overlays spannen ueber das ganze Bild;
 *    ohne `none` wuerde jeder Klick aufs Brett im Overlay haengenbleiben. Nur
 *    was man wirklich anfasst — Knoepfe, Aktionsleiste, Seitenleisten — bekommt
 *    `auto` zurueck. Sitzschilder und Einblendungen bleiben durchlaessig: sie
 *    sind reine Auskunft, und man soll darunter das Brett drehen koennen.
 * 2. Die Farben liegen als Marken auf `:root`, damit helles und dunkles Thema
 *    ueber `prefers-color-scheme` laufen und `data-theme` am Wurzelelement sie
 *    ueberschreiben kann — wie in `apps/board/styles.css`. Die Namen tragen
 *    alle das Praefix `--fh-`, damit sie mit nichts kollidieren.
 *
 * Systemschriften, keine Bilder, keine Stil-Attribute im Dokument: die Seite
 * laeuft unter einer strengen CSP.
 *
 * Das Overlay selbst ist immer dunkel, auch im hellen Thema: dunkles Milchglas
 * ueber dem dunklen Tisch (Entscheid 2026-09-23). Weisse Kaesten wirkten wie
 * eine Webseite, die ueber das Spiel gelegt wurde. Die Startschirme in
 * `lobby.css` folgen weiter dem Thema.
 */

:root {
  --fh-paper: #f2f4f5;
  --fh-surface: #fff;
  --fh-glass: rgba(255, 255, 255, 0.9);
  --fh-glass-soft: rgba(255, 255, 255, 0.78);
  --fh-ink: #12171b;
  --fh-muted: #68727b;
  --fh-line: #dbe1e6;
  --fh-shadow: rgba(9, 14, 19, 0.16);
  --fh-s0: #c8443c;
  --fh-s1: #2f6ba8;
  --fh-s2: #c99a12;
  --fh-s3: #3e8c5a;
  --fh-warn: #b4571d;
  --fh-focus: #2f6ba8;
  /* Dieselben Sitzfarben, aber als Textfarbe lesbar — Gelb auf Weiss ist sonst
     zu schwach. Im dunklen Thema sind die hellen Grundfarben schon kraeftig
     genug und werden nicht ersetzt. */
  --fh-t0: #b03a33;
  --fh-t1: #2a5f96;
  --fh-t2: #8a6a0c;
  --fh-t3: #347a4d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --fh-paper: #0d1114;
    --fh-surface: #161c21;
    --fh-glass: rgba(22, 28, 33, 0.92);
    --fh-glass-soft: rgba(22, 28, 33, 0.8);
    --fh-ink: #e3e8ec;
    --fh-muted: #8d979f;
    --fh-line: #2c353d;
    --fh-shadow: rgba(0, 0, 0, 0.5);
    --fh-s0: #e0685f;
    --fh-s1: #74a9dd;
    --fh-s2: #d9a521;
    --fh-s3: #5aae78;
    --fh-warn: #e08a4a;
    --fh-focus: #8cbdec;
    --fh-t0: #e0685f;
    --fh-t1: #74a9dd;
    --fh-t2: #d9a521;
    --fh-t3: #5aae78;
  }
}

:root[data-theme='dark'] {
  --fh-paper: #0d1114;
  --fh-surface: #161c21;
  --fh-glass: rgba(22, 28, 33, 0.92);
  --fh-glass-soft: rgba(22, 28, 33, 0.8);
  --fh-ink: #e3e8ec;
  --fh-muted: #8d979f;
  --fh-line: #2c353d;
  --fh-shadow: rgba(0, 0, 0, 0.5);
  --fh-s0: #e0685f;
  --fh-s1: #74a9dd;
  --fh-s2: #d9a521;
  --fh-s3: #5aae78;
  --fh-warn: #e08a4a;
  --fh-focus: #8cbdec;
  --fh-t0: #e0685f;
  --fh-t1: #74a9dd;
  --fh-t2: #d9a521;
  --fh-t3: #5aae78;
}

/* Farbe eines Sitzes: ein Attribut, und alles darin faerbt sich mit. */
.fh-ov [data-seat='0'] { --fh-seat: var(--fh-s0); --fh-seat-text: var(--fh-t0); }
.fh-ov [data-seat='1'] { --fh-seat: var(--fh-s1); --fh-seat-text: var(--fh-t1); }
.fh-ov [data-seat='2'] { --fh-seat: var(--fh-s2); --fh-seat-text: var(--fh-t2); }
.fh-ov [data-seat='3'] { --fh-seat: var(--fh-s3); --fh-seat-text: var(--fh-t3); }

/* Dunkles Milchglas, unabhaengig vom Thema. Ueberschreibt die Marken von
   `:root` fuer alles innerhalb des Overlays. */
.fh-ov {
  --fh-paper: #0b0f12;
  --fh-surface: rgba(255, 255, 255, 0.07);
  --fh-glass: rgba(14, 19, 23, 0.72);
  --fh-glass-strong: rgba(14, 19, 23, 0.88);
  --fh-ink: #eef2f4;
  --fh-muted: #9aa5ad;
  --fh-line: rgba(255, 255, 255, 0.1);
  --fh-line-strong: rgba(255, 255, 255, 0.2);
  --fh-shadow: rgba(0, 0, 0, 0.45);
  --fh-s0: #ec6d63;
  --fh-s1: #6fa8e2;
  --fh-s2: #e2b02c;
  --fh-s3: #5cbb7d;
  --fh-t0: #f08a82;
  --fh-t1: #8dbbea;
  --fh-t2: #ecc458;
  --fh-t3: #7dcb97;
  --fh-warn: #f0a060;
  --fh-focus: #8cbdec;
  --fh-accent: #f4f6f7;
  --fh-accent-ink: #11161a;
  --fh-blur: blur(18px) saturate(1.4);
  --fh-radius: 16px;
}

/* --- Geruest ------------------------------------------------------------- */

.fh-ov,
.fh-ov *,
.fh-ov *::before,
.fh-ov *::after {
  box-sizing: border-box;
}

.fh-ov [hidden] { display: none !important; }

.fh-ov {
  position: fixed;
  inset: 0;
  z-index: 10;
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  color: var(--fh-ink);
  /* Ohne das faengt das Overlay jeden Klick ab, der dem Brett gilt. */
  pointer-events: none;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Eine Glasflaeche. Alles, was ueber dem Tisch schwebt, sieht gleich aus. */
.fh-pill,
.fh-tool,
.fh-toast,
.fh-badge,
.fh-bar,
.fh-drawer {
  background: var(--fh-glass);
  -webkit-backdrop-filter: var(--fh-blur);
  backdrop-filter: var(--fh-blur);
  border: 1px solid var(--fh-line);
  box-shadow: 0 8px 28px var(--fh-shadow);
}

/* --- Oben: Runde und Knoepfe --------------------------------------------- */

.fh-top {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: calc(12px + env(safe-area-inset-left, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.fh-pill {
  margin: 0;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--fh-ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.fh-pill:empty { display: none; }

.fh-tools { display: flex; gap: 8px; margin-left: auto; pointer-events: auto; }

.fh-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  color: var(--fh-ink);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.fh-tool:hover { background: var(--fh-glass-strong); border-color: var(--fh-line-strong); }
.fh-tool[aria-expanded='true'] { background: var(--fh-accent); color: var(--fh-accent-ink); }

.fh-icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.fh-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.fh-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
  align-self: center;
  background: var(--fh-seat, var(--fh-muted));
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
}

/* --- Einblendung --------------------------------------------------------- */

/* In der obersten Zeile, zwischen Runde und Knoepfen: darunter steht das Schild
   des gegenueberliegenden Sitzes, und das darf sie nicht zudecken. */
.fh-toast {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  z-index: 2;
  left: 50%;
  max-width: min(520px, calc(100vw - 360px));
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.86rem;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.fh-toast.fh-show { opacity: 1; transform: translate(-50%, 0); }
/* Unter dem Ablagestapel: die Lage setzt overlay.ts, geblendet wird nur. */
/* `bottom: auto` ist noetig: schmal setzt die Regel unten einen Abstand nach
   unten, und mit `top: 0` zusammen spannte das die Pille zu einer Saeule auf. */
.fh-toast.fh-anchored { top: 0; bottom: auto; left: 0; transition: opacity 0.25s ease; }
.fh-toast-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Sitzschilder -------------------------------------------------------- */

.fh-seats { position: absolute; inset: 0; }

.fh-seats .fh-badge {
  position: absolute;
  left: 0;
  top: 0;
  /* Die Lage setzt `placeSeats` als transform. */
  will-change: transform;
}

.fh-badge {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 96px;
  padding: 7px 12px 8px;
  border-radius: 14px;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.fh-badge-head { display: flex; align-items: center; gap: 7px; }
.fh-badge-name {
  font-size: 0.86rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 11rem;
}
.fh-badge-dealer {
  margin-left: auto;
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1px solid var(--fh-line-strong);
  color: var(--fh-muted);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
}

.fh-badge-foot { display: flex; align-items: center; gap: 8px; min-height: 14px; }
.fh-badge-pips { display: inline-flex; gap: 4px; }
.fh-badge-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--fh-seat, var(--fh-muted));
  opacity: 0.55;
}
.fh-badge-pip.fh-on { background: var(--fh-seat, var(--fh-muted)); opacity: 1; }
.fh-badge-status {
  font-size: 0.74rem;
  color: var(--fh-seat-text, var(--fh-muted));
  white-space: nowrap;
}
.fh-badge-status:empty { display: none; }

/* Wer dran ist: Ring in der Sitzfarbe, der langsam atmet. */
.fh-badge.fh-active {
  border-color: var(--fh-seat);
  box-shadow:
    0 0 0 2px var(--fh-seat),
    0 0 22px color-mix(in srgb, var(--fh-seat) 55%, transparent),
    0 8px 28px var(--fh-shadow);
  animation: fh-breathe 2.4s ease-in-out infinite;
}

@keyframes fh-breathe {
  50% {
    box-shadow:
      0 0 0 2px var(--fh-seat),
      0 0 34px color-mix(in srgb, var(--fh-seat) 75%, transparent),
      0 8px 28px var(--fh-shadow);
  }
}

/* --- Aktionsleiste ------------------------------------------------------- */

/* Das eigene Blatt steht genau in der Mitte, die Leiste schmal links daneben,
   beide unten buendig. Uebereinander kostete das Brett unten eine ganze
   Kartenhoehe; nebeneinander, aber aus der Mitte geschoben, wirkte es schief.
   Drei Spalten: links die Leiste, Mitte die Karten, rechts leer als Gegenstueck.
   Die Kamera laesst unten Platz frei (siehe `hudInsets` in overlay.ts und
   `setInsets` in camera.ts). */
.fh-dock {
  position: absolute;
  left: calc(12px + env(safe-area-inset-left, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  column-gap: 12px;
}
.fh-dock .fh-hand-slot { grid-column: 2; grid-row: 1; }
.fh-dock .fh-bar {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  width: auto;
  max-width: 380px;
}

/* Zu schmal fuer beides nebeneinander: Karten ueber der Leiste. */
@media (max-width: 900px) {
  .fh-dock { display: flex; flex-direction: column; align-items: center; gap: 8px; }
  .fh-dock .fh-bar { width: min(720px, 100%); max-width: none; }
}

/* --- Eigenes Blatt ------------------------------------------------------- */

/* Liegt auf dem Bildschirm statt auf dem Tisch: bleibt sichtbar, wie nah die
   Kamera auch ans Brett geht. Die Karten zeichnet cardArt.ts. */
.fh-hand-slot { pointer-events: none; }
.fh-hand {
  pointer-events: auto;
  display: flex;
  justify-content: center;
  gap: 6px;
}
.fh-hand[hidden] { display: none; }
.fh-hand-card {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  display: block;
  width: 68px;
  aspect-ratio: 2 / 3;
  border-radius: 7px;
  overflow: hidden;
  background: #f7f3ea;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  cursor: pointer;
}
.fh-hand-card:disabled { cursor: default; }
.fh-hand-face { display: block; width: 100%; height: 100%; }
/* Am Zug: was nicht spielbar ist, tritt zurueck. */
.fh-hand.is-turn .fh-hand-card:not(.is-playable) { filter: brightness(0.5) saturate(0.6); }
.fh-hand-card.is-playable {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 8px 22px rgba(0, 0, 0, 0.5);
}
.fh-hand-card.is-playable:hover { transform: translateY(-8px); }
.fh-hand-card.is-selected {
  transform: translateY(-14px);
  box-shadow: 0 0 0 3px #ffd34d, 0 0 22px rgba(255, 211, 77, 0.55), 0 10px 24px rgba(0, 0, 0, 0.5);
}
.fh-hand-card:focus-visible { outline: 2px solid #ffd34d; outline-offset: 3px; }
.fh-hand-card.is-back { cursor: default; }

/* Schmal: so gross wie auf dem Desktop, dafuer ueberlappend wie ein Faecher in
   der Hand. Wert und Farbe stehen oben links und bleiben sichtbar; sechs Karten
   passen so auch auf 360 px. Die angefasste Karte kommt nach vorn. */
@media (max-width: 560px) {
  .fh-hand { gap: 0; }
  .fh-hand-card {
    position: relative;
    width: min(68px, calc((100vw - 24px) / 5.2));
    border-radius: 6px;
  }
  .fh-hand-card + .fh-hand-card { margin-left: calc(min(68px, calc((100vw - 24px) / 5.2)) * -0.18); }
  .fh-hand-card.is-playable:hover,
  .fh-hand-card.is-selected,
  .fh-hand-card:focus-visible { z-index: 1; }
}

.fh-bar {
  pointer-events: auto;
  width: min(720px, 100%);
  /* Neben den Karten darf die Leiste schrumpfen; der Text bricht dann um. */
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 8px;
  border-radius: 20px;
  /* Notbremse fuer flache Fenster: die Sieben bringt sieben Stufenknoepfe mit. */
  max-height: min(46vh, 340px);
}

/* Das eigene Schild in der Leiste: flacher, ohne eigenen Glaskasten. */
.fh-bar .fh-me {
  flex: none;
  align-self: stretch;
  justify-content: center;
  background: var(--fh-surface);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-color: transparent;
  box-shadow: none;
  border-radius: 13px;
}
.fh-bar .fh-me.fh-active {
  border-color: var(--fh-seat);
  box-shadow: 0 0 0 1px var(--fh-seat), 0 0 18px color-mix(in srgb, var(--fh-seat) 40%, transparent);
}

.fh-prompt {
  flex: 1 1 auto;
  min-width: 0;
  align-self: stretch;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 2px 0;
}
.fh-prompt > * { flex: none; }

.fh-prompt[data-tone='idle'] .fh-prompt-text { color: var(--fh-muted); }
.fh-prompt[data-tone='warn'] .fh-prompt-text { color: var(--fh-warn); }
.fh-prompt[data-tone='win'] .fh-prompt-text { font-weight: 600; font-size: 0.95rem; }
.fh-prompt[data-tone='lost'] .fh-prompt-text { color: var(--fh-ink); }
.fh-bar:has(.fh-prompt[data-tone='warn']) { border-color: color-mix(in srgb, var(--fh-warn) 60%, transparent); }

/* --- Eigener Sieg -------------------------------------------------------- */

/* Nur wenn jemand an diesem Geraet gewonnen hat. Die Leiste waechst, leuchtet
   golden und traegt ein grosses «Gewonnen!»; dazu kommt das Konfetti. Hat der
   Computer oder die Gegenseite gewonnen, bleibt die Leiste, wie sie ist. */
.fh-prompt-title {
  margin: 0;
  /* Dieselbe runde Schrift wie das Logo (`lobby.css` laedt sie). */
  font-family: 'Fredoka', ui-rounded, system-ui, sans-serif;
  font-size: clamp(1.9rem, 5vw, 2.8rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.01em;
  background: linear-gradient(100deg, #ffe27a 0%, #f2b33d 35%, #fff4c2 50%, #f2b33d 65%, #ffe27a 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  transform-origin: left center;
  animation: fh-shine 2.6s linear infinite, fh-pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.fh-dock.fh-victory .fh-bar {
  max-width: 460px;
  padding: 14px 16px 14px 12px;
  border-color: #f2c14e;
  box-shadow:
    0 0 0 1px #f2c14e,
    0 0 36px rgba(242, 193, 78, 0.45),
    0 12px 40px var(--fh-shadow);
  animation: fh-glow 1.8s ease-in-out infinite alternate;
}
.fh-dock.fh-victory .fh-prompt { gap: 10px; overflow: visible; }

/* --- Verloren: klar erkennbar, aber keine Feier --------------------------- */

/* Gleiche Groesse wie der Sieg, damit das Ende nicht zu uebersehen ist — aber
   kuehles Silberblau statt Gold, kein Glanz, kein Leuchten, kein Konfetti. */
.fh-dock.fh-defeat .fh-bar {
  max-width: 460px;
  padding: 14px 16px 14px 12px;
  border-color: rgba(143, 166, 255, 0.45);
  box-shadow: 0 0 0 1px rgba(143, 166, 255, 0.25), 0 12px 40px var(--fh-shadow);
}
.fh-dock.fh-defeat .fh-prompt { gap: 10px; overflow: visible; }

/* --- Spielende in der Bildschirmmitte ------------------------------------- */

/* Sieg und Niederlage stehen nicht unten in der Ecke, sondern mittig ueber dem
   leicht abgedunkelten Tisch: das Spiel ist vorbei, das Brett braucht niemand
   mehr (Ausnahme von «kein Element auf dem Brett», Entscheid 2026-09-25). Die
   eigene Hand ist in dem Moment leer und tritt ab. */
.fh-dock.fh-victory,
.fh-dock.fh-defeat {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(6, 9, 20, 0.35) 0%, rgba(6, 9, 20, 0.65) 100%);
  animation: fh-end-in 0.35s ease-out both;
}
.fh-dock.fh-victory .fh-hand-slot,
.fh-dock.fh-defeat .fh-hand-slot { display: none; }
.fh-dock.fh-victory .fh-bar,
.fh-dock.fh-defeat .fh-bar {
  width: min(480px, 100%);
  max-width: 480px;
  justify-self: auto;
}
@keyframes fh-end-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.fh-dock.fh-defeat .fh-prompt-title {
  background: linear-gradient(180deg, #e6ecff 0%, #9fb0d8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  animation: fh-pop 0.5s ease-out both;
}

@keyframes fh-shine {
  to { background-position: -220% 0; }
}
@keyframes fh-pop {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes fh-glow {
  from { box-shadow: 0 0 0 1px #f2c14e, 0 0 22px rgba(242, 193, 78, 0.3), 0 12px 40px var(--fh-shadow); }
  to { box-shadow: 0 0 0 1px #ffd873, 0 0 48px rgba(242, 193, 78, 0.6), 0 12px 40px var(--fh-shadow); }
}

/* Ueber allem, aber ohne Klicks: man soll darunter weiter drehen koennen. */
.fh-confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  pointer-events: none;
}

.fh-prompt-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.fh-prompt-text { flex: 1 1 11rem; min-width: 0; font-size: 0.92rem; }

.fh-card {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 7px;
  background: #f4f1ea;
  color: #1a1d20;
  font-size: 1.02rem;
  font-weight: 700;
}
.fh-card.fh-red { color: #c8443c; }

.fh-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

.fh-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 38px;
  padding: 8px 18px;
  border-radius: 12px;
  border: 1px solid var(--fh-accent);
  background: var(--fh-accent);
  color: var(--fh-accent-ink);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}
.fh-btn:hover { background: #ffffff; }
.fh-btn:active { transform: scale(0.97); }

.fh-btn-ghost {
  background: transparent;
  color: var(--fh-ink);
  border-color: var(--fh-line-strong);
  font-weight: 500;
}
.fh-btn-ghost:hover { background: var(--fh-surface); }
.fh-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.fh-steps { display: flex; flex-wrap: wrap; gap: 6px; }

.fh-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  min-height: 34px;
  min-width: 42px;
  justify-content: center;
  padding: 6px 13px;
  border: 1px solid var(--fh-line-strong);
  border-radius: 10px;
  background: var(--fh-surface);
  color: var(--fh-ink);
  cursor: pointer;
}
.fh-step:hover { background: var(--fh-accent); color: var(--fh-accent-ink); }
.fh-step:disabled { opacity: 0.4; cursor: not-allowed; }

/* Punktreihe statt Balken: keine Breite als Stil-Attribut noetig. */
.fh-pips { display: flex; gap: 4px; align-items: center; }
.fh-pip {
  width: 14px;
  height: 6px;
  border-radius: 3px;
  background: var(--fh-line-strong);
}
.fh-pip.fh-on { background: var(--fh-ink); }

.fh-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--fh-muted);
  font-size: 0.8rem;
}
.fh-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 9px;
  border: 1px solid var(--fh-line-strong);
  border-radius: 999px;
  color: var(--fh-ink);
}

/* --- Seitenleisten: Einstellungen und Protokoll -------------------------- */

.fh-drawer {
  position: absolute;
  top: calc(60px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 3;
  pointer-events: auto;
  width: min(360px, calc(100vw - 24px));
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 14px 16px 18px;
  border-radius: var(--fh-radius);
  background: var(--fh-glass-strong);
  animation: fh-slide 0.2s ease;
}

/* Die Einstellungen sind kurz; sie muessen nicht bis unten reichen. */
.fh-drawer:not(:has(.fh-log)) { bottom: auto; max-height: calc(100vh - 72px); }

@keyframes fh-slide {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: none; }
}

.fh-drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fh-drawer-title { margin: 0; font-size: 1rem; font-weight: 650; }

.fh-drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--fh-surface);
  color: var(--fh-muted);
  cursor: pointer;
}
.fh-drawer-close:hover { color: var(--fh-ink); background: var(--fh-line-strong); }

.fh-group {
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fh-legend {
  padding: 0;
  margin-bottom: 2px;
  color: var(--fh-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.fh-botrows { display: flex; flex-direction: column; gap: 6px; }

/* Ein Sitz in den Einstellungen: Farbe, Name, Schalter «Computer». */
.fh-seatrow { display: flex; align-items: center; gap: 10px; }
.fh-name {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--fh-line-strong);
  background: rgba(0, 0, 0, 0.25);
  color: var(--fh-ink);
  font: inherit;
  font-size: 0.88rem;
}
.fh-name::placeholder { color: var(--fh-muted); }
.fh-name:focus { outline: none; border-color: var(--fh-seat, var(--fh-focus)); }
.fh-name:disabled { opacity: 0.55; }
.fh-botswitch { flex: none; font-size: 0.8rem; color: var(--fh-muted); padding: 0; }

.fh-switch {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.88rem;
  cursor: pointer;
  padding: 4px 0;
}
.fh-switch input { cursor: pointer; accent-color: var(--fh-s1); flex: none; width: 16px; height: 16px; }
.fh-switch-text { min-width: 0; }

.fh-segments {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
}

.fh-segment { flex: 1 1 0; min-width: 0; cursor: pointer; }

/* Fuenf Bretter passen nicht in eine Zeile: «Landeskarte» wurde abgeschnitten. */
.fh-segments-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.fh-segment input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.fh-segment-text {
  display: block;
  padding: 6px 6px;
  border-radius: 9px;
  text-align: center;
  font-size: 0.84rem;
  color: var(--fh-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: capitalize;
}
.fh-segment:hover .fh-segment-text { color: var(--fh-ink); }
.fh-segment input:checked + .fh-segment-text {
  background: var(--fh-line-strong);
  color: var(--fh-ink);
  font-weight: 600;
}

.fh-log-empty { margin: 0; color: var(--fh-muted); font-size: 0.86rem; }
.fh-log-copy { flex: none; align-self: flex-start; }

.fh-log {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--fh-muted);
  font-size: 0.84rem;
  display: flex;
  flex-direction: column;
}
.fh-log:empty { display: none; }
.fh-logline { padding: 7px 0; border-bottom: 1px solid var(--fh-line); }
.fh-logline:first-child { color: var(--fh-ink); }
.fh-logline:last-child { border-bottom: 0; }

/* Raum verlassen. Der einzige Weg aus einer laufenden Partie zurueck in den
   Warteraum — im Spiel am selben Geraet ausgeblendet, dort gibt es keinen Raum. */
.fh-leave {
  cursor: pointer;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--fh-line-strong);
  background: var(--fh-surface);
  color: var(--fh-ink);
  font: inherit;
  font-weight: 600;
}
.fh-leave:hover { border-color: var(--fh-warn); color: var(--fh-warn); }

/* --- Deckende Ebene ------------------------------------------------------ */

.fh-curtain {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: auto;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--fh-paper);
}

.fh-curtain-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(420px, 100%);
  padding: 32px 22px;
  border: 1px solid var(--fh-line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
}
.fh-curtain-box:focus { outline: none; }
.fh-curtain-title { margin: 0; color: var(--fh-muted); }
.fh-curtain-who {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.4rem;
  font-weight: 650;
  color: var(--fh-seat-text, var(--fh-ink));
}
.fh-curtain-who .fh-dot { width: 14px; height: 14px; }
.fh-curtain .fh-actions { margin: 0; justify-content: center; }

/* --- Tastatur und Finger ------------------------------------------------- */

.fh-ov :focus-visible,
.fh-segment input:focus-visible + .fh-segment-text {
  outline: 2px solid var(--fh-focus);
  outline-offset: 2px;
}

@media (pointer: coarse) {
  .fh-btn, .fh-step { min-height: 42px; }
  .fh-tool { width: 44px; height: 44px; }
}

/* Schmal: die Leiste bricht um, das eigene Schild wird zur Zeile oben. */
@media (max-width: 559px) {
  .fh-bar { flex-direction: column; align-items: stretch; gap: 8px; padding: 8px; }
  .fh-bar .fh-me { flex-direction: row; align-items: center; justify-content: space-between; padding: 6px 10px; }
  .fh-bar .fh-me .fh-badge-head { flex: 1 1 auto; }
  .fh-bar .fh-me .fh-badge-dealer { margin-left: 4px; margin-right: auto; }
  .fh-actions { flex-basis: 100%; margin-left: 0; }
  .fh-badge { min-width: 0; padding: 5px 9px 6px; }
  .fh-badge-name { font-size: 0.8rem; max-width: 7rem; }
  /* Schmal ist oben kein Platz neben Runde und Knoepfen: dann ueber die Leiste. */
  .fh-toast {
    top: auto;
    bottom: calc(150px + env(safe-area-inset-bottom, 0px));
    max-width: calc(100vw - 32px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fh-ov *,
  .fh-drawer {
    animation: none !important;
    transition: none !important;
  }
}
