:root {
  --bg-deep: #f4f0e8;
  --bg-panel: #fffdf9;
  --bg-scene: #e8e2d6;
  --bg-cell: #faf7f2;
  --bg-cell-hover: #f0ebe2;
  --border: rgba(44, 36, 32, 0.14);
  --border-strong: rgba(44, 36, 32, 0.28);
  --text: #1a1614;
  --text-muted: #524b44;
  --text-placeholder: rgba(26, 22, 20, 0.28);
  --accent: #7a1f2b;
  --accent-bright: #8b1f2f;
  --accent-link: #7a1f2b;
  --accent-dim: #5c1720;
  --accent-soft: rgba(139, 31, 47, 0.1);
  --gold: #9a7b4f;
  --gold-text: #5c4520;
  --gold-soft: #f3ead8;
  --badge-bg: #f3ead8;
  --badge-text: #5c4520;
  --danger: #9f1f18;
  --success: #145a3a;
  --success-text: #145a3a;
  --victim: #452d66;
  --victim-text: #452d66;
  --victim-soft: rgba(69, 45, 102, 0.1);
  --btn-primary-bg: #8b1f2f;
  --btn-primary-text: #ffffff;
  --focus-ring: #8b1f2f;
  --focus-ring-offset: #fffdf9;
  --text-min: 0.875rem;
  --shadow: 0 1px 2px rgba(26, 22, 20, 0.04), 0 8px 24px rgba(26, 22, 20, 0.06);
  --shadow-lg: 0 4px 12px rgba(26, 22, 20, 0.06), 0 24px 48px rgba(26, 22, 20, 0.1);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --font-serif: "Crimson Pro", Georgia, serif;
  --font-ui: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --prop-color: #1a1614;
  --grid-gap: #1a1614;
  --cell-max: 108px;
  --surface-card: #ffffff;
  --surface-input: #ffffff;
  --surface-muted: #f8f5ef;
  --header-bg: rgba(255, 253, 249, 0.92);
  --room-edge: #1a1614;
  --modal-backdrop: rgba(244, 240, 232, 0.78);
  --highlight: rgba(139, 31, 47, 0.5);
  --highlight-fill: rgba(139, 31, 47, 0.08);
  --line-block: #1a1614;
  --line-block-fill: rgba(26, 22, 20, 0.06);
  --user-mark-fill: rgba(82, 75, 68, 0.1);
  --user-mark-line: rgba(82, 75, 68, 0.58);
  --placed-bg: rgba(20, 90, 58, 0.1);
  --placed-border: rgba(20, 90, 58, 0.45);
  --selected-bg: rgba(139, 31, 47, 0.06);
  --token-bg: #ffffff;
  --token-shadow: rgba(26, 22, 20, 0.12);
  --label-bg: rgba(255, 255, 255, 0.96);
  --label-border: rgba(26, 22, 20, 0.2);
  --theme-track: rgba(44, 36, 32, 0.16);
  --theme-thumb: #ffffff;
  --transition-theme: background-color 0.28s ease, color 0.28s ease, border-color 0.28s ease,
    box-shadow 0.28s ease;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg-deep: #0e0d0c;
  --bg-panel: #1a1816;
  --bg-scene: #121110;
  --bg-cell: #22201d;
  --bg-cell-hover: #2a2724;
  --border: rgba(245, 240, 232, 0.14);
  --border-strong: rgba(245, 240, 232, 0.24);
  --text: #f5f0e8;
  --text-muted: #c4bdb3;
  --text-placeholder: rgba(245, 240, 232, 0.32);
  --accent: #c23a50;
  --accent-bright: #e8707f;
  --accent-link: #e8707f;
  --accent-dim: #9b2335;
  --accent-soft: rgba(232, 112, 127, 0.14);
  --gold: #c4a574;
  --gold-text: #d4b87a;
  --gold-soft: #3d3528;
  --badge-bg: #3d3528;
  --badge-text: #d4b87a;
  --danger: #ef6b5f;
  --success: #3d9b72;
  --success-text: #6bc497;
  --victim: #b9a0e8;
  --victim-text: #b9a0e8;
  --victim-soft: rgba(185, 160, 232, 0.14);
  --btn-primary-bg: #a83245;
  --btn-primary-text: #ffffff;
  --focus-ring: #e8707f;
  --focus-ring-offset: #1a1816;
  --prop-color: #f5f0e8;
  --grid-gap: #0a0908;
  --surface-card: #1f1d1b;
  --surface-input: #242220;
  --surface-muted: #161412;
  --header-bg: rgba(26, 24, 22, 0.92);
  --room-edge: #f5f0e8;
  --modal-backdrop: rgba(14, 13, 12, 0.82);
  --highlight: rgba(232, 112, 127, 0.58);
  --highlight-fill: rgba(232, 112, 127, 0.12);
  --line-block: #f5f0e8;
  --line-block-fill: rgba(245, 240, 232, 0.08);
  --user-mark-fill: rgba(196, 189, 179, 0.12);
  --user-mark-line: rgba(196, 189, 179, 0.55);
  --placed-bg: rgba(61, 155, 114, 0.14);
  --placed-border: rgba(61, 155, 114, 0.5);
  --selected-bg: rgba(232, 112, 127, 0.12);
  --token-bg: #2a2724;
  --token-shadow: rgba(0, 0, 0, 0.35);
  --label-bg: rgba(34, 32, 29, 0.96);
  --label-border: rgba(245, 240, 232, 0.18);
  --theme-track: rgba(245, 240, 232, 0.18);
  --theme-thumb: #f5f0e8;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.app {
  width: 100%;
  margin: 0 auto;
  padding: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  transition: var(--transition-theme);
}

.brand-logo {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: none;
}

.brand-fre {
  color: var(--text);
  font-style: normal;
}

.brand-doku {
  color: var(--accent-bright);
  font-style: italic;
}

.tagline {
  margin: 0.45rem 0 0;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 3vw, 2rem);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: var(--transition-theme);
}

.header-brand h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text);
}

.header-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.settings-menu {
  position: relative;
  display: inline-flex;
}

.settings-menu-btn {
  gap: 0.45rem;
}

.settings-menu-panel {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  z-index: 60;
  min-width: 16rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  padding: 0.85rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
}

.settings-menu-panel[hidden] {
  display: none;
}

.settings-menu-panel .seed-badge {
  align-self: stretch;
  text-align: center;
}

.settings-menu-panel .language-switcher,
.settings-menu-panel .theme-toggle {
  width: 100%;
}

.settings-menu-panel .language-switcher {
  justify-content: center;
}

.settings-menu-panel .theme-toggle {
  justify-content: space-between;
}

.howto-btn {
  gap: 0.45rem;
}

.howto-lead {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

.howto-modal {
  z-index: 110;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.howto-modal-content {
  display: flex;
  flex-direction: column;
  max-width: min(32rem, 100%);
  max-height: min(90dvh, 100%);
  padding: 0;
  text-align: left;
  overflow: hidden;
}

.howto-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  padding: 1.35rem 1.35rem 0.75rem;
}

.howto-modal-header h2 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  text-align: left;
}

.howto-modal-x {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin: -0.25rem -0.25rem 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-cell);
  color: var(--text-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition-theme);
}

.howto-modal-x:hover,
.howto-modal-x:focus-visible {
  color: var(--text);
  border-color: var(--accent-bright);
  outline: none;
}

.howto-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 1.35rem 1rem;
  -webkit-overflow-scrolling: touch;
}

.howto-modal-body .rules-box {
  margin-top: 0.65rem;
}

.howto-modal-actions {
  flex-shrink: 0;
  padding: 0.75rem 1.35rem 1.35rem;
  border-top: 1px solid var(--border);
}

body.howto-modal-open {
  overflow: hidden;
}

.header-end {
  position: absolute;
  top: 0.9rem;
  right: clamp(1rem, 3vw, 2rem);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.language-switcher {
  display: inline-flex;
  align-items: stretch;
  gap: 0.15rem;
  padding: 0.2rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface-input);
  font-family: var(--font-ui);
}

.language-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 34px;
  padding: 0.3rem 0.7rem;
  border: 0;
  border-radius: calc(var(--radius-pill) - 2px);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: var(--text-min);
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition-theme);
}

.language-btn:hover {
  color: var(--text);
}

.language-btn.is-active,
.language-btn[aria-pressed="true"] {
  background: var(--bg-panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.language-btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.language-flag {
  width: 1.35rem;
  height: 0.9rem;
  flex-shrink: 0;
  display: block;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.language-code {
  letter-spacing: 0.04em;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  padding: 0.45rem 0.55rem 0.45rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--text-min);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  transition: var(--transition-theme), transform 0.12s ease;
}

.theme-toggle:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.theme-toggle-track {
  position: relative;
  width: 2.4rem;
  height: 1.35rem;
  border-radius: var(--radius-pill);
  background: var(--theme-track);
  flex-shrink: 0;
  transition: var(--transition-theme);
}

.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: var(--theme-thumb);
  box-shadow: 0 1px 3px var(--token-shadow);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), var(--transition-theme);
}

.theme-toggle[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(1.05rem);
}

.theme-toggle-text-light {
  color: var(--text);
}

.theme-toggle-text-dark {
  color: var(--text);
}

.theme-toggle:not([data-theme="dark"]) .theme-toggle-text-dark {
  display: none;
}

.theme-toggle[data-theme="dark"] .theme-toggle-text-light {
  display: none;
}

.theme-toggle-compact {
  padding: 0.4rem 0.5rem 0.4rem 0.55rem;
  font-size: var(--text-min);
}

.btn {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 700;
  min-height: 2.75rem;
  padding: 0.65rem 1.35rem;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease,
    transform 0.12s ease, box-shadow 0.18s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  box-shadow: 0 2px 8px rgba(139, 31, 47, 0.28);
}

.btn-primary:hover {
  background: var(--accent-dim);
  box-shadow: 0 4px 14px rgba(139, 31, 47, 0.32);
}

.btn-bold {
  padding: 0.7rem 1.45rem;
  font-size: 1rem;
}

.btn-secondary {
  background: transparent;
  color: var(--accent-link);
  border: 2px solid var(--accent-link);
}

.btn-secondary:hover {
  background: var(--accent-soft);
}

.btn-xl {
  font-size: 1.05rem;
  padding: 0.95rem 2rem;
  min-width: 11rem;
}

.btn-ghost {
  background: var(--surface-card);
  color: var(--text);
  border: 2px solid var(--border-strong);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-cell-hover);
}

.page-play {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(155, 35, 53, 0.06), transparent 60%),
    var(--bg-deep);
}

body.case-loading .page-play .app {
  visibility: hidden;
}

.case-loader {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--modal-backdrop);
  backdrop-filter: blur(6px);
}

.case-loader[hidden] {
  display: none;
}

.case-loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  max-width: 22rem;
  padding: 2rem 2.25rem;
  text-align: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.case-loader-spinner {
  width: 2.75rem;
  height: 2.75rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: case-loader-spin 0.85s linear infinite;
}

.case-loader-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.case-loader-subtitle {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.case-loader-progress {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
}

.case-loader-progress-track {
  width: 100%;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--bg-cell);
  border: 1px solid var(--border);
  overflow: hidden;
}

.case-loader-progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #c44d5e);
  transition: width 0.25s ease;
}

.case-loader-percent {
  margin: 0;
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.case-loader-back {
  margin-top: 0.35rem;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
}

.case-loader-back:hover {
  color: var(--accent);
  text-decoration: underline;
}

@keyframes case-loader-spin {
  to {
    transform: rotate(360deg);
  }
}

[data-theme="dark"] body.page-play {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(212, 90, 107, 0.08), transparent 60%),
    var(--bg-deep);
}

.page-play .app {
  height: 100vh;
  max-height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.play-header {
  flex-shrink: 0;
  margin: 0;
}

.play-header .header-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}

.case-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 2.5vw, 1.9rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  line-height: 1.2;
}

.case-tagline {
  margin: 0.2rem 0 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.play-main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(260px, 22vw) 1fr;
  gap: 0;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 900px) {
  .page-play .app {
    height: auto;
    min-height: 100dvh;
    max-height: none;
    overflow: visible;
  }

  .play-main {
    grid-template-columns: 1fr;
    overflow: visible;
    align-content: start;
  }

  .play-grid-section {
    order: -1;
    min-height: auto;
    flex: none;
    padding: 0.5rem 0 1rem;
    overflow: visible;
  }

  .play-sidebar {
    order: 0;
    max-height: none;
    border-right: none;
    border-bottom: none;
    border-top: 2px solid var(--border);
    overflow: visible;
  }

  .grid-body {
    flex-direction: column;
    overflow: visible;
    flex: none;
  }

  .grid-wrapper {
    width: 100%;
    padding: 0.5rem 0 0.65rem;
    border-left: none;
    border-right: none;
    border-radius: 0;
    box-shadow: none;
  }

  .grid-stage {
    padding: 0.35rem 0 0;
    overflow: visible;
  }

  .page-play .grid {
    width: 100%;
    max-width: 100%;
    margin: 0;
  }

  .grid-actions {
    padding: 0 0.75rem;
  }

  .grid-status {
    padding: 0 0.75rem;
  }
}

.play-sidebar {
  border-right: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  padding: 1.25rem clamp(0.85rem, 2vw, 1.35rem);
  overflow-y: auto;
  max-height: calc(100vh - 68px);
  background: var(--bg-panel);
  transition: var(--transition-theme);
}

.play-grid-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  padding: clamp(0.75rem, 2vw, 1.25rem) clamp(1rem, 3vw, 2rem) 1.5rem;
  background: var(--bg-scene);
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow);
  transition: var(--transition-theme);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.panel-header-heading {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0.01em;
}

.case-timer {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.modal-details .case-solve-time {
  margin: 0.35rem 0 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.badge {
  font-family: var(--font-mono);
  font-size: var(--text-min);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-pill);
  background: var(--badge-bg);
  color: var(--badge-text);
  border: 1px solid var(--border-strong);
}

.case-intro {
  margin: 0 0 1rem;
  font-family: var(--font-serif);
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.rules-details {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.rules-details summary {
  font-weight: 700;
  font-size: var(--text-min);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
}

.rules-box {
  margin-top: 0.65rem;
  padding: 0.9rem 1rem;
  border-left: 3px solid var(--accent-bright);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.rules-box ul {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 1rem;
  color: var(--text);
  line-height: 1.6;
}

.suspects-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.suspect-card {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.9rem;
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.suspect-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.suspect-card:active {
  transform: scale(0.99);
}

.suspect-card.selected {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--selected-bg);
}

.suspect-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--border-strong);
  background: var(--bg-cell);
  object-fit: cover;
  pointer-events: none;
}

.suspect-card.selected .suspect-avatar {
  border-color: var(--accent-bright);
}

.suspect-card.victim .suspect-avatar {
  border-color: var(--victim-text);
}

.suspect-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.suspect-card.placed {
  border-color: var(--placed-border);
  background: var(--placed-bg);
  opacity: 1;
}

.placed-check {
  color: var(--success-text);
  font-weight: 800;
}

.suspect-card.victim {
  border-color: var(--victim-text);
  background: var(--victim-soft);
}

.suspect-card.victim.selected {
  border-color: var(--victim-text);
  box-shadow: 0 0 0 3px var(--victim-soft);
}

.suspect-name {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1.08rem;
  color: var(--text);
}

.suspect-name.victim-label::after {
  content: " — Victim";
  font-weight: 600;
  font-size: var(--text-min);
  color: var(--victim-text);
}

.suspect-clue {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
}

.suspect-status {
  font-family: var(--font-mono);
  font-size: var(--text-min);
  font-weight: 600;
  color: var(--text-muted);
}

.grid-section {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 1;
  min-height: 0;
}

.grid-actions {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.grid-actions-main {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
}

.grid-actions-check {
  grid-column: 3;
  justify-self: end;
}

.grid-body {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(0.65rem, 1.5vw, 1rem);
  overflow: hidden;
}

.grid-wrapper {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  width: 100%;
  padding: clamp(0.65rem, 1.5vw, 1.25rem);
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  --grid-cols: 6;
}

.grid-stage {
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  transition: var(--transition-theme);
  overflow: hidden;
  box-sizing: border-box;
}

.grid {
  display: grid;
  gap: 0;
  padding: 0;
  background: var(--border-strong);
  border-radius: 10px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  flex-shrink: 0;
  width: min(100%, 72vmin);
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

@supports (width: 1cqw) {
  .grid-stage {
    container-type: size;
  }

  .page-play .grid {
    width: min(100cqw, 100cqh, 72vmin);
  }

  @media (max-width: 900px) {
    .grid-stage {
      container-type: inline-size;
    }

    .page-play .grid {
      width: 100cqw;
      max-width: 100%;
    }
  }
}

.page-play .cell {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
}

.cell {
  position: relative;
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  --cell-pad: 4px;
  padding: var(--cell-pad);
  background-color: var(--room-color, #ece8e0);
  overflow: hidden;
}

.cell.room-edge-n {
  border-top: 6px solid var(--room-edge);
}

.cell.room-edge-w {
  border-left: 6px solid var(--room-edge);
}

.cell.room-edge-s {
  border-bottom: 6px solid var(--room-edge);
}

.cell.room-edge-e {
  border-right: 6px solid var(--room-edge);
}

.cell.texture-grass {
  background-color: var(--room-color);
  background-image:
    repeating-linear-gradient(
      135deg,
      transparent,
      transparent 4px,
      rgba(0, 0, 0, 0.04) 4px,
      rgba(0, 0, 0, 0.04) 5px
    ),
    radial-gradient(circle at 25% 35%, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: auto, 10px 10px;
}

.cell.texture-wood {
  background-color: var(--room-color);
  background-image: repeating-linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.06) 0,
    rgba(0, 0, 0, 0.06) 2px,
    transparent 2px,
    transparent 14px
  );
}

.cell.texture-stone {
  background-color: var(--room-color);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(0, 0, 0, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 12px 12px, 16px 16px;
}

.cell.texture-tile {
  background-color: var(--room-color);
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
  background-size: 12px 12px;
}

.cell.texture-carpet {
  background-color: var(--room-color);
  background-image: repeating-linear-gradient(
    45deg,
    rgba(0, 0, 0, 0.03) 0,
    rgba(0, 0, 0, 0.03) 3px,
    transparent 3px,
    transparent 8px
  );
}

.cell.texture-parquet {
  background-color: var(--room-color);
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.04) 0,
      rgba(0, 0, 0, 0.04) 1px,
      transparent 1px,
      transparent 10px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.04) 0,
      rgba(0, 0, 0, 0.04) 1px,
      transparent 1px,
      transparent 10px
    );
  background-size: 20px 20px, 20px 20px;
}

.cell.texture-water {
  background-color: var(--room-color);
  background-image:
    repeating-linear-gradient(
      120deg,
      rgba(255, 255, 255, 0.08) 0,
      rgba(255, 255, 255, 0.08) 2px,
      transparent 2px,
      transparent 10px
    ),
    radial-gradient(circle at 30% 40%, rgba(255, 255, 255, 0.15) 1px, transparent 1px);
  background-size: auto, 14px 14px;
}

.cell.texture-sand {
  background-color: var(--room-color);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(0, 0, 0, 0.04) 1px, transparent 1px),
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 8px 8px, 12px 12px;
}

.cell.texture-metal {
  background-color: var(--room-color);
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(255, 255, 255, 0.06) 0,
    rgba(255, 255, 255, 0.06) 1px,
    transparent 1px,
    transparent 8px
  );
}

.cell.occupiable:hover {
  transform: scale(1.04);
  z-index: 2;
  box-shadow: 0 6px 16px var(--token-shadow);
}

.cell.blocked,
.cell:disabled {
  cursor: not-allowed;
  opacity: 1;
}

.cell.blocked::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 5px,
    var(--blocked-stripe, rgba(26, 22, 20, 0.45)) 5px,
    var(--blocked-stripe, rgba(26, 22, 20, 0.45)) 10px
  );
  background-position: calc(-1 * var(--grid-col, 0) * var(--stripe-cell-w, 0px))
    calc(-1 * var(--grid-row, 0) * var(--stripe-cell-h, 0px));
  pointer-events: none;
  z-index: 1;
}

.cell.blocked .furniture-stack,
.cell.blocked .decor-stack {
  opacity: 1;
  z-index: 5;
}

.cell.highlight-row,
.cell.highlight-col {
  outline: 3px solid var(--highlight);
  outline-offset: -2px;
  z-index: 2;
}

.cell.line-blocked {
  box-shadow: inset 0 0 0 999px var(--line-block-fill);
}

.cell.line-blocked::before {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 2px;
  pointer-events: none;
  z-index: 4;
  background:
    linear-gradient(
      to top left,
      transparent calc(50% - 5px),
      var(--line-block) calc(50% - 5px),
      var(--line-block) calc(50% + 5px),
      transparent calc(50% + 5px)
    ),
    linear-gradient(
      to top right,
      transparent calc(50% - 5px),
      var(--line-block) calc(50% - 5px),
      var(--line-block) calc(50% + 5px),
      transparent calc(50% + 5px)
    );
}

.cell.user-marked::before {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 2px;
  pointer-events: none;
  z-index: 4;
  background:
    linear-gradient(
      to top left,
      transparent calc(50% - 5px),
      var(--line-block) calc(50% - 5px),
      var(--line-block) calc(50% + 5px),
      transparent calc(50% + 5px)
    ),
    linear-gradient(
      to top right,
      transparent calc(50% - 5px),
      var(--line-block) calc(50% - 5px),
      var(--line-block) calc(50% + 5px),
      transparent calc(50% + 5px)
    );
}

.cell.conflict {
  border-color: var(--danger);
  animation: pulse-conflict 0.6s ease;
}

.cell.correct-placement {
  box-shadow: inset 0 0 0 3px var(--success-text);
}

.cell.correct-placement.has-person .person-token {
  outline: 2px solid var(--success-text);
  outline-offset: 1px;
}

.furniture-stack,
.decor-stack {
  position: absolute;
  top: var(--cell-pad);
  left: var(--cell-pad);
  right: var(--cell-pad);
  bottom: var(--cell-pad);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  gap: 1px;
  pointer-events: none;
  z-index: 1;
}

.prop-visual {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.furniture-prop,
.decor-prop {
  width: 75%;
  height: 75%;
  max-width: 75%;
  max-height: 75%;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px var(--token-shadow));
}

.decor-prop {
  opacity: 0.95;
}

.prop-label,
.furniture-label {
  flex: 0 0 auto;
  font-family: var(--font-ui);
  font-size: clamp(0.45rem, 0.95vmin, 0.625rem);
  font-weight: 800;
  line-height: 1.1;
  color: var(--prop-color);
  text-align: center;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.08rem 0.2rem;
  border-radius: 3px;
  background: var(--label-bg);
  border: 1px solid var(--label-border);
}

.cell.has-person .furniture-stack,
.cell.has-person .decor-stack {
  top: 3px;
  left: 3px;
  right: auto;
  bottom: auto;
  width: 32%;
  height: 32%;
  min-width: 22px;
  min-height: 22px;
  max-width: 34px;
  max-height: 34px;
  opacity: 0.82;
}

.cell.has-person .prop-label,
.cell.has-person .furniture-label {
  display: none;
}

.room-labels-layer {
  position: absolute;
  inset: 0;
  display: grid;
  pointer-events: none;
  z-index: 5;
}

.room-label {
  display: block;
  align-self: end;
  justify-self: stretch;
  margin: 0 var(--cell-pad) 2px;
  min-width: 0;
  width: auto;
  max-width: 100%;
  padding: 0;
  border: none;
  border-radius: 0;
  font-family: var(--font-ui);
  font-size: min(1.125rem, 12cqw, 1.6vmin);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
  color: #ffffff;
  background: transparent;
  box-shadow: none;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  container-type: inline-size;
  -webkit-text-stroke: 2.5px #1a1614;
  paint-order: stroke fill;
}

[data-theme="dark"] .room-label {
  color: #ffffff;
  -webkit-text-stroke: 2.5px #1a1614;
}


.hint-stack {
  position: absolute;
  bottom: 4px;
  right: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: flex-end;
  max-width: calc(100% - 8px);
  pointer-events: none;
  z-index: 2;
}

.hint-token {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(22px, 4.5vmin, 28px);
  height: clamp(22px, 4.5vmin, 28px);
  font-family: var(--font-ui);
  font-size: clamp(0.75rem, 1.7vmin, 0.875rem);
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  background: var(--label-bg);
  border: 2px dashed var(--label-border);
  border-radius: 6px;
  box-shadow: 1px 1px 0 var(--token-shadow);
}

.hint-token.victim {
  color: var(--victim-text);
  border-color: var(--victim-text);
}

.cell.has-person .hint-stack {
  bottom: auto;
  top: 4px;
  right: 4px;
}

.person-token {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  font-family: var(--font-ui);
  font-size: clamp(0.62rem, 1.6vmin, 0.86rem);
  font-weight: 800;
  text-align: center;
  line-height: 1.05;
  color: var(--text);
  background: var(--token-bg);
  border: 2px solid var(--border-strong);
  border-radius: 10px;
  padding: clamp(0.12rem, 0.7vmin, 0.28rem);
  word-break: break-word;
  max-width: 88%;
  max-height: 88%;
  box-shadow: 2px 2px 0 var(--token-shadow);
  transition: var(--transition-theme);
  z-index: 3;
}

.person-token-avatar {
  width: clamp(26px, 7vmin, 42px);
  height: clamp(26px, 7vmin, 42px);
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-cell);
  object-fit: cover;
  flex: 0 0 auto;
}

.person-token-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-token.victim {
  color: var(--victim-text);
  background: var(--victim-soft);
  border-color: var(--victim-text);
}

.grid-status {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  min-height: 1.4rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.grid-status.error {
  color: var(--danger);
}

.grid-status.ok {
  color: var(--success-text);
}

.placed-summary {
  font-family: var(--font-mono);
  font-size: var(--text-min);
  font-weight: 800;
  color: var(--gold-text);
  line-height: 1.2;
  margin: 0 0 0.65rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--badge-bg);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--modal-backdrop);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal-content {
  position: relative;
  max-width: 480px;
  width: 100%;
  padding: 2.25rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  text-align: center;
  transition: var(--transition-theme);
}

.modal-content h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--accent-bright);
  font-size: 1.85rem;
}

.modal-content p {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

.modal-details {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-cell);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 1rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.modal-actions .btn {
  min-width: 11rem;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  filter: brightness(0.95);
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 101;
  display: none;
}

.confetti-canvas.confetti-active {
  display: block;
}

.modal-details .killer-name {
  font-family: var(--font-ui);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--danger);
}

.modal-details .success-icon {
  color: var(--success-text);
  font-weight: 700;
}

@keyframes pulse-conflict {
  0%,
  100% {
    box-shadow: none;
  }
  50% {
    box-shadow: 0 0 14px rgba(180, 35, 24, 0.45);
  }
}

@media (max-width: 640px) {
  .beta-sticker {
    font-size: 0.55rem;
    padding: 0.2rem 0.42rem;
    transform: translate(88%, -8%) rotate(9deg);
  }

  .theme-toggle-text {
    display: none;
  }

  .theme-toggle {
    padding: 0.3rem;
  }

  .dashboard-toolbar {
    gap: 0.5rem;
  }

  .play-header {
    padding: 0.55rem max(0.75rem, env(safe-area-inset-right)) 0.55rem
      max(0.75rem, env(safe-area-inset-left));
    gap: 0.5rem;
  }

  .play-header .header-brand {
    gap: 0;
  }

  .case-tagline {
    display: none;
  }

  .case-title {
    font-size: 1.15rem;
  }

  .back-link {
    min-height: 2.25rem;
    line-height: 2.25rem;
    font-size: 0.8rem;
  }

  .howto-modal-content {
    max-height: min(92dvh, 100%);
  }

  .howto-modal-header {
    padding: 1.1rem 1rem 0.65rem;
  }

  .howto-modal-body {
    padding: 0 1rem 0.85rem;
  }

  .howto-modal-actions {
    padding: 0.65rem 1rem 1rem;
  }

  .play-sidebar {
    padding: 1rem max(0.85rem, env(safe-area-inset-right)) 1.25rem
      max(0.85rem, env(safe-area-inset-left));
  }

  .suspect-avatar {
    width: 52px;
    height: 52px;
  }

  .suspect-card {
    padding: 0.7rem 0.8rem;
    gap: 0.65rem;
  }

  .suspect-name {
    font-size: 1rem;
  }

  .suspect-clue {
    font-size: 0.92rem;
  }

  .grid-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }

  .grid-actions-main {
    grid-column: auto;
    justify-content: center;
    width: 100%;
    gap: 0.5rem;
  }

  .grid-actions-check {
    grid-column: auto;
    align-self: flex-end;
    width: auto;
    min-height: 2.75rem;
    font-size: 0.85rem;
  }

  .grid-actions-main .btn {
    min-height: 2.75rem;
    font-size: 0.85rem;
  }

  .person-token-avatar {
    width: clamp(22px, 6.5vmin, 34px);
    height: clamp(22px, 6.5vmin, 34px);
  }

  .person-token-name {
    font-size: 0.58rem;
  }

  .grid-status {
    font-size: 0.85rem;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  }

  .play-grid-section {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}

.back-link {
  display: inline-block;
  font-size: var(--text-min);
  font-family: var(--font-ui);
  font-weight: 700;
  color: var(--accent-link);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  min-height: 2.75rem;
  line-height: 2.75rem;
}

.back-link:hover {
  color: var(--accent-bright);
}

.seed-badge {
  font-family: var(--font-mono);
  font-size: var(--text-min);
  font-weight: 600;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-pill);
  background: var(--badge-bg);
  color: var(--badge-text);
  border: 1px solid var(--border-strong);
  letter-spacing: 0.04em;
}

.page-dashboard {
  background:
    radial-gradient(ellipse 90% 60% at 50% -20%, rgba(155, 35, 53, 0.07), transparent 55%),
    var(--bg-deep);
}

[data-theme="dark"] body.page-dashboard {
  background:
    radial-gradient(ellipse 90% 60% at 50% -20%, rgba(212, 90, 107, 0.1), transparent 55%),
    var(--bg-deep);
}

.page-dashboard .dashboard-app {
  max-width: none;
  padding: 0 0 3rem;
}

.dashboard-header {
  position: relative;
  justify-content: center;
  text-align: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  padding: 2rem clamp(1rem, 4vw, 2.5rem) 1.75rem;
}

.dashboard-header--minimal {
  min-height: 0;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: none;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.seed-hero-brand {
  margin-bottom: 1.35rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.seed-hero-logo-wrap {
  position: relative;
  display: inline-block;
  margin-bottom: 0.35rem;
}

.seed-hero-logo {
  font-size: clamp(2.75rem, 7vw, 4.25rem);
  margin: 0;
}

.beta-sticker {
  position: absolute;
  top: 0.2rem;
  right: 0;
  transform: translate(100%, -10%) rotate(11deg);
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.24rem 0.52rem;
  border-radius: 3px;
  background: linear-gradient(145deg, var(--accent-bright), #b91c3a);
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 2px 8px rgba(139, 31, 47, 0.32);
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

[data-theme="dark"] .beta-sticker {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

.seed-hero-tagline {
  margin: 0 0 1rem;
  font-family: var(--font-serif);
  font-size: clamp(1.05rem, 2.2vw, 1.2rem);
  font-weight: 500;
  font-style: italic;
  color: var(--text-muted);
}

.seed-hero {
  text-align: center;
  padding: clamp(1.75rem, 4vw, 2.75rem);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--bg-panel);
}

.dashboard-main {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  padding: max(0.85rem, env(safe-area-inset-top)) clamp(1rem, 4vw, 3rem) 3rem;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

.dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  flex-shrink: 0;
}

.dashboard-toolbar .language-switcher {
  flex-shrink: 0;
}

.seed-lead {
  margin: 0 auto 1.5rem;
  max-width: 42rem;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.seed-preview-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  min-height: 0;
  margin: 0 auto 1.25rem;
  max-width: 40rem;
}

.seed-preview-panel .btn-copy {
  margin-top: 0;
}

.seed-error {
  margin: -0.5rem auto 1rem;
  max-width: 36rem;
  width: 100%;
  font-size: 1rem;
  font-weight: 600;
  color: var(--danger);
  min-height: 1.25rem;
  line-height: 1.5;
  text-align: center;
}

.seed-label {
  display: block;
  margin-bottom: 0.5rem;
  font-family: var(--font-mono);
  font-size: var(--text-min);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
}

.seed-input {
  display: block;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto 0.85rem;
  padding: 1.15rem 1.35rem;
  font-family: var(--font-mono);
  font-size: clamp(1.3rem, 4vw, 1.85rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface-input);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.seed-input:focus {
  outline: none;
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.seed-input::placeholder {
  color: var(--text-placeholder);
  opacity: 1;
  font-weight: 500;
  text-transform: none;
}

.seed-options {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: 36rem;
  margin: 0 auto 1rem;
  width: 100%;
}

.seed-option-group {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.seed-option-label {
  display: block;
  margin: 0 0 0.45rem;
  font-family: var(--font-mono);
  font-size: var(--text-min);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-align: center;
}

.seed-segmented {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}

.seed-segmented-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.seed-segmented-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.45rem 0.95rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, color 0.18s, box-shadow 0.18s;
  user-select: none;
}

.seed-segmented-difficulty .seed-segmented-btn {
  flex: 1 1 5.5rem;
  max-width: 8.5rem;
}

.seed-segmented-size {
  flex-wrap: wrap;
}

.seed-segmented-size .seed-segmented-btn {
  flex: 1 1 3.6rem;
  min-width: 3.6rem;
  padding-inline: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  letter-spacing: 0.02em;
}

.seed-segmented-size .seed-segmented-btn-slow {
  flex: 1 1 7.5rem;
  min-width: 7rem;
  font-size: 0.8rem;
  line-height: 1.2;
  white-space: normal;
  padding-block: 0.45rem;
}

.seed-segmented-input:focus-visible + .seed-segmented-btn {
  outline: none;
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.seed-segmented-input:checked + .seed-segmented-btn {
  color: var(--text);
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 2px 0 var(--token-shadow);
}

.seed-segmented-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.seed-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.seed-preview-panel .seed-minimap {
  margin: 0 auto;
}

.seed-minimap {
  display: grid;
  gap: 1px;
  width: min(100%, 148px);
  aspect-ratio: 1;
  padding: 3px;
  border-radius: 8px;
  background: var(--border-strong);
  box-shadow: 2px 2px 0 var(--token-shadow);
  flex-shrink: 0;
}

.seed-minimap-cell {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 1px;
}

.seed-minimap-cell.blocked {
  filter: brightness(0.72) saturate(0.85);
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 2px,
    var(--blocked-stripe, rgba(0, 0, 0, 0.28)) 2px,
    var(--blocked-stripe, rgba(0, 0, 0, 0.28)) 4px
  );
}

.seed-minimap-cell.prop::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38%;
  height: 38%;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: var(--prop-color);
  opacity: 0.88;
}

.seed-preview {
  margin: 0;
  width: 100%;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--success-text);
  line-height: 1.5;
}

.btn-copy {
  margin-top: 0.75rem;
  font-size: 1rem;
}

.cases-lead {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.55;
}

.cases-section-header {
  margin-bottom: 1rem;
}

.cases-section-header h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 700;
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.cases-empty {
  margin: 0;
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-serif);
}

.cases-loading {
  margin: 0;
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-weight: 600;
}

.cases-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

.case-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1.4rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s, background 0.18s;
}

.case-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.case-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.case-size {
  font-family: var(--font-mono);
  font-size: var(--text-min);
  font-weight: 600;
  color: var(--text-muted);
}

.case-card-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.case-card-intro {
  margin: 0;
  flex: 1;
  font-family: var(--font-serif);
  font-size: 0.98rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.case-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.case-card-stats {
  flex-wrap: wrap;
}

.case-meta-item {
  font-family: var(--font-mono);
  font-size: var(--text-min);
  font-weight: 600;
  color: var(--text-muted);
}

.case-seed-id {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-min);
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  word-break: break-all;
}

.case-card-seed .case-play-btn {
  margin-top: 0.15rem;
}

.archive-remove-btn {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  z-index: 2;
  width: 2.35rem;
  height: 2.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-card);
  color: var(--danger);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.archive-remove-btn:hover,
.archive-remove-btn:focus-visible {
  transform: translateY(-1px);
  border-color: var(--danger);
  box-shadow: var(--shadow-lg);
}

.case-card-archive .case-card-top {
  padding-right: 2.25rem;
}

.case-rooms {
  display: flex;
  gap: 0.3rem;
}

.case-room-swatch {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background-color: var(--room-color, #ddd);
}

.case-play-btn {
  width: 100%;
  text-align: center;
  text-decoration: none;
  margin-top: 0.25rem;
}

/* WCAG 2.1 — focus, motion, contrast helpers */

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 200;
  padding: 0.75rem 1.25rem;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 1rem;
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.btn:focus-visible,
.theme-toggle:focus-visible,
.seed-input:focus-visible,
.suspect-card:focus-visible,
.cell:focus-visible,
.rules-details summary:focus-visible,
.back-link:focus-visible,
.case-play-btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px var(--accent-soft);
}

.seed-input:focus-visible {
  border-color: var(--accent-link);
}

.suspect-card:focus-visible {
  border-color: var(--accent-link);
}

.cell:focus-visible {
  z-index: 5;
  transform: none;
}

.hint-stack,
.hint-token,
.furniture-stack,
.person-token {
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .cell.occupiable:hover,
  .case-card:hover,
  .suspect-card:active {
    transform: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --border-strong: rgba(44, 36, 32, 0.45);
    --text-muted: #3a342f;
  }

  [data-theme="dark"] {
    --border-strong: rgba(245, 240, 232, 0.42);
    --text-muted: #e8e2d8;
  }

  .btn,
  .suspect-card,
  .case-card,
  .seed-input {
    border-width: 2px;
  }
}

/* Case Files Archive */

.archive-section {
  margin-top: 0.5rem;
}

.archive-grid.archive-grid--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: min(62vh, 28rem);
  grid-template-columns: unset;
}

.archive-empty {
  font-style: italic;
  max-width: 22rem;
  margin-inline: auto;
}

.case-card-solved {
  border-color: var(--placed-border);
  background: var(--placed-bg);
  box-shadow: var(--shadow);
}

.case-card-solved:hover {
  border-color: var(--success-text);
  box-shadow: var(--shadow-lg);
}

.case-solved-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  align-self: flex-start;
  margin-bottom: 0.15rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--placed-bg);
  border: 2px solid var(--success-text);
  color: var(--success-text);
  font-family: var(--font-ui);
  font-size: var(--text-min);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.case-solved-badge-compact {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  margin: 0;
  padding: 0.28rem 0.55rem;
  font-size: 0.8125rem;
}

.case-card-seed.case-card-solved {
  position: relative;
  padding-top: 1.35rem;
}

.case-solved-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: var(--success-text);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1;
  animation: check-pop 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.badge-solved {
  background: var(--placed-bg);
  color: var(--success-text);
  border-color: var(--placed-border);
}

.case-solved-meta {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-min);
  font-weight: 600;
  color: var(--success-text);
}

.case-replay-btn,
.case-card-solved .case-play-btn {
  margin-top: 0.15rem;
}

/* Micro-animations */

@keyframes card-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes check-pop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  70% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes modal-rise {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(16px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes place-pop {
  0% {
    transform: scale(0.88);
  }
  55% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes case-cell-reveal {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes case-prop-reveal {
  0% {
    opacity: 0;
    transform: scale(0.35);
  }
  62% {
    opacity: 1;
    transform: scale(1.1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes case-label-reveal {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes case-suspect-reveal {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.94);
  }
  70% {
    transform: translateY(0) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.grid-wrapper.case-reveal-pending.is-revealing {
  pointer-events: none;
}

.grid-wrapper.case-reveal-pending:not(.is-revealing) .cell-reveal {
  opacity: 0;
  transform: scale(0.9);
}

.grid-wrapper.is-revealing .cell-reveal {
  animation: case-cell-reveal 0.48s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: var(--reveal-delay, 0ms);
}

.grid-wrapper.is-revealing .cell-reveal .furniture-stack,
.grid-wrapper.is-revealing .cell-reveal .decor-stack {
  transform-origin: center bottom;
  animation: case-prop-reveal 0.58s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
  animation-delay: calc(var(--reveal-delay, 0ms) + 110ms);
}

.grid-wrapper.is-revealing .room-label-reveal {
  animation: case-label-reveal 0.55s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(var(--reveal-delay, 0ms) + 180ms);
}

.play-sidebar.case-reveal-pending:not(.is-revealing) .suspect-reveal {
  opacity: 0;
  transform: translateY(10px) scale(0.94);
}

.play-sidebar.is-revealing .suspect-reveal {
  animation: case-suspect-reveal 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: var(--reveal-delay, 0ms);
}

.play-sidebar.case-reveal-pending.is-revealing {
  pointer-events: none;
}

@keyframes preview-fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes btn-pulse-once {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes status-nudge {
  from {
    opacity: 0.4;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.case-grid-animated .case-card {
  animation: card-rise 0.48s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.modal.modal-visible .modal-content {
  animation: modal-rise 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal.modal-visible .modal-backdrop {
  animation: preview-fade 0.28s ease;
}

.cell-place-pop .person-token {
  animation: place-pop 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.seed-preview-animate {
  animation: preview-fade 0.32s ease;
}

.btn-pulse {
  animation: btn-pulse-once 0.42s ease;
}

.grid-status.ok,
.grid-status.error {
  animation: status-nudge 0.28s ease;
}

.case-card {
  transition:
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.22s ease;
}

.page-dashboard .dashboard-main {
  animation: preview-fade 0.45s ease;
}

@media (prefers-reduced-motion: reduce) {
  .case-grid-animated .case-card,
  .modal.modal-visible .modal-content,
  .modal.modal-visible .modal-backdrop,
  .cell-place-pop .person-token,
  .grid-wrapper.is-revealing .cell-reveal,
  .grid-wrapper.is-revealing .cell-reveal .furniture-stack,
  .grid-wrapper.is-revealing .cell-reveal .decor-stack,
  .grid-wrapper.is-revealing .room-label-reveal,
  .play-sidebar.is-revealing .suspect-reveal,
  .seed-preview-animate,
  .btn-pulse,
  .grid-status.ok,
  .grid-status.error,
  .page-dashboard .dashboard-main,
  .case-solved-check {
    animation: none !important;
  }

  .grid-wrapper.case-reveal-pending:not(.is-revealing) .cell-reveal,
  .play-sidebar.case-reveal-pending:not(.is-revealing) .suspect-reveal {
    opacity: 1;
    transform: none;
  }

  .case-card:hover,
  .suspect-card:active {
    transform: none;
  }
}
