/**
 * Krimi-Deduktion: Haupt-Stylesheet (style.css)
 * 
 * Farbfrei & themenneutral: Alle Farb-, Schrift- und Texturdefinitionen
 * stammen aus ui-themes.css über semantische CSS-Variablen.
 */

:root {
  /* Raum- & Abstands-Tokens (8pt / 4pt Rhythmus) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* Typografische Hierarchie */
  --fs-xs: 0.6875rem; /* 11px */
  --fs-sm: 0.8125rem; /* 13px */
  --fs-md: 0.9375rem; /* 15px */
  --fs-lg: 1.125rem;  /* 18px */
  --fs-xl: 1.375rem;  /* 22px */

  /* Einheitliche Bedienelement-Höhen */
  --control-h: 32px;
  --control-h-lg: 42px;

  /* Übergänge & Animationen */
  --dur-fast: 120ms;
  --dur: 200ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  /* Dynamische Gittergröße (wird von app.js gesetzt) */
  --grid-size: 6;
}

/* ========================================================================= */
/* Basis & Reset                                                            */
/* ========================================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-ui);
  background-color: var(--surface-app);
  background-image: var(--texture);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--accent-select);
  outline-offset: 2px;
}

.label-caps {
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-faint);
}

/* Feste Icon-Box für gleichmäßige Höhen & Baselines */
.icon {
  display: inline-grid;
  place-items: center;
  width: 1.25em;
  height: 1.25em;
  line-height: 1;
  flex-shrink: 0;
}

/* ========================================================================= */
/* Buttons                                                                  */
/* ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  height: var(--control-h);
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--fs-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
  user-select: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background-color: var(--accent-select);
  color: var(--text-on-accent);
  border-color: var(--accent-select);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background-color: var(--accent-select-hover);
  border-color: var(--accent-select-hover);
}

.btn-secondary {
  background-color: var(--surface-sunken);
  border-color: var(--line);
  color: var(--text);
}

.btn-secondary:hover {
  background-color: var(--surface-raised);
  border-color: var(--line-strong);
}

.btn-outline {
  background-color: transparent;
  border-color: var(--line);
  color: var(--text-soft);
}

.btn-outline:hover {
  background-color: var(--surface-raised);
  border-color: var(--line-strong);
  color: var(--text);
}

.btn-large {
  height: var(--control-h-lg);
  padding: 0 var(--space-4);
  font-size: var(--fs-md);
}

.btn-small {
  height: 26px;
  padding: 0 var(--space-2);
  font-size: var(--fs-xs);
}

.btn-icon-only {
  width: var(--control-h);
  padding: 0;
}

/* ========================================================================= */
/* Header                                                                    */
/* ========================================================================= */
.app-header {
  background-color: var(--surface-panel);
  border-bottom: 1px solid var(--line);
  padding: var(--space-2) var(--space-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow: hidden;
}

.game-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--accent-select);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-tag {
  display: inline-block;
  background-color: var(--accent-select-bg);
  color: var(--accent-select);
  border: 1px solid var(--accent-select-border);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}

.game-subtitle {
  font-family: var(--font-story);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--text-soft);
  display: none;
  white-space: nowrap;
}

.header-right {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-shrink: 0;
}

.btn-header {
  padding: 0 var(--space-2);
}

.btn-header .btn-text {
  display: none;
}

/* ========================================================================= */
/* Haupt-Spielfläche (Container)                                             */
/* ========================================================================= */
.game-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ========================================================================= */
/* Floorplan-Panel (Oberer Bereich mobile, Rechte Spalte Desktop)            */
/* ========================================================================= */
.floorplan-panel {
  display: flex;
  flex-direction: column;
  padding: var(--space-2);
  align-items: center;
  gap: var(--space-2);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Toolbar mit Modus- und Theme-Segmenten */
.board-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: var(--board-w, 580px);
  background-color: var(--surface-panel);
  border: 1px solid var(--line);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  gap: var(--space-2);
}

.tool-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.mode-segmented-control,
.theme-segmented-control {
  display: inline-flex;
  align-items: center;
  background-color: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
  height: var(--control-h);
}

.mode-btn,
.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  height: calc(var(--control-h) - 6px);
  padding: 0 var(--space-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-sm) - 1px);
  color: var(--text-soft);
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
  user-select: none;
}

.mode-btn:hover,
.theme-btn:hover {
  color: var(--text);
  background-color: var(--surface-raised);
}

.mode-btn.active,
.theme-btn.active {
  background-color: var(--surface-raised);
  color: var(--text);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

#mode-place-btn.active {
  background-color: var(--accent-select-bg);
  color: var(--accent-select);
  border-color: var(--accent-select-border);
}

#mode-note-btn.active {
  background-color: var(--accent-info-bg);
  color: var(--accent-info);
  border-color: var(--accent-info-border);
}

#mode-cross-btn.active {
  background-color: var(--accent-danger-bg);
  color: var(--accent-danger);
  border-color: var(--accent-danger-border);
}

/* ========================================================================= */
/* Spielfeld (Board Grid) & Grundriss                                        */
/* ========================================================================= */
.grid-outer-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.board-grid {
  --tile-size: calc((100vw - 20px) / var(--grid-size));
  --board-w: calc(var(--tile-size) * var(--grid-size) + 6px);
  display: grid;
  grid-template-columns: repeat(var(--grid-size), var(--tile-size));
  grid-template-rows: repeat(var(--grid-size), var(--tile-size));
  gap: 0;
  background-color: var(--surface-card);
  border: 3px solid var(--board-frame);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  touch-action: manipulation;
  width: var(--board-w);
  height: var(--board-w);
  user-select: none;
  -webkit-user-select: none;
}

/* Kacheln (Tiles) */
.grid-tile {
  width: var(--tile-size);
  height: var(--tile-size);
  background-color: var(--surface-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
  box-shadow: inset 0 0 0 0.5px var(--board-grid-line);
  transition: background-color var(--dur-fast) var(--ease);
}

.grid-tile:hover {
  background-color: var(--accent-select-bg);
}

/* Raumtönungen */
.room-0 { background-color: var(--room-0); }
.room-1 { background-color: var(--room-1); }
.room-2 { background-color: var(--room-2); }
.room-3 { background-color: var(--room-3); }
.room-4 { background-color: var(--room-4); }
.room-5 { background-color: var(--room-5); }

/* Raumwände als Pseudo-Element: verändert NICHT die Innenabmessungen */
.grid-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.grid-tile.wall-top::before {
  border-top: var(--board-wall-width) solid var(--board-wall);
}
.grid-tile.wall-bottom::before {
  border-bottom: var(--board-wall-width) solid var(--board-wall);
}
.grid-tile.wall-left::before {
  border-left: var(--board-wall-width) solid var(--board-wall);
}
.grid-tile.wall-right::before {
  border-right: var(--board-wall-width) solid var(--board-wall);
}

/* Raumnamen-Etikett in der oberen linken Kachelecke */
.room-name-tag {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: clamp(8px, calc(var(--tile-size) * 0.13), 11px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--room-label);
  pointer-events: none;
  z-index: 2;
  line-height: 1;
}

/* Landmarken (Blockierend) */
.grid-tile.has-landmark {
  cursor: not-allowed;
  background: var(--landmark-hatch);
}

.landmark-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.landmark-icon {
  font-size: clamp(1.3rem, calc(var(--tile-size) * 0.44), 2.4rem);
  line-height: 1;
}

.landmark-label {
  font-size: clamp(8px, calc(var(--tile-size) * 0.13), 11px);
  color: var(--text-soft);
  text-align: center;
  margin-top: 2px;
  line-height: 1.1;
  max-width: 95%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Begehbare Möbel */
.furniture-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  transition: opacity var(--dur-fast) var(--ease);
}

.furniture-icon {
  font-size: clamp(1.3rem, calc(var(--tile-size) * 0.44), 2.4rem);
  line-height: 1;
}

.furniture-label {
  font-size: clamp(8px, calc(var(--tile-size) * 0.13), 11px);
  color: var(--text-soft);
  text-align: center;
  margin-top: 2px;
  line-height: 1.1;
  max-width: 95%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.furniture-watermark {
  position: absolute;
  font-size: clamp(1.3rem, calc(var(--tile-size) * 0.44), 2.4rem);
  line-height: 1;
  opacity: 0.2;
  pointer-events: none;
  z-index: 1;
}

/* Möbel-Badge bei belegtem Feld: Unten rechts (keine Überlappung mit Raumname oben links) */
.furniture-occupied-badge {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: clamp(9px, calc(var(--tile-size) * 0.18), 14px);
  line-height: 1;
  pointer-events: none;
  z-index: 3;
}

.grid-tile.crossed .furniture-content,
.grid-tile.manual-crossed .furniture-content {
  opacity: 0.35;
}

/* Platzierte Figur & Kachel */
.grid-tile.has-placed-suspect {
  box-shadow: inset 0 0 0 0.5px var(--board-grid-line),
              inset 0 0 0 2px var(--accent-select) !important;
}

.token-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 2;
}

.person-token {
  font-size: clamp(1.5rem, calc(var(--tile-size) * 0.5), 2.6rem);
  line-height: 1;
  filter: drop-shadow(var(--shadow-sm));
  animation: popIn 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.person-token-label {
  font-size: clamp(8px, calc(var(--tile-size) * 0.14), 11px);
  font-weight: 700;
  color: var(--token-label-text);
  background-color: var(--token-label-bg);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  margin-top: 1px;
  max-width: 92%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  line-height: 1.1;
  box-shadow: var(--shadow-sm);
}

/* Notiz-Kandidaten (3x3 Raster) */
.tile-candidates {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 90%;
  height: 90%;
  align-items: center;
  justify-items: center;
  pointer-events: none;
  position: relative;
  z-index: 2;
  gap: 1px;
}

.candidate-note {
  font-size: clamp(9px, calc(var(--tile-size) * 0.22), 14px);
  line-height: 1;
  width: clamp(14px, calc(var(--tile-size) * 0.28), 20px);
  height: clamp(14px, calc(var(--tile-size) * 0.28), 20px);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface-sunken);
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-info-border);
}

/* Sperrkreuze: Auto-X und Manuell-X */
.grid-tile.crossed {
  cursor: default;
}

.grid-tile.crossed::after {
  content: '✕';
  position: absolute;
  font-size: clamp(1.4rem, calc(var(--tile-size) * 0.45), 2.2rem);
  font-weight: 300;
  color: var(--x-auto);
  pointer-events: none;
  z-index: 2;
}

.grid-tile.manual-crossed::after {
  content: '✕';
  position: absolute;
  font-size: clamp(1.4rem, calc(var(--tile-size) * 0.45), 2.2rem);
  font-weight: 800;
  color: var(--x-manual);
  pointer-events: none;
  z-index: 2;
}

@keyframes popIn {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========================================================================= */
/* Ermittlungs-Leitfaden / Walkthrough Panel                                 */
/* ========================================================================= */
.walkthrough-panel {
  width: 100%;
  max-width: var(--board-w, 580px);
  background-color: var(--surface-panel);
  border: 1px solid var(--accent-info-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  box-shadow: var(--shadow-sm);
}

.walkthrough-panel.hidden {
  display: none !important;
}

.walkthrough-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.walkthrough-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--accent-info);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.walkthrough-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.step-indicator {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-faint);
  min-width: 65px;
  text-align: center;
}

.walkthrough-close-btn {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: var(--fs-md);
  cursor: pointer;
  padding: 2px var(--space-1);
  border-radius: var(--radius-sm);
  line-height: 1;
}

.walkthrough-close-btn:hover {
  color: var(--text);
  background-color: var(--surface-sunken);
}

.walkthrough-content {
  font-size: var(--fs-sm);
  line-height: 1.45;
  background-color: var(--surface-sunken);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-info);
}

.nudge-text {
  color: var(--text);
  font-weight: 500;
}

.explanation-text {
  margin-top: var(--space-1);
  color: var(--text-soft);
  font-size: var(--fs-sm);
  border-top: 1px dashed var(--line);
  padding-top: var(--space-1);
}

.explanation-text.hidden {
  display: none;
}

/* Hinweismarkierungen auf dem Brett */
.grid-tile.hint-focus {
  outline: 3px solid var(--accent-select);
  outline-offset: -3px;
  animation: pulseFocus 1.4s infinite ease-in-out;
  z-index: 6;
}

.grid-tile.hint-eliminated {
  background-color: var(--accent-danger-bg) !important;
}

@keyframes pulseFocus {
  0%, 100% { outline-color: var(--accent-select); }
  50% { outline-color: var(--surface-raised); }
}

/* ========================================================================= */
/* Hinweiskarten (Cards Panel)                                               */
/* ========================================================================= */
.cards-panel {
  background-color: var(--surface-panel);
  border-top: 1px solid var(--line);
  padding: var(--space-2) var(--space-3);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  max-height: 38vh;
  overflow: hidden;
}

.panel-header {
  margin-bottom: var(--space-2);
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--text);
  margin-bottom: 2px;
}

.panel-help {
  font-size: var(--fs-xs);
  color: var(--text-soft);
}

/* Karussell (Mobile) */
.cards-list {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
  gap: var(--space-2);
  padding: 2px 2px var(--space-2) 2px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}

.cards-list::-webkit-scrollbar {
  height: 5px;
  width: 5px;
}

.cards-list::-webkit-scrollbar-thumb,
.cards-panel::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--radius-pill);
}

/* Einzelne Hinweiskarte */
.clue-card {
  background-color: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
  position: relative;
  min-width: min(270px, 80vw);
  max-width: min(270px, 80vw);
  flex-shrink: 0;
  user-select: none;
  scroll-snap-align: start;
}

.clue-card:hover {
  border-color: var(--accent-select);
  background-color: var(--surface-raised);
}

.clue-card.selected {
  border-color: var(--accent-select);
  background-color: var(--surface-raised);
  box-shadow: 0 0 0 2px var(--accent-select-border), var(--shadow-sm);
}

.clue-card.placed {
  border-color: var(--accent-success-border);
}

.clue-card.is-victim {
  border-left: 4px solid var(--accent-danger);
}

.clue-card.hint-active-card {
  border-color: var(--accent-info);
  background-color: var(--accent-info-bg);
  box-shadow: 0 0 0 2px var(--accent-info-border);
}

/* Kartenkopf: Avatar, Name & Status im sauberen Flex-Fluss */
.card-header-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.card-avatar {
  font-size: 1.5rem;
  line-height: 1;
}

.card-meta {
  flex: 1;
  min-width: 0;
}

.card-name {
  font-weight: 700;
  font-size: var(--fs-md);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-role {
  font-size: var(--fs-xs);
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-status-slot {
  display: none;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.clue-card.placed .card-status-slot {
  display: inline-flex;
}

.placed-status-tag {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--accent-success);
  background-color: var(--accent-success-bg);
  border: 1px solid var(--accent-success-border);
  padding: 1px var(--space-1);
  border-radius: var(--radius-sm);
}

.card-unplace-btn {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--accent-danger);
  background-color: var(--accent-danger-bg);
  border: 1px solid var(--accent-danger-border);
  padding: 1px var(--space-1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  line-height: 1;
  transition: background-color var(--dur-fast) var(--ease);
}

.card-unplace-btn:hover {
  background-color: var(--accent-danger);
  color: var(--text-on-accent);
}

/* Neutrale Regel-Badges */
.rule-badge-box {
  background-color: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
}

.rule-badge-box.victim-badge {
  background-color: var(--accent-danger-bg);
  border-color: var(--accent-danger-border);
}

.rule-icon {
  font-size: var(--fs-sm);
}

.rule-text {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text);
}

.card-story-quote {
  font-family: var(--font-story);
  font-style: italic;
  font-size: var(--fs-xs);
  color: var(--text-soft);
  line-height: 1.35;
  border-left: 2px solid var(--line-strong);
  padding-left: var(--space-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ========================================================================= */
/* Solve Action Bar (Footer)                                                 */
/* ========================================================================= */
.solve-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background-color: var(--surface-panel);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.progress-status {
  font-size: var(--fs-sm);
  color: var(--text);
}

.progress-status strong {
  color: var(--accent-select);
  font-size: var(--fs-md);
}

/* ========================================================================= */
/* Desktop- & Tablet-Layout (min-width: 768px)                              */
/* ========================================================================= */
@media (min-width: 768px) {
  body {
    height: 100vh;
    overflow: hidden;
  }

  .app-header {
    padding: var(--space-2) var(--space-5);
  }

  .game-title {
    font-size: 1.3rem;
  }

  .game-subtitle {
    display: inline;
  }

  .btn-header .btn-text {
    display: inline;
  }

  .game-container {
    display: grid;
    grid-template-columns: 360px 1fr;
    grid-template-rows: 1fr auto;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  /* Linke Spalte: Hinweiskarten */
  .cards-panel {
    grid-column: 1;
    grid-row: 1 / 3;
    border-top: none;
    border-right: 1px solid var(--line);
    max-height: none;
    height: 100%;
    min-height: 0;
    padding: var(--space-4);
    overflow-y: auto;
    scroll-snap-type: none;
  }

  .cards-list {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: visible;
    gap: var(--space-3);
    padding: 0;
    scroll-snap-type: none;
  }

  .clue-card {
    min-width: 0;
    max-width: none;
    padding: var(--space-3);
  }

  .card-story-quote {
    -webkit-line-clamp: 4;
  }

  /* Rechte Spalte: Floorplan & Spielbrett */
  .floorplan-panel {
    grid-column: 2;
    grid-row: 1;
    padding: var(--space-3) var(--space-4);
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    justify-content: flex-start;
  }

  .board-grid {
    --tile-size: min(84px, calc((100vh - 220px) / var(--grid-size)), calc((100vw - 440px) / var(--grid-size)));
    --board-w: calc(var(--tile-size) * var(--grid-size) + 6px);
    width: var(--board-w);
    height: var(--board-w);
  }

  .solve-action-bar {
    grid-column: 2;
    grid-row: 2;
    max-width: var(--board-w, 580px);
    margin: 0 auto;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border: 1px solid var(--line);
    border-bottom: none;
    padding: var(--space-2) var(--space-4);
  }
}

/* ========================================================================= */
/* Modals (Fallakten, Regeln, Sieg)                                          */
/* ========================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-card {
  background-color: var(--surface-panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 92%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-pop);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--accent-select);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  width: var(--control-h);
  height: var(--control-h);
  display: inline-grid;
  place-items: center;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
  background-color: var(--surface-sunken);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  line-height: 1.5;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.rule-explainer {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.rule-icon-box {
  font-size: 1.6rem;
  line-height: 1;
}

.rule-explainer h4 {
  font-size: var(--fs-md);
  color: var(--text);
  margin-bottom: 2px;
}

.rule-explainer p {
  font-size: var(--fs-sm);
  color: var(--text-soft);
}

/* Sieg-Modal */
.modal-victory-card .victory-header {
  flex-direction: column;
  text-align: center;
  border-bottom: none;
}

.victory-icon {
  font-size: 2.8rem;
  margin-bottom: var(--space-2);
}

.killer-reveal-box {
  background-color: var(--accent-select-bg);
  border: 1px solid var(--accent-select-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--accent-select);
  margin-top: var(--space-2);
}

/* Fallakten-Katalog Modal */
.modal-cases-card {
  max-width: 760px;
}

.modal-cases-intro {
  font-size: var(--fs-sm);
  color: var(--text-soft);
  margin-bottom: var(--space-2);
}

.cases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
  overflow-y: auto;
  padding-right: var(--space-1);
}

.case-select-card {
  background-color: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.case-select-card:hover {
  border-color: var(--accent-select);
  background-color: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.case-select-card.is-active {
  border-color: var(--accent-select);
  background-color: var(--accent-select-bg);
}

.case-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
}

.case-card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--accent-select);
  font-weight: 700;
  line-height: 1.25;
}

.case-card-subtitle {
  font-family: var(--font-story);
  font-style: italic;
  font-size: var(--fs-xs);
  color: var(--text-soft);
}

.case-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.case-badge {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.case-badge.diff-leicht {
  background-color: var(--accent-success-bg);
  color: var(--accent-success);
  border: 1px solid var(--accent-success-border);
}

.case-badge.diff-normal {
  background-color: var(--accent-select-bg);
  color: var(--accent-select);
  border: 1px solid var(--accent-select-border);
}

.case-badge.diff-schwer {
  background-color: var(--accent-danger-bg);
  color: var(--accent-danger);
  border: 1px solid var(--accent-danger-border);
}

.case-badge.badge-size {
  background-color: var(--surface-sunken);
  color: var(--text-soft);
  border: 1px solid var(--line);
}

.case-badge.badge-active {
  background-color: var(--accent-select);
  color: var(--text-on-accent);
}

.case-badge.badge-solved {
  background-color: var(--accent-info-bg);
  color: var(--accent-info);
  border: 1px solid var(--accent-info-border);
}

.case-card-meta {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: var(--space-2);
  margin-top: auto;
}

.case-card-meta strong {
  color: var(--text-soft);
}