/* ============================================================================
   CrimeRewind ⏮ - Unified High-Contrast Detective Board Game Design System
   WCAG AAA Readable Contrast | Cohesive Warm Case-File Palette
   ============================================================================ */

:root {
    --cr-bg: #f3efe6;
    --cr-surface: #ffffff;
    --cr-surface-alt: #f7f4ec;
    --cr-surface-hover: #efeae0;
    --cr-border: #1e293b;
    --cr-border-soft: #cbd5e1;
    --cr-text: #0f172a;
    --cr-text-secondary: #334155;
    --cr-text-muted: #475569;

    --cr-accent: #eab308;
    --cr-accent-soft: #fef08a;
    --cr-accent-border: #ca8a04;
    --cr-highlight-color: var(--cr-accent);

    --cr-primary: #2563eb;
    --cr-primary-soft: #dbeafe;
    --cr-primary-text: #1e3a8a;

    --cr-innocent-bg: #dcfce7;
    --cr-innocent-border: #15803d;
    --cr-innocent-text: #14532d;

    --cr-suspect-bg: #fee2e2;
    --cr-suspect-border: #b91c1c;
    --cr-suspect-text: #7f1d1d;

    --cr-grid-dim: 6;
    --cr-grid-scale: 1.0;
    --cr-ui-scale: 1.0;
    --cr-base-cell-size: clamp(24px, min(calc((48vw - 32px) / 6), calc((76vh - 160px) / 6)), 155px);
    --cr-target-cell-size: calc(var(--cr-base-cell-size) * var(--cr-grid-scale));
    --cr-cell-size: var(--cr-target-cell-size);

    /* Live user-configurable CSS variables (from Options -> Advanced Sliders) */
    --cg-room-label-size: 15px;
    --cg-floor-opacity: 0.85;
    --cg-object-scale: 1.0;
    --cg-wall-width: 5px;
    --cg-cross-scale: 1.0;
    --cg-shadow-opacity: 0.25;
}

.cr-theme-dark {
    --cr-bg: #0f172a;
    --cr-surface: #1e293b;
    --cr-surface-alt: #263349;
    --cr-surface-hover: #334155;
    --cr-border: #475569;
    --cr-border-soft: #334155;
    --cr-text: #f8fafc;
    --cr-text-secondary: #e2e8f0;
    --cr-text-muted: #cbd5e1;

    --cr-accent-soft: #422006;
    --cr-primary-soft: #1e3a8a;
    --cr-primary-text: #dbeafe;

    --cr-innocent-bg: #064e3b;
    --cr-innocent-border: #10b981;
    --cr-innocent-text: #d1fae5;

    --cr-suspect-bg: #7f1d1d;
    --cr-suspect-border: #f87171;
    --cr-suspect-text: #fee2e2;
}

html, body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--cr-bg);
    color: var(--cr-text);
    margin: 0;
    padding: 0;
    user-select: none;
    height: 100%;
}

.cr-root-layout,
.cr-app-shell {
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    background-color: var(--cr-bg);
    color: var(--cr-text);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Semantic typography helpers replacing unreadable Bootstrap .text-secondary */
.cr-text-main {
    color: var(--cr-text) !important;
}

.cr-text-sub {
    color: var(--cr-text-secondary) !important;
}

.cr-text-muted {
    color: var(--cr-text-muted) !important;
}

/* Vector Game Icons */
.cr-icon {
    display: inline-block;
    vertical-align: -0.14em;
    flex-shrink: 0;
}

.cr-btn-icon {
    padding: 0.28rem 0.45rem;
    min-width: 32px;
    min-height: 32px;
    justify-content: center;
}

.cr-btn-sm.cr-btn-icon {
    min-width: 30px;
    height: 30px;
    min-height: 30px;
    padding: 0.2rem 0.4rem;
    border-radius: 7px;
}

/* Unified Form Controls (Select / Input / Textarea) */
.cr-select,
.cr-input {
    background-color: var(--cr-surface-alt);
    color: var(--cr-text);
    border: 2px solid var(--cr-border);
    border-radius: 8px;
    padding: 0.28rem 0.65rem;
    font-weight: 700;
    font-size: 0.84rem;
}

.cr-select:focus,
.cr-input:focus {
    outline: 2px solid var(--cr-accent);
    background-color: var(--cr-surface);
    color: var(--cr-text);
}

/* ============================================================================
   TOP BAR & PHASE TABS
   ============================================================================ */
.cr-topbar {
    background: var(--cr-surface);
    border-bottom: 3px solid var(--cr-border);
    padding: 0.35rem 1rem;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    box-shadow: 0 3px 0 rgba(15, 23, 42, 0.06);
    z-index: 30;
    min-height: 48px;
}

.cr-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 900;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    color: var(--cr-text);
    white-space: nowrap;
    flex-shrink: 0;
}

.cr-brand-badge {
    background: #eab308;
    color: #0f172a;
    border: 2px solid #0f172a;
    border-radius: 8px;
    padding: 0.14rem 0.5rem;
    font-size: 0.88rem;
    font-weight: 900;
    box-shadow: 2px 2px 0 #0f172a;
}

/* ============================================================================
   FULL-WIDTH PHASE TABS BAR (Anchored directly under Header)
   ============================================================================ */
.cr-phase-tabs-bar {
    width: 100%;
    background: var(--cr-surface);
    border-bottom: 2.5px solid var(--cr-border);
    display: flex;
    align-items: stretch;
    box-shadow: 0 2px 0 rgba(15, 23, 42, 0.04);
    z-index: 20;
    flex-shrink: 0;
    overflow-x: auto;
}

.cr-phase-tab-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 0.65rem 1.25rem;
    background: transparent;
    border: none;
    border-right: 2px solid var(--cr-border-soft);
    border-bottom: 3.5px solid transparent;
    color: var(--cr-text-secondary);
    font-weight: 800;
    font-size: calc(clamp(0.82rem, 0.35vw + 0.5rem, 1.02rem) * var(--cr-ui-scale));
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
    user-select: none;
    margin-bottom: -2.5px;
    white-space: nowrap;
}

.cr-phase-tab-item:last-child {
    border-right: none;
}

.cr-phase-tab-item:hover:not(.locked) {
    background: var(--cr-surface-hover);
    color: var(--cr-text);
}

.cr-phase-tab-item.active {
    background: var(--cr-surface-alt);
    color: var(--cr-text);
    border-bottom-color: var(--cr-accent, #3b82f6);
}

.cr-theme-dark .cr-phase-tab-item.active {
    background: rgba(59, 130, 246, 0.12);
    color: #f8fafc;
    border-bottom-color: #60a5fa;
}

.cr-phase-tab-item.locked {
    opacity: 0.65;
    cursor: not-allowed;
    background: rgba(148, 163, 184, 0.08);
}

.cr-phase-tab-item.unlocked:not(.active) {
    color: #15803d;
}

.cr-theme-dark .cr-phase-tab-item.unlocked:not(.active) {
    color: #4ade80;
}

.cr-phase-tab-pill {
    background: #0f172a;
    color: #ffffff;
    font-size: 0.74rem;
    font-weight: 900;
    padding: 0.12rem 0.55rem;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

.cr-theme-dark .cr-phase-tab-pill {
    background: #334155;
    color: #f8fafc;
}

.cr-phase-tab-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 0.15rem 0.55rem;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cr-phase-tab-badge.badge-locked {
    background: #fee2e2;
    color: #991b1b;
    border: 1.5px solid #f87171;
}

.cr-theme-dark .cr-phase-tab-badge.badge-locked {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border-color: #ef4444;
}

.cr-phase-tab-badge.badge-ready {
    background: #dcfce7;
    color: #166534;
    border: 1.5px solid #22c55e;
    animation: crBadgePulse 1.8s infinite ease-in-out;
}

.cr-theme-dark .cr-phase-tab-badge.badge-ready {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
    border-color: #22c55e;
}

@keyframes crBadgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.cr-count-pill {
    background: #0f172a;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 999px;
}

/* ============================================================================
   GAME BADGE (UNIFIED PILL / STATUS BADGE COMPONENT)
   Consistent border-radius (999px) and tactile contrast across all screens
   ============================================================================ */
.cr-game-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
    font-weight: 800;
    line-height: 1.25;
    white-space: nowrap;
    border-radius: 999px;
    border: 1px solid transparent;
    vertical-align: middle;
    letter-spacing: 0.02em;
    user-select: none;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.cr-actor-clue-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 12px;
    row-gap: 10px;
}

.cr-actor-clue-header > :first-child { grid-row: 1 / span 2; align-self: start; }
.cr-actor-clue-identity { min-width: 0; }
.cr-actor-clue-name { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--cr-text); font-size: 0.95rem; }
.cr-actor-clue-role { margin-top: 3px; color: var(--cr-text-secondary); font-size: 0.74rem; overflow-wrap: anywhere; }
.cr-actor-clue-actions { display: flex; align-items: center; gap: 10px; }
.cr-actor-possibility-badges { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.cr-actor-clue-header > .cr-actor-possibility-badges { grid-column: 2 / -1; }
.cr-actor-possibility-badges .cr-game-badge,
.cr-clue-count-badge { gap: 5px; padding: 3px 8px; font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.cr-actor-possibility-badges .cr-icon,
.cr-clue-count-badge .cr-icon { width: 14px; height: 14px; flex-shrink: 0; }

.cr-game-badge-xs {
    padding: 0.1rem 0.48rem;
    font-size: 0.68rem;
}

.cr-game-badge-sm {
    padding: 0.16rem 0.58rem;
    font-size: 0.74rem;
}

.cr-game-badge-md {
    padding: 0.22rem 0.75rem;
    font-size: 0.84rem;
}

.cr-game-badge.cursor-help {
    cursor: help;
}

/* Variant Palettes */
.cr-game-badge-success {
    background: #15803d;
    color: #ffffff;
    border-color: #166534;
}

.cr-game-badge-danger {
    background: #b91c1c;
    color: #ffffff;
    border-color: #991b1b;
}

.cr-game-badge-warning {
    background: #f59e0b;
    color: #0f172a;
    border-color: #d97706;
}

.cr-game-badge-secondary {
    background: #475569;
    color: #ffffff;
    border-color: #334155;
}

.cr-game-badge-dark {
    background: #0f172a;
    color: #ffffff;
    border-color: #1e293b;
}

.cr-game-badge-primary {
    background: #2563eb;
    color: #ffffff;
    border-color: #1d4ed8;
}

.cr-game-badge-info {
    background: #0284c7;
    color: #ffffff;
    border-color: #0369a1;
}

.cr-game-badge-purple {
    background: #7e22ce;
    color: #ffffff;
    border-color: #6b21a8;
}

.cr-game-badge-gold {
    background: #ca8a04;
    color: #0f172a;
    border-color: #a16207;
}

.cr-game-badge-default {
    background: var(--cr-surface-alt);
    color: var(--cr-text);
    border-color: var(--cr-border-soft);
}

.cr-top-actions {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.35rem;
    margin-left: auto;
    flex-shrink: 0;
}

@media (max-width: 767.98px) {
    .cr-topbar.cr-topbar-with-account {
        flex-wrap: wrap;
    }

    .cr-topbar.cr-topbar-with-account .cr-top-actions {
        flex-wrap: wrap;
        flex-shrink: 1;
        justify-content: flex-end;
        min-width: 0;
        max-width: 100%;
    }
}

.cr-timer {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-weight: 800;
    font-size: 0.84rem;
    background: var(--cr-surface-alt);
    border: 2px solid var(--cr-border);
    border-radius: 7px;
    padding: 0.18rem 0.55rem;
    height: 30px;
    display: inline-flex;
    align-items: center;
    color: var(--cr-text);
    box-shadow: 0 2px 0 var(--cr-border);
    box-sizing: border-box;
}

/* Toast Notifications (Bottom-Left Stacking) */
.cr-toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 1050;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    max-width: 440px;
    width: calc(100vw - 48px);
    pointer-events: none;
}

.cr-toast-item {
    pointer-events: auto;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 14px;
    border: 2.5px solid var(--cr-border);
    background: var(--cr-surface);
    color: var(--cr-text);
    box-shadow: 0 4px 0 var(--cr-border), 0 8px 24px rgba(15, 23, 42, 0.16);
    cursor: pointer;
    user-select: none;
    animation: crToastSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.15s ease;
}

.cr-toast-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 var(--cr-border), 0 10px 28px rgba(15, 23, 42, 0.2);
}

.cr-toast-item:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 var(--cr-border);
}

.cr-toast-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.cr-toast-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.cr-toast-title {
    font-size: 0.92rem;
    font-weight: 800;
    line-height: 1.25;
}

.cr-toast-message {
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.35;
    opacity: 0.95;
    word-break: break-word;
}

.cr-toast-close {
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    padding: 0.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: opacity 0.1s ease, transform 0.1s ease;
    flex-shrink: 0;
}

.cr-toast-close:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* Toast Variants */
.cr-toast-item.cr-toast-success {
    background: #dcfce7;
    color: #14532d;
    border-color: #15803d;
    box-shadow: 0 4px 0 #15803d, 0 8px 24px rgba(21, 128, 61, 0.16);
}

.cr-toast-item.cr-toast-success .cr-toast-icon {
    background: #16a34a;
    color: #ffffff;
}

.cr-toast-item.cr-toast-error {
    background: #fee2e2;
    color: #7f1d1d;
    border-color: #b91c1c;
    box-shadow: 0 4px 0 #b91c1c, 0 8px 24px rgba(185, 28, 28, 0.16);
}

.cr-toast-item.cr-toast-error .cr-toast-icon {
    background: #dc2626;
    color: #ffffff;
}

.cr-toast-item.cr-toast-warning {
    background: #fef9c3;
    color: #713f12;
    border-color: #ca8a04;
    box-shadow: 0 4px 0 #ca8a04, 0 8px 24px rgba(202, 138, 4, 0.16);
}

.cr-toast-item.cr-toast-warning .cr-toast-icon {
    background: #eab308;
    color: #0f172a;
}

.cr-toast-item.cr-toast-info {
    background: #e0f2fe;
    color: #0c4a6e;
    border-color: #0284c7;
    box-shadow: 0 4px 0 #0284c7, 0 8px 24px rgba(2, 132, 199, 0.16);
}

.cr-toast-item.cr-toast-info .cr-toast-icon {
    background: #0284c7;
    color: #ffffff;
}

/* Dark Mode Variants */
.cr-theme-dark .cr-toast-item.cr-toast-success {
    background: #064e3b;
    color: #ecfdf5;
    border-color: #34d399;
    box-shadow: 0 4px 0 #34d399, 0 8px 24px rgba(0, 0, 0, 0.45);
}

.cr-theme-dark .cr-toast-item.cr-toast-success .cr-toast-icon {
    background: #10b981;
    color: #0f172a;
}

.cr-theme-dark .cr-toast-item.cr-toast-error {
    background: #7f1d1d;
    color: #fef2f2;
    border-color: #f87171;
    box-shadow: 0 4px 0 #f87171, 0 8px 24px rgba(0, 0, 0, 0.45);
}

.cr-theme-dark .cr-toast-item.cr-toast-error .cr-toast-icon {
    background: #ef4444;
    color: #ffffff;
}

.cr-theme-dark .cr-toast-item.cr-toast-warning {
    background: #78350f;
    color: #fefce8;
    border-color: #fde047;
    box-shadow: 0 4px 0 #fde047, 0 8px 24px rgba(0, 0, 0, 0.45);
}

.cr-theme-dark .cr-toast-item.cr-toast-warning .cr-toast-icon {
    background: #facc15;
    color: #0f172a;
}

.cr-theme-dark .cr-toast-item.cr-toast-info {
    background: #0c4a6e;
    color: #f0f9ff;
    border-color: #38bdf8;
    box-shadow: 0 4px 0 #38bdf8, 0 8px 24px rgba(0, 0, 0, 0.45);
}

.cr-theme-dark .cr-toast-item.cr-toast-info .cr-toast-icon {
    background: #38bdf8;
    color: #0f172a;
}

@keyframes crToastSlideIn {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Tactile Board-Game Buttons */
.cr-btn {
    background: var(--cr-surface);
    color: var(--cr-text);
    border: 2px solid var(--cr-border);
    border-radius: 9px;
    padding: 0.38rem 0.78rem;
    font-weight: 800;
    font-size: 0.84rem;
    cursor: pointer;
    box-shadow: 0 3px 0 var(--cr-border);
    transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.12s;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.cr-btn-sm {
    padding: 0.25rem 0.58rem;
    font-size: 0.78rem;
    border-radius: 7px;
    box-shadow: 0 2px 0 var(--cr-border);
}

.cr-btn-xs {
    padding: 0.15rem 0.45rem;
    font-size: 0.72rem;
    border-radius: 6px;
    box-shadow: 0 1.5px 0 var(--cr-border);
}

.cr-btn-collapse {
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 7px !important;
    flex-shrink: 0;
    line-height: 1;
}

.cr-btn-collapse .cr-icon,
.cr-btn-collapse svg {
    width: 14px !important;
    height: 14px !important;
    display: block !important;
    margin: auto !important;
}

.cr-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 0 var(--cr-border);
    background: var(--cr-surface-hover);
}

.cr-btn:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--cr-border);
}

.cr-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.cr-btn-primary {
    background: var(--cr-primary-soft);
    color: var(--cr-primary-text);
}

.cr-btn-gold {
    background: #fde047;
    color: #0f172a;
    border-color: #0f172a;
}

.cr-btn-gold:hover:not(:disabled) {
    background: #facc15;
    color: #0f172a;
}

/* ============================================================================
   MAIN WORKSPACE & FULL-HEIGHT DOCKED SIDEBAR
   ============================================================================ */
.cr-main-workspace {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    flex: 1;
    min-height: 0;
    height: 0; /* allows flex children with overflow to calculate height correctly */
    overflow: hidden;
    box-sizing: border-box;
}

.cr-board-area {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    overflow-x: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: clamp(2.35rem, 4vh, 3.5rem) clamp(1.5rem, 3vw, 3.5rem);
    box-sizing: border-box;
    container-type: inline-size;
    container-name: boardarea;
}

.cr-main-workspace.cr-workspace-stacked {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.cr-main-workspace.cr-workspace-stacked .cr-board-area {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    min-height: auto;
    max-height: none;
    overflow: visible;
    padding: clamp(0.75rem, 2vw, 1.5rem) clamp(0.35rem, 1.5vw, 1rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.cr-main-workspace.cr-workspace-stacked .cr-board-stage {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-inline: auto;
}

.cr-main-workspace.cr-workspace-stacked .cr-board-wrapper {
    max-width: calc(100vw - 1rem);
    box-sizing: border-box;
}

.cr-main-workspace.cr-workspace-stacked .cr-side-panel {
    flex: 0 0 auto;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    height: auto;
    min-height: auto;
    max-height: none;
    border-left: none;
    border-top: 2.5px solid var(--cr-border);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.04);
    overflow: visible;
}

.cr-main-workspace.cr-workspace-stacked .cr-panel-scroll {
    overflow: visible;
    flex: none;
    height: auto;
    max-height: none;
    padding: 0.75rem 0.65rem;
}

/* Unified Sub-Toolbar above the Board (Scales with Board Width & UI Scale!) */
.cr-subtoolbar {
    --cr-max-cell-width: max(24px, calc((100cqi - 24px) / (var(--cr-grid-dim, 6) + 0.66)));
    --cr-fit-cell-size: min(var(--cr-base-cell-size, 110px), var(--cr-max-cell-width));
    --cr-cell-size: calc(var(--cr-fit-cell-size) * var(--cr-grid-scale, 1));
    background: var(--cr-surface);
    color: var(--cr-text);
    border: 2.5px solid var(--cr-border);
    border-radius: 12px;
    padding: 0.65rem 1.15rem;
    margin-bottom: 0.9rem;
    box-shadow: 0 4px 0 rgba(15, 23, 42, 0.08);
    max-width: min(100%, max(480px, calc(var(--cr-cell-size) * var(--cr-grid-dim, 6) + 72px)));
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: calc(clamp(0.84rem, 0.42vw + 0.48rem, 1.08rem) * var(--cr-ui-scale));
    box-sizing: border-box;
}

.cr-board-wrapper {
    /* Fit at 100%; zoom changes cell geometry and scrolls the complete board. */
    --cr-max-cell-width: max(24px, calc((100cqi - 24px) / (var(--cr-grid-dim, 6) + 0.66)));
    --cr-fit-cell-size: min(var(--cr-base-cell-size, 110px), var(--cr-max-cell-width));
    --cr-cell-size: calc(var(--cr-fit-cell-size) * var(--cr-grid-scale, 1));
    position: relative;
    background: var(--cr-surface);
    border: 3px solid var(--cr-border);
    border-radius: 18px;
    padding: calc(var(--cr-cell-size) * 0.14) calc(var(--cr-cell-size) * 0.18) calc(var(--cr-cell-size) * 0.18);
    box-shadow: 0 8px 0 rgba(15, 23, 42, 0.1), 0 12px 24px rgba(15, 23, 42, 0.06);
    display: inline-flex;
    flex-direction: column;
    width: max-content;
    max-width: none;
    flex: 0 0 auto;
    align-self: flex-start;
    margin-inline: auto;
    box-sizing: border-box;
}

.cr-room-hover-banner {
    position: absolute;
    top: -36px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--cr-surface);
    color: var(--cr-text);
    font-weight: 900;
    font-size: calc(clamp(0.82rem, 0.4vw + 0.45rem, 1.05rem) * var(--cr-ui-scale));
    padding: 0.25rem 0.95rem;
    border-radius: 999px;
    border: 2.5px solid var(--cr-border);
    box-shadow: 0 3px 0 var(--cr-border);
    z-index: 25;
    white-space: nowrap;
    pointer-events: none;
    gap: 0.35rem;
}

.cr-hover-object-sep {
    margin: 0 0.35rem;
    color: var(--cr-text-muted);
    font-weight: 700;
    opacity: 0.6;
}

.cr-hover-object-name,
.cr-hover-clutter-name {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 800;
    color: var(--cr-text);
}

.cr-hover-object-mini-art {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    vertical-align: middle;
}

.cr-hover-object-mini-art svg {
    width: 100%;
    height: 100%;
}

.cr-hover-object-badge {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    letter-spacing: 0.03em;
    line-height: 1.2;
    margin-left: 0.35rem;
}

.cr-hover-object-badge.cr-badge-blocked {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.cr-hover-object-badge.cr-badge-walkable {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #22c55e;
}

/* Dynamic Cursor Tooltip (Pill style matching Room Hover Banner) */
.cr-cursor-tooltip {
    position: fixed;
    top: -9999px;
    left: -9999px;
    background: var(--cr-surface);
    color: var(--cr-text);
    font-weight: 900;
    font-size: calc(clamp(0.82rem, 0.4vw + 0.45rem, 1.05rem) * var(--cr-ui-scale));
    padding: 0.25rem 0.95rem;
    border-radius: 999px;
    border: 2.5px solid var(--cr-border);
    box-shadow: 0 3px 0 var(--cr-border), 0 8px 20px rgba(15, 23, 42, 0.14);
    z-index: 1000;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.08s ease;
}

.cr-tooltip-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid var(--cr-border);
    display: inline-block;
    flex-shrink: 0;
}

.cr-tooltip-sep {
    opacity: 0.45;
    margin: 0 0.15rem;
}

/* Column & Row Headers (A..F, 1..6) */
.cr-col-headers {
    display: grid;
    margin-left: calc(var(--cr-cell-size) * 0.30 + 8px);
    margin-bottom: 4px;
}

.cr-col-header {
    text-align: center;
    font-weight: 900;
    font-size: calc(var(--cr-cell-size) * 0.15);
    color: var(--cr-text-secondary);
    padding: 2px 0;
    border-radius: 5px;
}

.cr-col-header.cr-axis-highlight,
.cr-row-header.cr-axis-highlight {
    background: color-mix(in srgb, var(--cr-highlight-color) 24%, white);
    color: #0f172a;
}

.cr-board-row-container {
    display: flex;
    align-items: stretch;
}

.cr-row-headers {
    display: grid;
    flex-shrink: 0;
    width: calc(var(--cr-cell-size) * 0.30);
    margin-right: 4px;
}

.cr-row-header {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: calc(var(--cr-cell-size) * 0.15);
    color: var(--cr-text-secondary);
    border-radius: 5px;
}

/* ============================================================================
   2.5D GRID & HARMONIOUS PASTEL/MUTED FLOOR PALETTE (LIKE MURDOKU)
   ============================================================================ */
.cr-grid {
    display: grid;
    flex: 0 0 auto;
    border: 4px solid #1e293b;
    border-radius: 8px;
    background: #1e293b;
    box-shadow: 0 6px 0 #1e293b;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.cr-cell {
    position: relative;
    width: var(--cr-cell-size);
    height: var(--cr-cell-size);
    box-sizing: border-box;
    border: 0 solid rgba(30, 41, 59, 0.22);
    cursor: pointer;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
}

/* Grid lines sit above floors but below scenery, without separating SVG slices. */
.cr-cell::before,
.cr-mini-cell::before {
    content: "";
    position: absolute;
    inset: 0;
    box-sizing: border-box;
    border: 1px solid;
    border-color: inherit;
    pointer-events: none;
    z-index: 2;
}

.cr-cell:hover {
    z-index: 12;
    filter: brightness(1.04);
    box-shadow: inset 0 0 0 2.5px #1e293b;
}

.cr-cell.cr-cell-blocked:hover {
    box-shadow: inset 0 0 0 3px #ef4444, inset 0 0 14px rgba(239, 68, 68, 0.45) !important;
    outline: 2px solid #ef4444 !important;
    cursor: not-allowed !important;
}

.cr-cell.has-open-menu {
    z-index: 110 !important;
    filter: none !important;
}

/* Scalable Vector Floor Layers (100% resolution & zoom independent) */
.cr-floor-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.cr-floor-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.cr-floor-wood { background-color: #e7cfa8; }
.cr-floor-stone { background-color: #cbd5e1; }
.cr-floor-marble { background-color: #f8fafc; }
.cr-floor-grass { background-color: #d1fae5; }
.cr-floor-noble { background-color: #e9d5ff; }
.cr-floor-slate { background-color: #cbd5e1; }
.cr-floor-checkered { background-color: #f8fafc; }
.cr-floor-sand { background-color: #fef3c7; }
.cr-floor-terracotta { background-color: #ea580c; }
.cr-floor-metal { background-color: #475569; }
.cr-floor-water { background-color: #38bdf8; }
.cr-floor-herringbone { background-color: #d4a373; }
.cr-floor-universal { background-color: #64748b; }

.cr-cell-blocked {
    box-shadow: inset 0 0 14px rgba(15, 23, 42, var(--cg-shadow-opacity));
}

.cr-cell-highlight {
    --cr-highlight-edge: clamp(3px, calc(var(--cr-cell-size) * 0.04), 6px);
}

.cr-cell-highlight::after {
    content: "";
    position: absolute;
    inset: 0;
    box-sizing: border-box;
    background: color-mix(in srgb, var(--cr-highlight-color) 30%, transparent);
    border: 0 solid var(--cr-highlight-color);
    border-width: var(--cr-highlight-n, 0px) var(--cr-highlight-e, 0px) var(--cr-highlight-s, 0px) var(--cr-highlight-w, 0px);
    pointer-events: none;
    z-index: 9;
}

.cr-highlight-n { --cr-highlight-n: var(--cr-highlight-edge); }
.cr-highlight-e { --cr-highlight-e: var(--cr-highlight-edge); }
.cr-highlight-s { --cr-highlight-s: var(--cr-highlight-edge); }
.cr-highlight-w { --cr-highlight-w: var(--cr-highlight-edge); }

.cr-coord-watermark {
    position: absolute;
    top: 3px;
    right: 4px;
    font-size: calc(var(--cr-cell-size) * 0.11);
    font-weight: 800;
    color: #334155;
    background: rgba(255, 255, 255, 0.72);
    padding: 0 4px;
    border-radius: 3px;
    pointer-events: none;
    z-index: 3;
    line-height: 1.2;
}

/* Permanent Murdoku-Style Room Name Label along the bottom wall of each room */
.cr-room-wall-label {
    position: absolute;
    transform: translate(-50%, -88%);
    font-family: 'Segoe UI Black', 'Arial Black', system-ui, sans-serif;
    font-size: calc(var(--cg-room-label-size) * (var(--cr-cell-size) / 96px));
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #ffffff;
    white-space: nowrap;
    pointer-events: none;
    z-index: 16;
    line-height: 1;
    padding: 0 4px;
    paint-order: stroke fill;
    -webkit-text-stroke: 3.5px #0f172a;
    text-shadow:
        -1.5px -1.5px 0 #0f172a,
         1.5px -1.5px 0 #0f172a,
        -1.5px  1.5px 0 #0f172a,
         1.5px  1.5px 0 #0f172a,
         0px    2px   3px rgba(0, 0, 0, 0.45);
    transition: color 0.12s ease, transform 0.12s ease;
}

.cr-room-wall-label.hovered {
    color: color-mix(in srgb, var(--cr-highlight-color) 65%, white);
    transform: translate(-50%, -88%) scale(1.06);
}

.cr-room-label-icon {
    display: inline-block;
    vertical-align: -0.1em;
    width: 0.95em;
    height: 0.95em;
    margin-right: 0.22em;
    fill: #ffffff;
    stroke: #0f172a;
    stroke-width: 2.2px;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.55));
}

.cr-room-wall-label.hovered .cr-room-label-icon {
    fill: color-mix(in srgb, var(--cr-highlight-color) 65%, white);
}

/* Layer 1B: 2.5D Walls, Doors & Windows */
.cr-edge-n-wall {
    position: absolute;
    top: calc(-0.5 * var(--cg-wall-width));
    left: -1px;
    right: -1px;
    height: var(--cg-wall-width);
    background: #1e293b;
    box-shadow: 0 2px 0 rgba(15, 23, 42, 0.25);
    z-index: 8;
    pointer-events: none;
}

.cr-edge-s-wall {
    position: absolute;
    bottom: calc(-0.5 * var(--cg-wall-width));
    left: -1px;
    right: -1px;
    height: var(--cg-wall-width);
    background: #1e293b;
    z-index: 8;
    pointer-events: none;
}

.cr-edge-e-wall {
    position: absolute;
    right: calc(-0.5 * var(--cg-wall-width));
    top: -1px;
    bottom: -1px;
    width: var(--cg-wall-width);
    background: #1e293b;
    z-index: 8;
    pointer-events: none;
}

.cr-edge-w-wall {
    position: absolute;
    left: calc(-0.5 * var(--cg-wall-width));
    top: -1px;
    bottom: -1px;
    width: var(--cg-wall-width);
    background: #1e293b;
    box-shadow: 2px 0 0 rgba(15, 23, 42, 0.2);
    z-index: 8;
    pointer-events: none;
}

/* Doors (Warm Wooden Threshold) */
.cr-edge-n-door::after,
.cr-edge-s-door::after {
    content: "";
    position: absolute;
    left: 24%;
    width: 52%;
    top: -2px;
    bottom: -2px;
    background: #d97706;
    border: 1.5px solid #0f172a;
    border-radius: 3px;
}

.cr-edge-e-door::after,
.cr-edge-w-door::after {
    content: "";
    position: absolute;
    top: 24%;
    height: 52%;
    left: -2px;
    right: -2px;
    background: #d97706;
    border: 1.5px solid #0f172a;
    border-radius: 3px;
}

/* Windows (Sky Blue Glass Pane) */
.cr-edge-n-window::after,
.cr-edge-s-window::after {
    content: "";
    position: absolute;
    left: 20%;
    width: 60%;
    top: -2px;
    bottom: -2px;
    background: #38bdf8;
    border: 1.5px solid #0f172a;
}

.cr-edge-e-window::after,
.cr-edge-w-window::after {
    content: "";
    position: absolute;
    top: 20%;
    height: 60%;
    left: -2px;
    right: -2px;
    background: #38bdf8;
    border: 1.5px solid #0f172a;
}

/* Layer 2 (Main Object) & Layer 3 (Clutter) - Proportional to Cell Size! */
.cr-object-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(var(--cg-object-scale));
    pointer-events: none;
    z-index: 2;
    overflow: visible;
}

.cr-clutter-layer {
    position: absolute;
    top: 6%;
    right: 6%;
    width: calc(var(--cr-cell-size) * 0.36);
    height: calc(var(--cr-cell-size) * 0.36);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
    pointer-events: none;
    filter: drop-shadow(0 1.5px 2.5px rgba(0, 0, 0, 0.45));
}

/* Layer 4: Actor Cell Portraits (Only Color + Portrait/Letter inside Rectangle, NO Name Text!) */
.cr-actor-token {
    position: relative;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(var(--cr-cell-size) * 0.85);
    height: calc(var(--cr-cell-size) * 0.85);
    margin-bottom: calc(var(--cr-cell-size) * 0.02);
    padding: 0;
    border-radius: calc(var(--cr-cell-size) * 0.16);
    background: var(--actor-color, #64748b);
    border: 2.5px solid #0f172a;
    box-shadow: 0 3px 0 rgba(15, 23, 42, 0.35);
    transition: transform 0.1s ease, box-shadow 0.1s ease, outline 0.1s ease;
    overflow: visible;
}

.cr-actor-token:hover,
.cr-actor-token.cr-actor-hovered {
    transform: scale(1.06);
}

.cr-actor-token.cr-r1-innocent {
    outline: 3.5px solid #16a34a;
    box-shadow: 0 0 0 2px #ffffff, 0 4px 0 #15803d;
}

.cr-actor-token.cr-r1-suspect {
    outline: 3.5px solid #dc2626;
    box-shadow: 0 0 0 2px #ffffff, 0 4px 0 #b91c1c;
}

.cr-actor-token.cr-r2-placed {
    box-shadow: 0 3px 0 #0f172a;
    animation: crTokenPopIn 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transform-origin: center center;
}

.cr-actor-token.cr-token-collision {
    box-shadow: 0 0 0 3px #ef4444, 0 4px 6px rgba(239, 68, 68, 0.4) !important;
}

.cr-actor-token.cr-token-discrepancy {
    box-shadow: 0 0 0 3px #f59e0b, 0 4px 6px rgba(245, 158, 11, 0.4) !important;
}

.cr-actor-token.cr-token-removing {
    animation: crTokenPopOut 0.13s cubic-bezier(0.4, 0, 1, 1) forwards !important;
    pointer-events: none;
}

@keyframes crTokenPopIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    70% {
        transform: scale(1.08);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes crTokenPopOut {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.2);
        opacity: 0;
    }
}

.cr-portrait-art-clip {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cr-portrait-letter {
    font-family: 'Segoe UI Black', 'Arial Black', system-ui, sans-serif;
    font-size: calc(var(--cr-cell-size) * 0.38);
    font-weight: 900;
    color: #ffffff;
    line-height: 1;
    user-select: none;
    paint-order: stroke fill;
    -webkit-text-stroke: 3px #0f172a;
    text-shadow: 0 2px 0 #0f172a;
}

.cr-card-portrait .cr-portrait-letter {
    font-size: calc(26px * var(--cr-ui-scale));
}

.cr-status-corner-badge {
    position: absolute;
    bottom: calc(var(--cr-cell-size) * -0.04);
    right: calc(var(--cr-cell-size) * -0.04);
    width: calc(var(--cr-cell-size) * 0.30);
    height: calc(var(--cr-cell-size) * 0.30);
    min-width: 24px;
    min-height: 24px;
    border-radius: 50%;
    border: max(2.5px, calc(var(--cr-cell-size) * 0.022)) solid #0f172a;
    color: #ffffff;
    font-size: calc(var(--cr-cell-size) * 0.17);
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 2.5px 0 #0f172a;
    line-height: 1;
    transform-origin: center center;
    animation: crCornerBadgePopIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes crCornerBadgePopIn {
    0% {
        transform: scale(0.2);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.cr-status-corner-badge svg,
.cr-status-corner-badge .cr-icon {
    width: 68% !important;
    height: 68% !important;
    display: block;
}

.cr-card-portrait .cr-status-corner-badge {
    bottom: -5px;
    right: -5px;
    width: calc(20px * var(--cr-ui-scale));
    height: calc(20px * var(--cr-ui-scale));
    font-size: calc(0.72rem * var(--cr-ui-scale));
}

/* Sidebar Cell Portrait Box (Left of Clue/Person Info) */
.cr-person-card-layout {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.cr-card-portrait-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    width: calc(52px * var(--cr-ui-scale));
}

.cr-portrait-coord-badge {
    font-size: calc(0.7rem * var(--cr-ui-scale));
    font-weight: 800;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
    border: 1.5px solid #0f172a;
    box-shadow: 0 1.5px 0 #0f172a;
    width: 100%;
    max-width: calc(52px * var(--cr-ui-scale));
    text-align: center;
    line-height: 1.15;
    letter-spacing: 0.02em;
    box-sizing: border-box;
}

.cr-portrait-coord-badge .cr-icon {
    width: 11px !important;
    height: 11px !important;
    stroke-width: 2.6px;
}

.cr-card-portrait {
    position: relative;
    width: calc(52px * var(--cr-ui-scale));
    height: calc(52px * var(--cr-ui-scale));
    border-radius: 10px;
    border: 2.5px solid #0f172a;
    box-shadow: 0 3px 0 rgba(15, 23, 42, 0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: visible;
}

.cr-card-portrait.cr-r1-innocent {
    outline: 3px solid #16a34a;
}

.cr-card-portrait.cr-r1-suspect {
    outline: 3px solid #dc2626;
}

.cr-card-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cr-actor-header-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.45rem;
    line-height: 1.3;
}

.cr-actor-name {
    font-size: calc(0.95rem * var(--cr-ui-scale));
    font-weight: 800;
    color: var(--cr-text);
}

.cr-actor-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: calc(0.78rem * var(--cr-ui-scale));
    font-weight: 600;
    color: var(--cr-text-muted);
}

.cr-meta-role {
    color: var(--cr-text-secondary);
}

.cr-meta-sep {
    opacity: 0.55;
    font-weight: 800;
}

.cr-meta-coord {
    font-weight: 700;
    font-size: calc(0.73rem * var(--cr-ui-scale));
    color: var(--cr-text-secondary);
    background: rgba(15, 23, 42, 0.065);
    padding: 0.05rem 0.4rem;
    border-radius: 5px;
}

.cr-theme-dark .cr-meta-coord {
    background: rgba(255, 255, 255, 0.1);
}

.cr-clue-locked-hint {
    font-size: calc(0.76rem * var(--cr-ui-scale));
    color: var(--cr-text-muted);
    font-style: italic;
}

/* Segmented Top Border for Portrait Color Markings (Board & Sidebar) */
.cr-portrait-top-segments {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--cr-cell-size) * 0.115);
    min-height: 9px;
    display: flex;
    overflow: hidden;
    border-top-left-radius: calc(var(--cr-cell-size) * 0.105);
    border-top-right-radius: calc(var(--cr-cell-size) * 0.105);
    border-bottom: 2.5px solid #0f172a;
    z-index: 8;
    pointer-events: none;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.35);
}

.cr-card-portrait .cr-portrait-top-segments {
    height: 9px;
    min-height: 9px;
    border-top-left-radius: 7.5px;
    border-top-right-radius: 7.5px;
    border-bottom: 2px solid #0f172a;
}

.cr-color-segment {
    flex: 1;
    height: 100%;
}

.cr-color-segment + .cr-color-segment {
    border-left: 2px solid #0f172a;
}

/* Segmented Left Border for Clue Card Color Markings */
.cr-card-left-segments {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
    border-right: 2px solid #0f172a;
    z-index: 6;
    pointer-events: none;
}

.cr-color-segment-v {
    flex: 1;
    width: 100%;
}

.cr-color-segment-v + .cr-color-segment-v {
    border-top: 2px solid #0f172a;
}

.cr-color-dot {
    width: calc(var(--cr-cell-size) * 0.12);
    height: calc(var(--cr-cell-size) * 0.12);
    min-width: 11px;
    min-height: 11px;
    border-radius: 50%;
    border: 1.5px solid #0f172a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    display: inline-block;
}

/* Layer 5A: Candidate Mini-Badges in Top-Left of Cell (Round 2) */
.cr-candidates-grid {
    --cr-note-columns: 3;
    --cr-note-rows: var(--cr-note-columns);
    --cr-note-size: min(max(21px, calc(var(--cr-cell-size) * .23)), calc((var(--cr-cell-size) - 12px - (var(--cr-note-columns) - 1) * 2px) / var(--cr-note-columns)), calc((var(--cr-cell-size) - 12px - (var(--cr-note-rows) - 1) * 2px) / var(--cr-note-rows)));
    position: absolute;
    inset: 4px;
    display: grid;
    grid-template-columns: repeat(var(--cr-note-columns), var(--cr-note-size));
    grid-auto-rows: var(--cr-note-size);
    align-content: start;
    gap: 2px;
    z-index: 6;
    pointer-events: none;
}

.cr-candidates-grid > :is(.cr-mini-badge, .cr-symbol-note) {
    width: var(--cr-note-size);
    height: var(--cr-note-size);
    min-width: 0;
    min-height: 0;
    font-size: calc(var(--cr-note-size) * .56);
    border-width: min(1.5px, calc(var(--cr-note-size) * .07));
    border-radius: min(5px, calc(var(--cr-note-size) * .23));
    box-shadow: 0 min(1.5px, calc(var(--cr-note-size) * .07)) 0 #0f172a;
}

.cr-mini-badge {
    width: calc(var(--cr-cell-size) * 0.23);
    height: calc(var(--cr-cell-size) * 0.23);
    min-width: 21px;
    min-height: 21px;
    border-radius: 5px;
    border: 1.5px solid #0f172a;
    font-size: calc(var(--cr-cell-size) * 0.13);
    font-weight: 900;
    color: #0f172a;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1.5px 0 #0f172a;
    transform-origin: center center;
    animation: crBadgePopIn 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.cr-mini-badge.cr-badge-removing {
    animation: crBadgePopOut 0.12s cubic-bezier(0.4, 0, 1, 1) forwards !important;
}

@keyframes crBadgePopIn {
    0% {
        transform: scale(0.2);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes crBadgePopOut {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.2);
        opacity: 0;
    }
}

/* ============================================================================
   ROUND 2 ABSTRACT DEDUCTION SYMBOL NOTES (PURE COMIC SHAPE, NO BOX BACKGROUND)
   ============================================================================ */
.cr-symbol-note {
    width: calc(var(--cr-cell-size) * 0.23);
    height: calc(var(--cr-cell-size) * 0.23);
    min-width: 21px;
    min-height: 21px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0;
    margin: 0;
    pointer-events: none;
    transform-origin: center center;
    animation: crBadgePopIn 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.cr-symbol-note svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 1.5px 0 #0f172a);
    display: block;
    overflow: visible;
}

.cr-symbol-note.cr-badge-removing {
    animation: crBadgePopOut 0.12s cubic-bezier(0.4, 0, 1, 1) forwards !important;
}

.cr-symbol-note.cr-badge-preview {
    opacity: 0.50 !important;
    animation: crBadgePreviewPop 0.12s ease-out forwards;
}

.cr-symbol-note.cr-badge-preview svg {
    stroke-dasharray: 3.5 2;
    filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.3));
}

.cr-symbol-note.cr-badge-hover-remove {
    opacity: 0.45 !important;
    filter: grayscale(0.2);
}

.cr-symbol-note.cr-badge-hover-remove svg {
    stroke: #dc2626 !important;
    stroke-width: 3px !important;
    filter: drop-shadow(0 0 3px rgba(220, 38, 38, 0.6)) !important;
}

.cr-theme-dark .cr-symbol-note svg {
    filter: drop-shadow(0 1.5px 0 #000000);
}

.cr-theme-dark .cr-symbol-note.cr-badge-preview svg {
    stroke: #f8fafc;
}

/* ============================================================================
   ROUND 2 CANDIDATE NOTE & TOKEN HOVER PREVIEWS (GHOST VISUALS WITH LOWER OPACITY)
   ============================================================================ */
.cr-mini-badge.cr-badge-preview {
    opacity: 0.50 !important;
    border: 1.5px dashed #0f172a !important;
    box-shadow: 0 1.5px 4px rgba(15, 23, 42, 0.25) !important;
    pointer-events: none;
    animation: crBadgePreviewPop 0.12s ease-out forwards;
}

.cr-theme-dark .cr-mini-badge.cr-badge-preview {
    border-color: #f8fafc !important;
    box-shadow: 0 1.5px 5px rgba(0, 0, 0, 0.4) !important;
}

.cr-mini-badge.cr-badge-hover-remove {
    opacity: 0.40 !important;
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 1.5px #dc2626 !important;
    filter: grayscale(0.25);
}

@keyframes crBadgePreviewPop {
    0% {
        transform: scale(0.6);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 0.50;
    }
}

.cr-actor-token.cr-token-preview {
    opacity: 0.45 !important;
    border: max(2.5px, calc(var(--cr-cell-size) * 0.025)) dashed #0f172a !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2) !important;
    pointer-events: none;
    z-index: 10;
    animation: crTokenPreviewPop 0.12s ease-out forwards;
}

.cr-theme-dark .cr-actor-token.cr-token-preview {
    border-color: #f8fafc !important;
}

@keyframes crTokenPreviewPop {
    0% {
        transform: scale(0.85);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 0.45;
    }
}

.cr-cross-overlay.cr-cross-preview {
    opacity: 0.35 !important;
    pointer-events: none;
    z-index: 10;
    animation: none !important;
}

.cr-cross-overlay.cr-cross-hover-remove {
    opacity: 0.35 !important;
    color: #dc2626 !important;
    filter: drop-shadow(0 0 2px rgba(220, 38, 38, 0.5));
}

/* Layer 5B: Manual & Auto Cross ('X') */
.cr-cross-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0f172a;
    transform: scale(var(--cg-cross-scale));
    pointer-events: none;
    z-index: 5;
    transform-origin: center center;
    animation: crCrossPopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: var(--cr-cross-delay, 0ms);
}

.cr-theme-dark .cr-cross-overlay {
    color: #f8fafc;
}

.cr-cross-overlay.cr-cross-auto {
    color: #1e293b;
}

.cr-theme-dark .cr-cross-overlay.cr-cross-auto {
    color: #e2e8f0;
}

.cr-cross-overlay .cr-board-cross-mark {
    width: 100%;
    height: 100%;
    stroke-width: 4.4;
    stroke-linecap: round;
    filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.75));
}

.cr-cross-overlay.cr-cross-static {
    animation: none;
}

@media (prefers-reduced-motion: reduce) {
    .cr-cross-overlay {
        animation: none;
    }
}

.cr-cross-overlay.cr-cross-removing {
    animation: crCrossPopOut 0.12s cubic-bezier(0.4, 0, 1, 1) forwards !important;
}

@keyframes crCrossPopIn {
    0% {
        transform: scale(calc(var(--cg-cross-scale) * 0.2));
        opacity: 0;
    }
    100% {
        transform: scale(var(--cg-cross-scale));
        opacity: 1;
    }
}

@keyframes crCrossPopOut {
    0% {
        transform: scale(var(--cg-cross-scale));
        opacity: 1;
    }
    100% {
        transform: scale(calc(var(--cg-cross-scale) * 0.2));
        opacity: 0;
    }
}

/* ============================================================================
   ROUND 2 LONG-PRESS GROWING INDICATOR (SQUARE IN SCHWARZ/GRAU 50% TRANSPARENZ)
   ============================================================================ */
.cr-longpress-square {
    position: absolute;
    width: calc(var(--cr-cell-size) * 0.85);
    height: calc(var(--cr-cell-size) * 0.85);
    margin-bottom: calc(var(--cr-cell-size) * 0.02);
    border-radius: calc(var(--cr-cell-size) * 0.16);
    background: rgba(15, 23, 42, 0.50);
    pointer-events: none;
    z-index: 25;
    transform-origin: center center;
    animation: crLongPressGrow 380ms linear forwards;
}

.cr-theme-dark .cr-longpress-square {
    background: rgba(248, 250, 252, 0.50);
}

@keyframes crLongPressGrow {
    0% {
        transform: scale(0);
        opacity: 0.1;
    }
    100% {
        transform: scale(1);
        opacity: 0.50;
    }
}

/* ============================================================================
   ROUND 1 GHOST / REFERENCE POSITION TOKENS ON ROUND 2 BOARD (FESTE GRUNDEBENE)
   Exact same square style & colored background as Round 1, but with dashed border!
   ============================================================================ */
.cr-actor-token.cr-r1-ghost-square {
    position: relative;
    z-index: 4;
    border: max(2.5px, calc(var(--cr-cell-size) * 0.025)) dashed #0f172a;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.2);
    opacity: 0.85;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease, border-color 0.12s ease;
}

.cr-theme-dark .cr-actor-token.cr-r1-ghost-square {
    border-color: #f8fafc;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.cr-actor-token.cr-r1-ghost-square:hover,
.cr-actor-token.cr-r1-ghost-square.cr-actor-hovered {
    transform: scale(1.08);
    opacity: 1;
    border-color: #3b82f6;
    border-style: dashed;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.6), 0 4px 10px rgba(0, 0, 0, 0.25);
    z-index: 15;
}

/* ============================================================================
   ROUND 1 RADIAL / CIRCLE MENU & RIGHT-CLICK COMMIT POPOVER
   ============================================================================ */
.cr-click-away-overlay {
    position: fixed;
    inset: 0;
    z-index: 95;
    background: transparent;
}

.cr-circle-menu-backdrop {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 120;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cr-circle-menu-backdrop.cr-circle-menu-fixed {
    position: fixed;
    z-index: 135;
}

.cr-circle-menu {
    position: relative;
    width: calc(var(--cr-cell-size) * 1.54);
    height: calc(var(--cr-cell-size) * 1.54);
    flex-shrink: 0;
    border-radius: 50%;
    background: transparent;
    border: none;
    box-shadow: none;
    pointer-events: none;
    z-index: 125;
}

@keyframes crCircleItemPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.3);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.cr-circle-item {
    position: absolute;
    transform: translate(-50%, -50%);
    width: calc(var(--cr-cell-size) * 0.27);
    height: calc(var(--cr-cell-size) * 0.27);
    min-width: 26px;
    min-height: 26px;
    font-size: calc(var(--cr-cell-size) * 0.135);
    border-radius: 50%;
    border: max(2.5px, calc(var(--cr-cell-size) * 0.022)) solid #0f172a;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.35), 0 2px 0 #0f172a;
    cursor: pointer;
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    animation: crCircleItemPop 0.14s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    transition: transform 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
}

.cr-circle-item.cr-circle-item-hypothesis {
    width: calc(var(--cr-cell-size) * 0.30);
    height: calc(var(--cr-cell-size) * 0.30);
    min-width: 30px;
    min-height: 30px;
    font-size: calc(var(--cr-cell-size) * 0.15);
}

.cr-circle-item:hover {
    transform: translate(-50%, -50%) scale(1.18);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.45), 0 2px 0 #0f172a;
    z-index: 130;
}

.cr-circle-item.active {
    border: max(2.5px, calc(var(--cr-cell-size) * 0.022)) solid #ffffff;
    outline: max(3px, calc(var(--cr-cell-size) * 0.025)) solid #0f172a;
    transform: translate(-50%, -50%) scale(1.12);
}

.cr-filter-bar .cr-circle-item {
    position: static;
    transform: none;
    width: calc(24px * var(--cr-ui-scale));
    height: calc(24px * var(--cr-ui-scale));
    min-width: 20px;
    min-height: 20px;
    border-width: 2px;
}

.cr-filter-bar .cr-circle-item:hover {
    transform: scale(1.15);
}

.cr-filter-bar .cr-circle-item.active {
    transform: scale(1.12);
    border-width: 2px;
    outline-width: 2.5px;
}

.cr-commit-popover {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 190px;
    background: var(--cr-surface);
    color: var(--cr-text);
    border: 3px solid #0f172a;
    border-radius: 12px;
    padding: 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.35), 0 4px 0 #0f172a;
    z-index: 125;
}

.cr-commit-popover .cr-btn {
    width: 100%;
    justify-content: center;
}

/* ============================================================================
   RIGHT SIDE PANEL: COHESIVE CASE-FILE LOOK AS FULL-HEIGHT DOCKED SIDEBAR
   ============================================================================ */
.cr-side-panel {
    background: var(--cr-surface);
    color: var(--cr-text);
    border-left: 2.5px solid var(--cr-border);
    border-top: none;
    border-right: none;
    border-bottom: none;
    border-radius: 0;
    box-shadow: -4px 0 20px rgba(15, 23, 42, 0.05);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    width: calc(clamp(480px, 32vw, 640px) * var(--cr-ui-scale));
    flex-shrink: 0;
    overflow: hidden;
    box-sizing: border-box;
    z-index: 10;
}

.cr-panel-header {
    padding: 0.85rem 1.1rem;
    background: var(--cr-surface-alt);
    border-bottom: 2px solid var(--cr-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.cr-filter-bar {
    padding: 0.55rem 1.1rem;
    background: var(--cr-surface);
    border-bottom: 1.5px solid var(--cr-border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--cr-text-secondary);
}

/* ============================================================================
   CASE DESIGNER: TOP-PINNED SOLVER STATUS IN RIGHT SIDEBAR
   ============================================================================ */
.cr-designer-solver-panel {
    background: var(--cr-surface-alt);
    border-bottom: 2.5px solid var(--cr-border);
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.04);
}

.cr-solver-status-rows {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.cr-solver-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.cr-designer-feedback {
    font-size: 0.78rem;
    line-height: 1.3;
}

.cr-panel-scroll {
    flex: 1;
    min-height: 0;
    padding: 0.9rem 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

/* Photoshop-Style Note Layer Panel */
.cr-layer-panel {
    background: var(--cr-surface-alt);
    border-bottom: 2px solid var(--cr-border);
    padding: 0.55rem 0.85rem;
    transition: none;
}

.cr-layer-panel.cr-layer-panel-collapsed {
    padding: 0.55rem 0.85rem;
}

.cr-layer-header {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    min-height: 28px;
    margin-bottom: 0.4rem;
}

.cr-layer-panel.cr-layer-panel-collapsed .cr-layer-header {
    margin-bottom: 0;
}

.cr-layer-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 180px;
    overflow-y: auto;
}

.cr-layer-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    background: var(--cr-surface);
    border: 1.5px solid var(--cr-border-soft);
    color: var(--cr-text);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.cr-layer-row:hover {
    border-color: var(--cr-border);
}

.cr-layer-row.active {
    background: var(--cr-primary-soft);
    color: var(--cr-primary-text);
    border: 2px solid var(--cr-primary);
    font-weight: 800;
}

.cr-layer-row.cr-layer-base-r1 {
    background: rgba(148, 163, 184, 0.12);
    border: 1.5px dashed var(--cr-border);
    margin-top: 0.25rem;
}

.cr-layer-row.cr-layer-base-r1:hover {
    background: rgba(148, 163, 184, 0.22);
    border-color: var(--cr-text-secondary);
}

.cr-layer-row.cr-layer-base-r1.active {
    background: rgba(59, 130, 246, 0.12);
    border: 1.5px dashed #3b82f6;
    color: var(--cr-text);
}

.cr-layer-row.cr-layer-base-r1.muted {
    opacity: 0.65;
}

.cr-icon-btn {
    background: var(--cr-surface);
    border: 1.5px solid var(--cr-border-soft);
    border-radius: 6px;
    padding: 0 !important;
    width: 24px;
    height: 24px;
    min-width: 24px;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--cr-text);
    cursor: pointer;
    line-height: 1 !important;
    box-sizing: border-box;
    flex-shrink: 0;
    transition: transform 0.08s ease, background-color 0.12s ease, border-color 0.12s ease;
}

.cr-icon-btn .cr-icon,
.cr-icon-btn svg {
    display: block !important;
    margin: auto !important;
    vertical-align: middle !important;
}

.cr-icon-btn:hover {
    border-color: var(--cr-border);
    background: var(--cr-surface-hover);
}

.cr-icon-btn.muted {
    opacity: 0.42;
}

.cr-icon-btn.solo {
    background: #fef08a;
    color: #0f172a;
    border-color: #0f172a;
}

/* Global Case Rules Box */
.cr-global-rules-box {
    background: #f5f3ff;
    color: #1e1b4b;
    border: 2px solid #7e22ce;
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
}

.cr-theme-dark .cr-global-rules-box {
    background: rgba(126, 34, 206, 0.2);
    color: #f3e8ff;
    border-color: #a855f7;
}

.cr-global-rules-title {
    font-weight: 900;
    font-size: 0.84rem;
    color: #581c87;
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.cr-theme-dark .cr-global-rules-title {
    color: #e9d5ff;
}

/* Clue & Suspect Cards (High-Contrast Paper Cards) */
.cr-clue-card,
.cr-suspect-card {
    position: relative;
    background: var(--cr-surface-alt);
    color: var(--cr-text);
    border: 2px solid var(--cr-border-soft);
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
    cursor: pointer;
    transition: border-color 0.12s ease, background-color 0.12s ease, box-shadow 0.12s ease, padding-left 0.12s ease;
}

.cr-designer-actor-card {
    border: 2px solid var(--cr-border-soft);
    background: var(--cr-surface);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.cr-designer-actor-card:hover {
    border-color: var(--cr-primary);
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.15);
    transform: translateY(-1px);
}

.cr-designer-actor-card.is-selected {
    border-color: var(--cr-primary) !important;
    background: #e0f2fe !important;
    box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25), 0 3px 8px rgba(2, 132, 199, 0.2) !important;
}

.cr-clue-card.has-left-color-segments {
    padding-left: 1.35rem;
}

.cr-clue-card.has-open-menu {
    z-index: 120 !important;
    border-color: var(--cr-border);
    background: var(--cr-surface);
    opacity: 1 !important;
}

.cr-clue-card:hover,
.cr-suspect-card:hover {
    border-color: var(--cr-border);
    background: var(--cr-surface);
}

.cr-clue-card.selected,
.cr-clue-card.cr-card-highlighted,
.cr-suspect-card.selected,
.cr-suspect-card.cr-card-highlighted {
    border: 2.5px solid #0f172a;
    background: #fef9c3;
    color: #0f172a;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14), 0 3px 0 #0f172a;
}

.cr-theme-dark .cr-clue-card.selected,
.cr-theme-dark .cr-clue-card.cr-card-highlighted,
.cr-theme-dark .cr-suspect-card.selected,
.cr-theme-dark .cr-suspect-card.cr-card-highlighted {
    border-color: #fde047;
    background: rgba(234, 179, 8, 0.22);
    color: #f8fafc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 3px 0 #fde047;
}

.cr-clue-card.cr-clue-checked.selected,
.cr-clue-card.cr-clue-checked.cr-card-highlighted,
.cr-suspect-card.cr-clue-checked.selected,
.cr-suspect-card.cr-clue-checked.cr-card-highlighted {
    border-color: #16a34a !important;
    background: #fef9c3;
    box-shadow: 0 0 0 2.5px #0f172a, 0 4px 12px rgba(15, 23, 42, 0.14), 0 3px 0 #0f172a !important;
}

.cr-theme-dark .cr-clue-card.cr-clue-checked.selected,
.cr-theme-dark .cr-clue-card.cr-clue-checked.cr-card-highlighted,
.cr-theme-dark .cr-suspect-card.cr-clue-checked.selected,
.cr-theme-dark .cr-suspect-card.cr-clue-checked.cr-card-highlighted,
.cr-theme-dark .cr-suspect-card.placed.selected,
.cr-theme-dark .cr-suspect-card.placed.cr-card-highlighted {
    border-color: #22c55e !important;
    background: rgba(234, 179, 8, 0.25);
    box-shadow: 0 0 0 2.5px #fde047, 0 4px 12px rgba(0, 0, 0, 0.4), 0 3px 0 #fde047 !important;
}

.cr-clue-card.cr-clue-checked.selected,
.cr-clue-card.cr-clue-checked.cr-card-highlighted,
.cr-suspect-card.cr-clue-checked.selected,
.cr-suspect-card.cr-clue-checked.cr-card-highlighted,
.cr-suspect-card.placed.selected,
.cr-suspect-card.placed.cr-card-highlighted {
    border-color: #16a34a !important;
}

.cr-clue-card.cr-clue-checked,
.cr-suspect-card.cr-clue-checked,
.cr-suspect-card.placed {
    border: 3.5px solid #16a34a !important;
}

.cr-theme-dark .cr-clue-card.cr-clue-checked,
.cr-theme-dark .cr-suspect-card.cr-clue-checked,
.cr-theme-dark .cr-suspect-card.placed {
    border-color: #22c55e !important;
}

.cr-clue-checked .cr-clue-text {
    opacity: 0.58;
    transition: opacity 0.15s ease;
}

.cr-clue-card.cr-clue-checked:hover .cr-clue-text,
.cr-suspect-card.cr-clue-checked:hover .cr-clue-text {
    opacity: 0.85;
}

/* Clue Completion Status Badge (Anchored at Top-Left Corner) */
.cr-clue-status-badge {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #0f172a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
    z-index: 10;
    outline: none;
    box-shadow: 0 2px 0 #0f172a;
}

/* Rich Instant Hover Tooltip for Clue & Witness Status Badges */
.cr-clue-status-badge[data-cr-tooltip]::after {
    content: attr(data-cr-tooltip);
    position: absolute;
    top: calc(100% + 7px);
    left: -2px;
    background: #0f172a;
    color: #f8fafc;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1.25;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-3px);
    transition: opacity 0.14s ease, transform 0.14s ease;
    z-index: 100;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.cr-clue-status-badge[data-cr-tooltip]::before {
    content: "";
    position: absolute;
    top: calc(100% + 1px);
    left: 7px;
    border: 5px solid transparent;
    border-bottom-color: #0f172a;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-3px);
    transition: opacity 0.14s ease, transform 0.14s ease;
    z-index: 100;
}

.cr-clue-status-badge[data-cr-tooltip]:hover::after,
.cr-clue-status-badge[data-cr-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.cr-clue-status-badge.neutral {
    background: var(--cr-surface);
    color: #0f172a;
}

.cr-clue-status-badge.neutral .cr-icon {
    opacity: 0;
    color: #16a34a;
    transition: opacity 0.12s ease;
}

.cr-clue-status-badge.neutral:hover {
    transform: scale(1.15);
    background: #f1f5f9;
}

.cr-clue-status-badge.neutral:hover .cr-icon {
    opacity: 0.5;
}

.cr-clue-status-badge.checked {
    background: #16a34a;
    border-color: #0f172a;
    color: #ffffff;
    box-shadow: 0 2.5px 0 #0f172a;
}

.cr-clue-status-badge.checked:hover {
    transform: scale(1.15);
    background: #15803d;
}

.cr-clue-status-badge svg,
.cr-clue-status-badge .cr-icon {
    width: 68% !important;
    height: 68% !important;
    display: block;
    stroke-width: 2.8px;
}

.cr-clue-status-badge.locked,
.cr-clue-status-badge:disabled:not(.checked) {
    cursor: default;
    background: var(--cr-surface) !important;
    color: var(--cr-text-muted, #64748b) !important;
    border-color: #0f172a;
    box-shadow: 0 2px 0 #0f172a;
    transform: none !important;
}

.cr-clue-status-badge.locked svg,
.cr-clue-status-badge.locked .cr-icon {
    width: 62% !important;
    height: 62% !important;
    opacity: 0.75;
    stroke-width: 2.2px;
}

.cr-clue-status-badge.neutral:disabled svg,
.cr-clue-status-badge.neutral:disabled .cr-icon {
    opacity: 0 !important;
    display: none !important;
}

.cr-clue-status-badge:disabled.checked {
    cursor: default;
    background: #16a34a !important;
    border-color: #0f172a !important;
    color: #ffffff !important;
    box-shadow: 0 2.5px 0 #0f172a !important;
    transform: none !important;
}

.cr-clue-status-badge:disabled.checked svg,
.cr-clue-status-badge:disabled.checked .cr-icon {
    opacity: 1 !important;
    color: #ffffff !important;
    stroke-width: 2.8px;
}

.cr-theme-dark .cr-clue-status-badge.neutral {
    background: #1e293b;
    border-color: #0f172a;
    box-shadow: 0 2px 0 #000000;
}

.cr-theme-dark .cr-clue-status-badge.neutral:hover {
    background: #334155;
}

.cr-theme-dark .cr-clue-status-badge.checked,
.cr-theme-dark .cr-clue-status-badge:disabled.checked {
    background: #16a34a !important;
    border-color: #0f172a !important;
    color: #ffffff !important;
    box-shadow: 0 2.5px 0 #000000 !important;
}

.cr-theme-dark .cr-clue-status-badge.locked,
.cr-theme-dark .cr-clue-status-badge:disabled:not(.checked) {
    background: #1e293b !important;
    color: #94a3b8 !important;
    border-color: #0f172a;
    box-shadow: 0 2px 0 #000000;
}

.cr-suspect-card-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.4rem;
}

.cr-person-eye-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-right: 0.5rem;
}

.cr-speaker-badge {
    background: var(--cr-surface);
    color: var(--cr-text);
    border: 1.5px solid var(--cr-border);
    font-weight: 800;
    font-size: 0.76rem;
    padding: 0.18rem 0.55rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.cr-clue-text {
    font-size: calc(clamp(0.88rem, 0.45vw + 0.45rem, 1.15rem) * var(--cr-ui-scale));
    font-weight: 500;
    line-height: 1.55;
    color: var(--cr-text);
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: manual;
}

/* Interactive Clue Token Styling (Readable on Both Light & Dark Cards!) */
.cr-clue-token-kw {
    font-weight: 800;
    color: var(--cr-text);
    background: rgba(234, 179, 8, 0.28);
    border-bottom: 2px dotted #b45309;
    cursor: help;
    padding: 0 4px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap !important;
    word-break: keep-all !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
}

.cr-clue-token-ref {
    font-weight: 800;
    color: var(--cr-primary-text);
    padding: 1px 6px;
    border-radius: 5px;
    background: var(--cr-primary-soft);
    border-bottom: 2px solid var(--cr-primary);
    cursor: pointer;
    transition: background-color 0.12s;
    display: inline-flex;
    align-items: center;
    white-space: nowrap !important;
    word-break: keep-all !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
}

.cr-clue-token-ref:hover,
.cr-clue-token-ref:focus-visible {
    background: color-mix(in srgb, var(--cr-highlight-color) 30%, white);
    color: #0f172a;
    border-bottom-color: var(--cr-highlight-color);
}

/* ============================================================================
   MODALS (Options & HowToPlay)
   ============================================================================ */
.cr-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.cr-modal-copilot-backdrop {
    background: rgba(15, 23, 42, 0.2) !important;
    justify-content: flex-end !important;
    padding-right: 2.5rem !important;
}

@media (max-width: 992px) {
    .cr-modal-copilot-backdrop {
        justify-content: center !important;
        padding-right: 1rem !important;
    }
}

.cr-modal-window {
    background: var(--cr-surface);
    color: var(--cr-text);
    border: 3px solid var(--cr-border);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
    width: 100%;
    max-width: 640px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cr-modal-header {
    padding: 0.9rem 1.25rem;
    background: var(--cr-surface-alt);
    border-bottom: 2px solid var(--cr-border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 56px;
    box-sizing: border-box;
}

.cr-modal-title {
    margin: 0;
    font-weight: 900;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.25;
}

.cr-modal-close {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    max-width: 34px;
    max-height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    flex-shrink: 0;
    box-sizing: border-box;
}

.cr-modal-subheader {
    flex-shrink: 0;
}

.cr-modal-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.75rem 1.25rem 0;
}

.cr-modal-tabs .cr-btn {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
}

.cr-modal-footer {
    padding: 0.75rem 1.25rem;
    background: var(--cr-surface-alt);
    border-top: 2px solid var(--cr-border-soft);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.cr-modal-body {
    padding: 1.15rem 1.25rem;
    overflow-y: auto;
}

/* ============================================================================
   FAQ ACCORDION (HowToPlayModal)
   ============================================================================ */
.cr-faq-item {
    border: 2px solid var(--cr-border, #0f172a);
    border-radius: 10px;
    background: var(--cr-surface);
    color: var(--cr-text);
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

.cr-faq-item:hover {
    background: var(--cr-surface-hover);
}

.cr-faq-item.expanded {
    border: 2.5px solid #0f172a;
    background: #fef9c3;
    color: #0f172a;
}

.cr-theme-dark .cr-faq-item.expanded {
    border-color: #fde047;
    background: rgba(234, 179, 8, 0.18);
    color: #fef08a;
}

.cr-faq-item:focus-visible {
    outline: 2px solid var(--cr-primary, #2563eb);
    outline-offset: 2px;
}

.cr-faq-header {
    font-weight: 900;
    user-select: none;
}

.cr-faq-body {
    user-select: text;
}

/* ============================================================================
   CUSTOM SELECT BOX (CrimeRewind Design System - No OS Style)
   ============================================================================ */
.cr-select-container {
    position: relative;
    display: inline-block;
}

.cr-select-container.open {
    z-index: 3005;
}

.cr-select-trigger {
    background-color: var(--cr-surface-alt);
    color: var(--cr-text);
    border: 2px solid var(--cr-border);
    border-radius: 8px;
    padding: 0.32rem 0.65rem;
    font-weight: 700;
    font-size: 0.84rem;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    cursor: pointer;
    box-shadow: 0 2px 0 var(--cr-border);
    transition: background-color 0.12s ease, border-color 0.12s ease;
    text-align: left;
    box-sizing: border-box;
}

.cr-select-trigger:hover:not(:disabled) {
    background-color: var(--cr-surface-hover);
}

.cr-select-trigger.open {
    border-color: var(--cr-border);
    box-shadow: 0 2px 0 var(--cr-border);
}

.cr-select-trigger:focus-visible {
    outline: 2px solid var(--cr-primary, #2563eb);
    outline-offset: 2px;
}

.cr-select-trigger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cr-select-value {
    flex: 1 1 auto;
    min-width: 0;
}

.cr-select-chevron {
    font-size: 0.62rem;
    opacity: 0.75;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.cr-select-chevron.rotate {
    transform: rotate(180deg);
}

.cr-select-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: transparent;
}

.cr-select-menu {
    position: fixed;
    top: -9999px;
    left: -9999px;
    opacity: 0;
    width: max-content;
    max-width: 320px;
    background: var(--cr-surface);
    color: var(--cr-text);
    border: 2px solid var(--cr-border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
    padding: 0.3rem;
    margin: 0;
    list-style: none;
    z-index: 3010;
    max-height: 240px;
    overflow-y: auto;
    box-sizing: border-box;
    transition: opacity 0.06s ease;
}

.cr-select-option {
    padding: 0.4rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 0.84rem;
    transition: background-color 0.1s ease;
}

.cr-select-option:hover {
    background-color: var(--cr-surface-hover);
}

.cr-select-option.selected {
    background-color: #fef9c3;
    color: #0f172a;
    font-weight: 800;
}

.cr-theme-dark .cr-select-option.selected {
    background-color: rgba(234, 179, 8, 0.22);
    color: #fef08a;
}

.cr-select-subtitle {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--cr-text-muted);
}

.cr-select-checkmark {
    font-weight: 900;
    margin-left: 0.5rem;
    color: #16a34a;
}

.cr-theme-dark .cr-select-checkmark {
    color: #4ade80;
}

/* ============================================================================
   Blazor Framework Error UI (Fallback)
   ============================================================================ */
#blazor-error-ui {
    background: #fef3c7;
    color: #92400e;
    border-top: 2px solid #d97706;
    bottom: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.25);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.75rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 10000;
    font-weight: 600;
}

#blazor-error-ui .reload {
    color: #b45309;
    font-weight: 700;
    text-decoration: underline;
    margin-left: 0.5rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    line-height: 1;
}

/* ============================================================================
   CrimeRewind - Reconnect Modal Styles
   ============================================================================ */

#components-reconnect-modal {
    padding: 0;
    border: none;
    outline: none;
    background: transparent;
    margin: auto;
    max-width: 95vw;
    opacity: 0;
    transform: scale(0.92) translateY(14px);
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                overlay 0.3s allow-discrete,
                display 0.3s allow-discrete;
}

#components-reconnect-modal[open] {
    opacity: 1;
    transform: scale(1) translateY(0);
}

@starting-style {
    #components-reconnect-modal[open] {
        opacity: 0;
        transform: scale(0.92) translateY(14px);
    }
}

#components-reconnect-modal::backdrop {
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.3s ease, overlay 0.3s allow-discrete, display 0.3s allow-discrete;
}

#components-reconnect-modal[open]::backdrop {
    opacity: 1;
}

@starting-style {
    #components-reconnect-modal[open]::backdrop {
        opacity: 0;
    }
}

.cr-reconnect-window {
    background: var(--cr-surface, #ffffff);
    color: var(--cr-text, #0f172a);
    border: 3px solid var(--cr-border, #0f172a);
    border-radius: 18px;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.45), 6px 6px 0px rgba(15, 23, 42, 0.35);
    width: min(92vw, 460px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cr-reconnect-header {
    background: var(--cr-surface-alt, #f7f4ec);
    border-bottom: 2px solid var(--cr-border-soft, #cbd5e1);
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.cr-reconnect-brand {
    font-size: 1.15rem;
    gap: 0.5rem;
}

.cr-reconnect-tag {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    background: rgba(234, 179, 8, 0.18);
    color: #b45309;
    border: 1.5px solid #ca8a04;
}

.cr-reconnect-body {
    padding: 1.75rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
}

.cr-reconnect-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 112px;
}

.cr-reconnect-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
}

.cr-reconnect-title {
    font-weight: 900;
    font-size: 1.15rem;
    margin: 0;
    line-height: 1.3;
    color: var(--cr-text, #0f172a);
}

.cr-reconnect-desc {
    font-size: 0.92rem;
    color: var(--cr-text-secondary, #334155);
    margin: 0;
    line-height: 1.45;
}

.cr-reconnect-seconds-pill {
    background: #0f172a;
    color: #fef08a;
    border: 2px solid #ca8a04;
    border-radius: 999px;
    padding: 0.05rem 0.6rem;
    font-weight: 900;
    font-size: 0.95rem;
    display: inline-block;
    min-width: 2rem;
    text-align: center;
    box-shadow: 1px 1px 0 #ca8a04;
    vertical-align: middle;
    margin: 0 0.25rem;
    line-height: 1.35;
}

.cr-reconnect-dots {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.4rem;
}

.cr-reconnect-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #eab308;
    display: inline-block;
    animation: cr-dots-pulse 1.4s infinite ease-in-out both;
}

.cr-reconnect-dots span:nth-child(1) { animation-delay: -0.32s; }
.cr-reconnect-dots span:nth-child(2) { animation-delay: -0.16s; }

.cr-reconnect-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    width: 100%;
}

.cr-chrono-wrapper {
    position: relative;
    width: 112px;
    height: 112px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cr-chrono-svg {
    overflow: visible;
}

.cr-chrono-ring-outer {
    color: var(--cr-border, #1e293b);
}

.cr-chrono-ticks {
    color: var(--cr-border-soft, #94a3b8);
    transform-origin: 60px 60px;
    animation: cr-spin-ccw 24s linear infinite;
}

.cr-chrono-arc {
    transform-origin: 60px 60px;
    animation: cr-spin-ccw 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.cr-chrono-orbit {
    transform-origin: 60px 60px;
    animation: cr-spin-ccw 2.2s linear infinite;
}

.cr-chrono-chevrons {
    transform-origin: 52.5px 60px;
    animation: cr-chevrons-pulse 1.8s ease-in-out infinite;
}

#components-reconnect-modal .components-reconnect-first-attempt-visible,
#components-reconnect-modal .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal .components-reconnect-failed-visible,
#components-reconnect-modal .components-pause-visible,
#components-reconnect-modal .components-resume-failed-visible,
#components-reconnect-modal .components-rejoining-animation {
    display: none !important;
}

#components-reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-show .components-rejoining-animation,
#components-reconnect-modal:not(.components-reconnect-retrying):not(.components-reconnect-failed):not(.components-reconnect-paused):not(.components-reconnect-resume-failed) .components-reconnect-first-attempt-visible,
#components-reconnect-modal:not(.components-reconnect-retrying):not(.components-reconnect-failed):not(.components-reconnect-paused):not(.components-reconnect-resume-failed) .components-rejoining-animation {
    display: flex !important;
}

#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .components-rejoining-animation {
    display: flex !important;
}
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-first-attempt-visible {
    display: none !important;
}

#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible {
    display: flex !important;
}
#components-reconnect-modal.components-reconnect-failed .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-repeated-attempt-visible {
    display: none !important;
}

#components-reconnect-modal.components-reconnect-paused .components-pause-visible {
    display: flex !important;
}
#components-reconnect-modal.components-reconnect-paused .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-paused .components-reconnect-first-attempt-visible {
    display: none !important;
}

#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible {
    display: flex !important;
}
#components-reconnect-modal.components-reconnect-resume-failed .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-resume-failed .components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed .components-reconnect-first-attempt-visible {
    display: none !important;
}

body:has(.cr-theme-dark) .cr-reconnect-window,
.cr-theme-dark .cr-reconnect-window {
    background: #1e293b;
    color: #f8fafc;
    border-color: #475569;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.7), 6px 6px 0px #0f172a;
}

body:has(.cr-theme-dark) .cr-reconnect-header,
.cr-theme-dark .cr-reconnect-header {
    background: #0f172a;
    border-color: #334155;
    color: #f8fafc;
}

body:has(.cr-theme-dark) .cr-reconnect-title,
.cr-theme-dark .cr-reconnect-title {
    color: #f8fafc;
}

body:has(.cr-theme-dark) .cr-reconnect-desc,
.cr-theme-dark .cr-reconnect-desc {
    color: #cbd5e1;
}

body:has(.cr-theme-dark) .cr-reconnect-tag,
.cr-theme-dark .cr-reconnect-tag {
    color: #fef08a;
    background: rgba(234, 179, 8, 0.15);
    border-color: #ca8a04;
}

/* ============================================================================
   ROUND 2 SIDEBAR TOOLS & DEDUCTION SYMBOLS BOX
   ============================================================================ */
.cr-sidebar-tools-box {
    background: #ffffff;
    border: 2px solid #0f172a;
    border-radius: 12px;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 3px 0 #0f172a;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.cr-theme-dark .cr-sidebar-tools-box {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 3px 0 #0f172a;
}

.cr-sidebar-tools-box.cr-tools-collapsed {
    padding: 0.55rem 0.75rem;
    gap: 0;
}

.cr-sidebar-tools-box .cr-tools-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.cr-sidebar-tools-box .cr-tools-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--cr-text-sub);
    margin-right: 0.2rem;
}

/* ============================================================================
   ROUND 2 STAGGERED SOLUTION EVALUATION (HAND-DRAWN COMIC KRINGEL)
   ============================================================================ */
.cr-evaluation-kringel {
    position: absolute;
    inset: -16px;
    width: calc(100% + 32px);
    height: calc(100% + 32px);
    pointer-events: none;
    z-index: 100;
    overflow: visible;
}

.cr-evaluation-kringel path {
    stroke-dasharray: 440;
    stroke-dashoffset: 440;
    animation: crDrawKringel 0.45s cubic-bezier(0.2, 1, 0.3, 1) forwards;
}

@keyframes crDrawKringel {
    to {
        stroke-dashoffset: 0;
    }
}

.cr-evaluation-kringel.kringel-success path {
    stroke: #22c55e;
    filter: drop-shadow(0 0 1.2px #0f172a) drop-shadow(3.5px 4px 0px #0f172a);
}

.cr-evaluation-kringel.kringel-error path {
    stroke: #ef4444;
    filter: drop-shadow(0 0 1.2px #0f172a) drop-shadow(3.5px 4px 0px #0f172a);
}

.cr-theme-dark .cr-evaluation-kringel.kringel-success path {
    stroke: #22c55e;
    filter: drop-shadow(0 0 1.5px #000000) drop-shadow(3.5px 4px 0px #000000);
}

.cr-theme-dark .cr-evaluation-kringel.kringel-error path {
    stroke: #ef4444;
    filter: drop-shadow(0 0 1.5px #000000) drop-shadow(3.5px 4px 0px #000000);
}

/* Resolution Backdrop & Grid Spotlight */
.cr-resolution-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 50;
    pointer-events: auto;
    animation: crBackdropFadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes crBackdropFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.cr-board-area.cr-board-spotlight {
    position: relative;
    z-index: 60;
}

.cr-board-area.cr-board-spotlight .cr-board-wrapper {
    box-shadow: 0 0 0 4px #facc15, 0 16px 40px rgba(0, 0, 0, 0.5);
    border-color: #facc15;
    transition: box-shadow 0.6s ease, border-color 0.6s ease;
}

.cr-theme-dark .cr-board-area.cr-board-spotlight .cr-board-wrapper {
    box-shadow: 0 0 35px rgba(250, 204, 21, 0.35), 0 20px 48px rgba(0, 0, 0, 0.8);
    border-color: #facc15;
}

/* Crime Spotlight Board Stage & Darkening */
.cr-main-workspace.cr-solved-spotlight-active .cr-side-panel {
    display: none !important;
}

.cr-board-stage {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: clamp(1rem, 2.5vw, 2.5rem);
    width: max-content;
    max-width: none;
    flex: 0 0 auto;
    align-self: flex-start;
    margin-inline: auto;
}

@media (max-width: 1100px) {
    .cr-board-stage {
        flex-direction: column;
        align-items: center;
        gap: 1.25rem;
    }

    .cr-case-solved-banner {
        width: 100%;
        max-width: 600px;
        animation: crBannerSlideUp 1.1s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
    }
}

/* Darkening of rooms / cells outside murderer & victim (Slow dramatic fade) */
.cr-cell.cr-cell-crime-dimmed {
    opacity: 0.18;
    filter: brightness(0.35) grayscale(0.4);
    transition: opacity 1.8s cubic-bezier(0.2, 0.8, 0.2, 1), filter 1.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.cr-cell.cr-cell-crime-spotlight {
    z-index: 25;
    opacity: 1 !important;
    filter: none !important;
    transition: transform 1.2s cubic-bezier(0.2, 1, 0.3, 1), filter 1.2s cubic-bezier(0.2, 1, 0.3, 1);
}

.cr-cell.cr-cell-crime-spotlight .cr-actor-token {
    box-shadow: 0 0 0 3.5px #facc15, 0 8px 24px rgba(250, 204, 21, 0.65), 0 4px 8px rgba(0, 0, 0, 0.4) !important;
    transform: scale(1.06);
    transition: box-shadow 1.2s cubic-bezier(0.2, 1, 0.3, 1), transform 1.2s cubic-bezier(0.2, 1, 0.3, 1);
}

.cr-room-wall-label.room-dimmed {
    opacity: 0.15;
    transition: opacity 1.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.cr-room-wall-label.crime-room-spotlight {
    color: #facc15;
    text-shadow:
        -1.5px -1.5px 0 #0f172a,
         1.5px -1.5px 0 #0f172a,
        -1.5px  1.5px 0 #0f172a,
         1.5px  1.5px 0 #0f172a,
         0px 0px 14px rgba(250, 204, 21, 0.85);
    transform: translate(-50%, -88%) scale(1.08);
    transition: all 1.2s cubic-bezier(0.2, 1, 0.3, 1);
}

.cr-evaluation-kringel-slot {
    transition: opacity 1.8s cubic-bezier(0.2, 0.8, 0.2, 1), filter 1.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.cr-evaluation-kringel-slot.kringel-dimmed {
    opacity: 0.14;
    filter: grayscale(0.6);
}

.cr-evaluation-kringel-slot.kringel-spotlight .cr-evaluation-kringel.kringel-success path {
    filter: drop-shadow(0 0 3px #22c55e) drop-shadow(0 0 14px rgba(34, 197, 94, 0.9)) drop-shadow(3.5px 4px 0px #0f172a);
}

/* Fall Gelöst Banner (Right-Side Placement with slower, graceful entrance) */
.cr-case-solved-banner {
    position: relative;
    width: clamp(340px, 28vw, 440px);
    max-width: 100%;
    margin-top: 0;
    padding: 1.4rem 1.6rem;
    border-radius: 20px;
    background: linear-gradient(135deg, #fefce8 0%, #fef08a 50%, #fde047 100%);
    border: 3.5px solid #0f172a;
    box-shadow: 0 8px 0 #0f172a, 0 16px 36px rgba(0, 0, 0, 0.35);
    color: #0f172a;
    flex-shrink: 0;
    animation: crBannerSlideInRight 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.cr-theme-dark .cr-case-solved-banner {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-color: #facc15;
    color: #f8fafc;
    box-shadow: 0 8px 0 #000000, 0 0 35px rgba(250, 204, 21, 0.25);
}

@keyframes crBannerSlideInRight {
    0% {
        opacity: 0;
        transform: translateX(45px) scale(0.94);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes crBannerSlideUp {
    0% {
        opacity: 0;
        transform: translateY(32px) scale(0.94);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cr-solved-trophy-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: #f59e0b;
    color: #ffffff;
    border-radius: 14px;
    border: 2.5px solid #0f172a;
    box-shadow: 0 3px 0 #0f172a;
    flex-shrink: 0;
}

.cr-theme-dark .cr-solved-trophy-badge {
    border-color: #facc15;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.6);
}

.cr-solved-tag {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #854d0e;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.cr-theme-dark .cr-solved-tag {
    color: #facc15;
}

.cr-solved-stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.85);
    border: 2px solid #0f172a;
    font-weight: 800;
    font-size: 0.88rem;
    box-shadow: 0 2px 0 #0f172a;
}

.cr-theme-dark .cr-solved-stat-badge {
    background: rgba(30, 41, 59, 0.85);
    border-color: #475569;
    color: #f8fafc;
    box-shadow: 0 2px 0 #000000;
}

.cr-solved-story {
    font-size: 0.95rem;
    line-height: 1.45;
}

/* ============================================================================
   SPECIAL STAND PILLS (ADELIG, RITTER, DORFBEWOHNER) & FLAVOUR ROLES
   ============================================================================ */
.cr-stand-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: 1.5px solid #0f172a;
    box-shadow: 0 1.5px 0 #0f172a;
    white-space: nowrap !important;
    word-break: keep-all !important;
    hyphens: none !important;
    line-height: 1.2;
    flex-shrink: 0;
}

.cr-stand-pill.noble {
    background: #f3e8ff;
    color: #6b21a8;
    border-color: #7e22ce;
}

.cr-stand-pill.knight {
    background: #fee2e2;
    color: #991b1b;
    border-color: #b91c1c;
}

.cr-stand-pill.commoner {
    background: #fef3c7;
    color: #92400e;
    border-color: #b45309;
}

.cr-stand-pill.servant {
    background: #ccfbf1;
    color: #0f766e;
    border-color: #0d9488;
}

.cr-theme-dark .cr-stand-pill.noble {
    background: rgba(147, 51, 234, 0.25);
    color: #d8b4fe;
    border-color: #a855f7;
    box-shadow: 0 1.5px 0 #000000;
}

.cr-theme-dark .cr-stand-pill.knight {
    background: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    border-color: #ef4444;
    box-shadow: 0 1.5px 0 #000000;
}

.cr-theme-dark .cr-stand-pill.commoner {
    background: rgba(245, 158, 11, 0.25);
    color: #fde68a;
    border-color: #f59e0b;
    box-shadow: 0 1.5px 0 #000000;
}

.cr-theme-dark .cr-stand-pill.servant {
    background: rgba(20, 184, 166, 0.25);
    color: #5eead4;
    border-color: #14b8a6;
    box-shadow: 0 1.5px 0 #000000;
}

.cr-meta-flavour {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 600;
    color: var(--cr-text);
    font-size: 0.8rem;
}

/* ============================================================================
   MURDOKU-INSPIRED CASE SELECTION HOME & ENVELOPE CARDS
   ============================================================================ */

.cr-designer-case-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.25rem;
    background: var(--cr-surface);
    border-bottom: 2px solid var(--cr-border);
    flex-wrap: wrap;
    gap: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.cr-home-page {
    min-height: 100vh;
    background: var(--cr-bg);
    color: var(--cr-text);
    display: flex;
    flex-direction: column;
}

.cr-home-container {
    max-width: 1360px;
    width: 100%;
    margin: 0 auto;
    padding: 2.2rem 1.5rem 4rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cr-home-header {
    text-align: center;
    margin-bottom: 2rem;
    max-width: 760px;
}

.cr-home-title {
    font-size: 2.25rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    color: var(--cr-text);
    margin-bottom: 0.75rem;
}

.cr-home-subtitle-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.95rem;
    color: var(--cr-text-muted);
    margin-bottom: 0.5rem;
}

.cr-home-badge {
    background: #0284c7;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    text-transform: uppercase;
}

.cr-home-stats {
    font-size: 1rem;
    font-weight: 800;
    color: var(--cr-text);
    margin-top: 0.6rem;
}

.cr-home-stats-solved {
    color: #16a34a;
}

/* Filters & Controls */
.cr-filter-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 2.75rem;
    width: 100%;
}

.cr-diff-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.cr-diff-tab-btn {
    border: 2px solid var(--cr-border);
    background: var(--cr-surface);
    color: var(--cr-text);
    font-weight: 700;
    font-size: 0.92rem;
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 0 var(--cr-border);
    transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.12s ease;
}

.cr-diff-tab-btn:hover {
    background: var(--cr-surface-hover);
    transform: translateY(-1px);
}

.cr-diff-tab-btn.is-active {
    background: #fef08a;
    border-color: #ca8a04;
    color: #854d0e;
    box-shadow: 0 3px 0 #ca8a04;
    transform: translateY(-1px);
}

.cr-theme-dark .cr-diff-tab-btn.is-active {
    background: #ca8a04;
    border-color: #facc15;
    color: #000000;
    box-shadow: 0 3px 0 #000000;
}

.cr-subfilters {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.cr-toggle-filter-btn {
    border: 2px solid var(--cr-border-soft);
    background: var(--cr-surface);
    color: var(--cr-text);
    font-weight: 600;
    font-size: 0.86rem;
    padding: 0.42rem 0.9rem;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.15s ease;
}

.cr-toggle-filter-btn.is-active {
    background: var(--cr-primary-soft);
    border-color: var(--cr-primary);
    color: var(--cr-primary-text);
}

/* ============================================================================
   CASES GRID & 3D TILT CARDS
   ============================================================================ */

.cr-cases-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
    gap: 2.2rem;
    width: 100%;
}

/* Silver Pin at Top Center */
.cr-case-pin {
    position: absolute;
    top: 7px;
    left: 50%;
    transform: translateX(-50%);
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #94a3b8 60%, #475569 100%);
    border: 1.5px solid #1e293b;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
    z-index: 25;
}

/* Adhesive Tape Strips on Sides */
.cr-case-tape {
    position: absolute;
    top: 35%;
    width: 18px;
    height: 48px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(1px);
    border-radius: 2px;
    z-index: 15;
}

.cr-case-tape-left {
    left: -7px;
    transform: rotate(-3deg);
}

.cr-case-tape-right {
    right: -7px;
    transform: rotate(3deg);
}

/* Green Solved Checkmark Badge (Top Right) */
.cr-case-solved-check {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #22c55e;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.4);
    z-index: 25;
}

/* ============================================================================
   2. REVEALED CASE CARD (AUFGEDECKTER / GELÖSTER FALL)
   ============================================================================ */

.cr-revealed-card {
    background: #e9e3d5;
    background-image: radial-gradient(circle at 40% 30%, #f4efe4 0%, #ded7c6 100%);
    border: 2px solid #1e293b;
    border-radius: 14px;
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.1);
}

.cr-theme-dark .cr-revealed-card {
    background: #1e293b;
    background-image: radial-gradient(circle at 40% 30%, #273549 0%, #17202e 100%);
    border-color: #0f172a;
}

.cr-card-grid-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    margin-top: 0.6rem;
    margin-bottom: 0.75rem;
    border: 2px solid #0f172a;
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}

.cr-card-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    margin-top: auto;
}

.cr-card-title {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0;
    text-align: center;
    color: var(--cr-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.cr-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cr-case-dim-badge {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--cr-text-secondary);
}

.cr-card-time {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.86rem;
    font-weight: 800;
    color: #15803d;
}

/* ============================================================================
   DIFFICULTY BADGES
   ============================================================================ */

.cr-diff-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.55rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1.5px solid transparent;
}

.cr-diff-very-easy {
    background: #ccfbf1;
    color: #0f766e;
    border-color: #14b8a6;
}

.cr-diff-easy {
    background: #e0f2fe;
    color: #0369a1;
    border-color: #38bdf8;
}

.cr-diff-medium {
    background: #fef3c7;
    color: #92400e;
    border-color: #f59e0b;
}

.cr-diff-hard {
    background: #ffedd5;
    color: #c2410c;
    border-color: #f97316;
}

.cr-diff-expert {
    background: #fee2e2;
    color: #991b1b;
    border-color: #ef4444;
}

/* ============================================================================
   MINI GRID PREVIEW
   ============================================================================ */

.cr-mini-grid-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: inherit;
}

.cr-mini-grid {
    display: grid;
    width: 100%;
    height: 100%;
}

.cr-mini-cell {
    position: relative;
    border: 0 solid rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Tall props keep their one-cell footprint while their upper artwork crosses the tile boundary. */
.cr-mini-cell:has(.cr-board-art-overhang) {
    overflow: visible;
}

/* Scaled Floor Textures for Mini Grid Preview are now rendered directly via SVG FloorVectorArt */
.cr-mini-cell .cr-floor-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.cr-mini-edge {
    position: absolute;
    background: #0f172a;
    z-index: 10;
}

.cr-mini-edge-n {
    top: 0;
    left: 0;
    right: 0;
    height: 2.5px;
}

.cr-mini-edge-s {
    bottom: 0;
    left: 0;
    right: 0;
    height: 2.5px;
}

.cr-mini-edge-e {
    top: 0;
    bottom: 0;
    right: 0;
    width: 2.5px;
}

.cr-mini-edge-w {
    top: 0;
    bottom: 0;
    left: 0;
    width: 2.5px;
}

.cr-mini-edge.is-door {
    background: #b45309;
}

.cr-mini-object {
    position: absolute;
    inset: 4px;
    z-index: 3;
    pointer-events: none;
}

.cr-mini-clutter {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 40%;
    height: 40%;
    z-index: 4;
    pointer-events: none;
}

.cr-mini-actor-marker {
    width: 75%;
    height: 75%;
    border-radius: 4px;
    border: 1.5px solid #0f172a;
    color: #ffffff;
    font-weight: 900;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.cr-mini-cross {
    font-size: 0.72rem;
    font-weight: 900;
    color: rgba(15, 23, 42, 0.7);
    z-index: 5;
}

/* Solved Stamp Overlay */
.cr-stamp-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 20;
    background: rgba(255, 255, 255, 0.15);
}

.cr-stamp-badge {
    border: 4px solid #16a34a;
    color: #15803d;
    background: rgba(240, 253, 244, 0.88);
    font-size: 1.35rem;
    font-weight: 950;
    letter-spacing: 0.1em;
    padding: 0.35rem 0.85rem;
    border-radius: 8px;
    text-transform: uppercase;
    transform: rotate(-12deg);
    box-shadow: 0 3px 8px rgba(22, 163, 74, 0.3);
}

/* ============================================================================
   OBJECTS & SYMBOLS LEGEND MODAL
   ============================================================================ */

.cr-legend-card {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--cr-surface);
    border: 1.5px solid var(--cr-border);
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.04);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.cr-legend-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(15, 23, 42, 0.08);
}

.cr-legend-card.is-blocked {
    border-color: rgba(239, 68, 68, 0.4);
    background: linear-gradient(135deg, var(--cr-surface) 0%, rgba(254, 226, 226, 0.25) 100%);
}

.cr-legend-card.is-walkable {
    border-color: rgba(34, 197, 94, 0.3);
}

.cr-legend-icon-box {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.06);
    border: 1px solid var(--cr-border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.cr-legend-icon-box svg {
    width: 100%;
    height: 100%;
}

.cr-legend-symbol-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--cr-surface);
    border: 1.5px solid var(--cr-border);
    border-radius: 10px;
}

.cr-legend-symbol-preview {
    min-width: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ============================================================================
   CASE DESIGNER: STEP 1 MAP ARCHITECT & PALETTE STYLES
   ============================================================================ */

/* Interactive Edge Click Targets on the Board in Edge Mode */
.cr-edge-click-target {
    position: absolute;
    z-index: 28;
    cursor: pointer;
    background: transparent;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.cr-edge-target-n {
    top: 0;
    left: 8px;
    right: 8px;
    height: 14px;
    border-top: 2px dashed rgba(245, 158, 11, 0.4);
}

.cr-edge-target-e {
    top: 8px;
    bottom: 8px;
    right: 0;
    width: 14px;
    border-right: 2px dashed rgba(245, 158, 11, 0.4);
}

.cr-edge-target-s {
    bottom: 0;
    left: 8px;
    right: 8px;
    height: 14px;
    border-bottom: 2px dashed rgba(245, 158, 11, 0.4);
}

.cr-edge-target-w {
    top: 8px;
    bottom: 8px;
    left: 0;
    width: 14px;
    border-left: 2px dashed rgba(245, 158, 11, 0.4);
}

.cr-edge-click-target:hover {
    background: rgba(245, 158, 11, 0.45) !important;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.8) !important;
    border-color: #f59e0b !important;
}

/* Visual Asset Palette Cards */
.cr-asset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 0.45rem;
}

.cr-asset-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.4rem 0.3rem;
    border-radius: 8px;
    border: 1.5px solid var(--cr-border);
    background: var(--cr-surface);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    position: relative;
    user-select: none;
}

.cr-asset-card:hover {
    border-color: var(--cr-gold);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.cr-asset-card.active {
    border-color: var(--cr-gold);
    background: rgba(245, 158, 11, 0.12);
    box-shadow: 0 0 0 2px var(--cr-gold);
}

.cr-asset-icon-box {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.2rem;
}

.cr-asset-name {
    font-size: 0.73rem;
    font-weight: 600;
    line-height: 1.15;
    color: var(--cr-text-main);
    margin-bottom: 0.2rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cr-asset-badge {
    font-size: 0.65rem;
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    font-weight: 700;
}

.cr-asset-badge-walkable {
    background: rgba(16, 185, 129, 0.18);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.cr-asset-badge-blocked {
    background: rgba(239, 68, 68, 0.18);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Room Manager & Palette */
.cr-room-palette-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.cr-room-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.65rem;
    border-radius: 8px;
    border: 1.5px solid var(--cr-border);
    background: var(--cr-surface);
    cursor: pointer;
    transition: all 0.15s ease;
}

.cr-room-card:hover {
    border-color: var(--cr-gold);
}

.cr-room-card.active {
    border-color: var(--cr-gold);
    background: rgba(245, 158, 11, 0.08);
    box-shadow: 0 0 0 2px var(--cr-gold);
}

.cr-room-color-pill {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* Tool Mode Selector Tabs */
.cr-brush-mode-bar {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    background: var(--cr-surface);
    padding: 0.35rem;
    border-radius: 8px;
    border: 1px solid var(--cr-border);
}

.cr-brush-btn {
    flex: 1;
    min-width: 75px;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.3rem 0.45rem;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--cr-text-sub);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.cr-brush-btn:hover {
    color: var(--cr-text-main);
    background: var(--cr-surface-alt);
}

.cr-brush-btn.active {
    background: var(--cr-surface-alt);
    color: var(--cr-gold);
    border-color: var(--cr-gold);
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Live Cell Inspector Status Bar */
.cr-cell-inspector-bar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0.75rem;
    background: var(--cr-surface-alt);
    border: 1px solid var(--cr-border);
    border-radius: 6px;
    font-size: 0.76rem;
    color: var(--cr-text-sub);
    flex-wrap: wrap;
}

/* Cutout / Void Cells (Donut holes, non-rectangular building layouts) */
.cr-cell.cr-cell-void {
    background: rgba(15, 23, 42, 0.45);
    background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 8px 8px;
    border-color: rgba(30, 41, 59, 0.15) !important;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.35) !important;
}

.cr-cell.cr-cell-void .cr-coord-watermark {
    opacity: 0.18;
}

/* Void cell in Play Mode: completely transparent / seamless cutout hole without interaction */
.cr-board-area:not(.cr-designer-board) .cr-cell.cr-cell-void {
    background: transparent !important;
    background-image: none !important;
    border-color: transparent !important;
    box-shadow: none !important;
    pointer-events: none !important;
    cursor: default !important;
}

.cr-board-area:not(.cr-designer-board) .cr-cell.cr-cell-void .cr-coord-watermark {
    display: none !important;
}

/* Void cell hover in Case Designer */
.cr-designer-board .cr-cell.cr-cell-void:hover {
    box-shadow: inset 0 0 0 2px #38bdf8, inset 0 0 12px rgba(56, 189, 248, 0.3) !important;
    cursor: pointer;
}

.cr-void-icon-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(148, 163, 184, 0.35);
    font-size: 0.85rem;
    pointer-events: none;
    transition: all 0.15s ease;
}

.cr-cell.cr-cell-void:hover .cr-void-icon-overlay {
    color: #38bdf8;
    transform: scale(1.15);
}

/* Compact Floor Swatch Grid (Palette style like image) */
.cr-floor-swatch-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.55rem;
    background: var(--cr-surface-alt);
    border: 1px solid var(--cr-border);
    border-radius: 10px;
    align-items: center;
}

.cr-floor-swatch-btn {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 2px solid rgba(15, 23, 42, 0.2);
    cursor: pointer;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 2px 4px;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.cr-floor-swatch-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.cr-floor-swatch-btn.active {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.45), 0 2px 6px rgba(0, 0, 0, 0.25) !important;
    transform: translateY(-1px);
}

.cr-floor-swatch-key {
    font-size: 0.65rem;
    font-weight: 800;
    line-height: 1;
    color: rgba(15, 23, 42, 0.85);
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 3px;
    padding: 1px 3px;
    pointer-events: none;
}

.cr-theme-dark .cr-floor-swatch-key {
    color: rgba(255, 255, 255, 0.95);
    background: rgba(15, 23, 42, 0.8);
}

/* Transparent Checkered Pattern for Room-Standard Swatch */
.cr-floor-swatch-standard {
    background:
        linear-gradient(45deg, #cbd5e1 25%, transparent 25%),
        linear-gradient(-45deg, #cbd5e1 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #cbd5e1 75%),
        linear-gradient(-45deg, transparent 75%, #cbd5e1 75%),
        #ffffff !important;
    background-size: 10px 10px !important;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px !important;
}

.cr-theme-dark .cr-floor-swatch-standard {
    background:
        linear-gradient(45deg, #334155 25%, transparent 25%),
        linear-gradient(-45deg, #334155 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #334155 75%),
        linear-gradient(-45deg, transparent 75%, #334155 75%),
        #1e293b !important;
    background-size: 10px 10px !important;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px !important;
}

/* Floor Swatch Vector Layer */
.cr-floor-swatch-btn .cr-floor-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Floor Tinting Panel in Case Designer */
.cr-floor-tint-panel {
    background: var(--cr-surface-alt);
    border: 1px solid var(--cr-border);
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cr-floor-color-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cr-object-color-picker {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    padding: 0;
    border: 2px solid var(--cr-border);
    border-radius: 50%;
    overflow: hidden;
    background: var(--cr-surface);
    cursor: pointer;
}

.cr-object-color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.cr-object-color-picker::-webkit-color-swatch { border: 0; border-radius: 50%; }
.cr-object-color-picker::-moz-color-swatch { border: 0; border-radius: 50%; }
.cr-object-color-picker:focus-visible { outline: 2px solid var(--cr-primary); outline-offset: 2px; }

.cr-floor-color-picker {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 2px solid var(--cr-border);
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
}

.cr-floor-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.cr-floor-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.cr-tint-preset-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.cr-tint-preset-chip {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    border: 2px solid rgba(15, 23, 42, 0.25);
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.cr-tint-preset-chip:hover {
    transform: scale(1.18);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    z-index: 3;
}

.cr-tint-preset-chip.active {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 2px #3b82f6 !important;
    transform: scale(1.12);
}












/* Persistent cell-relative scenery, shared by designer and play. */
.cr-clutter-instance { right: auto; transform: translate(-50%, -50%); }
.cr-clutter-no-shadow { filter: none; }
.cr-clutter-no-shadow [data-clutter-shadow] { display: none; }
.cr-scenery-editor .cr-clutter-shadow-label { display: block; }
.cr-scenery-selected { outline: 2px solid var(--cr-primary); outline-offset: 3px; }
.cr-scenery-editor { display: grid; gap: .65rem; margin-bottom: 1rem; }
.cr-scenery-editor label { display: grid; grid-template-columns: 1fr 5rem; gap: .5rem; align-items: center; }
.cr-scenery-editor input[type=number] { width: 100%; border: 1px solid var(--cr-border); border-radius: 4px; padding: .25rem; background: var(--cr-surface); color: var(--cr-text-main); }
.cr-scenery-editor input[type=range] { width: 100%; accent-color: var(--cr-primary); }
[data-scenery-mode=select] .cr-clutter-instance { pointer-events: auto; cursor: grab; touch-action: none; }
[data-scenery-mode=place] { touch-action: none; }
.cr-clutter-preview { opacity: .55; pointer-events: none; }

.cr-mini-cell:has(.cr-clutter-instance), .cr-mini-cell:has(.cr-object-layer) { overflow: visible; }

/* Hover must not lift an entire cell above scenery and actors in adjacent cells. */
.cr-cell:hover { z-index: auto; filter: none; }

.cr-clutter-colors { display: grid; gap: .5rem; }
.cr-clutter-swatch { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; border: 1px solid var(--cr-border); background: var(--swatch-color); cursor: pointer; }
.cr-clutter-swatch.active { outline: 2px solid var(--cr-text-main); outline-offset: 2px; }
.cr-clutter-swatch:focus-visible { outline: 2px solid var(--cr-primary); outline-offset: 3px; }

/* Shared, keyboard-accessible zoom controls for play and authoring. */
.cr-zoom-control {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    overflow: hidden;
    border: 2px solid var(--cr-border);
    border-radius: 7px;
    background: var(--cr-surface);
    box-shadow: 0 2px 0 var(--cr-border);
    height: 30px;
    box-sizing: border-box;
}
.cr-zoom-control .cr-btn { border: none; border-radius: 0; box-shadow: none; min-width: 28px; height: 100%; padding: 0 .45rem; justify-content: center; }
.cr-zoom-control .cr-zoom-reset { font-size: .74rem; font-weight: 800; }

.cr-designer-topbar, .cr-designer-topbar .cr-top-actions { flex-wrap: nowrap; }

.cr-top-actions .cr-btn-sm,
.cr-top-actions .cr-zoom-control,
.cr-top-actions .cr-verification-pill {
    height: 30px;
    min-height: 30px;
    box-sizing: border-box;
}

.cr-verification-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    height: 30px;
    min-height: 30px;
    box-sizing: border-box;
    background: var(--cr-surface-alt);
    color: var(--cr-text);
    border: 2px solid var(--cr-border);
    border-radius: 7px;
    padding: 0 0.55rem;
    box-shadow: 0 2px 0 var(--cr-border);
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.12s;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}
.cr-verification-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 0 var(--cr-border);
    background: var(--cr-surface-hover);
}
.cr-verification-pill:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 var(--cr-border);
}
.cr-verification-pill:focus-visible {
    outline: 2px solid var(--cr-primary);
    outline-offset: 2px;
}

.cr-pill-item {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    padding: 2px 3px;
    border-radius: 4px;
    transition: color 0.15s ease;
}
.cr-pill-item > svg,
.cr-pill-item > .cr-icon {
    transition: transform 0.12s ease;
}
.cr-pill-item:hover > svg,
.cr-pill-item:hover > .cr-icon {
    transform: scale(1.15);
}
.cr-pill-item.status-success {
    color: #15803d;
}
.cr-pill-item.status-warning {
    color: #b45309;
}
.cr-pill-item.status-danger {
    color: #b91c1c;
}
.cr-pill-item.status-muted {
    color: var(--cr-text-muted);
    opacity: 0.5;
}

.cr-theme-dark .cr-pill-item.status-success { color: #22c55e; }
.cr-theme-dark .cr-pill-item.status-warning { color: #f59e0b; }
.cr-theme-dark .cr-pill-item.status-danger { color: #ef4444; }

/* Direct Pill Tooltip on Symbol Hover (positioned to the left of the status display to avoid cursor occlusion) */
.cr-pill-tooltip {
    position: absolute;
    right: calc(100% + 9px);
    top: 50%;
    transform: translateY(-50%) translateX(4px);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--cr-surface);
    color: var(--cr-text);
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    border: 2px solid var(--cr-border);
    box-shadow: 0 3px 0 var(--cr-border), 0 6px 16px rgba(15, 23, 42, 0.14);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.1s ease, transform 0.1s ease;
    z-index: 1050;
}

.cr-pill-tooltip::before {
    content: "";
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-left-color: var(--cr-border);
    pointer-events: none;
}
.cr-pill-tooltip::after {
    content: "";
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 3px solid transparent;
    border-left-color: var(--cr-surface);
    pointer-events: none;
    margin-left: -2px;
}

.cr-pill-item:hover .cr-pill-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

.cr-pill-tooltip-title {
    font-weight: 800;
    color: var(--cr-text);
}

.cr-pill-tooltip-desc {
    font-weight: 600;
    color: var(--cr-text-secondary);
}

.cr-pill-tooltip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid var(--cr-border);
    flex-shrink: 0;
}
.cr-pill-tooltip-dot.dot-success { background: #15803d; }
.cr-pill-tooltip-dot.dot-warning { background: #b45309; }
.cr-pill-tooltip-dot.dot-danger { background: #b91c1c; }
.cr-pill-tooltip-dot.dot-muted { background: var(--cr-text-muted); opacity: 0.5; }

.cr-theme-dark .cr-pill-tooltip-dot.dot-success { background: #22c55e; }
.cr-theme-dark .cr-pill-tooltip-dot.dot-warning { background: #f59e0b; }
.cr-theme-dark .cr-pill-tooltip-dot.dot-danger { background: #ef4444; }

.cr-pill-divider {
    width: 1px;
    height: 14px;
    background: var(--cr-border);
    opacity: 0.25;
}

.cr-pill-count {
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    margin-left: 1px;
}

.cr-floor-transition-edges { position: absolute; inset: 0; pointer-events: none; }

/* Step 1: a stable tool picker and one scrolling work area. */
.cr-map-summary, .cr-map-tool-heading, .cr-map-placement-modes {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.cr-map-tools { display: contents; }
.cr-map-tool-picker {
    position: sticky;
    top: -0.9rem;
    z-index: 2;
    background: var(--cr-surface);
    padding: 0.65rem 0 0.5rem;
    border-bottom: 1px solid var(--cr-border);
}
.cr-map-tool-picker .cr-brush-mode-bar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    margin-top: 0.4rem;
}
.cr-map-tool-picker .cr-brush-btn {
    min-width: 0;
    min-height: 40px;
    position: relative;
    padding: 0.45rem 0;
}
/* Tool names appear for mouse and keyboard users without widening the row. */
.cr-map-tool-picker [data-tool-tooltip]::after {
    content: attr(data-tool-tooltip);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--cr-border);
    border-radius: 6px;
    background: var(--cr-surface);
    color: var(--cr-text-main);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    visibility: hidden;
    z-index: 3;
}
.cr-map-tool-picker [data-tool-tooltip]:hover::after,
.cr-map-tool-picker [data-tool-tooltip]:focus-visible::after { visibility: visible; }
.cr-map-tool-picker [data-tool-tooltip]:first-child::after { left: 0; transform: none; }
.cr-map-tool-picker [data-tool-tooltip]:last-child::after { left: auto; right: 0; transform: none; }
.cr-map-tool-content { min-width: 0; }
.cr-map-tool-heading { margin: 0.3rem 0 0.5rem; }
.cr-map-properties {
    border: 1px solid var(--cr-border);
    border-radius: 8px;
    background: var(--cr-surface-alt);
    margin-bottom: 0.85rem;
}
.cr-map-properties > summary { padding: 0.65rem; font-size: 0.82rem; font-weight: 700; cursor: pointer; overflow-wrap: anywhere; }
.cr-map-properties-body { padding: 0.25rem 0.65rem 0.65rem; }
.cr-map-diagnostics { margin-top: 0.4rem; font-size: 0.75rem; }
.cr-map-diagnostics > summary { cursor: pointer; }
.cr-map-placement-modes { justify-content: flex-start; margin-bottom: 0.65rem; }
.cr-map-tool-content .cr-room-palette-list { max-height: none; overflow: visible; }
.cr-map-tool-content .cr-room-card { width: 100%; text-align: left; }
.cr-map-tool-content .cr-room-card > div { min-width: 0; }
.cr-map-tool-content .cr-room-card .small { overflow-wrap: anywhere; }
.cr-map-tool-content .cr-asset-card { font: inherit; color: var(--cr-text-main); }
.cr-map-tool-content .cr-asset-name { overflow-wrap: anywhere; }
.cr-map-tool-content button:focus-visible, .cr-map-properties > summary:focus-visible,
.cr-map-tool-picker button:focus-visible, .cr-map-diagnostics > summary:focus-visible {
    outline: 2px solid var(--cr-primary);
    outline-offset: 2px;
}
.cr-map-tool-content .cr-asset-name { white-space: normal; }
.cr-map-tool-content .cr-map-joining { background: var(--cr-surface); }
.cr-map-tool-content .cr-floor-color-input-wrapper { flex-wrap: wrap; }
.cr-map-tool-content > .d-flex { flex-wrap: wrap; gap: 0.5rem; }
@media (max-width: 1080px) {
    .cr-side-panel.cr-map-panel { width: 100%; max-height: none; overflow: visible; }
    .cr-map-panel .cr-panel-scroll { overflow: visible; flex: none; }
}
@media (max-width: 480px) {
    .cr-map-settings .col-8, .cr-map-settings .col-4 { width: 100%; }
    .cr-map-settings .justify-content-between { flex-wrap: wrap; gap: 0.5rem; }
}

/* Rooms share one focused editor for creation and changes. */
.cr-room-list-item { display: flex; align-items: center; gap: 0.5rem; }
.cr-room-list-item .cr-room-card { flex: 1; min-width: 0; width: auto; margin: 0; }
.cr-room-list-item > .cr-btn { flex-shrink: 0; min-width: 36px; min-height: 36px; }
.cr-room-form { display: grid; gap: 1.25rem; }
.cr-room-form-field { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.cr-room-form-field > label, .cr-room-form-field > span { color: var(--cr-text-sub); font-size: 0.8rem; font-weight: 700; }
.cr-room-floor-fields { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; padding-top: 1rem; border-top: 1px solid var(--cr-border-soft); }
.cr-room-color-choices { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem; }
.cr-room-color-choice { width: 26px; height: 26px; border-radius: 50%; background: var(--room-color); border: 1px solid var(--cr-border); cursor: pointer; }
.cr-room-color-choice[aria-pressed="true"] { outline: 2px solid var(--cr-text-main); outline-offset: 2px; }
.cr-room-custom-color { width: 32px; height: 32px; border: 1px solid var(--cr-border); border-radius: 50%; padding: 2px; background: var(--cr-surface); cursor: pointer; flex-shrink: 0; }
.cr-room-custom-color::-webkit-color-swatch-wrapper { padding: 0; }
.cr-room-custom-color::-webkit-color-swatch { border: 0; border-radius: 50%; }
.cr-room-custom-color::-moz-color-swatch { border: 0; border-radius: 50%; }
.cr-room-floor-preview { width: 36px; height: 36px; border: 1px solid var(--cr-border); border-radius: 6px; overflow: hidden; flex-shrink: 0; }
.cr-room-floor-preview svg { width: 100%; height: 100%; display: block; }
.cr-room-editor-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; width: 100%; }
.cr-room-form button:focus-visible, .cr-room-form input:focus-visible, .cr-room-list-item button:focus-visible { outline: 2px solid var(--cr-primary); outline-offset: 2px; }
@media (max-width: 520px) {
    .cr-room-floor-fields { grid-template-columns: minmax(0, 1fr); }
}

/* Murderer status and placement actions form one padded group. */
.cr-placement-summary { padding: 0.85rem 1rem; cursor: default; }
.cr-placement-status, .cr-placement-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.cr-placement-status { font-size: 0.78rem; }
.cr-placement-status > button { flex-shrink: 0; }
.cr-placement-actions {
    flex-wrap: wrap;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--cr-border-soft);
}
.cr-placement-actions > span { white-space: nowrap; }

/* Round 2 candidate notes beside rows and above columns. Keep these scoped to play. */
.cr-board-with-axis-notes {
    --cr-axis-note-width: calc(var(--cr-cell-size) * 0.66);
}

.cr-board-with-axis-notes .cr-col-headers {
    margin-left: calc(var(--cr-axis-note-width) + 8px);
}

.cr-board-with-axis-notes .cr-row-headers {
    width: var(--cr-axis-note-width);
}

.cr-axis-notes {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border-radius: 5px;
    background: var(--cr-surface-alt);
    color: var(--cr-text-main);
    overflow: hidden;
}

.cr-col-headers .cr-axis-notes {
    height: calc(var(--cr-cell-size) * 0.95);
    margin-inline: 2px;
}

.cr-row-headers .cr-axis-notes {
    margin-block: 2px;
}

.cr-axis-notes.cr-axis-highlight {
    background: color-mix(in srgb, var(--cr-highlight-color) 24%, white);
}

.cr-axis-note-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
    width: 100%;
    min-height: 28px;
    padding: 2px;
    font-weight: 900;
}

.cr-axis-notes {
    padding: 0;
    border: 0;
    font: inherit;
    cursor: pointer;
    text-align: center;
}

.cr-axis-notes[aria-disabled="true"] {
    cursor: default;
}

.cr-axis-notes[aria-disabled="false"]:hover {
    background: var(--cr-border-soft);
}

.cr-axis-notes:focus-visible {
    outline: 2px solid var(--cr-primary);
    outline-offset: -2px;
}

.cr-axis-candidates {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
    gap: 4px;
    width: 100%;
    min-height: 0;
    overflow-y: auto;
    padding: 3px 3px 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--cr-border) var(--cr-surface-alt);
}

.cr-axis-candidates > span {
    flex-shrink: 0;
}

/* ============================================================================
   RESPONSIVE DESIGN & MOBILE PLAY MODE
   ============================================================================ */

/* Mobile Jump Navigation Pill (docked bottom-right) */
.cr-mobile-jump-group {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 40;
    display: inline-flex;
    align-items: center;
    background: var(--cr-surface);
    border: 2px solid #0f172a;
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.22);
    overflow: hidden;
    padding: 2px;
    gap: 2px;
}

.cr-mobile-jump-group button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border: none;
    background: transparent;
    color: var(--cr-text);
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    border-radius: 999px;
    transition: background-color 0.12s ease;
}

.cr-mobile-jump-group button:hover,
.cr-mobile-jump-group button:active {
    background: var(--cr-surface-alt);
    color: var(--cr-text-main);
}

.cr-theme-dark .cr-mobile-jump-group {
    border-color: #facc15;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}

/* 1. Stacked Layout for screens <= 1080px */
@media (max-width: 1080px) {
    .cr-main-workspace {
        flex-direction: column !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        height: auto !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        -webkit-overflow-scrolling: touch;
    }

    .cr-main-workspace .cr-board-area,
    .cr-board-area {
        flex: 0 0 auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        padding: clamp(0.75rem, 2vw, 1.5rem) clamp(0.35rem, 1.5vw, 1rem) !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
    }

    .cr-main-workspace .cr-board-stage,
    .cr-board-stage {
        flex: 0 0 auto !important;
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        margin-inline: auto !important;
        gap: 1.25rem !important;
    }

    .cr-main-workspace .cr-board-wrapper,
    .cr-board-wrapper {
        max-width: calc(100vw - 1rem) !important;
        box-sizing: border-box !important;
    }

    .cr-main-workspace .cr-side-panel,
    .cr-side-panel {
        flex: 0 0 auto !important;
        width: 100% !important;
        max-width: 960px !important;
        margin: 0 auto !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        border-left: none !important;
        border-top: 2.5px solid var(--cr-border) !important;
        box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.04) !important;
        overflow: visible !important;
    }

    .cr-side-panel .cr-panel-scroll,
    .cr-panel-scroll {
        overflow: visible !important;
        flex: none !important;
        height: auto !important;
        max-height: none !important;
        padding: 0.75rem 0.65rem !important;
    }
}

/* 2. Tablet & Mobile Play Mode (<= 768px) */
@media (max-width: 768px) {
    .cr-topbar {
        padding: 0.25rem 0.5rem;
        min-height: 42px;
        gap: 0.35rem;
    }

    .cr-brand {
        font-size: 0.95rem;
        gap: 0.35rem;
    }

    .cr-brand-badge {
        font-size: 0.78rem;
        padding: 0.12rem 0.4rem;
    }

    .cr-top-actions {
        gap: 0.22rem;
    }

    .cr-top-actions .cr-btn-sm,
    .cr-top-actions .cr-btn-icon,
    .cr-top-actions .cr-zoom-control,
    .cr-top-actions .cr-verification-pill {
        height: 28px;
        min-height: 28px;
        padding: 0 0.35rem;
    }

    .cr-timer {
        height: 28px;
        padding: 0.12rem 0.4rem;
        font-size: 0.78rem;
    }

    .cr-phase-tabs-bar {
        scrollbar-width: none;
    }

    .cr-phase-tabs-bar::-webkit-scrollbar {
        display: none;
    }

    .cr-phase-tab-item {
        padding: 0.45rem 0.75rem;
        font-size: 0.82rem;
        gap: 0.45rem;
    }

    .cr-layer-panel {
        padding: 0.4rem 0.6rem;
    }

    .cr-layer-header {
        min-height: 24px;
        margin-bottom: 0.25rem;
    }

    .cr-sidebar-tools-box {
        padding: 0.45rem 0.6rem;
        gap: 0.45rem;
    }

    .cr-sidebar-tools-box .cr-tools-row {
        gap: 0.25rem;
    }
}

/* 3. Small Mobile Phones (<= 480px) */
@media (max-width: 480px) {
    .cr-topbar {
        padding: 0.2rem 0.35rem;
        min-height: 38px;
        gap: 0.2rem;
    }

    .cr-brand-badge {
        font-size: 0.72rem;
        padding: 0.1rem 0.3rem;
    }

    .cr-top-actions {
        gap: 0.18rem;
    }

    .cr-top-actions .cr-btn-sm,
    .cr-top-actions .cr-btn-icon {
        height: 28px;
        min-height: 28px;
        width: 28px;
        min-width: 28px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .cr-phase-tab-item {
        padding: 0.35rem 0.5rem;
        font-size: 0.76rem;
        gap: 0.3rem;
    }

    .cr-board-area {
        padding: 0.5rem 0.25rem !important;
    }

    .cr-panel-scroll {
        padding: 0.5rem 0.4rem !important;
    }

    .cr-clue-card {
        padding: 0.5rem 0.6rem;
    }

    .cr-sidebar-tools-box .cr-tools-label {
        font-size: 0.68rem;
    }
}

/* Asset colors stay beside their selection; the native popover escapes modal clipping. */
.cr-asset-selection { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.cr-asset-selection > .cr-select-container { flex: 1 1 0; min-width: 0; }
.cr-color-trigger, .cr-color-preset { display: inline-flex; align-items: center; justify-content: center; padding: 5px; background: var(--cr-surface); border: 1.5px solid var(--cr-border); border-radius: 50%; flex: 0 0 auto; cursor: pointer; }
.cr-color-trigger { width: 32px; height: 32px; padding: 3px; }
.cr-color-swatch { display: block; width: 100%; height: 100%; min-height: 18px; border-radius: 50%; background: var(--swatch-color); border: 1px solid rgba(15, 23, 42, .3); }
.cr-color-trigger:hover, .cr-color-preset:hover { border-color: var(--cr-text-main); }
.cr-color-trigger:focus-visible, .cr-color-preset:focus-visible { outline: 2px solid var(--cr-primary); outline-offset: 2px; }
.cr-color-popover { position: fixed; inset: auto; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 280px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; box-sizing: border-box; margin: 0; padding: 14px; border: 2px solid var(--cr-text-main); border-radius: 12px; background: var(--cr-surface); color: var(--cr-text-main); box-shadow: 0 8px 24px rgba(15, 23, 42, .2); }
.cr-color-popover[data-positioned] { transform: none; }
.cr-color-popover::backdrop { background: transparent; }
.cr-color-popover-header, .cr-color-custom, .cr-color-popover-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cr-color-popover-header { margin-bottom: 12px; font-size: .85rem; }
.cr-color-palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 14px; }
.cr-color-preset { width: 32px; height: 32px; padding: 3px; }
.cr-color-preset[aria-pressed="true"] { outline: 2px solid var(--cr-text-main); outline-offset: 1px; }
.cr-color-custom { border-top: 1px solid var(--cr-border-soft); padding-top: 12px; font-size: .8rem; cursor: pointer; }
.cr-color-custom-input { position: relative; display: block; width: 32px; height: 32px; padding: 3px; border: 1.5px solid var(--cr-border); border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.cr-color-custom-input input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.cr-color-custom-input:focus-within { outline: 2px solid var(--cr-primary); outline-offset: 2px; }
.cr-color-popover-footer { margin-top: 10px; font-size: .72rem; color: var(--cr-text-sub); }

.cr-portrait-settings { display: grid; grid-template-columns: minmax(0, 1fr) 100px minmax(0, 1fr); align-items: center; gap: 8px; margin: 8px 0; }
.cr-portrait-color-field { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: .72rem; font-weight: 700; color: var(--cr-text-sub); }

.cr-gender-badge { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; vertical-align: -.1em; margin-inline: .2em; }
.cr-feature-trigger { cursor: help; }
.cr-feature-trigger:focus-visible { outline: 2px solid var(--cr-primary); outline-offset: 2px; border-radius: 4px; }
.cr-feature-popover { position: fixed; inset: auto; margin: 0; width: 180px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 12px; border: 1.5px solid var(--cr-border); border-radius: 10px; background: var(--cr-surface); color: var(--cr-text-main); box-shadow: 0 6px 18px rgba(15, 23, 42, .18); pointer-events: none; text-align: center; font-size: .8rem; }
.cr-feature-popover:popover-open { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.cr-feature-gender-preview { display: inline-flex; font-size: 56px; padding: 8px; }

.cr-object-reference-preview { display: inline-flex; align-items: center; justify-content: center; width: 112px; height: 96px; }
.cr-object-reference-preview > svg { width: 100%; height: 100%; }
