/* =========================================================================
 * Cluedo – Villa Neubrunn · V3
 *
 * Farbwelt nach dem grafischen Konzept (Grafisches_Konzept.png):
 * tiefes Mitternachtsblau, Messinggold als Akzent, cremefarbene Karten,
 * warme Brauntöne nur auf dem Spielbrett selbst (Nostalgie). Alle Werte
 * liegen als Custom Properties vor.
 * ========================================================================= */

:root {
  /* Flächen – Mitternachtsblau wie im Konzeptposter */
  --bg:            #0b1322;
  --bg-2:          #0e1829;
  --panel:         #131f36;
  --panel-2:       #182844;
  --zeile:         #1b2c4a;
  --inset:         #0e1727;
  --line:          #24344f;
  --line-hell:     #33476b;

  /* Schrift */
  --text:          #eef1f7;
  --text-dim:      #9aa7c0;
  --text-schwach:  #6b7690;

  /* Akzente */
  --gold:          #d9b36c;
  --gold-hell:     #f2d9a0;
  --gold-dunkel:   #93763d;
  --creme:         #f3e9d4;
  --gefahr:        #b4453c;
  --gefahr-bg:     #3f1d22;
  --erfolg:        #3f9d63;
  --erfolg-bg:     #16362a;

  /* Abstände */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;
  --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;

  /* Radien */
  --r-1: 6px; --r-2: 10px; --r-3: 14px; --r-4: 20px;

  /* Schatten */
  --sh-1: 0 1px 3px rgba(0,0,0,.45);
  --sh-2: 0 4px 16px rgba(0,0,0,.5);
  --sh-3: 0 14px 38px rgba(0,0,0,.6);
  --sh-gold: 0 0 0 2px rgba(217,179,108,.4), 0 0 22px rgba(217,179,108,.22);

  /* Zeiten */
  --t-schnell: 130ms;
  --t-normal:  260ms;
  --t-ruhig:   480ms;

  /* Ebenen */
  --z-brett: 1;
  --z-dock: 20;
  --z-side: 25;
  --z-szene: 40;
  --z-overlay: 50;
  --z-toast: 60;

  --schrift-ui: "Segoe UI", system-ui, -apple-system, sans-serif;
  --schrift-titel: Georgia, "Times New Roman", serif;
}

/* Bewegung reduzieren: Systemeinstellung ODER App-Schalter (Klasse setzt
   app.js/bewegungsklasseSetzen – reine CSS-Animationen hoeren sonst nicht
   auf den Schalter in der Kopfleiste) */
@media (prefers-reduced-motion: reduce) {
  :root { --t-schnell: 1ms; --t-normal: 1ms; --t-ruhig: 1ms; }
}
:root.bewegung-reduziert { --t-schnell: 1ms; --t-normal: 1ms; --t-ruhig: 1ms; }

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: radial-gradient(1200px 700px at 65% -10%, #14223c 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--schrift-ui);
}

h1, h2, h3, h4 { font-family: var(--schrift-titel); font-weight: 600; letter-spacing: .01em; margin: 0 0 var(--sp-3); }
h2 { font-size: 20px; color: var(--gold); }
h3 { font-size: 17px; color: var(--gold); }
h4 { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .09em; }
p { margin: 0 0 var(--sp-3); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--text-dim); }
.small { font-size: 13px; }
.mt { margin-top: var(--sp-4); }
.spacer, .grow { flex: 1; }
.row { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin-top: var(--sp-3); }

/* ---------------------------------------------------------- Bedienung -- */

button {
  font: inherit; cursor: pointer;
  border: 1px solid var(--line-hell);
  border-radius: var(--r-2);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  color: var(--text);
  padding: 9px 15px;
  min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  transition: background var(--t-schnell), border-color var(--t-schnell), transform var(--t-schnell);
}
button:hover:not(:disabled) { border-color: var(--gold-dunkel); background: var(--panel-2); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .42; cursor: default; }
button:focus-visible { outline: 3px solid var(--gold-hell); outline-offset: 2px; }

button.primary {
  background: linear-gradient(180deg, #23573f, #17422f);
  border-color: #2f6d4f; color: #d9f2e2; font-weight: 600;
}
button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #2a6549, #1b4c37); }
button.danger { background: linear-gradient(180deg, #5d2823, var(--gefahr-bg)); border-color: #8d4038; color: #ffd9d3; }
button.gross { font-size: 16px; padding: 12px 22px; }
button.block { width: 100%; }
button.link {
  background: none; border: none; color: var(--gold); text-decoration: underline;
  padding: 0 4px; min-height: auto;
}
button.icon-btn { padding: 8px; min-width: 44px; }
button.icon-btn.aktiv { border-color: var(--gold); color: var(--gold-hell); }

input, select {
  font: inherit; background: var(--inset);
  border: 1px solid var(--line); border-radius: var(--r-2);
  color: var(--text); padding: 10px 12px; width: 100%; min-height: 44px;
}
input:focus-visible { outline: 3px solid var(--gold-hell); outline-offset: 1px; border-color: transparent; }
input[type="checkbox"] { width: auto; min-height: auto; accent-color: var(--gold); }

.icon { width: 1.4em; height: 1.4em; display: inline-block; vertical-align: -.25em; }
.btn-icon { width: 1.5em; height: 1.5em; }
.logo-icon { width: 1.1em; height: 1.1em; color: var(--gold); vertical-align: -.15em; }

.badge {
  font-size: 12px; padding: 3px 10px; border-radius: 20px;
  border: 1px solid var(--line-hell); color: var(--text-dim); white-space: nowrap;
}
.badge.lobby { color: var(--gold-hell); border-color: var(--gold-dunkel); }
.badge.running { color: #b6f0c0; border-color: #3d7a4a; }
.tag {
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-hell);
  color: var(--text-dim); margin-left: 6px; white-space: nowrap;
}
.tag.bot { color: #cfe4ff; border-color: #46618d; background: #14233d; }
.tag.du  { color: var(--gold-hell); border-color: var(--gold-dunkel); background: #2b2410; }

/* ------------------------------------------------------------- Gerüst -- */

#app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  background: linear-gradient(180deg, #0d1626, #0a111e);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: var(--z-dock);
}
.topbar h1 { font-size: 19px; margin: 0; color: var(--gold); white-space: nowrap; }
.topnav { display: flex; gap: var(--sp-1); }
.topbar button { min-height: 38px; padding: 6px 12px; }
.topbar .user { color: var(--text-dim); font-size: 14px; }

.page { flex: 1; padding: var(--sp-4); max-width: 1400px; margin: 0 auto; width: 100%; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-3); padding: var(--sp-5); box-shadow: var(--sh-1);
}

/* ---------------------------------------------------------- Anmeldung -- */

.auth-wrap { display: flex; align-items: center; justify-content: center; flex: 1; padding: var(--sp-5); }
.auth-card { width: 400px; max-width: 94vw; box-shadow: var(--sh-3); }
.auth-card .field { margin-bottom: var(--sp-3); }
.auth-card label { display: block; margin-bottom: var(--sp-1); color: var(--text-dim); font-size: 13px; }
.auth-card .actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-4); }
.auth-card .actions button { flex: 1; }
.auth-switch { margin-top: var(--sp-4); font-size: 13px; color: var(--text-dim); text-align: center; }

/* -------------------------------------------------------------- Lobby -- */

.lobby-grid { display: grid; grid-template-columns: 1fr 330px; gap: var(--sp-4); align-items: start; }
@media (max-width: 950px) { .lobby-grid { grid-template-columns: 1fr; } }

.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: var(--sp-3); }
.mode-card {
  background: var(--inset); border: 1px solid var(--line); border-radius: var(--r-3);
  padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2);
}
.mode-card.gedimmt { opacity: .6; }
.mode-head { display: flex; align-items: center; gap: var(--sp-2); }
.mode-head h3 { margin: 0; }
.mode-icon { color: var(--gold); display: inline-flex; }
.mode-icon .icon { width: 26px; height: 26px; }
.mode-card .row { margin-top: 0; flex-wrap: nowrap; }
.mode-card .row input { min-width: 0; }

.game-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.game-row {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--zeile); border: 1px solid var(--line);
  border-radius: var(--r-2); padding: var(--sp-3) var(--sp-4); flex-wrap: wrap;
}
.gname { font-weight: 600; }
.gmeta { color: var(--text-dim); font-size: 13px; }

.joincode {
  background: var(--inset); border: 1px dashed var(--line-hell);
  border-radius: var(--r-2); padding: var(--sp-3); margin: var(--sp-3) 0;
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
}
.joincode b { color: var(--gold); letter-spacing: 4px; font-size: 19px; }

.checkrow { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-3); color: var(--text-dim); font-size: 14px; }

/* ------------------------------------------------------- Figurenwahl --- */

.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--sp-3); margin: var(--sp-3) 0; }
.char-card {
  --ring: var(--gold);
  position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--sp-1);
  background: var(--inset); border: 2px solid var(--line); border-radius: var(--r-3);
  padding: var(--sp-2); min-height: auto; overflow: hidden;
}
.char-card:hover:not(:disabled) { border-color: var(--ring); }
.char-card.sel { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 30%, transparent); }
.char-card.belegt { opacity: .75; }
.char-portrait { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--r-2); display: block; }
.char-name { font-weight: 600; font-size: 14px; text-align: center; }
.char-by { font-size: 12px; color: var(--text-dim); }

/* ---------------------------------------------------------- Avatare ---- */

.avatar {
  --sz: 48px; --ring: var(--gold);
  width: var(--sz); height: var(--sz); flex: none;
  border-radius: 50%; overflow: hidden; position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--inset);
  box-shadow: 0 0 0 2px var(--ring), var(--sh-1);
  transition: box-shadow var(--t-normal), transform var(--t-normal);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.aktiv { box-shadow: 0 0 0 3px var(--gold), 0 0 20px rgba(217,179,108,.5); }
.avatar-fallback { font-weight: 700; color: var(--text); }

/* ======================================================================
 * Spieltisch: Aktionen links, Brett dominiert die Mitte, Seitenleiste
 * rechts – alles passt ohne Scrollen auf den Schirm
 * ====================================================================== */

.table-layout {
  flex: none; display: grid; gap: var(--sp-3);
  grid-template-columns: 250px minmax(0, 1fr) 312px;
  grid-template-rows: minmax(0, 1fr) auto auto;
  grid-template-areas:
    "aktion board side"
    "aktion hand  side"
    "aktion notes side";
  padding: var(--sp-3);
  max-width: 1750px; margin: 0 auto; width: 100%;
  /* Alles passt auf einen Schirm; die Spalten scrollen bei Bedarf intern
     (55px = Kopfleiste). min-height: 0 ist Pflicht – sonst zieht der
     Inhalt (Notizblock!) das Flex-Kind auf Inhaltshöhe auf und die Seite
     scrollt doch. Auf schmalen Schirmen hebt die Tablet-Regel das auf. */
  height: calc(100vh - 55px);
  min-height: 0;
}

.aktion-spalte {
  grid-area: aktion; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; gap: var(--sp-3);
  overflow-y: auto; scrollbar-width: thin;
}
.board-area { grid-area: board; position: relative; min-width: 0; min-height: 0; }
.handstrip  { grid-area: hand; }
.notesdock  { grid-area: notes; }
.side       {
  grid-area: side; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; gap: var(--sp-3);
}

/* ---- Brett (bewusst gross) ---- */

.board-wrap {
  background: linear-gradient(180deg, #101b2f, #0d1626);
  border: 1px solid var(--line);
  border-radius: var(--r-3); padding: var(--sp-2); box-shadow: var(--sh-2);
  height: 100%;
  display: flex; align-items: center; justify-content: center;
}
/* Die Hoehe kommt aus dem Grid (1fr-Zeile) – das Brett nimmt genau den
   Platz, der ueber Handkarten und Notizblock uebrig bleibt */
.board-wrap svg {
  width: 100%; height: 100%; max-height: 100%;
  display: block;
  transition: transform .6s ease;
}

/* 3D-Ansicht: Das Brett kippt wie auf einem Spieltisch. Klickziele bleiben
   funktional (CSS-Transformationen behalten die Treffererkennung). */
.board-wrap { perspective: 1300px; overflow: hidden; }
.board-wrap.dreid svg {
  transform: rotateX(30deg) scale(1.24);
  transform-origin: 50% 62%;
}
@media (prefers-reduced-motion: reduce) { .board-wrap svg { transition: none; } }
:root.bewegung-reduziert .board-wrap svg { transition: none; }

.board-bg { fill: #1b2718; }
.flur { fill: #d8c8a4; stroke: #a89573; stroke-width: .6; }

.raum { fill: #3d2f22; stroke: var(--gold-dunkel); stroke-width: 1.4; }
.raum-bild { opacity: .92; }
.raum-schleier {
  fill: #0a0f1c; opacity: .38; pointer-events: none;
  transition: opacity var(--t-ruhig);
}
.raum-schleier.betreten { opacity: .05; }
.raum-schild { fill: rgba(9, 13, 24, .78); stroke: rgba(217,179,108,.5); stroke-width: .8; }
.raum-name {
  fill: var(--gold-hell); font-size: 11.5px; font-family: var(--schrift-titel);
  font-weight: bold; pointer-events: none; letter-spacing: .02em;
}
.gang-icon { color: var(--gold-hell); opacity: .8; pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.8)); }
.tuer { fill: var(--gold); }
.fallakte { fill: #10182a; stroke: var(--gold-dunkel); stroke-width: 1.4; }
.fallakte-icon { color: var(--gold); opacity: .65; pointer-events: none; }

.ziel-feld {
  fill: var(--gold); opacity: .45; cursor: pointer;
  transition: opacity var(--t-schnell);
  animation: pulsen 1.8s infinite ease-in-out;
}
/* animation: none ist noetig – eine laufende Animation auf opacity wuerde
   die Hover-/Fokuswerte sonst einfach ueberschreiben */
.ziel-feld:hover, .ziel-feld:focus-visible { animation: none; opacity: .9; outline: none; }
.ziel-feld:focus-visible { stroke: var(--gold-hell); stroke-width: 3; }
.ziel-raum {
  fill: var(--gold); opacity: .18; stroke: var(--gold-hell); stroke-width: 2.5;
  stroke-dasharray: 8 6; cursor: pointer;
  animation: pulsen 1.8s infinite ease-in-out;
}
.ziel-raum:hover, .ziel-raum:focus-visible { animation: none; opacity: .45; outline: none; }
.ziel-raum:focus-visible { stroke-width: 4; stroke-dasharray: none; }
@keyframes pulsen { 0%, 100% { opacity: .3; } 50% { opacity: .6; } }
@media (prefers-reduced-motion: reduce) {
  .ziel-feld, .ziel-raum { animation: none; }
}
:root.bewegung-reduziert .ziel-feld,
:root.bewegung-reduziert .ziel-raum { animation: none; }

.token { transition: transform var(--t-schnell); }
.token-ring { fill: none; stroke-width: 2.5; }
.token.am-zug .token-ring { stroke: var(--gold-hell); stroke-width: 3.5; filter: drop-shadow(0 0 6px rgba(242,217,160,.9)); }
.waffe-token { color: var(--gold-hell); filter: drop-shadow(0 1px 2px rgba(0,0,0,.9)); }

/* ---- Seitenleiste ---- */

.panel-titel {
  margin: 0 0 var(--sp-2); font-size: 12px; letter-spacing: .12em;
  color: var(--text-dim);
}

/* Doppelt so gross wie eine Spielerzeile, oben links: wer handelt, ist
   unübersehbar. */
.aktiv-card {
  --ring: var(--gold);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--gold-dunkel); border-radius: var(--r-3);
  padding: var(--sp-4); box-shadow: var(--sh-gold);
}
.aktiv-inhalt {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-3); text-align: center;
}
.aktiv-text { min-width: 0; width: 100%; }
.aktiv-name {
  font-family: var(--schrift-titel); font-size: 23px; color: var(--text);
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  overflow-wrap: anywhere;   /* lange Benutzernamen brechen um statt auszulaufen */
}
.aktiv-char { color: var(--gold); font-size: 15px; margin-top: 2px; }
.aktiv-status {
  color: var(--text-dim); font-size: 14px; margin-top: 6px;
  display: flex; align-items: center; justify-content: center; gap: var(--sp-1);
}

.spieler-panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-3); padding: var(--sp-3);
  flex: none;
}
.sp-row {
  --ring: var(--gold);
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--zeile); border: 1px solid transparent;
  border-radius: var(--r-2); padding: 7px 10px; margin-bottom: 7px;
  transition: border-color var(--t-normal), box-shadow var(--t-normal);
}
.sp-row:last-child { margin-bottom: 0; }
.sp-row.aktiv { border-color: var(--gold); box-shadow: 0 0 10px rgba(217,179,108,.25); }
.sp-row.raus { opacity: .5; }
.sp-row.raus .sp-name { text-decoration: line-through; }
.sp-info { min-width: 0; flex: 1; }
.sp-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-du  { color: var(--gold-hell); font-weight: 400; }
.sp-bot { color: var(--text-dim); font-weight: 400; }
.sp-status { font-size: 12px; color: var(--gold); display: flex; align-items: center; gap: var(--sp-1); }
.sp-pawn {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid rgba(0,0,0,.45); box-shadow: 0 0 5px rgba(0,0,0,.5);
}

.denkt { display: inline-flex; gap: 3px; align-items: center; }
.denkt i {
  width: 4px; height: 4px; border-radius: 50%; background: var(--gold);
  animation: denken 1.1s infinite ease-in-out;
}
.denkt i:nth-child(2) { animation-delay: .18s; }
.denkt i:nth-child(3) { animation-delay: .36s; }
@keyframes denken { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ---- Ermittlungen in der Seitenleiste ---- */

.ermittlungen {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-3); display: flex; flex-direction: column;
  min-height: 0; flex: 1; overflow: hidden;
}
.erm-tabs { display: flex; gap: 2px; padding: var(--sp-2); border-bottom: 1px solid var(--line); flex: none; }
.erm-tab {
  flex: 1; min-height: 38px; padding: 6px 8px; font-size: 13.5px;
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--text-dim);
}
.erm-tab.sel { color: var(--gold-hell); border-bottom-color: var(--gold); background: none; }
.erm-body { padding: var(--sp-3); overflow-y: auto; min-height: 120px; flex: 1; scrollbar-width: thin; }

.cardlist { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.ccard {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  border: 1px solid var(--line-hell); background: var(--creme); color: #241f18;
  padding: 5px 10px; border-radius: var(--r-1); font-size: 13.5px; font-weight: 600;
}
.ccard .icon { width: 18px; height: 18px; }
.ccard.person { box-shadow: inset 3px 0 0 #a33; }
.ccard.weapon { box-shadow: inset 3px 0 0 #776; }
.ccard.room   { box-shadow: inset 3px 0 0 #468; }
.ccard .from { color: #6b6357; font-weight: 400; font-size: 12px; }
.ccard-icon { color: #3a342c; }

.log { display: flex; flex-direction: column; gap: 2px; font-size: 13px; max-height: 44vh; overflow-y: auto; }
.log .entry { padding: 3px 6px; border-radius: var(--r-1); margin: 0; }
.log .entry.important { background: var(--panel-2); color: var(--gold-hell); }
.log .entry.turn { color: var(--gold); border-top: 1px solid var(--line); padding-top: 6px; margin-top: 4px; }
.log .entry.win { background: var(--erfolg-bg); color: #d8ffd8; }

/* ---- Handkarten: dauerhaft sichtbar ---- */

.handstrip.leer { display: none; }   /* ohne eigene Hand keine leere Leiste */
.handstrip {
  display: flex; align-items: center; gap: var(--sp-3);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--r-3);
  padding: var(--sp-2) var(--sp-3);
  overflow-x: auto; scrollbar-width: thin;
  position: relative;
  transition: transform .55s cubic-bezier(.3, .85, .3, 1.03), box-shadow .55s;
}

/* Zeigepflicht: die Leiste fliegt über die Brettmitte (Weg misst app.js) */
.handstrip.zeigt {
  z-index: 45;                        /* über Brett und Szenen, unter Modalen */
  flex-direction: column; align-items: center; gap: var(--sp-2);
  overflow: visible;
  border-color: var(--gold);
  box-shadow: 0 20px 55px rgba(0, 0, 0, .7), 0 0 0 2px rgba(217, 179, 108, .35);
}
.zeig-hinweis { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.zeig-hinweis strong { font-family: var(--schrift-titel); font-size: 17px; color: var(--gold-hell); }
.zeig-hinweis span { font-size: 13px; color: var(--text-dim); max-width: 560px; }

.spielkarte.passend {
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--gold), 0 6px 18px rgba(217, 179, 108, .4);
  transform: translateY(-2px);
  transition: transform var(--t-schnell), box-shadow var(--t-schnell);
}
.spielkarte.passend:hover, .spielkarte.passend:focus-visible {
  transform: translateY(-6px) scale(1.05); outline: none;
  box-shadow: 0 0 0 3px var(--gold-hell), 0 10px 26px rgba(217, 179, 108, .55);
}
.spielkarte.gedimmt { opacity: .32; filter: grayscale(.6); pointer-events: none; }

/* Auf schmalen Schirmen darf die Kartenreihe im Zeige-Modus umbrechen –
   overflow ist dort visible, seitliches Scrollen gaebe es nicht mehr */
.handstrip.zeigt .hand-cards { flex-wrap: wrap; justify-content: center; max-width: 100%; }

@media (prefers-reduced-motion: reduce) {
  .handstrip { transition: none; }
}
:root.bewegung-reduziert .handstrip { transition: none; }
.hand-label {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-dim); flex: none; writing-mode: vertical-rl;
  transform: rotate(180deg); text-align: center;
}
.hand-cards { display: flex; gap: var(--sp-2); }

/* Die Hand liegt als ECHTE Spielkarten aus (V6) – kompakt unter dem Brett,
   mit fettem Namen darunter; im Zeige-Modus groesser. Beim Austeilen
   erscheinen die Karten erst, wenn ihre Karte vom Stapel "ankommt". */
.hand-slot {
  display: inline-flex; flex-direction: column; align-items: center;
  gap: 3px; flex: none;
  transition: opacity .45s ease, transform .45s ease;
}
.hand-titel {
  font-weight: 700; font-size: 12.5px; line-height: 1.15;
  color: var(--gold-hell); text-align: center; max-width: 122px;
}
.hand-slot.gedimmt-slot .hand-titel { opacity: .4; }
.handstrip .hand-cards .spielkarte { width: 92px; }
.handstrip:not(.zeigt) .hand-cards .spielkarte:hover { transform: translateY(-4px); }
.handstrip .hand-cards .spielkarte { transition: transform var(--t-schnell); }
.handstrip.zeigt .hand-cards .spielkarte { width: 122px; }
.hand-cards .hand-slot.unverteilt {
  opacity: 0; transform: translateY(16px) scale(.92);
  pointer-events: none;
}

/* ---- Aktionsdock: senkrecht in der linken Spalte, direkt neben dem
       Brett – „Würfeln" ist damit immer ohne Scrollen erreichbar ---- */

.dock {
  display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-3);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--r-3);
  padding: var(--sp-3); box-shadow: var(--sh-2);
  /* flex: 1 streckt das Dock bis zum Spaltenende (Anklage unten). KEIN
     explizites min-height: Das wuerde die Min-Content-Untergrenze ersetzen,
     und bei niedrigen Fenstern quoellen die Knoepfe aus dem Rahmen, statt
     dass die Spalte scrollt. */
  flex: 1;
}
.dock-status { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-dim); min-width: 0; flex: none; }
.dock-status.ergebnis { color: var(--gold-hell); }
.dock-actions { display: flex; flex-direction: column; gap: var(--sp-2); }
.dock-accuse { margin-top: auto; }
.wuerfel-klein { display: inline-flex; gap: 4px; color: var(--creme); }
.wuerfel-klein .w-icon { width: 30px; height: 30px; }

/* ---- Notizblock: dauerhaft unter den Handkarten, drei Spalten ---- */

.notesdock {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-3); padding: var(--sp-1) var(--sp-3) var(--sp-2);
  transition: border-color var(--t-normal), box-shadow var(--t-normal);
}
.notesdock.leer { display: none; }
/* Notierphase: der Blick soll hierhin */
.notesdock.notieren {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(217, 179, 108, .35), 0 0 18px rgba(217, 179, 108, .2);
}
.notes-kopf { display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; }
.notes-kopf .panel-titel { margin-bottom: 4px; }
.notes-legende { font-size: 11.5px; color: var(--text-dim); }
.notes-spalten {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 var(--sp-4);
  align-items: start;
}

.notes-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.notes-table th {
  text-align: left; color: var(--gold); font-family: var(--schrift-titel);
  padding: 2px 4px; border-bottom: 1px solid var(--line); font-size: 11.5px;
}
.notes-table td { padding: 0 4px; border-bottom: 1px dotted #223050; vertical-align: middle; }
.notes-table td:first-child { display: flex; align-items: center; gap: 5px; min-height: 21px; }
.note-icon { width: 13px; height: 13px; color: var(--text-dim); }
.notes-table tr.hand td:first-child { color: var(--gold-hell); }
.notes-table td.mark {
  width: 36px; text-align: center; cursor: pointer; user-select: none;
  font-weight: 700; font-size: 13.5px; border-radius: var(--r-1);
}
.notes-table td.mark:hover { background: var(--panel-2); }
.notes-table td.mark:focus-visible { outline: 3px solid var(--gold-hell); outline-offset: -3px; }
.notes-table td.mark.sx { color: #ff9c8f; }
.notes-table td.mark.s\? { color: var(--gold-hell); }
.notes-table td.mark.s\! { color: #8ce09a; }
.notes-table td.mark.sleer { color: var(--text-dim); }

/* ---- Szenen über dem Brett ---- */

.scene {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0; transition: opacity var(--t-normal);
  z-index: var(--z-szene);
}
.scene.an { opacity: 1; }
.scene > * {
  background: rgba(10, 15, 28, .94); border: 1px solid var(--gold-dunkel);
  border-radius: var(--r-4); padding: var(--sp-5) var(--sp-6);
  box-shadow: var(--sh-3); text-align: center; max-width: 92%;
}

.turn-scene { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.turn-scene strong { font-size: 22px; font-family: var(--schrift-titel); color: var(--gold-hell); }

/* ---- Kartenverteilung zu Spielbeginn ---- */

.deal-scene { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); }
.deal-scene strong { font-family: var(--schrift-titel); font-size: 20px; color: var(--gold-hell); }
.deal-stapel { position: relative; width: 220px; height: 120px; }
.deal-karte {
  position: absolute; left: 50%; top: 8px; width: 60px; height: 84px;
  margin-left: -30px; border-radius: 7px;
  background: linear-gradient(135deg, #1b2a47, #101a30);
  background-image: url('graphics/cards/rueckseite.webp');
  background-size: cover; background-position: center;
  border: 1px solid var(--gold-dunkel); box-shadow: var(--sh-2);
  transition: transform .85s cubic-bezier(.3, .8, .4, 1), opacity .85s;
}
.deal-karte.flieg { transform: translateY(130px) rotate(7deg) scale(.82); opacity: 0; }

/* ---- Zugende-Countdown ---- */

.dock button.blinkt {
  animation: blinken .9s infinite ease-in-out;
  border-color: var(--gold);
}
@keyframes blinken {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 179, 108, 0); }
  50%      { box-shadow: 0 0 0 3px rgba(217, 179, 108, .55), 0 0 16px rgba(217, 179, 108, .4); background: var(--panel-2); }
}
@media (prefers-reduced-motion: reduce) {
  .dock button.blinkt { animation: none; border-color: var(--gold-hell); }
}
:root.bewegung-reduziert .dock button.blinkt { animation: none; border-color: var(--gold-hell); }

/* ---- 3D-Würfel ---- */

.dice-scene { display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); }
.dice-row { display: flex; gap: 44px; }

.w3d { width: 84px; height: 84px; perspective: 620px; }
.w3d-cube {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transform: rotateX(0deg) rotateY(0deg);
}
.w3d-face {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  border-radius: 14px;
  box-shadow: inset 0 0 10px rgba(0,0,0,.35);
  backface-visibility: hidden;
}
/* Anordnung der sechs Flächen (42px = halbe Kantenlänge) */
.w3d-f1 { transform: rotateY(  0deg) translateZ(42px); }
.w3d-f2 { transform: rotateY( 90deg) translateZ(42px); }
.w3d-f3 { transform: rotateX( 90deg) translateZ(42px); }
.w3d-f4 { transform: rotateX(-90deg) translateZ(42px); }
.w3d-f5 { transform: rotateY(-90deg) translateZ(42px); }
.w3d-f6 { transform: rotateY(180deg) translateZ(42px); }

.die-sum { font-family: var(--schrift-titel); font-size: 24px; color: var(--gold-hell); }

/* ---- Verdachtsszene mit Zimmerkulisse und Spielkarten ---- */

/* Waehrend der Verdachtsszene ist die Szenenebene anklickbar (Weiter) */
.scene.klickbar { pointer-events: auto; cursor: pointer; }

.sugg-scene { display: flex; flex-direction: column; gap: var(--sp-3); align-items: center; position: relative; overflow: hidden; }
.sugg-scene.mit-kulisse::before {
  content: ''; position: absolute; inset: 0;
  background-image: var(--kulisse); background-size: cover; background-position: center;
  opacity: .22; border-radius: inherit;
}
.sugg-scene > * { position: relative; }
.sugg-text { font-family: var(--schrift-titel); font-size: 19px; color: var(--text); margin: 0; }
.sugg-mark {
  color: var(--gold-hell); font-weight: 700;
  border-bottom: 2px solid var(--gold-dunkel); padding-bottom: 1px;
}
.sugg-karten {
  display: flex; gap: var(--sp-3); align-items: stretch; justify-content: center;
  flex-wrap: wrap;   /* auf schmalen Brettern umbrechen statt abschneiden */
  max-width: 100%;
}
.sugg-weiter { margin: 0; font-size: 12px; color: var(--text-dim); }

/* ---- Spielkarten im gelieferten Design ---- */

.spielkarte {
  position: relative; display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center; flex: none;
  width: 118px; border-radius: 8px; overflow: hidden;
  background: var(--creme); box-shadow: var(--sh-2);
  /* ALLE Karten exakt gleich hoch: Die Assets sind einheitlich 2:3
     aufbereitet, und die Box erzwingt das Verhaeltnis zusaetzlich – so
     bleibt jede Kartenreihe buendig, egal welche Quelle dahintersteckt. */
  aspect-ratio: 2 / 3;
}
.spielkarte img {
  width: 100%; height: 100%; object-fit: cover;
  display: block; border-radius: 8px;
}
.sk-titel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(9, 13, 24, .82); color: var(--gold-hell);
  font-family: var(--schrift-titel); font-size: 13px; font-weight: 700;
  text-align: center; padding: 3px 4px;
}
.spielkarte.ohne-bild {
  min-height: 150px; gap: 4px; color: #241f18; padding: var(--sp-2);
}
.sk-icon { width: 34px; height: 34px; color: #3a342c; }
.sk-name { font-weight: 700; font-size: 13px; text-align: center; }

/* ---- Modale ---- */

.overlay {
  position: fixed; inset: 0; background: rgba(6,9,17,.8);
  display: flex; align-items: center; justify-content: center;
  z-index: var(--z-overlay); padding: var(--sp-4);
}
.modal {
  background: var(--panel); border: 1px solid var(--gold-dunkel);
  border-radius: var(--r-4); padding: var(--sp-5);
  width: 560px; max-width: 96vw; max-height: 92vh; overflow-y: auto;
  box-shadow: var(--sh-3);
}
.modal.breit { width: 720px; }
.modal.schmal { width: 400px; text-align: center; }
.modal .sub { color: var(--text-dim); font-size: 14px; }
.pick-group { margin: var(--sp-4) 0; }
.pick-grid { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.pick-item {
  border: 2px solid var(--line); border-radius: var(--r-2); background: var(--inset);
  padding: 8px 14px; font-size: 14px;
}
.pick-item.mit-icon { gap: var(--sp-2); }
.pick-item:hover:not(:disabled) { border-color: var(--gold-dunkel); }
.pick-item.sel { border-color: var(--gold); background: var(--panel-2); color: var(--gold-hell); }
.pick-icon { width: 22px; height: 22px; color: var(--gold); }
.modal .mactions { display: flex; gap: var(--sp-2); margin-top: var(--sp-5); justify-content: flex-end; }
.warnbox {
  background: var(--gefahr-bg); border: 1px solid #8d4038; color: #ffd9d3;
  border-radius: var(--r-2); padding: var(--sp-3); font-size: 14px; margin-top: var(--sp-3);
}

/* Kartenenthüllung: Einblendung ueber dem Brett – der Notizblock darunter
   bleibt frei bedienbar */
.reveal-lage {
  position: absolute; inset: 0; padding: var(--sp-2);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0; transition: opacity var(--t-normal);
  z-index: calc(var(--z-szene) + 2);
}
.reveal-lage.an { pointer-events: auto; opacity: 1; }
.reveal-box {
  background: rgba(10, 15, 28, .96); border: 1px solid var(--gold-dunkel);
  border-radius: var(--r-4); padding: var(--sp-3) var(--sp-5);
  box-shadow: var(--sh-3); text-align: center; max-width: 92%;
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  /* Auf niedrigen Brettern (kleine Fenster) nicht ueber den Rand quellen */
  max-height: 100%; overflow-y: auto; scrollbar-width: thin;
}
.reveal-box h3 { margin: 0; }
.reveal-box .zeitstrahl { width: 100%; margin: 0; }
.reveal-box .flip { margin: var(--sp-1) auto; width: 186px; height: 260px; }
.flip-front.bild, .flip-back.bild { padding: 0; background: none; border: none; overflow: hidden; }
.flip-front.bild .spielkarte { width: 100%; height: 100%; box-shadow: none; }
.flip-front.bild .spielkarte img { height: 100%; object-fit: cover; }
.flip-back.bild img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--r-3); }

/* Notierfenster: grosser Hinweis, grosse Karten, Countdown, Bereit */
.notier-box { max-width: 96%; }
.notier-titel { font-size: 21px; color: var(--gold-hell); }
.notier-karten { display: flex; gap: var(--sp-3); justify-content: center; flex-wrap: wrap; max-width: 100%; }
.notier-karten .spielkarte { width: 150px; }
.notier-fuss { display: flex; align-items: center; gap: var(--sp-4); justify-content: center; flex-wrap: wrap; }
.notier-countdown { font-family: var(--schrift-titel); font-size: 20px; color: var(--gold-hell); min-width: 92px; }
.zeitstrahl-balken.statisch { animation: none; transform: none; width: 100%; }

/* Der Zeitstrahl läuft von rechts nach links ab (Ursprung links: die rechte
   Kante wandert nach links). Die letzten fünf Sekunden werden rot. */
.zeitstrahl {
  height: 10px; border-radius: 6px; overflow: hidden;
  background: var(--inset); border: 1px solid var(--line-hell);
  margin: 0 0 var(--sp-4);
}
.zeitstrahl-balken {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-hell));
  transform-origin: left center;
  animation: zeitablauf 15s linear forwards;
}
.zeitstrahl.endspurt .zeitstrahl-balken {
  background: linear-gradient(90deg, #c4574c, #e2837a);
}
/* Nutzer arbeitet im Dialog: Uhr angehalten, Auto-Schliessen abgeschaltet */
.zeitstrahl.pausiert { opacity: .45; }
.zeitstrahl.pausiert .zeitstrahl-balken { animation-play-state: paused; }
@keyframes zeitablauf { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Kartenenthüllung */
.flip { perspective: 900px; width: 190px; height: 250px; margin: var(--sp-4) auto; }
.flip-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform var(--t-ruhig) cubic-bezier(.4,.1,.3,1);
  transform-style: preserve-3d;
}
.flip.gedreht .flip-inner { transform: rotateY(180deg); }
.flip-back, .flip-front {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: var(--r-3); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--sp-2);
  box-shadow: var(--sh-2);
}
.flip-back { background: linear-gradient(135deg, #1b2a47, #101a30); border: 2px solid var(--gold-dunkel); color: var(--gold); }
.flip-back .icon { width: 64px; height: 64px; }
.flip-front { background: var(--creme); color: #241f18; border: 2px solid var(--gold-dunkel); transform: rotateY(180deg); }
.flip-front strong { font-size: 18px; }
.flip-icon { width: 62px; height: 62px; color: #3a342c; }

/* ---- Bestenliste ---- */

.stats-table { width: 100%; border-collapse: collapse; }
.stats-table th, .stats-table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); }
.stats-table th { color: var(--gold); font-family: var(--schrift-titel); }
.stats-table td.num, .stats-table th.num { text-align: right; }
.stats-table tr.top td { color: var(--gold-hell); font-weight: 700; }

/* ---- Benutzerverwaltung ---- */

button.klein { min-height: 32px; padding: 4px 10px; font-size: 12.5px; }
button.klein.aktiv-gruen { border-color: #2f6d4f; color: #b6f0c0; }
button.klein.aus { border-color: #8d4038; color: #ffb3a8; }
.stats-table tr.raus td { opacity: .55; }
.stats-table tr.raus td:first-child { text-decoration: line-through; }

/* ---- Toast ---- */

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--gefahr-bg); color: #ffd9d3; border: 1px solid #8d4038;
  padding: 12px 20px; border-radius: var(--r-2); z-index: var(--z-toast);
  max-width: 90vw; opacity: 0; transition: opacity var(--t-normal); pointer-events: none;
  box-shadow: var(--sh-3);
}
#toast.show { opacity: 1; }

/* =========================================================================
 * Tablet
 * ========================================================================= */
@media (max-width: 1150px) {
  .table-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
    grid-template-areas: "board" "hand" "notes" "aktion" "side";
    height: auto; min-height: auto;   /* gestapelt darf die Seite scrollen */
  }
  .aktion-spalte { overflow-y: visible; }
  .board-wrap { height: auto; }
  .board-wrap svg { max-height: 72vh; }
  .aktion-spalte { flex-direction: row; align-items: stretch; flex-wrap: wrap; }
  .aktion-spalte > * { flex: 1 1 300px; }
  .aktion-spalte .aktiv-card { height: 100%; }
  .side { flex-direction: row; flex-wrap: wrap; }
  .side > * { flex: 1 1 300px; }
  /* Fingerbedienung: groessere Trefferflaechen im Notizblock */
  .notes-table td:first-child { min-height: 32px; }
  .notes-table td.mark { width: 46px; font-size: 16px; }
}

/* =========================================================================
 * Smartphone
 * ========================================================================= */
@media (max-width: 720px) {
  .topbar { padding: var(--sp-2); gap: var(--sp-2); flex-wrap: wrap; }
  .topbar h1 { font-size: 16px; }
  .topbar .user { display: none; }
  .page { padding: var(--sp-3); }
  .card { padding: var(--sp-4); }

  .table-layout { padding: var(--sp-2); gap: var(--sp-2); padding-bottom: 96px; }
  .board-wrap { padding: 4px; }
  .board-wrap svg { max-height: none; }

  /* Am unteren Rand ist das Dock wieder eine waagrechte Leiste */
  .dock {
    position: fixed; left: 0; right: 0; bottom: 0; border-radius: 0;
    border-left: none; border-right: none; border-bottom: none;
    padding: var(--sp-2) var(--sp-3); z-index: var(--z-dock);
    flex-direction: row; align-items: center; flex-wrap: wrap; flex: none;
  }
  .dock-actions { flex-direction: row; flex-wrap: wrap; }
  .dock-accuse { margin-top: 0; margin-left: auto; }

  .aktion-spalte { flex-direction: column; }
  /* Die Tablet-Regel (flex-basis 300px) wuerde in der Spalte zur HOEHE */
  .aktion-spalte > * { flex: initial; }

  .notes-spalten { grid-template-columns: 1fr; }
  .spielkarte { width: 96px; }
  .handstrip .hand-cards .spielkarte { width: 68px; }
  .hand-titel { font-size: 10.5px; max-width: 76px; }

  .side { flex-direction: column; }
  /* Die Tablet-Regel (flex-basis 300px) wuerde in der Spalte zur HOEHE –
     hier zuruecksetzen, sonst werden alle Seitenpanels 300px hoch */
  .side > * { flex: initial; }

  .modal { padding: var(--sp-4); }
  .sugg-items { gap: var(--sp-3); }
  .sugg-icon .icon { width: 40px; height: 40px; }
  .sugg-raumbild { width: 56px; height: 56px; }
  .w3d { width: 64px; height: 64px; }
  .w3d-f1, .w3d-f2, .w3d-f3, .w3d-f4, .w3d-f5, .w3d-f6 { transform: none; }
  .w3d-f1 { transform: rotateY(  0deg) translateZ(32px); }
  .w3d-f2 { transform: rotateY( 90deg) translateZ(32px); }
  .w3d-f3 { transform: rotateX( 90deg) translateZ(32px); }
  .w3d-f4 { transform: rotateX(-90deg) translateZ(32px); }
  .w3d-f5 { transform: rotateY(-90deg) translateZ(32px); }
  .w3d-f6 { transform: rotateY(180deg) translateZ(32px); }
  .flip { width: 160px; height: 210px; }
}
