/* 
  DICCIONARIO DE EXAMEN MENTAL - SISTEMA DE APOYO CLÍNICO
  Diseño adaptativo con dos registros visuales: Claridad Técnica y Enfoque Estructural.
*/

:root {
    /* Common */
    --transition-speed: 0.3s;
    --md-sys-motion-standard: cubic-bezier(0.2, 0, 0, 1);
    
    /* M3 Radii */
    --radius-none: 0;
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 28px;
    --radius-full: 999px;

    /* REGISTRO CLARO — "The Valley" (M3 Light adaptation) */
    --v-bg: #FFF8E7; /* Crema Papel */
    --v-text: #1C1B1F; /* On Surface */
    --v-primary: #56D8B6; /* Primary */
    --v-on-primary: #FFFFFF;
    --v-primary-container: #D1F3E9;
    --v-on-primary-container: #002019;
    --v-secondary-container: #E8DEF8;
    --v-accent: #FF8E72;
    --v-detail: #FFC857;
    --v-border: 2px solid #2B2F40;
    --v-font: 'Outfit', sans-serif;
    --v-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);

    /* Current Active (Light by default) */
    --bg: var(--v-bg);
    --text-p: var(--v-text);
    --accent: var(--v-accent);
    --primary: var(--v-primary);
    --primary-rgb: 86, 216, 182;
    --primary-container: var(--v-primary-container);
    --on-primary-container: var(--v-on-primary-container);
    --secondary-container: var(--v-secondary-container);
    --border: var(--v-border);
    --font-main: var(--v-font);
    --shadow: var(--v-shadow);
    --glass: blur(8px) saturate(150%);
    --header-bg: rgba(255, 248, 231, 0.9);

    /* M3 Surface levels */
    --surface-1: rgba(var(--primary-rgb), 0.05);
    --surface-2: rgba(var(--primary-rgb), 0.08);
    --surface-3: rgba(var(--primary-rgb), 0.11);
    
    --text-secondary: #49454F;
    --border-subtle: rgba(28, 27, 31, 0.12);
    --primary-dark: #3bba98;
    --success: #2ecc71;
}

[data-theme="dark"] {
    /* REGISTRO OSCURO — "The Void" (M3 Dark adaptation) */
    --o-bg: #1C1B1F; /* Dark Surface */
    --o-text: #E6E1E5; /* On Surface */
    --o-accent-a: #FFB4AB; /* Error Light */
    --o-accent-b: #80F6CD; /* Primary Dark Variant */
    --o-primary-container: #005141;
    --o-on-primary-container: #80F6CD;
    --o-secondary-container: #4A4458;
    --o-light: #FFB900;
    --o-font: 'Space Grotesk', sans-serif;
    --o-shadow-glow: 0 4px 8px rgba(0,0,0,0.5);

    /* Override Active */
    --bg: var(--o-bg);
    --text-p: var(--o-text);
    --accent: var(--o-accent-a);
    --primary: var(--o-accent-b);
    --primary-rgb: 128, 246, 205;
    --primary-container: var(--o-primary-container);
    --on-primary-container: var(--o-on-primary-container);
    --secondary-container: var(--o-secondary-container);
    --border: none;
    --font-main: var(--o-font);
    --shadow: var(--o-shadow-glow);
    --header-bg: rgba(28, 27, 31, 0.9);

    /* M3 Surface levels Dark */
    --surface-1: rgba(255, 255, 255, 0.05);
    --surface-2: rgba(255, 255, 255, 0.08);
    --surface-3: rgba(255, 255, 255, 0.11);

    --text-secondary: #CAC4D0;
    --border-subtle: rgba(230, 225, 229, 0.12);
    --primary-dark: var(--o-accent-b);
    --success: #81C784;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    transition: background-color var(--transition-speed), color var(--transition-speed), border var(--transition-speed), box-shadow var(--transition-speed), transform 0.2s;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text-p);
    line-height: 1.6;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Texture Overlays */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("https://www.transparenttextures.com/patterns/paper-fibers.png");
    opacity: 0.05;
    pointer-events: none;
    z-index: 1000;
}

[data-theme="dark"] body::before {
    background-image: url("https://www.transparenttextures.com/patterns/stardust.png");
    opacity: 0.1;
}

/* Header Ritual */
.app-header {
    background: var(--header-bg);
    backdrop-filter: var(--glass);
    -webkit-backdrop-filter: var(--glass);
    padding: 1rem 1rem 1.25rem;
    z-index: 100;
    position: relative;
}

[data-theme="light"] .app-header {
    border-bottom: var(--border);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.ritual-header {
    text-align: center;
}

.ritual-subtitle {
    font-size: 0.65rem;
    letter-spacing: 0.3em;
    opacity: 0.6;
    display: block;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.app-header h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    text-transform: uppercase;
}

[data-theme="dark"] .app-header h1 {
    color: var(--o-accent-b);
    text-shadow: 0 0 10px var(--o-accent-b);
}

.icon-btn {
    background: none;
    border: var(--border);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-p);
    width: 45px;
    height: 45px;
}

[data-theme="dark"] .icon-btn {
    border: 1px solid var(--o-accent-b);
    box-shadow: var(--o-shadow-glow);
}

/* Search Box M3 */
.search-container {
    max-width: 720px;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: center;
}

.search-container input {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 3.5rem;
    border: none;
    border-radius: var(--radius-xl);
    background: var(--surface-2);
    color: var(--text-p);
    font-family: var(--font-main);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s var(--md-sys-motion-standard);
    box-shadow: none;
}

.search-container::before {
    content: "🔍";
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    opacity: 0.6;
    pointer-events: none;
}

.clear-btn {
    position: absolute;
    right: 1.25rem;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-p);
    opacity: 0.5;
    padding: 0.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.clear-btn:hover {
    background: var(--surface-3);
    opacity: 1;
}

.search-container input:focus {
    background: var(--bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

[data-theme="light"] .search-container input {
    border: 1px solid rgba(0,0,0,0.1);
}

[data-theme="dark"] .search-container input {
    background: var(--surface-3);
    border: 1px solid rgba(255,255,255,0.05);
}

/* Content Area */
main {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem 7rem;
    scroll-behavior: smooth;
}

/* Cards & Items M3 */
.card {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    position: relative;
    animation: slideIn 0.4s var(--md-sys-motion-standard);
    transition: transform 0.2s, background 0.2s;
}

[data-theme="light"] .card {
    background: #FFFBFE;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

[data-theme="dark"] .card {
    background: var(--surface-2);
    border-left: none;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--surface-1);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s var(--md-sys-motion-standard);
}

.list-item:hover {
    background: var(--secondary-container);
    transform: scale(1.01);
}

[data-theme="light"] .list-item {
    border: 1px solid var(--border-subtle);
}

[data-theme="dark"] .list-item {
    background: var(--surface-2);
    box-shadow: none;
}

/* Typography Details */
.term-title {
    font-size: 2.2rem;
    margin: 0.5rem 0;
    font-weight: 800;
    text-transform: uppercase;
}

[data-theme="dark"] .term-title {
    color: #FFF;
    text-shadow: 2px 2px 0 var(--o-accent-a);
}

.badge {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    border: 1px solid currentColor;
}

.badge-risk-critical {
    background: var(--v-accent);
    color: white;
}

[data-theme="dark"] .badge-risk-critical {
    background: var(--o-accent-a);
    box-shadow: var(--o-shadow-red);
    border: none;
}

.section-label {
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    font-weight: 900;
    opacity: 0.5;
    margin-bottom: 0.75rem;
    display: block;
}

/* Navigation M3 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--header-bg);
    backdrop-filter: var(--glass);
    display: flex;
    padding: 0.75rem 0 1.5rem;
    border-top: 1px solid var(--border-subtle);
    z-index: 100;
}

.bottom-nav button {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-p);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-family: var(--font-main);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: none;
    opacity: 0.7;
    cursor: pointer;
    position: relative;
    transition: opacity 0.2s;
}

.bottom-nav button .nav-icon {
    font-size: 1.4rem;
    padding: 4px 20px;
    border-radius: 16px;
    transition: background 0.3s var(--md-sys-motion-standard), color 0.3s;
}

.bottom-nav button.active {
    opacity: 1;
    font-weight: 700;
}

.bottom-nav button.active .nav-icon {
    background: var(--secondary-container);
    color: var(--on-primary-container);
}

[data-theme="dark"] .bottom-nav button.active .nav-icon {
    background: var(--primary-container);
    color: var(--on-primary-container);
}

/* Ritual Effects */
.alert-critical-banner {
    border: 4px solid var(--v-accent);
    padding: 1.5rem;
    border-radius: var(--radius-soft);
    margin: 2rem 0;
    background: white;
    box-shadow: 8px 8px 0 var(--v-accent);
}

[data-theme="dark"] .alert-critical-banner {
    border: 1px solid var(--o-accent-a);
    box-shadow: var(--o-shadow-red);
    background: rgba(255, 60, 60, 0.1);
    border-radius: var(--radius-sharp);
}

/* Alphabet Header */
.alphabet-header {
    font-size: 1.2rem;
    font-weight: 900;
    padding: 2rem 0 0.5rem;
    border-bottom: 3px solid currentColor;
    margin-bottom: 1rem;
}

/* Grid for Domains */
.domain-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem;
}

.domain-card {
    background: var(--bg);
    border: var(--border);
    padding: 2rem 1rem;
    border-radius: var(--radius-soft);
    text-align: center;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

[data-theme="dark"] .domain-card {
    border-radius: var(--radius-sharp);
    border: 1px solid rgba(0, 255, 194, 0.3);
}

.domain-card .domain-icon {
    font-size: 2.5rem;
}

.domain-card .domain-title {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.domain-card .domain-subtitle {
    font-size: 0.65rem;
    opacity: 0.6;
    text-transform: none;
    font-style: italic;
}

/* Custom Scrollbar - Ritualistic Path */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--v-text);
    border-radius: 10px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--o-accent-b);
    box-shadow: 0 0 10px var(--o-accent-b);
}

/* Badge Pulse Animation */
[data-theme="dark"] .badge-risk-critical {
    animation: neonPulse 2s infinite ease-in-out;
}

@keyframes neonPulse {
    0% {
        box-shadow: 0 0 5px var(--o-accent-a);
    }

    50% {
        box-shadow: 0 0 20px var(--o-accent-a);
    }

    100% {
        box-shadow: 0 0 5px var(--o-accent-a);
    }
}

/* Responsive */
@media (min-width: 768px) {
    body {
        max-width: 1200px;
        margin: 0 auto;
        border-left: var(--border);
        border-right: var(--border);
        box-shadow: 0 0 100px rgba(0, 0, 0, 0.2);
    }

    [data-theme="dark"] body {
        border-left: 1px solid rgba(0, 255, 194, 0.2);
        border-right: 1px solid rgba(0, 255, 194, 0.2);
    }

    /* Grid Layouts for Desktop */
    #all-terms-list,
    #results-view,
    .domain-grid,
    #cases-view {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 1.5rem;
    }

    #domain-grid-container .domain-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .list-item {
        margin-bottom: 0;
        height: 100%;
        align-items: flex-start;
        flex-direction: column;
        justify-content: center;
        gap: 0.5rem;
    }

    .alphabet-header {
        grid-column: 1 / -1;
        margin-top: 1rem;
    }

    /* Keep Search and specific views centered/contained if needed */
    .search-container {
        max-width: 600px;
    }

    /* Detail views should not be grid */
    #term-view,
    #domain-detail-container,
    .case-detail-view {
        max-width: 800px;
        margin: 0 auto;
        display: block;
    }
}

.tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background: rgba(0, 51, 102, 0.05);
    border: 1px solid rgba(43, 47, 64, 0.2);
    color: var(--text-p);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: capitalize;
}

.tag:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-1px);
}

[data-theme="dark"] .tag {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(0, 255, 194, 0.3);
}

[data-theme="dark"] .tag:hover {
    background: var(--o-accent-b);
    color: var(--o-bg);
    box-shadow: 0 0 10px var(--o-accent-b);
}

.hidden {
    display: none !important;
}

/* --- TRAINING / GAME MODULE --- */

/* Game Card */
.game-card {
    min-height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.5rem;
}

/* Controls */
.game-controls-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.segmented-control {
    width: 100%;
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-sharp);
    padding: 2px;
}

.segmented-btn {
    flex: 1;
    border: none;
    background: none;
    padding: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: var(--radius-sharp);
    font-weight: 600;
    transition: all 0.2s;
    color: var(--text-p);
    opacity: 0.6;
}

.segmented-btn[aria-selected="true"] {
    background: var(--bg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    opacity: 1;
    color: var(--primary);
}

[data-theme="dark"] .segmented-btn[aria-selected="true"] {
    background: rgba(255, 255, 255, 0.1);
    color: var(--o-accent-b);
}

.game-select {
    flex: 1;
    min-width: 140px;
    padding: 0.6rem;
    border: var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text-p);
    font-family: var(--font-main);
    font-size: 0.9rem;
}

/* Stats */
.game-stats {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
}

[data-theme="dark"] .game-stats {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    opacity: 0.7;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
}

.stat-value {
    font-weight: 800;
    font-size: 1.1rem;
}

/* Game Prompt Area */
.game-prompt {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    text-align: center;
    color: var(--text-p);
    line-height: 1.3;
}

.game-subprompt {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

/* Options */
.game-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.opt {
    background: var(--bg);
    border: 2px solid rgba(0, 0, 0, 0.1);
    padding: 1rem;
    border-radius: 12px;
    text-align: left;
    font-family: var(--font-main);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-p);
}

.opt:hover {
    border-color: var(--primary);
    transform: translateX(4px);
    background: rgba(var(--primary-rgb), 0.05);
}

.opt:disabled {
    opacity: 0.7;
    pointer-events: none;
}

[data-theme="dark"] .opt {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

[data-theme="dark"] .opt:hover {
    border-color: var(--o-accent-b);
    background: rgba(0, 255, 194, 0.1);
}

/* Feedback */
.feedback {
    margin-top: 1.5rem;
    text-align: center;
    font-weight: 800;
    min-height: 1.5rem;
    padding: 0.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
}

.feedback.ok {
    color: #2f855a;
    background: rgba(47, 133, 90, 0.1);
}

.feedback.bad {
    color: #c53030;
    background: rgba(197, 48, 48, 0.1);
}

[data-theme="dark"] .feedback.ok {
    color: #48bb78;
    background: rgba(72, 187, 120, 0.1);
}

[data-theme="dark"] .feedback.bad {
    color: #fc8181;
    background: rgba(252, 129, 129, 0.1);
}

/* Hint */
.game-hint {
    font-size: 0.85rem;
    color: var(--text-p);
    opacity: 0.7;
    font-style: italic;
    text-align: center;
    margin-top: 1rem;
}

/* Action Buttons */
.game-actions {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    /* Mobile first: stack them */
    align-items: center;
    gap: 1rem;
}

.btn.ghost {
    background: none;
    border: none;
    color: var(--text-p);
    opacity: 0.6;
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
}

.btn.primary {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .btn.primary {
    background: var(--o-accent-b);
    color: #000;
    box-shadow: 0 0 10px var(--o-accent-b);
}

/* Desktop Fix for Game */
@media (min-width: 768px) {
    #game-view {
        max-width: 800px;
        margin: 0 auto;
    }

    .game-actions {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .btn.primary {
        width: auto;
    }
}

/* ChromaGrid Component styles */
.chroma-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--cols, 3), 1fr);
    gap: 1.5rem;
    padding: 1rem;
    --r: 300px;
    --x: 50%;
    --y: 50%;
}

@media (max-width: 768px) {
    .chroma-grid {
        grid-template-columns: 1fr;
    }
}

.chroma-card {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: background 0.3s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    z-index: 10;
}

[data-theme="light"] .chroma-card {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.chroma-card:hover {
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .chroma-card:hover {
    background: rgba(0, 0, 0, 0.04);
}

.chroma-img-wrapper {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 1rem;
    border: 3px solid var(--card-border, var(--primary));
}

.chroma-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chroma-info .name {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-p);
}

.chroma-info .handle {
    display: block;
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.chroma-info .role {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Mouse Follow Effect */
.chroma-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    background: radial-gradient(var(--r, 300px) circle at var(--x) var(--y),
            rgba(var(--primary-rgb, 86, 216, 182), 0.15),
            transparent 80%);
}

.chroma-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(400px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
            rgba(var(--primary-rgb, 86, 216, 182), 0.1),
            transparent 40%);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

.chroma-card:hover::before {
    opacity: 1;
}

.chroma-fade {
    position: absolute;
    inset: 0;
    background: var(--bg);
    pointer-events: none;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.6s ease;
}

/* Buy Me a Coffee - Visibility Polish */
.coffee-card {
    --card-border: #FFDD00;
    background: #FFDD0015 !important;
    border: 2px solid #FFDD00 !important;
    box-shadow: 0 0 20px #FFDD0030;
    animation: coffeePulse 3s infinite ease-in-out;
    cursor: pointer;
}

[data-theme="dark"] .coffee-card {
    background: #FFDD0010 !important;
    box-shadow: 0 0 25px #FFDD0040;
}

.coffee-card:hover {
    transform: scale(1.02);
    background: #FFDD0025 !important;
}

.coffee-card .chroma-img-wrapper {
    background: #FFDD00 !important;
    color: #444;
}

@keyframes coffeePulse {
    0% {
        box-shadow: 0 0 10px #FFDD0020;
    }

    50% {
        box-shadow: 0 0 30px #FFDD0060;
    }

    100% {
        box-shadow: 0 0 10px #FFDD0020;
    }
}

/* Game Timer & Arcade Enhancements */
.game-timer-container {
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    margin: 1rem 0;
    overflow: hidden;
    position: relative;
}

[data-theme="dark"] .game-timer-container {
    background: rgba(255, 255, 255, 0.05);
}

.game-timer-bar {
    height: 100%;
    width: 100%;
    background: var(--primary);
    transform-origin: left;
    transition: transform 0.1s linear;
}

[data-theme="dark"] .game-timer-bar {
    background: var(--o-accent-b);
    box-shadow: 0 0 10px var(--o-accent-b);
}

/* Animations */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-10px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(10px);
    }
}

.animate-shake {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes pulse-success {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
        background: rgba(var(--primary-rgb), 0.2);
    }

    100% {
        transform: scale(1);
    }
}

.animate-pulse {
    animation: pulse-success 0.4s ease-out;
}

.combo-pop {
    display: inline-block;
    animation: pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

/* Arcade Highscore Look */
.game-stats .stat-value {
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: 1px;
}

/* ========================================
   MISSING COMPONENT STYLES
   ======================================== */

/* Back Button */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 1rem;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    opacity: 0.65;
    transition: opacity 0.2s, transform 0.2s;
    color: var(--text-p);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    user-select: none;
}

.btn-back:hover {
    opacity: 1;
    transform: translateX(-3px);
}

/* Definition Sections */
.definition-section {
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
}

.definition-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Recent Searches Bar */
.recent-searches-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.recent-search-tag {
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary);
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.78rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s, transform 0.15s;
    border: 1px solid rgba(var(--primary-rgb), 0.3);
    white-space: nowrap;
}

.recent-search-tag:hover {
    background: rgba(var(--primary-rgb), 0.25);
    transform: translateY(-1px);
}

/* Domain Detail Header */
.domain-detail-header {
    margin-bottom: 1.5rem;
    padding: 1.25rem;
    background: rgba(var(--primary-rgb), 0.06);
    border-radius: 12px;
    border-left: 4px solid var(--primary);
}

[data-theme="dark"] .domain-detail-header {
    background: rgba(var(--primary-rgb), 0.04);
    border-left: 4px solid var(--primary);
}

.domain-detail-title {
    font-size: 1.4rem;
    font-weight: 800;
    margin: 0;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.2;
}

/* Section Containers */
.section-container {
    margin-bottom: 1.5rem;
}

/* Subcomponents */
.subcomponent-item {
    padding: 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    margin-bottom: 0.75rem;
    background: var(--surface-2);
}

[data-theme="dark"] .subcomponent-item {
    background: rgba(255, 255, 255, 0.02);
}

.subcomponent-label {
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--primary);
    display: block;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Wording Boxes */
.wording-box {
    padding: 1rem 1.25rem;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    margin-top: 1.5rem;
}

.wording-recommended {
    background: rgba(47, 133, 90, 0.06);
    border-left: 4px solid #2f855a;
}

[data-theme="dark"] .wording-recommended {
    background: rgba(72, 187, 120, 0.06);
    border-left: 4px solid #48bb78;
}

.wording-list {
    padding-left: 1.25rem;
    font-size: 0.9rem;
    line-height: 1.7;
    margin: 0.5rem 0 0;
}

/* Clinical Box */
.clinical-box {
    padding: 1rem;
    border-radius: 10px;
}

/* Examples */
.examples-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.example-item {
    padding: 1rem;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
}

[data-theme="dark"] .example-item {
    background: rgba(255, 255, 255, 0.03);
}

.example-item.patient_quote {
    border-left: 3px solid var(--primary);
}

.example-item p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.example-type-badge {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.55;
    margin-bottom: 0.5rem;
    display: block;
}

/* ========================================
   AESTHETIC IMPROVEMENTS
   ======================================== */

/* Active nav indicator */
.bottom-nav button {
    position: relative;
    padding-top: 0.75rem;
    transition: opacity 0.2s, color 0.2s;
}

.bottom-nav button.active::after {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

[data-theme="dark"] .bottom-nav button.active::after {
    background: var(--o-accent-b);
    box-shadow: 0 0 8px var(--o-accent-b);
}

/* Smoother list item arrow on mobile */
.list-item {
    transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
}

/* Search input focus ring */
.search-container input:focus {
    outline: none;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15), var(--shadow) !important;
}

/* ========================================
   MOBILE OPTIMIZATIONS (≤ 480px)
   ======================================== */

@media (max-width: 480px) {
    /* Header */
    .app-header {
        padding: 0.65rem 0.75rem 0.75rem;
    }

    .header-top {
        margin-bottom: 0.65rem;
    }

    .app-header h1 {
        font-size: 1.15rem;
        letter-spacing: -0.03em;
    }

    .ritual-subtitle {
        font-size: 0.5rem;
        letter-spacing: 0.2em;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
        padding: 0.35rem;
    }

    /* Search */
    .search-container input {
        padding: 0.7rem 1rem;
        font-size: 1rem; /* prevents iOS zoom */
        border-radius: 14px;
    }

    /* Main content */
    main {
        padding: 1rem 0.75rem 6rem;
    }

    /* Cards */
    .card {
        padding: 1rem;
        border-radius: 14px;
    }

    /* Term title */
    .term-title {
        font-size: 1.5rem;
    }

    /* List items */
    .list-item {
        padding: 1rem;
    }

    /* Domain grid: 1 column on very small screens */
    .domain-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .domain-card {
        padding: 1.25rem 1rem;
        flex-direction: row;
        text-align: left;
        align-items: center;
        gap: 1rem;
    }

    .domain-card .domain-icon {
        font-size: 2rem;
        flex-shrink: 0;
    }

    /* Game stats: wrap into grid for readability */
    .game-stats {
        flex-wrap: wrap;
        gap: 0.5rem 0;
        justify-content: space-around;
    }

    .stat-item {
        width: calc(100% / 4);
        min-width: 0;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    .stat-value {
        font-size: 0.95rem;
    }

    /* Game prompt */
    .game-prompt {
        font-size: 1.05rem;
    }

    .game-subprompt {
        font-size: 0.82rem;
    }

    /* Game card */
    .game-card {
        min-height: 300px;
        padding: 1rem;
    }

    /* Options */
    .opt {
        padding: 0.85rem;
        font-size: 0.9rem;
    }

    /* Bottom nav */
    .bottom-nav {
        padding: 0.6rem 0.25rem 1.2rem;
    }

    .bottom-nav button {
        font-size: 0.6rem;
        gap: 0.3rem;
    }

    .bottom-nav button .nav-icon {
        font-size: 1.35rem;
    }

    /* Alert banner */
    .alert-critical-banner {
        padding: 1rem;
        margin: 1rem 0;
    }

    /* Domain detail title */
    .domain-detail-title {
        font-size: 1.15rem;
    }

    /* Segmented control */
    .segmented-btn {
        font-size: 0.8rem;
        padding: 0.45rem 0.25rem;
    }

    /* Game selects */
    .game-select {
        font-size: 0.82rem;
        padding: 0.5rem;
    }
}

/* ========================================
   DONATION WIDGET
   ======================================== */

.donation-widget {
    position: fixed;
    bottom: 80px; /* above bottom nav */
    right: 16px;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg);
    border: var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: donation-slide-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    max-width: 180px;
}

.donation-widget.hidden {
    display: none !important;
}

@keyframes donation-slide-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.donation-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.65rem 0.45rem 0.75rem;
    text-decoration: none;
    color: var(--text-p);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font-main);
    white-space: nowrap;
    transition: background 0.15s;
    flex: 1;
    min-width: 0;
}

.donation-link:hover {
    background: rgba(var(--primary-rgb), 0.12);
}

.donation-icon {
    font-size: 1rem;
    flex-shrink: 0;
    line-height: 1;
}

.donation-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

.donation-close {
    background: none;
    border: none;
    border-left: var(--border);
    color: var(--text-secondary);
    font-size: 0.7rem;
    padding: 0.45rem 0.55rem;
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    font-family: var(--font-main);
}

.donation-close:hover {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--text-p);
}

[data-theme="dark"] .donation-widget {
    background: #1a1025;
    border-color: rgba(0, 255, 194, 0.25);
    box-shadow: 0 0 12px rgba(0, 255, 194, 0.15);
}

[data-theme="dark"] .donation-link {
    color: var(--o-text, #E4D8EB);
}

[data-theme="dark"] .donation-close {
    border-left-color: rgba(0, 255, 194, 0.2);
    color: rgba(228, 216, 235, 0.5);
}

[data-theme="dark"] .donation-link:hover {
    background: rgba(0, 255, 194, 0.08);
}

[data-theme="dark"] .donation-close:hover {
    background: rgba(0, 255, 194, 0.08);
    color: #E4D8EB;
}

/* M3 Switch Layout */
.m3-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.m3-switch input {
    display: none;
}

.m3-switch-slider {
    position: relative;
    width: 52px;
    height: 32px;
    background: var(--surface-3);
    border-radius: var(--radius-full);
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid var(--border-subtle);
}

.m3-switch-slider::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 4px;
    width: 20px;
    height: 20px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.m3-switch input:checked + .m3-switch-slider {
    background: var(--primary);
    border-color: var(--primary);
}

.m3-switch input:checked + .m3-switch-slider::before {
    transform: translateX(20px);
    background: white;
    padding: 0 0.5rem;
}

.view-actions-header {
    padding: 0 0.5rem;
}

.game-instructions-banner {
    background: var(--surface-2);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    border-left: 6px solid var(--primary);
    box-shadow: var(--shadow);
}

.game-instructions-banner h4 {
    margin: 0 0 0.25rem 0;
    color: var(--primary);
    font-size: 0.9rem;
    text-transform: uppercase;
}

.game-instructions-banner p {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.8;
    line-height: 1.4;
}

.global-footer {
    margin-top: 4rem;
    padding: 2rem 1rem;
    background: var(--surface-1);
    border-top: 1px solid var(--border-subtle);
    text-align: center;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-content p {
    font-size: 0.8rem;
    opacity: 0.6;
    margin: 0;
}

.support-nudge p {
    color: var(--text-secondary);
}

.animate-pulse {
    animation: pulse 0.5s ease-in-out alternate;
}

.integrator-view {
    max-width: 1200px;
    margin: 0 auto;
}

.integrator-header {
    margin-bottom: 2rem;
    text-align: center;
    position: relative;
}

.m3-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    color: var(--primary);
    margin: 1rem 0 0.25rem;
    text-transform: uppercase;
    letter-spacing: -0.02em;
    font-size: 1.8rem;
}

.m3-progress-container {
    width: 100%;
    height: 4px;
    background: var(--surface-3);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.m3-progress-bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.integrator-container {
    display: grid;
    grid-template-columns: 260px 1fr 340px;
    gap: 1.5rem;
    align-items: start;
}

/* Stepper Sidebar */
.stepper-sidebar {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    background: var(--surface-1);
    border-radius: var(--radius-xl);
    padding: 1rem;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow);
}

#integrator-steps-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.step-item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s var(--md-sys-motion-standard);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid transparent;
}

.step-item:hover {
    background: var(--surface-2);
    transform: translateX(4px);
}

.step-item.active {
    background: var(--primary-container);
    color: var(--on-primary-container);
    font-weight: 700;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.15);
}

.step-item.completed {
    background: rgba(var(--primary-rgb), 0.05);
}

.step-item.completed::after {
    content: "✓";
    margin-left: auto;
    font-weight: 800;
    color: var(--success);
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--surface-3);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.active .step-number {
    background: var(--primary);
    color: var(--v-on-primary);
}

/* Step Content Area */
.step-content {
    min-height: 520px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    border-radius: var(--radius-xl);
    padding: 2rem;
}

[data-theme="dark"] .step-content {
    background: var(--surface-1);
}

#step-label {
    font-size: 1.6rem;
    font-weight: 800;
    margin: 0;
    color: var(--primary);
    letter-spacing: -0.01em;
}

#step-description {
    font-size: 0.95rem;
    opacity: 0.8;
    margin-top: 0.4rem;
    line-height: 1.4;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.65rem;
    max-height: 220px;
    overflow-y: auto;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    background: var(--surface-1);
}

.int-opt {
    padding: 0.6rem 0.85rem;
    background: var(--bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.int-opt:hover {
    background: var(--secondary-container);
    transform: scale(1.05);
}

.int-opt.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.35);
    transform: scale(1.08);
}

.step-writing-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.step-writing-area label {
    font-weight: 800;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.6;
}

.step-writing-area textarea {
    width: 100%;
    flex: 1;
    min-height: 140px;
    padding: 1.25rem;
    font-family: inherit;
    font-size: 1rem;
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    background: var(--bg);
    color: var(--text-p);
    resize: none;
    line-height: 1.6;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.step-writing-area textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 5px rgba(var(--primary-rgb), 0.15);
}

.step-navigation {
    display: flex;
    justify-content: space-between;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border-subtle);
}

/* Preview Panel */
.report-preview-panel {
    position: sticky;
    top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--surface-2);
    max-height: calc(100vh - 200px);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
}

[data-theme="dark"] .report-preview-panel {
    background: #14101d;
}

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

.preview-header h3 {
    font-size: 0.85rem;
    font-weight: 800;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--primary);
}

[data-theme="dark"] .report-output {
    background: rgba(0,0,0,0.2);
}

.report-output {
    flex: 1;
    padding: 1.25rem;
    background: var(--bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    line-height: 1.7;
    overflow-y: auto;
    white-space: pre-wrap;
    color: var(--text-p);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.report-actions {
    display: flex;
    justify-content: flex-end;
}

/* Responsive Integrator */
@media (max-width: 1024px) {
    .integrator-container {
        grid-template-columns: 200px 1fr;
    }
    .report-preview-panel {
        grid-column: span 2;
        position: static;
        max-height: none;
    }
}

@media (max-width: 480px) {
    .integrator-container {
        grid-template-columns: 1fr;
    }
    .stepper-sidebar {
        position: static;
        max-height: 120px;
        margin-bottom: 1rem;
    }
    #integrator-steps-list {
        display: flex;
        gap: 0.5rem;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }
    .step-item {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 0.4rem 0.6rem;
    }
    .step-content {
        min-height: auto;
    }
    #step-label {
        font-size: 1.2rem;
    }
}