/* Main CSS - Imports all runtime modules */

/* IMPORTANT: All color variables are defined in styles/theme.css (loaded first in index.html)
   This file imports functional CSS modules that reference those variables.
   Never define color variables here - theme.css is the single source of truth. */

/* Core modules - loaded in order of importance */
/* START base.css */
/* CSS Variables and Base Styles - Arcane Terminal Redesign */

/* ===== Accessibility ===== */
/* Skip link: visually hidden until focused, then pinned top-left. Lets keyboard
   users jump straight past chrome into the game. */
.skip-link {
    position: absolute;
    top: 0;
    left: 0;
    transform: translateY(-120%);
    z-index: var(--z-skip-link);
    padding: 0.6rem 1rem;
    background: var(--primary, var(--color-code));
    color: var(--bg-void);
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    transition: transform 0.15s ease;
}
.skip-link:focus {
    transform: translateY(0);
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

/* Keyboard focus ring for interactive elements (mouse clicks don't show it). */
:focus-visible {
    outline: 2px solid var(--primary, var(--color-code));
    outline-offset: 2px;
}
/* The <main> skip target is programmatically focusable but shouldn't show a ring. */
#main-content:focus,
#main-content:focus-visible {
    outline: none;
}

:root {
    /* Note: Core color variables are defined in styles/theme.css */
    /* This file contains functional mappings and spacing/typography tokens */

    /* Functional Variables (Mapped to theme.css colors) */
    --primary-glow: var(--color-code);
    --accent-glow: var(--color-magic);
    --text: var(--color-system);
    --bg-primary: var(--bg-terminal);
    --bg-secondary: var(--color-void-700);
    --border: var(--border-ui);

    /* Terminal Specifics */
    --font-main: 'Space Grotesk', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

    --scanline-color: color-mix(in srgb, var(--ky-cyan) 4%, transparent);

    /* Spacing Scale */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;
    --spacing-2xl: 32px;

    /* Animations */
    --anim-flash: 0.1s ease-out;
    --anim-boot: 1s cubic-bezier(0.1, 0.9, 0.2, 1);

    /* Additional z-index values */
    --z-devtools: 110;
    --z-guidance: 120;
    --z-critical: 140;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: hidden; /* Prevent page scroll, we use internal scrolling */
    color-scheme: dark;
}

body {
    font-family: var(--font-main);
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-system);
    background: var(--bg-void);
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* CRT Scanline Overlay */
body::after {
    content: " ";
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(color-mix(in srgb, var(--ky-void) 0%, transparent) 50%, color-mix(in srgb, var(--ky-void) 25%, transparent) 50%), linear-gradient(90deg, color-mix(in srgb, var(--ky-red) 8%, transparent), color-mix(in srgb, var(--ky-green) 4%, transparent), color-mix(in srgb, var(--ky-cyan) 8%, transparent));
    z-index: var(--z-crt-overlay);
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
    opacity: 0.16;
}

/* Typography Override */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
    color: var(--color-code);
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--color-dim);
    border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-code-dim);
}

/* Selection */
::selection {
    background: var(--color-code);
    color: var(--bg-void);
    text-shadow: none;
}

/* Utility: High Contrast / No Animation Mode (Accessibility) */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------------------------------------------------------------------------
 * Modern CSS progressive enhancements (2026)
 * All purely additive — they refine wrapping quality, native-control tinting,
 * and Firefox scrollbars WITHOUT changing any layout box. Unsupported browsers
 * simply ignore them.
 * ------------------------------------------------------------------------- */

/* Balance headings (no orphan last word), and improve body wrapping/orphans. */
h1, h2, h3,
.story-title, .tier-title, .sidebar-header h3, .modal-title {
    text-wrap: balance;
}

p, .story-text, .story-text-secondary, .destructive-text {
    text-wrap: pretty;
}

/* Tint native form controls (checkboxes, radios, range sliders) with the brand
 * accent instead of the OS default blue. */
input[type="checkbox"],
input[type="radio"],
input[type="range"],
progress {
    accent-color: var(--accent, var(--color-code));
}

/* Standard scrollbar styling for Firefox, mirroring the existing -webkit- rules
 * so the terminal aesthetic is consistent across engines. */
html {
    scrollbar-width: thin;
    scrollbar-color: var(--color-dim) transparent;
}

/* END base.css */
/* START layout.css */
/* Layout Styles - Dashboard Architecture */

/* Main Container - The Terminal Screen.
   Flex column matching the actual DOM (header / .game-area / control-deck). The
   old CSS used `display:grid` with a 280px sidebar column, but the markup was
   refactored to wrap the sidebar + content in a `.game-area` flex row — so the
   wrapper landed in the 280px column and ALL tab content collapsed to ~280px.
   The Tailwind utility classes (flex/flex-1/w-64) that were meant to drive this
   are not loaded (tailwind.css is never linked), so the layout must be defined
   here explicitly. */
.main-game {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 100svh;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Row holding the sidebar + the tab content; fills the space between the HUD and
   the control deck. */
.game-area {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* 1. Top HUD - System Status Bar */
.hud {
    grid-column: 1 / -1;
    grid-row: 1;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 64px;
    padding: var(--spacing-sm) var(--spacing-xl);
    z-index: 50;
    flex: 0 0 auto;
}

/* 2. Sidebar - Resource Monitor */
.sidebar {
    flex: 0 0 280px; /* Fixed-width column in the .game-area flex row */
    width: 280px;
    background: var(--bg-terminal);
    border-right: 1px solid var(--border-light);
    padding: var(--spacing-lg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    position: relative; /* Remove fixed positioning */
    height: auto;
    transform: none; /* Reset transform */
}

.sidebar-header {
    border-bottom: 1px solid var(--color-dim);
    padding-bottom: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.sidebar-header h3 {
    font-size: 12px;
    color: var(--color-dim);
    letter-spacing: 1px;
}

/* 3. Main Content Area - The "Viewport". Grows to fill the rest of the
   .game-area row (min-width:0 lets it shrink instead of forcing overflow). */
.tabs-content {
    flex: 1 1 0%;
    min-width: 0;
    position: relative;
    overflow: hidden;
    padding: 0;
    background: radial-gradient(circle at center, var(--ky-basalt-ridge) 0%, var(--bg-void) 100%);
    display: flex;
    flex-direction: column;
}

/* 4. Bottom Control Deck - The Interaction Zone */
.control-deck {
    grid-column: 2;
    grid-row: 3;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: var(--z-control-deck);
    flex: 0 0 auto;
    min-height: 132px;
    padding: var(--spacing-md);
}

.combo-display {
    right: var(--spacing-xl);
    bottom: var(--spacing-xl);
}

/* Tab Navigation - File Directory Style */
.tabs-nav {
    grid-column: 2;
    grid-row: 1; /* Move tabs to HUD area or just below */
    /* Actually, let's float them in the main content area top or integrate with HUD */
    /* For this design, let's put them at the top of the main content area */
    display: flex;
    gap: 2px;
    padding: 0;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-terminal);
    position: sticky;
    top: 0;
    z-index: var(--z-tabs);
    margin: 0; /* Reset margin */
    flex: 0 0 auto;
    overflow-x: auto;
    scrollbar-width: thin;
}

.content-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    padding-bottom: 100px; /* Space for scrolling */
    max-height: none; /* Let grid handle height */
}

.tab-panels-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: var(--spacing-xl);
    -webkit-overflow-scrolling: touch;
}

.tab-panel {
    min-height: 100%;
}

#workstation-list,
#upgrade-list,
#boon-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: var(--spacing-lg);
}

#inventory-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
    gap: var(--spacing-md);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .main-game {
        height: 100dvh;
        min-height: 100svh;
    }

    .hud {
        min-height: 56px;
        padding: var(--spacing-sm) var(--spacing-md);
        gap: var(--spacing-sm);
    }

    .hud-center {
        display: none;
    }

    .tabs-nav {
        white-space: nowrap;
        display: flex;
    }

    .sidebar {
        display: none;
    }

    .sidebar.active {
        display: flex;
        transform: translateX(0);
    }

    .tabs-content {
        flex: 1 1 auto;
        min-height: 0;
    }

    .control-deck {
        min-height: 104px;
        padding: var(--spacing-sm) var(--spacing-md) calc(var(--spacing-sm) + env(safe-area-inset-bottom));
    }

    .tab-panels-container {
        padding: var(--spacing-md);
        padding-bottom: calc(var(--spacing-xl) + env(safe-area-inset-bottom));
    }

    .cast-container {
        width: 96px;
        height: 96px;
    }

    @media (max-width: 380px) {
        .control-deck {
            min-height: 88px;
            padding: 6px var(--spacing-sm) calc(6px + env(safe-area-inset-bottom));
        }

        .cast-container {
            width: 82px;
            height: 82px;
        }
    }

    .combo-display {
        right: var(--spacing-md);
        bottom: calc(var(--spacing-sm) + env(safe-area-inset-bottom));
    }

    .auto-toggle {
        left: var(--spacing-md);
        bottom: calc(var(--spacing-sm) + env(safe-area-inset-bottom));
    }
}

/* END layout.css */
/* START components.css */
/* Component Styles - Arcane Terminal */

/* 1. The Cast Interface (Rune Button) */
.cast-container {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-cast {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--ky-basalt) 82%, transparent);
    border: 2px solid var(--color-code);
    color: var(--color-code);
    font-size: 16px;
    font-family: var(--font-mono);
    letter-spacing: 2px;
    position: relative;
    z-index: 10;
    box-shadow: 0 0 24px color-mix(in srgb, var(--ky-cyan) 28%, transparent), 0 0 36px color-mix(in srgb, var(--ky-magenta) 16%, transparent);
    transition: transform 0.1s ease, background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
    overflow: visible;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-width: 96px;
    min-height: 96px;
}

@media (max-width: 380px) {
    .btn-cast {
        width: 72px;
        height: 72px;
        min-width: 72px;
        min-height: 72px;
        font-size: 12px;
        letter-spacing: 1px;
    }

    .btn-cast::before {
        top: -7px;
        right: -7px;
        bottom: -7px;
        left: -7px;
    }

    .btn-cast::after {
        top: -13px;
        right: -13px;
        bottom: -13px;
        left: -13px;
    }

    .cast-glyph {
        width: 22px;
        height: 22px;
    }
}

.btn-cast::before {
    content: "";
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border: 1px dashed var(--ky-steel);
    border-radius: 50%;
    animation: rotate 10s linear infinite;
}

.btn-cast::after {
    content: "";
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    border: 1px solid var(--border-light);
    border-radius: 50%;
    opacity: 0.3;
}

.btn-cast:hover {
    background: color-mix(in srgb, var(--ky-cyan) 12%, transparent);
    box-shadow: 0 0 32px color-mix(in srgb, var(--ky-cyan) 42%, transparent), 0 0 40px color-mix(in srgb, var(--ky-magenta) 22%, transparent);
    transform: scale(1.02);
    cursor: pointer;
}

.btn-cast:active {
    transform: scale(0.95);
    box-shadow: 0 0 18px color-mix(in srgb, var(--ky-magenta) 46%, transparent);
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.btn-cast:focus-visible {
    box-shadow: 0 0 0 3px var(--ky-crystal), 0 0 36px color-mix(in srgb, var(--ky-cyan) 55%, transparent);
}

.cast-icon {
    font-size: 24px;
    margin-bottom: 4px;
    filter: drop-shadow(0 0 8px color-mix(in srgb, var(--ky-cyan) 50%, transparent));
}

.cast-glyph {
    width: 28px;
    height: 28px;
    position: relative;
}

.cast-glyph::before {
    content: "";
    position: absolute;
    inset: 2px 7px;
    background: currentColor;
    clip-path: polygon(48% 0, 100% 0, 58% 48%, 100% 48%, 18% 100%, 38% 58%, 0 58%);
}

.css-icon-gear {
    width: 20px;
    height: 20px;
    display: inline-block;
    border: 2px solid currentColor;
    border-radius: 50%;
    position: relative;
}

.css-icon-gear::before {
    content: "";
    position: absolute;
    inset: 4px;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.css-icon-gear::after {
    content: "";
    position: absolute;
    inset: -5px;
    background:
        linear-gradient(currentColor, currentColor) center top / 2px 5px no-repeat,
        linear-gradient(currentColor, currentColor) center bottom / 2px 5px no-repeat,
        linear-gradient(90deg, currentColor, currentColor) left center / 5px 2px no-repeat,
        linear-gradient(90deg, currentColor, currentColor) right center / 5px 2px no-repeat;
}

/* 2. Module Cards (Workstations) */
.card,
.workstation-card {
    background: var(--ky-basalt);
    border: 1px solid var(--ky-line);
    border-left: 4px solid var(--ky-cyan); /* Status indicator line - will be overridden by tier colors */
    border-radius: 8px;
    padding: var(--spacing-md);
    position: relative;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.card:hover,
.workstation-card:hover {
    border-color: var(--ky-cyan);
    box-shadow: 0 4px 20px color-mix(in srgb, var(--ky-cyan) 18%, transparent);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--ky-line);
    padding-bottom: var(--spacing-sm);
}

.card-title {
    font-family: var(--font-mono);
    color: var(--color-code);
    font-size: 16px;
    text-transform: uppercase;
}

.card-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: var(--spacing-xs);
}

.card-owned {
    font-family: var(--font-mono);
    color: var(--color-code);
    font-size: 12px;
    font-weight: bold;
    margin-left: var(--spacing-sm);
}

.card-description,
.card-desc {
    font-size: 12px;
    color: var(--color-dim);
    line-height: 1.5;
    margin-bottom: var(--spacing-md);
    margin-top: var(--spacing-xs);
}

/* Workstation Card Specific Styles */
.workstation-card .card-header {
    flex-direction: column;
    align-items: stretch;
}

/* Cost and Production Display */
.cost-display {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: var(--spacing-sm);
}

.cost-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--ky-void) 42%, transparent);
    border-left: 2px solid var(--color-code);
    font-size: 11px;
    line-height: 1.35;
}

.cost-item.affordable {
    background: rgba(0, 240, 255, 0.1);
    border-left-color: var(--color-code);
}

.cost-item.unaffordable {
    background: rgba(0, 0, 0, 0.3);
    border-left-color: var(--color-dim);
    opacity: 0.6;
}

.cost-amount {
    font-weight: bold;
    color: var(--color-code);
}

.cost-name {
    color: var(--color-dim);
    font-weight: 600;
}

.production-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: color-mix(in srgb, var(--ky-void) 30%, transparent);
    border-radius: 4px;
}

.production-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    line-height: 1.4;
}

.prod-amount {
    color: var(--success);
    font-weight: bold;
}

.prod-name {
    color: var(--color-dim);
}

.card-actions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.button-group {
    display: flex;
    gap: var(--spacing-sm);
}

.btn-craft,
.btn-craft-max {
    flex: 1;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--color-code);
    color: var(--color-code);
    font-family: var(--font-mono);
    font-size: 12px;
    text-transform: uppercase;
    cursor: pointer;
    min-height: 44px;
    border-radius: 4px;
    transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    position: relative;
}

.btn-craft:hover,
.btn-craft-max:hover {
    background: var(--color-code);
    color: var(--bg-terminal);
    box-shadow: 0 0 18px color-mix(in srgb, var(--ky-cyan) 42%, transparent);
}

.btn-craft:active,
.btn-craft-max:active {
    transform: scale(0.97);
}

.btn-craft:focus-visible,
.btn-craft-max:focus-visible {
    outline: 2px solid var(--color-code);
    outline-offset: 2px;
    box-shadow: 0 0 22px color-mix(in srgb, var(--ky-cyan) 50%, transparent), 0 0 0 4px color-mix(in srgb, var(--ky-cyan) 18%, transparent);
}

.btn-craft:disabled,
.btn-craft-max:disabled {
    border-color: var(--color-dim);
    color: var(--color-dim);
    cursor: not-allowed;
    box-shadow: none;
    background: color-mix(in srgb, var(--ky-steel) 8%, transparent);
    opacity: 0.6;
    position: relative;
}

.btn-craft:disabled::after,
.btn-craft-max:disabled::after {
    content: attr(data-disabled-reason);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    border: 1px solid var(--color-dim);
    color: var(--color-dim);
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 10px;
    font-family: var(--font-mono);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.btn-craft:disabled:hover::after,
.btn-craft-max:disabled:hover::after {
    opacity: 1;
}

/* 3. Tab Navigation (File Path Style) */
.tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-dim);
    font-family: var(--font-mono);
    font-size: 12px;
    padding: var(--spacing-md) var(--spacing-lg);
    cursor: pointer;
    text-transform: uppercase;
    opacity: 0.7;
    min-height: 44px;
    transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    position: relative;
}

.tab-btn:hover {
    color: var(--color-code);
    opacity: 1;
    background: color-mix(in srgb, var(--ky-cyan) 4%, transparent);
}

.tab-btn:active {
    transform: scale(0.98);
}

.tab-btn:focus-visible {
    background: color-mix(in srgb, var(--ky-cyan) 6%, transparent);
    outline: 2px solid var(--color-code);
    outline-offset: -2px;
}

.tab-btn.active {
    color: var(--color-code);
    border-bottom-color: var(--color-code);
    opacity: 1;
    text-shadow: 0 0 8px color-mix(in srgb, var(--ky-cyan) 55%, transparent);
    background: rgba(0, 240, 255, 0.04);
}

.tab-btn.active:hover {
    background: color-mix(in srgb, var(--ky-cyan) 8%, transparent);
}

.tab-btn.active:focus-visible {
    outline: 2px solid var(--color-code);
    outline-offset: -2px;
}

.tab-btn.active::before {
    content: "> ";
    color: var(--color-magic);
}

.tab-btn.locked {
    color: var(--ky-steel);
    cursor: help;
}

.tab-btn[aria-disabled="true"] {
    color: var(--color-dim);
    cursor: not-allowed;
    opacity: 0.5;
}

.tab-btn[aria-disabled="true"]::after {
    content: "LOCK";
    margin-left: var(--spacing-sm);
    color: var(--color-magic);
    font-size: 10px;
}

/* 4. Buttons (General) */
.btn-primary {
    background: transparent;
    border: 1px solid var(--color-code);
    color: var(--color-code);
    font-family: var(--font-mono);
    text-transform: uppercase;
    padding: 8px 16px;
    font-size: 12px;
    cursor: pointer;
    min-height: 44px;
    border-radius: 4px;
    transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    position: relative;
}

.btn-primary:hover {
    background: var(--color-code);
    color: var(--bg-terminal);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-primary:focus-visible {
    outline: 2px solid var(--color-code);
    outline-offset: 2px;
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.5), 0 0 0 4px rgba(0, 240, 255, 0.15);
}

.btn-primary:disabled {
    border-color: var(--color-dim);
    color: var(--color-dim);
    cursor: not-allowed;
    box-shadow: none;
    background: rgba(168, 175, 207, 0.05);
    opacity: 0.6;
    position: relative;
}

.btn-primary:disabled::after {
    content: attr(data-disabled-reason);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    border: 1px solid var(--color-dim);
    color: var(--color-dim);
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 10px;
    font-family: var(--font-mono);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.btn-primary:disabled:hover::after {
    opacity: 1;
}

/* Loading state for buttons */
.btn-primary.loading,
.btn-craft.loading,
.btn-craft-max.loading {
    color: transparent;
    pointer-events: none;
    position: relative;
}

.btn-primary.loading::after,
.btn-craft.loading::after,
.btn-craft-max.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid var(--color-dim);
    border-top-color: var(--color-code);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-primary.loading:hover::after,
.btn-craft.loading:hover::after,
.btn-craft-max.loading:hover::after {
    opacity: 1;
}

.btn-icon {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--border-light);
    color: var(--color-code);
    background: rgba(10, 10, 18, 0.78);
    cursor: pointer;
    transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.btn-icon:hover {
    color: var(--text-primary);
    border-color: var(--color-code);
    background: rgba(0, 240, 255, 0.12);
    box-shadow: 0 0 18px rgba(0, 240, 255, 0.25);
}

.btn-icon:active {
    transform: scale(0.95);
}

.btn-icon:focus-visible {
    color: var(--text-primary);
    border-color: var(--color-code);
    background: rgba(0, 240, 255, 0.12);
    box-shadow: 0 0 18px rgba(0, 240, 255, 0.25), 0 0 0 3px rgba(0, 240, 255, 0.2);
    outline: none;
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(10, 10, 18, 0.4);
}

.btn-secondary,
.btn-danger {
    font-family: var(--font-mono);
    text-transform: uppercase;
    min-height: 44px;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.btn-secondary {
    border: 1px solid var(--border);
    background: rgba(168, 175, 207, 0.12);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(168, 175, 207, 0.22);
    border-color: var(--color-dim);
}

.btn-secondary:active {
    transform: scale(0.97);
}

.btn-secondary:focus-visible {
    background: rgba(168, 175, 207, 0.22);
    border-color: var(--color-dim);
    outline: 2px solid var(--color-dim);
    outline-offset: 2px;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(168, 175, 207, 0.05);
}

.btn-danger {
    border: 1px solid var(--error);
    background: rgba(255, 42, 109, 0.18);
    color: var(--text-primary);
}

.btn-danger:hover {
    background: rgba(255, 42, 109, 0.34);
    box-shadow: 0 0 18px rgba(255, 42, 109, 0.28);
}

.btn-danger:active {
    transform: scale(0.97);
}

.btn-danger:focus-visible {
    background: rgba(255, 42, 109, 0.34);
    box-shadow: 0 0 18px rgba(255, 42, 109, 0.28);
    outline: 2px solid var(--error);
    outline-offset: 2px;
}

.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 42, 109, 0.05);
}

/* 5. Resource Counters (Sidebar) */
.element-counter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    padding: 4px 0;
}

.element-label {
    color: var(--color-dim);
    font-size: 12px;
}

.element-amount {
    color: var(--color-system);
    font-weight: bold;
}

/* 6. Progress Bars (Terminal Style) */
.progress-bar {
    height: 4px;
    background: var(--color-dim);
    margin-top: 8px;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--color-code);
    box-shadow: 0 0 5px var(--color-code);
}

/* Animations */
@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse-glow {
    0% { box-shadow: 0 0 10px rgba(0, 240, 255, 0.2); }
    50% { box-shadow: 0 0 20px rgba(0, 240, 255, 0.5); }
    100% { box-shadow: 0 0 10px rgba(0, 240, 255, 0.2); }
}

/* 7. Loading and Saving States */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid var(--color-dim);
    border-top-color: var(--color-code);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-loading.btn-primary::after {
    border-top-color: var(--bg-terminal);
}

/* Saving state with different spinner */
.btn-saving {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-saving::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    top: 50%;
    left: 50%;
    margin: -7px 0 0 -7px;
    border: 2px solid transparent;
    border-top-color: var(--color-code);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Processing state for cards */
.card.processing {
    position: relative;
    overflow: hidden;
}

.card.processing::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-code), transparent);
    animation: loading-slide 1.5s ease-in-out infinite;
}

@keyframes loading-slide {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Disabled state enhancements */
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled,
.btn-craft:disabled,
.btn-craft-max:disabled,
.btn-icon:disabled {
    position: relative;
}

.btn-primary:disabled::before,
.btn-secondary:disabled::before,
.btn-danger:disabled::before,
.btn-craft:disabled::before,
.btn-craft-max:disabled::before,
.btn-icon:disabled::before {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 2px,
        rgba(168, 175, 207, 0.05) 2px,
        rgba(168, 175, 207, 0.05) 4px
    );
    border-radius: inherit;
    pointer-events: none;
}

/* 8. Link and Interactive Element States */
a, .link {
    color: var(--color-code);
    text-decoration: none;
    transition: color 0.18s ease, text-shadow 0.18s ease;
    position: relative;
}

a:hover, .link:hover {
    color: var(--color-code);
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
}

a:active, .link:active {
    transform: scale(0.98);
}

a:focus-visible, .link:focus-visible {
    outline: 2px solid var(--color-code);
    outline-offset: 2px;
    border-radius: 2px;
}

a:disabled, .link:disabled,
a[aria-disabled="true"], .link[aria-disabled="true"] {
    color: var(--color-dim);
    cursor: not-allowed;
    opacity: 0.6;
    text-decoration: none;
}

/* 9. Interactive Form Elements */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
textarea,
select {
    min-height: 44px;
    border: 1px solid var(--border);
    background: var(--bg-panel);
    color: var(--color-system);
    font-family: var(--font-mono);
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 4px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-code);
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

input:disabled,
textarea:disabled,
select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(168, 175, 207, 0.05);
}

/* Checkbox and Radio accessibility */
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    outline: 2px solid var(--color-code);
    outline-offset: 2px;
}

/* Modal Button Feedback */
.modal-btn-feedback {
    position: relative;
    overflow: hidden;
}

.modal-btn-feedback.success {
    border-color: var(--success) !important;
    color: var(--success) !important;
    box-shadow: 0 0 15px rgba(60, 227, 197, 0.4);
}

.modal-btn-feedback.error {
    border-color: var(--error) !important;
    color: var(--error) !important;
    box-shadow: 0 0 15px rgba(255, 42, 109, 0.4);
    animation: shake 0.5s ease-in-out;
}

.modal-btn-feedback.processing {
    opacity: 0.7;
    cursor: wait;
}

.modal-btn-feedback.processing::after {
    content: "...";
    animation: processing-dots 1.5s infinite;
}

@keyframes processing-dots {
    0%, 20% { content: "."; }
    40% { content: ".."; }
    60%, 100% { content: "..."; }
}

/* Skeleton Loader */
.skeleton {
    background: linear-gradient(90deg, var(--bg-panel) 25%, var(--bg-panel-alt, #1a1a2e) 50%, var(--bg-panel) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    min-height: 20px;
}

.skeleton-card {
    height: 80px;
    margin-bottom: 8px;
}

.skeleton-line {
    height: 16px;
    margin-bottom: 8px;
    width: 80%;
}

.skeleton-line-short {
    height: 16px;
    margin-bottom: 8px;
    width: 40%;
}

/* Error State */
.error-state {
    padding: 16px;
    border: 1px solid var(--color-glitch-500, #ff0055);
    border-radius: 4px;
    background: rgba(255, 0, 85, 0.1);
    color: var(--color-glitch-500, #ff0055);
    font-family: var(--font-mono, monospace);
    font-size: 12px;
    text-align: center;
}

.error-state__icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.error-state__message {
    margin-bottom: 8px;
}

.error-state__retry {
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--color-glitch-500, #ff0055);
    color: var(--color-glitch-500, #ff0055);
    padding: 4px 12px;
    font-family: var(--font-mono, monospace);
    font-size: 11px;
    border-radius: 2px;
}

.error-state__retry:hover {
    background: rgba(255, 0, 85, 0.2);
}

/* Form Validation */
input:invalid, textarea:invalid {
    border-color: var(--color-glitch-500, #ff0055);
}

input:focus:invalid, textarea:focus:invalid {
    box-shadow: 0 0 0 2px rgba(255, 0, 85, 0.3);
}

input[aria-invalid="true"], textarea[aria-invalid="true"] {
    border-color: var(--color-glitch-500, #ff0055);
    background: rgba(255, 0, 85, 0.05);
}

.field-error {
    color: var(--color-glitch-500, #ff0055);
    font-size: 11px;
    font-family: var(--font-mono, monospace);
    margin-top: 4px;
    display: none;
}

.field-error.visible {
    display: block;
}

/* 10. Empty State Components */
.empty-state-hint {
    color: var(--color-system);
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.8;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 11px;
    margin-top: 8px;
    min-height: 32px;
}

/* Screen reader only class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Bolt icon (replaces Font Awesome fa-bolt) */
.css-icon-bolt {
    display: inline-block;
    width: 0.7em;
    height: 1em;
    margin-right: 0.25em;
    vertical-align: -0.1em;
    background: currentColor;
    clip-path: polygon(55% 0, 20% 55%, 48% 55%, 40% 100%, 80% 42%, 52% 42%);
}

.css-icon-fire {
    display: inline-block;
    width: 0.75em;
    height: 1em;
    margin-right: 0.2em;
    vertical-align: -0.1em;
    background: currentColor;
    clip-path: polygon(50% 0, 70% 35%, 95% 30%, 75% 60%, 90% 100%, 50% 80%, 10% 100%, 25% 60%, 5% 30%, 30% 35%);
}

/* Tier 0: hard mono deprivation (scoped — never filter body; cast stays playable) */
body.tier-0 .glow-text,
body.tier-0 .text-ky-cyan.glow-text {
    text-shadow: none !important;
    color: var(--ky-crystal) !important;
}

body.tier-0 .glass-panel {
    /* color-mix only — never opacity on the panel (cast lives inside .control-deck.glass-panel) */
    background: color-mix(in srgb, var(--ky-void) 96%, transparent) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    border-color: var(--ky-line) !important;
}

body.tier-0 .hud .text-ky-cyan,
body.tier-0 .hud .text-ky-green {
    color: var(--ky-steel) !important;
}

body.tier-0 .workstation-card,
body.tier-0 .card {
    box-shadow: none !important;
    border-left-color: var(--ky-steel) !important;
}

/* Scoped desaturation — do NOT put filter on body (breaks fixed toasts / CRT containing block) */
body.tier-0 .hud,
body.tier-0 .game-area,
body.tier-0 .sidebar {
    filter: grayscale(0.92) contrast(1.04);
}
body.tier-0 #cast-button,
body.tier-0 .cast-button,
body.tier-0 .btn-cast {
    filter: none;
    opacity: 1;
    outline: 1px solid var(--ky-crystal);
}
body.tier-0::after {
    opacity: 0.08;
    filter: grayscale(1);
}

/* Tier 0 dramatization: secondary chrome dim; cast stays primary */
body.tier-0 .tab-btn,
body.tier-0 .sidebar-header,
body.tier-0 .sidebar-footer {
    opacity: 0.72;
}

/* Heal-moment tier advance — outline on body; filter ONLY on main content (Opus 5 A5) */
body.tier-advance-heal {
    outline: 3px solid var(--ky-cyan);
    outline-offset: -3px;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ky-green) 55%, transparent),
        0 0 48px color-mix(in srgb, var(--ky-cyan) 35%, transparent);
}
body.tier-advance-heal #main-content,
body.tier-advance-heal .game-area {
    animation: heal-restore-pulse 1.6s ease-out 1;
}
body.tier-advance-heal.heal-ceremony-dim #main-content,
body.tier-advance-heal.heal-ceremony-dim .game-area {
    filter: brightness(0.72) saturate(0.55);
}
body.tier-advance-heal.heal-ceremony-restore #main-content,
body.tier-advance-heal.heal-ceremony-restore .game-area {
    filter: brightness(1.35) saturate(1.25);
}
body.tier-advance-heal.heal-ceremony-chrome #main-content,
body.tier-advance-heal.heal-ceremony-chrome .game-area {
    filter: brightness(1.1) saturate(1.1);
}
body.tier-advance-heal .compile-goal-rail:not([hidden]) {
    border-color: var(--ky-cyan);
    box-shadow: 0 0 16px color-mix(in srgb, var(--ky-cyan) 40%, transparent);
}
@keyframes heal-restore-pulse {
    0% { filter: brightness(1.45) saturate(1.35); }
    35% { filter: brightness(1.15) saturate(1.1); }
    100% { filter: none; }
}
@media (prefers-reduced-motion: reduce) {
    body.tier-advance-heal {
        outline: 2px solid var(--ky-cyan);
        box-shadow: inset 0 0 0 1px var(--ky-cyan);
    }
    body.tier-advance-heal #main-content,
    body.tier-advance-heal .game-area,
    body.tier-advance-heal.heal-ceremony-dim #main-content,
    body.tier-advance-heal.heal-ceremony-dim .game-area,
    body.tier-advance-heal.heal-ceremony-restore #main-content,
    body.tier-advance-heal.heal-ceremony-restore .game-area,
    body.tier-advance-heal.heal-ceremony-chrome #main-content,
    body.tier-advance-heal.heal-ceremony-chrome .game-area {
        animation: none;
        filter: none;
    }
}
.compile-goal-rail {
    border: 1px solid color-mix(in srgb, var(--ky-green) 35%, transparent);
    min-width: 12rem;
    max-width: min(28rem, 42vw);
}
/* Pipeline role HUD — Capture→Store→Bind→Compile→Shield */
.pipeline-role-hud {
    border: 1px solid color-mix(in srgb, var(--ky-cyan) 30%, transparent);
    max-width: 100%;
    overflow: hidden;
}
.affinity-foreshadow {
    max-width: min(42rem, 100%);
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.35;
}
.pipeline-role-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.65rem;
    letter-spacing: 0.04em;
}
.pipeline-role-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid color-mix(in srgb, var(--ky-green) 35%, transparent);
    background: color-mix(in srgb, var(--ky-green) 6%, transparent);
    color: var(--ky-green, #7dffb3);
    min-height: 2rem;
}
.pipeline-role-count {
    color: var(--ky-cyan, #7dd3fc);
    font-weight: 700;
}
.pipeline-role-arrow {
    color: color-mix(in srgb, var(--ky-steel, #94a3b8) 80%, transparent);
    user-select: none;
}
@media (max-width: 480px) {
    .pipeline-role-row {
        gap: 0.2rem;
    }
    .pipeline-role-chip {
        padding: 0.2rem 0.35rem;
        font-size: 0.6rem;
    }
}
@media (prefers-reduced-motion: reduce) {
    .pipeline-role-chip {
        transition: none;
    }
}
.pipeline-role-badge {
    display: inline-block;
    margin: 0.25rem 0 0.35rem;
    padding: 0.15rem 0.4rem;
    border-radius: 0.2rem;
    border: 1px solid color-mix(in srgb, var(--ky-cyan) 40%, transparent);
    color: var(--ky-cyan, #7dd3fc);
    background: color-mix(in srgb, var(--ky-cyan) 8%, transparent);
}
.pipeline-role-badge[data-role="store"] {
    color: var(--ky-amber, #fbbf24);
    border-color: color-mix(in srgb, var(--ky-amber, #fbbf24) 40%, transparent);
}
.pipeline-role-badge[data-role="bind"] {
    color: var(--ky-magenta, #e879f9);
    border-color: color-mix(in srgb, var(--ky-magenta, #e879f9) 40%, transparent);
}
.pipeline-role-badge[data-role="compile"] {
    color: var(--ky-green, #7dffb3);
    border-color: color-mix(in srgb, var(--ky-green, #7dffb3) 40%, transparent);
}
.pipeline-role-badge[data-role="shield"] {
    color: var(--ky-steel, #94a3b8);
    border-color: color-mix(in srgb, var(--ky-steel, #94a3b8) 40%, transparent);
}
/* Full SHARE_RESTORE label — persistent + touch-friendly (Opus 5 Rank 2) */
.heal-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 2.75rem;
    min-width: 2.75rem;
    padding: 0.4rem 0.8rem;
    border-radius: 0.375rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    line-height: 1.2;
    color: var(--ky-cyan);
    border: 1px solid color-mix(in srgb, var(--ky-cyan) 45%, transparent);
    background: color-mix(in srgb, var(--ky-cyan) 8%, transparent);
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.heal-share-btn:hover,
.heal-share-btn:focus-visible {
    background: color-mix(in srgb, var(--ky-cyan) 18%, transparent);
    border-color: var(--ky-cyan);
    box-shadow: 0 0 12px color-mix(in srgb, var(--ky-cyan) 35%, transparent);
    outline: none;
}
.heal-share-btn .heal-share-label {
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
}
/* Narrow rails: keep full meaning via aria-label; shorten visible glyph only */
@media (max-width: 420px) {
    .heal-share-btn .heal-share-label {
        font-size: 0.65rem;
        letter-spacing: 0.04em;
    }
}
@media (max-width: 360px) {
    .heal-share-btn .heal-share-label::after {
        content: '';
    }
    .heal-share-btn .heal-share-label {
        /* Still show SHARE_RESTORE; allow wrap inside button if needed */
        white-space: normal;
        line-height: 1.1;
        max-width: 5.5rem;
        text-align: center;
    }
}
}
#heal-share-button:not([hidden]) {
    display: inline-flex;
}
#heal-share-button.heal-share-btn--ready:not([hidden]) {
    outline: 1px solid var(--ky-cyan);
}
#heal-share-button.heal-share-btn--pulse:not([hidden]) {
    animation: heal-share-pulse 1.2s ease-out 2;
}
@keyframes heal-share-pulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ky-cyan) 0%, transparent); }
    40% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--ky-cyan) 35%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
    #heal-share-button.heal-share-btn--pulse:not([hidden]),
    #heal-share-button.heal-share-btn--ready:not([hidden]) {
        animation: none;
        outline: 1px solid var(--ky-cyan);
    }
}
@media (max-width: 640px) {
    .heal-share-btn {
        font-size: 0.65rem;
        padding: 0.3rem 0.45rem;
        letter-spacing: 0.04em;
    }
}

/* END components.css */
/* START animations.css */
/* Animation Styles - CRT & Glitch Effects */

/* 1. Glitch Effect */
@keyframes glitch {
    0% {
        transform: translate(0);
    }
    20% {
        transform: translate(-2px, 2px);
    }
    40% {
        transform: translate(-2px, -2px);
    }
    60% {
        transform: translate(2px, 2px);
    }
    80% {
        transform: translate(2px, -2px);
    }
    100% {
        transform: translate(0);
    }
}

.glitch-effect {
    animation: glitch 0.3s cubic-bezier(.25, .46, .45, .94) both infinite;
    color: var(--color-corruption);
}

/* 2. CRT Flicker */
@keyframes flicker {
    0% {
        opacity: 0.97;
    }
    5% {
        opacity: 0.95;
    }
    10% {
        opacity: 0.9;
    }
    15% {
        opacity: 0.95;
    }
    20% {
        opacity: 0.99;
    }
    25% {
        opacity: 0.95;
    }
    30% {
        opacity: 0.9;
    }
    35% {
        opacity: 0.96;
    }
    40% {
        opacity: 0.98;
    }
    45% {
        opacity: 0.95;
    }
    50% {
        opacity: 0.99;
    }
    55% {
        opacity: 0.93;
    }
    60% {
        opacity: 0.9;
    }
    65% {
        opacity: 0.96;
    }
    70% {
        opacity: 1;
    }
    75% {
        opacity: 0.97;
    }
    80% {
        opacity: 0.95;
    }
    85% {
        opacity: 0.96;
    }
    90% {
        opacity: 1;
    }
    95% {
        opacity: 0.99;
    }
    100% {
        opacity: 0.94;
    }
}

.crt-flicker {
    animation: flicker 0.15s infinite;
}

/* 3. Boot Sequence Fade In */
@keyframes bootUp {
    0% {
        opacity: 0;
        filter: blur(10px);
    }
    100% {
        opacity: 1;
        filter: blur(0);
    }
}

.boot-sequence {
    animation: bootUp 1.5s ease-out forwards;
}

/* 4. Data Stream (Matrix-like rain but subtle) */
@keyframes dataStream {
    0% {
        background-position: 0% 0%;
    }
    100% {
        background-position: 0% 100%;
    }
}

.data-stream-bg {
    background: linear-gradient(transparent 50%, rgba(0, 240, 255, 0.05) 50%);
    background-size: 100% 4px;
    animation: dataStream 10s linear infinite;
}

/* 5. Pulse Glow (for buttons) */
@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 5px var(--primary-glow);
    }
    50% {
        box-shadow: 0 0 20px var(--primary-glow);
    }
    100% {
        box-shadow: 0 0 5px var(--primary-glow);
    }
}

.pulse-glow {
    animation: pulseGlow 2s infinite;
}

/* 6. Slide In (UI Elements) */
@keyframes slideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-slide-in {
    animation: slideIn 0.3s ease-out forwards;
}

/* 7. Number Ticker Transition */
.number-ticker {
    transition: color 0.2s;
}

.number-ticker.up {
    color: var(--success);
}

.number-ticker.down {
    color: var(--error);
}

/* 8. Error State Animations */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-4px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(4px);
    }
}

@keyframes flashError {
    0%, 100% {
        border-color: var(--border-light);
    }
    50% {
        border-color: var(--error);
        box-shadow: 0 0 20px rgba(255, 42, 109, 0.6);
    }
}

.error-shake {
    animation: shake 0.5s ease-in-out;
}

.error-flash {
    animation: flashError 0.6s ease-in-out;
}

/* 9. Success Feedback Animation */
@keyframes successPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(60, 227, 197, 0);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 20px rgba(60, 227, 197, 0.6);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(60, 227, 197, 0);
    }
}

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

/* Shimmer Animation for Skeleton Loaders */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* END animations.css */
/* START responsive.css */
/**
 * Responsive Design Enhancements
 * Ensures equal quality experience across mobile, tablet, desktop, and laptop
 *
 * Breakpoints:
 * - Mobile: 0-767px
 * - Tablet: 768px-1023px
 * - Desktop/Laptop: 1024px+
 */

/* ==============================================
   MOBILE-FIRST BASE STYLES
   ============================================== */

/* Touch targets - minimum 44x44px for accessibility */
.btn,
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-icon,
.tab-btn,
.workstation-card,
.upgrade-card,
.btn-cast {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation; /* Prevents double-tap zoom */
}

/* Improved tap feedback */
.btn:active,
.btn-primary:active,
.btn-secondary:active,
.btn-danger:active,
.btn-icon:active,
.tab-btn:active,
.btn-cast:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* Prevent text selection on buttons (better UX on touch) */
.btn,
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-icon,
.tab-btn,
.btn-cast {
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ==============================================
   MOBILE STYLES (0-767px)
   ============================================== */

@media (max-width: 767px) {
    /* Layout adjustments */
    body {
        font-size: 14px; /* Slightly smaller for mobile */
    }

    .sidebar {
        display: none;
    }

    /* Collapsible sidebar toggle */
    .sidebar.collapsed {
        height: auto;
        min-height: unset;
    }

    .sidebar-toggle {
        display: block !important;
        position: absolute;
        top: 12px;
        right: 12px;
        z-index: 101;
    }

    /* Stack tabs vertically on mobile */
    .tabs-container {
        flex-direction: column;
        gap: 8px;
    }

    .tab-btn {
        flex: 0 0 auto;
        width: auto;
        justify-content: center;
        padding: 12px 16px;
    }

    /* Optimize main content for mobile */
    .tabs-content {
        min-height: 0;
        margin: 0;
    }

    /* Card grids - single column on mobile */
    #workstation-list,
    #upgrade-list,
    #inventory-list,
    #boon-list {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    /* Larger touch targets for cards */
    .workstation-card,
    .upgrade-card {
        padding: 16px;
        min-height: 120px;
    }

    /* Cast button - prominent on mobile */
    .btn-cast {
        width: 82px;
        height: 82px;
        min-width: 82px;
        min-height: 82px;
        font-size: 16px;
    }

    /* Modal full-screen on mobile */
    .modal-content {
        width: 95vw;
        max-width: 95vw;
        max-height: 90vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    /* Bottom navigation for mobile (optional) */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-top: 2px solid var(--border);
        display: flex;
        justify-content: space-around;
        padding: 8px;
        z-index: 1000;
    }

    /* Hide desktop-only elements */
    .desktop-only {
        display: none !important;
    }

    /* Adjust font sizes for mobile */
    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 20px;
    }

    h3 {
        font-size: 18px;
    }

    /* Stats display - responsive stacking */
    .sidebar-stats {
        flex-direction: column;
        gap: 8px;
    }

    .stat-item {
        width: 100%;
    }

    /* Reduce padding on mobile */
    .tab-panels-container {
        padding: 12px;
    }

    /* Optimize meditation canvas for mobile */
    #meditation-canvas {
        width: 100%;
        max-width: 100vw;
        height: auto;
        max-height: 60vh;
    }

    /* Notification positioning for mobile */
    #notification-container,
    #notifications-container {
        top: 60px; /* Below header */
        left: 8px;
        right: 8px;
        max-width: calc(100% - 16px);
    }

    .notification {
        max-width: 100%;
        font-size: 14px;
        padding: 12px;
    }
}

/* ==============================================
   LANDSCAPE MOBILE (narrow viewport, landscape)
   ============================================== */

@media (max-width: 767px) and (orientation: landscape) {
    /* Optimize for landscape mode */
    .sidebar {
        max-height: 100vh;
        overflow-y: auto;
    }

    .tabs-content {
        max-height: 100vh;
        overflow-y: auto;
    }

    /* Meditation canvas - full width in landscape */
    #meditation-canvas {
        max-height: 80vh;
    }

    /* Modal adjustments for landscape */
    .modal-content {
        max-height: 85vh;
    }
}

/* ==============================================
   TABLET STYLES (768px-1023px)
   ============================================== */

@media (min-width: 768px) and (max-width: 1023px) {
    /* Tablet-specific optimizations */
    body {
        font-size: 15px;
    }

    /* Sidebar can be narrower on tablet */
    .sidebar {
        width: 280px;
        min-width: 280px;
    }

    /* 2-column grid for cards on tablet */
    #workstation-list,
    #upgrade-list,
    #boon-list {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px;
    }

    #inventory-list {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px;
    }

    /* Cast button - moderate size */
    .btn-cast {
        font-size: 18px;
        padding: 16px 28px;
        min-height: 56px;
    }

    /* Modal sizing for tablet */
    .modal-content {
        width: 80vw;
        max-width: 600px;
    }

    /* Tabs - horizontal on tablet */
    .tab-btn {
        flex: 1 1 auto;
        min-width: 120px;
    }
}

/* ==============================================
   TABLET LANDSCAPE
   ============================================== */

@media (min-width: 768px) and (max-width: 1023px) and (orientation: landscape) {
    /* More horizontal space - utilize it */
    #workstation-list,
    #upgrade-list,
    #boon-list {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .sidebar {
        width: 300px;
    }
}

/* ==============================================
   DESKTOP/LAPTOP STYLES (1024px+)
   ============================================== */

@media (min-width: 1024px) {
    /* Desktop optimizations */
    body {
        font-size: 16px;
    }

    /* Standard sidebar width */
    .sidebar {
        width: 320px;
        min-width: 320px;
    }

    /* 3-column grid on desktop */
    #workstation-list,
    #upgrade-list,
    #boon-list {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 20px;
    }

    #inventory-list {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 16px;
    }

    /* Cast button - standard size */
    .btn-cast {
        font-size: 16px;
        padding: 14px 24px;
        min-height: 52px;
    }

    /* Modal - comfortable size */
    .modal-content {
        width: 600px;
        max-width: 90vw;
    }

    /* Hide mobile-only elements */
    .mobile-only {
        display: none !important;
    }

    /* Hover effects (desktop only) */
    .btn:hover,
    .tab-btn:hover,
    .workstation-card:hover,
    .upgrade-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 16px var(--shadow-glow);
    }

    /* Better tooltips positioning */
    .custom-tooltip {
        max-width: 400px;
    }
}

/* ==============================================
   LARGE DESKTOP (1440px+)
   ============================================== */

@media (min-width: 1440px) {
    /* Even more space - use it wisely */
    .sidebar {
        width: 360px;
    }

    /* 4-column grid on large screens */
    #workstation-list,
    #upgrade-list,
    #boon-list {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 24px;
    }

    #inventory-list {
        grid-template-columns: repeat(5, 1fr) !important;
    }

    /* Larger fonts on large screens */
    body {
        font-size: 17px;
    }

    h1 {
        font-size: 36px;
    }

    h2 {
        font-size: 28px;
    }

    /* More comfortable modal */
    .modal-content {
        width: 800px;
    }
}

/* ==============================================
   ULTRA-WIDE (1920px+)
   ============================================== */

@media (min-width: 1920px) {
    /* 5-column grid for ultra-wide */
    #workstation-list,
    #upgrade-list,
    #boon-list {
        grid-template-columns: repeat(5, 1fr) !important;
    }

    #inventory-list {
        grid-template-columns: repeat(6, 1fr) !important;
    }

    /* Limit max width to prevent extreme stretching */
    .tabs-content {
        max-width: 1800px;
        margin: 0 auto;
    }
}

/* ==============================================
   ACCESSIBILITY - REDUCED MOTION
   ============================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    /* Disable glitch effects for accessibility */
    body::before,
    body::after {
        display: none !important;
    }
}

/* ==============================================
   HIGH CONTRAST MODE
   ============================================== */

@media (prefers-contrast: high) {
    :root {
        --text: var(--text-primary);
        --text-dim: #E0E0E0;
        --bg-dark: var(--bg-void);
        --bg-light: var(--color-void-700);
        --border: var(--text-primary);
        --primary: var(--color-witch-500);
        --secondary: var(--color-code);
    }

    /* Stronger borders for high contrast */
    .btn,
    .tab-btn,
    .workstation-card,
    .upgrade-card {
        border-width: 3px;
    }
}

/* ==============================================
   PRINT STYLES
   ============================================== */

@media print {
    /* Hide non-essential elements when printing */
    .sidebar,
    .tabs-container,
    .btn,
    .notification,
    .modal-overlay,
    .tutorial-overlay {
        display: none !important;
    }

    /* Show all tab content */
    .tab-panel {
        display: block !important;
        page-break-after: always;
    }

    /* Black text on white for print */
    body {
        background: white;
        color: black;
    }
}

/* ==============================================
   DEVICE-SPECIFIC FIXES
   ============================================== */

/* iOS Safari fixes */
@supports (-webkit-touch-callout: none) {
    /* Fix iOS vh units bug */
    body {
        min-height: -webkit-fill-available;
    }

    /* Prevent iOS zoom on input focus */
    input,
    textarea,
    select {
        font-size: 16px !important;
    }

    /* Fix iOS button styling */
    button,
    .btn {
        -webkit-appearance: none;
        appearance: none;
    }
}

/* Android Chrome fixes */
@media screen and (max-width: 767px) {
    /* Let the parent flex layout reserve space for the bottom control deck. */
    .tabs-content {
        min-height: 0;
    }
}

@media (max-width: 380px) {
    .control-deck {
        min-height: 92px;
        padding: 6px var(--spacing-sm) calc(6px + env(safe-area-inset-bottom));
    }

    .cast-container {
        width: 82px;
        height: 82px;
    }

    .btn-cast {
        width: 72px;
        height: 72px;
        min-width: 72px;
        min-height: 72px;
        font-size: 12px;
        letter-spacing: 1px;
    }

    .btn-cast::before {
        top: -7px;
        right: -7px;
        bottom: -7px;
        left: -7px;
    }

    .btn-cast::after {
        top: -13px;
        right: -13px;
        bottom: -13px;
        left: -13px;
    }

    .cast-glyph {
        width: 22px;
        height: 22px;
    }
}

/* ==============================================
   ORIENTATION CHANGE HANDLING
   ============================================== */

@media (orientation: portrait) {
    /* Portrait-specific adjustments */
    .landscape-only {
        display: none !important;
    }
}

@media (orientation: landscape) {
    /* Landscape-specific adjustments */
    .portrait-only {
        display: none !important;
    }

    /* Optimize sidebar in landscape */
    .sidebar {
        max-height: 100vh;
        overflow-y: auto;
    }
}

/* ==============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================== */

/* GPU acceleration for smooth animations */
.btn,
.tab-btn,
.workstation-card,
.upgrade-card {
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Smooth scrolling with momentum */
.scrollable,
.tabs-content,
.modal-content {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
}

/* ==============================================
   DARK MODE ENHANCEMENTS
   ============================================== */

@media (prefers-color-scheme: dark) {
    /* Already dark by default, but ensure consistency */
    :root {
        color-scheme: dark;
    }
}

@media (prefers-color-scheme: light) {
    /* Light mode override (if user wants light theme) */
    body.light-mode {
        --bg-dark: #F5F5F5;
        --bg-light: #FFFFFF;
        --bg-card: #FFFFFF;
        --text: #1A1A1A;
        --text-dim: #666666;
        --border: #CCCCCC;
    }
}

/* END responsive.css */
/* START meditation.css */
/* Meditation UI Styles */

/* Tower Cards */
.tower-card .card-title {
    font-size: 13px;
    margin-bottom: 4px;
}

.tower-card .card-description {
    font-size: 10px;
    margin-bottom: 6px;
    opacity: 0.8;
}

.tower-card .card-section {
    margin-bottom: 6px;
    line-height: 1.4;
}

.tower-place-button,
.tower-upgrade-button,
.upgrade-purchase-button {
    width: 100%;
    padding: 6px;
    font-size: 11px;
    margin-top: 4px;
}

.tower-place-button.selected {
    background: var(--success);
    border-color: var(--success);
    color: var(--bg-dark);
}

/* Recipe Items */
.recipe-item-inline {
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 4px;
    background: var(--meditation-shadow);
    border-left: 2px solid var(--primary);
}

.recipe-item-inline.can-afford {
    background: rgba(60, 227, 197, 0.1);
    border-left-color: var(--success);
}

.recipe-item-inline.cannot-afford {
    background: var(--meditation-shadow);
    border-left-color: var(--primary);
}

/* Placed Towers Header */
.placed-towers-container {
    margin-top: 20px;
}

.placed-towers-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 6px;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    background: var(--meditation-shadow);
    border: 1px solid var(--meditation-grid-line);
}

.placed-towers-header.upgrade-available {
    background: rgba(60, 227, 197, 0.15);
    border: 1px solid var(--success);
    box-shadow: 0 0 10px var(--meditation-glow);
}

.placed-towers-header-text {
    font-weight: 600;
    color: var(--text-dim);
}

.placed-towers-header.upgrade-available .placed-towers-header-text {
    color: var(--success);
}

.placed-towers-expand-icon {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.placed-towers-content {
    display: none;
    margin-top: 8px;
}

.placed-towers-content.expanded {
    display: block;
}

.placed-towers-expand-icon.expanded {
    transform: rotate(180deg);
}

/* Inventory Items */
.inventory-item-card .card-title {
    font-size: 12px;
    margin-bottom: 2px;
}

.inventory-item-card .card-value {
    font-size: 11px;
    opacity: 0.9;
}

.empty-message {
    padding: 10px;
    text-align: center;
    color: var(--text-dim);
    font-style: italic;
    font-size: 12px;
}

/* Upgrade Cards */
.upgrade-card .card-title {
    font-size: 13px;
    margin-bottom: 4px;
}

.upgrade-card .card-description {
    font-size: 10px;
    margin-bottom: 6px;
    opacity: 0.8;
}

/* Bonus Display */
.meditation-bonus-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(60, 227, 197, 0.1);
    border-radius: 8px;
    border: 1px solid var(--success);
}

.meditation-bonus-label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meditation-bonus-value {
    font-size: 16px;
    font-weight: bold;
    color: var(--success);
}

/* END meditation.css */
/* START utilities.css */
/* CSP Compliance Utility Classes */
.hidden {
    display: none !important;
}

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.inset-0 { inset: 0; }
.top-1\/2 { top: 50%; }
.left-1\/2 { left: 50%; }
.right-8 { right: 2rem; }
.bottom-8 { bottom: 2rem; }
.z-10 { z-index: 10; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }
.z-\[100\] { z-index: 100; }
.pointer-events-none { pointer-events: none; }

.block { display: block; }
.flex { display: flex; }
.grid { display: grid; }
.inline-flex { display: inline-flex; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-auto { overflow-x: auto; }
.min-w-0 { min-width: 0; }

.w-full { width: 100%; }
.w-24 { width: 6rem; }
.w-32 { width: 8rem; }
.h-24 { height: 6rem; }
.h-32 { height: 8rem; }
.h-full { height: 100%; }
.max-w-md { max-width: 28rem; }
.max-w-2xl { max-width: 42rem; }
.max-h-\[70vh\] { max-height: 70vh; }
.aspect-square { aspect-ratio: 1; }

.mx-4 { margin-left: 1rem; margin-right: 1rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.ml-auto { margin-left: auto; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }

.p-2 { padding: 0.5rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }

.rounded { border-radius: 4px; }
.rounded-md { border-radius: 6px; }
.rounded-lg { border-radius: 8px; }
.rounded-full { border-radius: 999px; }
.border { border-width: 1px; border-style: solid; }
.border-r { border-right-width: 1px; border-right-style: solid; }
.border-t { border-top-width: 1px; border-top-style: solid; }
.border-b { border-bottom-width: 1px; border-bottom-style: solid; }

.font-sans { font-family: var(--font-main); }
.font-mono,
.font-orbitron { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-4xl { font-size: 2rem; }
.leading-none { line-height: 1; }
.tracking-wider,
.tracking-widest { letter-spacing: 0; }
.uppercase { text-transform: uppercase; }

.text-white { color: var(--text-primary); }
.text-black { color: var(--bg-void); }
.text-code { color: var(--color-code); }
.text-witch-500 { color: var(--ky-magenta); }
.text-soul-400 { color: var(--ky-green); }
.text-gold-400,
.text-gold-400 { color: var(--ky-amber); }
.text-red-400 { color: #ff6f99; }
.text-gray-300 { color: var(--color-system); }
.text-gray-400 { color: var(--color-dim); }
.text-gray-500 { color: #8790b4; }

.bg-void-950 { background-color: var(--bg-void); }
.bg-void-900\/50 { background-color: rgba(10, 10, 18, 0.5); }
.bg-void-900\/60 { background-color: rgba(10, 10, 18, 0.6); }
.bg-void-900\/80 { background-color: rgba(10, 10, 18, 0.8); }
.bg-black\/30 { background-color: rgba(0, 0, 0, 0.3); }
.bg-black\/80 { background-color: rgba(0, 0, 0, 0.8); }
.bg-white\/5 { background-color: rgba(255, 255, 255, 0.05); }
.bg-white\/10 { background-color: rgba(255, 255, 255, 0.1); }
.bg-code\/80 { background-color: rgba(38, 230, 255, 0.8); }
.bg-corruption\/80 { background-color: rgba(255, 26, 61, 0.8); }
.bg-witch-500 { background-color: var(--color-witch-500); }
.bg-gray-700 { background-color: var(--color-void-700); }
.from-void-900 { --gradient-from: var(--color-void-900); }
.to-black { --gradient-to: var(--bg-void); }
.bg-gradient-to-b { background-image: linear-gradient(to bottom, var(--gradient-from, var(--color-void-900)), var(--gradient-to, var(--bg-void))); }

.border-white\/10 { border-color: rgba(255, 255, 255, 0.1); }
.border-witch-500\/20 { border-color: rgba(255, 47, 109, 0.2); }
.border-witch-500\/30,
.border-witch-500\/50 { border-color: rgba(255, 47, 109, 0.5); }

/* Kyanite utility aliases */
.text-ky-cyan { color: var(--ky-cyan); }
.text-ky-magenta { color: var(--ky-magenta); }
.text-ky-amber { color: var(--ky-amber); }
.text-ky-green { color: var(--ky-green); }
.text-ky-red { color: var(--ky-red); }
.bg-ky-cyan { background-color: var(--ky-cyan); }
.bg-ky-magenta { background-color: var(--ky-magenta); }
.bg-ky-amber { background-color: var(--ky-amber); }
.bg-ky-green { background-color: var(--ky-green); }
.bg-ky-red { background-color: var(--ky-red); }
.bg-ky-cyan\/10 { background-color: rgba(38, 230, 255, 0.1); }
.bg-ky-cyan\/20 { background-color: rgba(38, 230, 255, 0.2); }
.border-ky-line { border-color: var(--ky-line); }
.border-ky-magenta\/20 { border-color: rgba(255, 47, 109, 0.2); }
.border-ky-magenta\/30 { border-color: rgba(255, 47, 109, 0.3); }
.border-ky-magenta\/50 { border-color: rgba(255, 47, 109, 0.5); }
.backdrop-blur-md,
.backdrop-blur-sm { backdrop-filter: blur(10px); }
.shadow-2xl { box-shadow: 0 22px 70px rgba(0, 0, 0, 0.45); }
.shadow-\[0_0_30px_rgba\(255\,0\,255\,0\.3\)\] { box-shadow: 0 0 30px rgba(255, 0, 255, 0.3); }

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

@media (min-width: 768px) {
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .lg\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .lg\:col-span-2 { grid-column: span 2 / span 2; }
}

.transition-colors { transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease; }
.transition-all { transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease; }
.duration-200 { transition-duration: 0.2s; }
.duration-300 { transition-duration: 0.3s; }
.scale-95 { transform: scale(0.95); }
.opacity-0 { opacity: 0; }
.opacity-10 { opacity: 0.1; }
.blur-3xl { filter: blur(32px); }
.transform { transform: var(--tw-transform, none); }
.-translate-x-1\/2 { --tw-translate-x: -50%; transform: translate(var(--tw-translate-x), var(--tw-translate-y, 0)); }
.-translate-y-1\/2 { --tw-translate-y: -50%; transform: translate(var(--tw-translate-x, 0), var(--tw-translate-y)); }

.mr-2 {
    margin-right: 8px;
}

.mt-2 {
    margin-top: 10px;
}

.cast-icon {
    margin-right: 0;
    vertical-align: middle;
}

.cast-icon.cast-glyph {
    width: 28px;
    height: 28px;
}

.particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: var(--z-effects);
    display: none;
}

.experiment-intro {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-secondary, var(--color-void-700));
    border-radius: 8px;
    border: 1px solid var(--border);
}

.experiment-text {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

.text-primary {
    color: var(--text-primary);
}

.story-text {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 15px;
}

.text-accent {
    color: var(--accent);
}

.text-success {
    color: var(--success);
}

.help-modal-content {
    max-width: 700px;
}

.specialization-indicator {
    display: none;
    margin-left: 10px;
    font-size: 20px;
}

.force-visible {
    position: relative !important;
    z-index: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
    display: block !important;
}

/* Loading State Styles */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner-large {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-message-text {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

/* Privacy Banner Styles */
.privacy-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 2px solid var(--accent);
    padding: 20px;
    z-index: 10000;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3);
}

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

.privacy-text-container {
    flex: 1;
    min-width: 250px;
}

.privacy-title {
    margin: 0 0 8px 0;
    color: var(--text-primary);
    font-size: 18px;
}

.privacy-description {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.privacy-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.privacy-btn {
    padding: 12px 24px;
}

/* Progress Indicator Styles */
.progress-indicator {
    margin-bottom: 16px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-dark);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-bar {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.unlock-message {
    padding: 12px;
    background: var(--bg-panel);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 12px;
}

.notification-container {
    position: fixed;
    top: 84px;
    right: 16px;
    z-index: 11000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(320px, calc(100vw - 32px));
    max-height: min(28vh, 220px);
    overflow-y: auto;
    overflow-x: hidden;
    pointer-events: none;
    /* Keep toasts in a top-right safe band so workstation cards stay legible */
    max-width: min(320px, 28vw);
}

@media (max-width: 900px) {
    .notification-container {
        max-width: min(360px, calc(100vw - 24px));
        width: min(360px, calc(100vw - 24px));
        max-height: min(24vh, 180px);
    }
}

.notification {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: 6px;
    background: rgba(10, 10, 18, 0.94);
    border: 1px solid var(--border);
    color: var(--text-primary);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.38);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}

.notification.fade-out {
    opacity: 0;
    transform: translateY(-8px);
}

.notification-success { border-color: var(--success); }
.notification-error { border-color: var(--error); }
.notification-warning { border-color: var(--warning); }
.notification-info { border-color: var(--color-code); }

.notification-close {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font: inherit;
    line-height: 1;
    min-width: 32px;
    min-height: 32px;
    border-radius: 4px;
}

.notification-close:hover,
.notification-close:focus-visible {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.install-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(12px, 4vw, 32px);
    background: rgba(0, 0, 0, 0.84);
    backdrop-filter: blur(10px);
    overflow-y: auto;
}

.install-modal-content {
    width: min(100%, 560px);
    max-height: min(88dvh, 740px);
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--ky-line);
    border-radius: 8px;
    padding: clamp(20px, 4vw, 32px);
    color: var(--text-primary);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.56);
}

.install-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.install-modal-close {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    min-width: 40px;
    min-height: 40px;
    border-radius: 4px;
    font: inherit;
}

.install-modal-close:hover,
.install-modal-close:focus-visible {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.install-benefits {
    margin: 16px 0 24px;
    padding-left: 1.25rem;
    color: var(--text-secondary);
}

.install-benefits li {
    margin-bottom: 8px;
}

.install-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-end;
}

/* Onboarding Tutorial Styles */
#tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.tutorial-tooltip {
    position: fixed;
    max-width: 400px;
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 20px;
    z-index: 10000;
    box-shadow: 0 8px 32px rgba(255, 45, 170, 0.3);
    pointer-events: auto;
}

.tutorial-tooltip-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.tutorial-highlight {
    position: fixed;
    border: 3px solid var(--primary);
    border-radius: 8px;
    pointer-events: none;
    z-index: var(--z-guidance);
    animation: tutorial-pulse 2s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(255, 45, 170, 0.5);
}

@keyframes tutorial-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

.tutorial-tooltip-content h3 {
    color: var(--primary);
    margin: 0 0 12px 0;
    font-size: 20px;
}

.tutorial-tooltip-content p {
    color: var(--text);
    margin: 0 0 16px 0;
    line-height: 1.6;
}

.tutorial-tooltip-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.tutorial-progress {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
}

.tutorial-tooltip-content h3.success-title {
    color: var(--success);
}

/* Performance Monitor Styles */
.performance-overlay {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: #05050a;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 10px;
    border-radius: 5px;
    z-index: 10000;
    min-width: 200px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.perf-header {
    font-weight: bold;
    margin-bottom: 5px;
}

.perf-suggestions {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.perf-suggestions-header {
    font-weight: bold;
    margin-bottom: 3px;
}

.perf-suggestion-item {
    margin-bottom: 3px;
}

.perf-suggestion-details {
    font-size: 10px;
    color: #ccc;
}

.debug-console {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 400px;
    height: 200px;
    background: rgba(0, 0, 0, 0.9);
    color: var(--ky-green);
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 10px;
    border: 1px solid #00ff00;
    border-radius: 5px;
    z-index: 10001;
    overflow-y: auto;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.debug-console-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #00ff00;
}

.debug-console-clear-btn {
    background: #00ff00;
    color: black;
    border: none;
    padding: 2px 5px;
    border-radius: 3px;
    cursor: pointer;
}

.debug-console-output {
    height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.debug-console-input-container {
    display: flex;
    margin-top: 5px;
}

.debug-console-input {
    flex: 1;
    background: rgba(0, 255, 0, 0.1);
    color: var(--ky-green);
    border: 1px solid #00ff00;
    padding: 2px 5px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.debug-log-entry {
    margin-bottom: 2px;
    padding: 2px;
    border-radius: 3px;
}

.debug-timestamp {
    opacity: 0.7;
    font-size: 10px;
}

/* Debug Log Colors */
.debug-log-command {
    color: var(--ky-green);
}

.debug-log-error {
    color: #ff0000;
}

.debug-log-warning {
    color: #ffff00;
}

.debug-log-info {
    color: var(--ky-green);
}

/* Suggestion Colors */
.suggestion-high {
    color: #ff6b6b;
}

.suggestion-medium {
    color: #f59e0b;
}

.suggestion-low {
    color: #10b981;
}

/* Meditation UI Styles */
.tower-upgrade-label {
    font-size: 10px; /* Fixed: was 9px, minimum is 10px for readability */
    color: var(--text-dim);
    margin-bottom: 4px;
}

/* Easter Egg Styles */
@keyframes konamiEffect {
    0% {
        transform: rotate(0deg) scale(1);
        filter: hue-rotate(0deg);
    }

    50% {
        transform: rotate(180deg) scale(1.2);
        filter: hue-rotate(180deg);
    }

    100% {
        transform: rotate(360deg) scale(1);
        filter: hue-rotate(360deg);
    }
}

.konami-effect {
    animation: konamiEffect 2s ease-in-out;
}

@keyframes hyperClickPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(255, 0, 255, 0.8);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
    }
}

.hyper-click-active {
    animation: hyperClickPulse 0.5s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.8);
}

.midnight-magic-effect {
    filter: hue-rotate(180deg) saturate(1.5);
}

@keyframes matrixRain {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 0 100%;
    }
}

.matrix-rain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
    background: repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 255, 0, 0.1) 2px);
    background-size: 100% 20px;
    animation: matrixRain 3s linear infinite;
}

.demonic-effect {
    filter: invert(1) hue-rotate(180deg);
}

.harmony-effect {
    filter: sepia(0.2) saturate(1.2);
}

.binary-effect {
    filter: contrast(1.5) grayscale(1);
}

.pi-day-effect {
    filter: hue-rotate(120deg) saturate(1.5);
}

.unlucky-effect {
    filter: sepia(0.3) contrast(1.2);
}

.dev-console-overlay {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 300px;
    height: 200px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #00ff00;
    border-radius: 5px;
    color: var(--ky-green);
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 10px;
    z-index: var(--z-devtools);
    overflow-y: auto;
}

.dev-console-title {
    color: var(--ky-green);
    font-weight: bold;
    margin-bottom: 10px;
}

/* Modal Styles */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: clamp(12px, 4vw, 32px);
    background: color-mix(in srgb, var(--ky-void) 84%, transparent);
    z-index: 1000;
    backdrop-filter: blur(10px);
    overflow-y: auto;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: min(100%, 560px);
    max-height: min(88dvh, 760px);
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid rgba(217, 63, 240, 0.42);
    border-radius: 8px;
    padding: clamp(20px, 4vw, 32px);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.56);
    transform: none;
    opacity: 1;
    -webkit-overflow-scrolling: touch;
}

.story-intro-modal,
.meditation-story-modal,
.full-story-modal,
.specialization-modal,
.modal-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    min-height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(12px, 4vw, 32px);
    z-index: 10001;
    backdrop-filter: blur(10px);
    overflow-y: auto;
}

.full-story-modal {
    overflow-y: auto;
}

.story-intro-content,
.meditation-story-content,
.full-story-content,
.specialization-content,
.destructive-confirmation-modal {
    background: var(--bg-primary, var(--bg-panel));
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: clamp(20px, 5vw, 40px);
    max-width: 600px;
    width: 90%;
    max-height: min(90dvh, 760px);
    overflow-y: auto;
    text-align: left;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    -webkit-overflow-scrolling: touch;
}

.full-story-content {
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 0;
}

.specialization-content {
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.destructive-confirmation-modal {
    background: var(--bg-card);
    border: 2px solid var(--error);
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    text-align: left;
}

.story-title {
    color: var(--accent);
    font-size: clamp(28px, 8vw, 36px);
    margin-bottom: 16px;
    text-align: center;
}

.story-text {
    color: var(--text-primary);
    font-size: clamp(15px, 4vw, 18px);
    line-height: 1.6;
    margin-bottom: 15px;
}

.story-text-secondary {
    color: var(--text-secondary);
    font-size: clamp(14px, 3.6vw, 16px);
    line-height: 1.6;
    margin-bottom: 20px;
}

.story-button {
    padding: 15px 40px;
    min-height: 48px;
    font-size: 16px;
    background: var(--accent);
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--bg-void);
    font-weight: 700;
    cursor: pointer;
    transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    display: block;
    margin: 24px auto 0;
}

.btn-primary.story-button {
    color: var(--bg-void);
}

.story-button:focus-visible {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.full-story-header {
    text-align: center;
    margin-bottom: 30px;
}

.full-story-body {
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.8;
    margin-bottom: 20px;
    text-align: left;
}

.full-story-section-title {
    color: var(--accent);
    font-size: 24px;
    margin-top: 30px;
    margin-bottom: 15px;
}

.full-story-subsection-title {
    color: var(--success);
    font-size: 20px;
    margin-top: 20px;
    margin-bottom: 10px;
}

.full-story-list {
    margin-left: 20px;
    margin-bottom: 15px;
    list-style: none;
}

.full-story-list-item {
    margin-bottom: 10px;
}

.specialization-title {
    text-align: center;
    margin-bottom: 20px;
    color: var(--accent);
    font-size: 28px;
}

.specialization-subtitle {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-secondary);
    font-size: 16px;
}

.element-choices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.element-choice-card {
    background: var(--bg-secondary, var(--color-void-700));
    border: 2px solid var(--accent);
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
    text-align: center;
}

.element-choice-card:hover {
    transform: scale(1.05);
    border-color: var(--success);
    box-shadow: 0 5px 20px rgba(0, 212, 170, 0.3);
}

.element-icon-large {
    font-size: 48px;
    margin-bottom: 10px;
}

.element-choice-name {
    margin: 10px 0;
    color: var(--text-primary);
    font-size: 18px;
}

.element-choice-desc {
    margin: 10px 0;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.4;
}

.element-bonuses-list {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.element-bonus-item {
    font-size: 11px;
    color: var(--success);
    margin: 3px 0;
}

.destructive-title {
    color: var(--error);
    margin-bottom: 16px;
    font-size: 24px;
}

.destructive-text {
    color: var(--text-primary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.destructive-input-container {
    margin-bottom: 20px;
}

.destructive-input-label {
    display: block;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-weight: 600;
}

.destructive-input {
    width: 100%;
    padding: 12px;
    background: var(--bg-dark);
    border: 2px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 16px;
}

.destructive-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.destructive-btn {
    padding: 12px 24px;
}

/* Mobile Navigation Styles */
.mobile-hamburger {
    display: none;
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
}

.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: var(--z-modal);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.mobile-menu-overlay.active {
    display: flex;
}

.mobile-menu-btn {
    width: 80%;
    max-width: 300px;
    padding: 20px;
    font-size: 20px;
    min-height: 60px;
}

.mobile-menu-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
}

@media (max-width: 768px) {
    .mobile-hamburger {
        display: none;
    }

    .sidebar {
        display: none !important;
    }

    .tabs-nav {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* Workstation UI Styles */
.workstation-list-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    visibility: visible;
    opacity: 1;
}

.empty-state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(28px, 6vw, 56px);
    text-align: center;
    min-height: 220px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: rgba(10, 10, 18, 0.44);
}

.empty-state-sigil {
    width: 72px;
    height: 72px;
    margin-bottom: 20px;
    border: 1px solid var(--color-code);
    border-radius: 50%;
    box-shadow: 0 0 24px rgba(0, 240, 255, 0.22);
    position: relative;
    animation: emptyStatePulse 3s ease-in-out infinite;
}

@keyframes emptyStatePulse {
    0%, 100% {
        box-shadow: 0 0 24px rgba(0, 240, 255, 0.22);
        opacity: 0.9;
    }
    50% {
        box-shadow: 0 0 40px rgba(0, 240, 255, 0.35);
        opacity: 1;
    }
}

.empty-state-sigil::before,
.empty-state-sigil::after {
    content: "";
    position: absolute;
    inset: 16px;
    border: 1px solid var(--color-magic);
    transform: rotate(45deg);
}

.empty-state-sigil::after {
    inset: 28px;
    border-color: var(--color-witch-500);
}

.empty-state-message {
    color: var(--text-secondary);
    font-size: 16px;
    max-width: 36rem;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
    letter-spacing: 0.5px;
}

.tier-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 20px 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid;
    /* Color set dynamically */
}

.tier-symbol {
    font-size: 24px;
}

.tier-title {
    margin: 0;
    /* Font family set dynamically */
}

.inscription-bonus {
    color: var(--accent);
    font-size: 0.8em;
    margin-top: 4px;
}

/* Floating Text Styles */
#floating-text-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: var(--z-effects);
    overflow: hidden;
}

.floating-text {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
    font-weight: bold;
    font-size: 1.2rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    opacity: 1;
    transition: transform 1s ease-out, opacity 1s ease-out;
}

.floating-text-success {
    color: var(--success);
}

.floating-text-error {
    color: var(--error);
}

.floating-text-info {
    color: var(--text-primary);
}

.floating-text-crit {
    color: var(--accent);
    font-size: 1.5rem;
}

.floating-text-animate {
    transform: translate(-50%, -150%);
    opacity: 0;
}

/* Experiment UI Styles */
.experiment-result-visible {
    display: block;
    visibility: visible;
    opacity: 1;
}

.experiment-result-illustration {
    width: 256px;
    height: 256px;
    object-fit: contain;
    margin: 0 auto 20px;
    display: block;
}

.experiment-error-message {
    color: var(--danger);
    padding: 15px;
    font-size: 16px;
    text-align: center;
}

.craft-recipe-btn {
    position: relative;
    z-index: 100;
    pointer-events: auto;
    cursor: pointer;
    visibility: visible;
    display: inline-block;
}

/* Event Styles */
.event-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.event-timer {
    font-size: 12px;
    color: var(--text-dim);
}

.debug-console-title {
    font-weight: bold;
}

.debug-console-clear-btn {
    background: #00ff00;
    color: black;
    border: none;
    padding: 2px 5px;
    border-radius: 3px;
    cursor: pointer;
}

.unlock-message-highlight {
    color: var(--primary);
    font-weight: 600;
}

.pwa-icon {
    font-size: 20px;
}

/* Easter Egg Styles */
.easter-egg-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, var(--color-code) 0%, var(--color-witch-500) 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    animation: easterEggNotification 0.5s ease-out;
    max-width: 300px;
}

.easter-egg-title {
    font-size: 16px;
    margin-bottom: 5px;
}

.easter-egg-name {
    font-weight: normal;
}

.easter-egg-desc {
    font-size: 12px;
    margin-top: 5px;
    opacity: 0.8;
}

@keyframes konamiEffect {
    0% {
        filter: hue-rotate(0deg);
    }

    50% {
        filter: hue-rotate(180deg) saturate(2);
    }

    100% {
        filter: hue-rotate(360deg);
    }
}

@keyframes hyperClickPulse {

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

    50% {
        transform: scale(1.1);
    }
}

@keyframes matrixRain {
    0% {
        transform: translateY(-100%);
    }

    100% {
        transform: translateY(100%);
    }
}

@keyframes easterEggNotification {
    0% {
        opacity: 0;
        transform: translateX(100%);
    }

    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes easterEggNotificationFade {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateX(100%) scale(0.8);
    }
}

/* Stats UI Styles */
.stats-tab-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    visibility: visible;
    opacity: 1;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 10px;
}

.stats-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stat-item {
    margin-bottom: 0;
}

.stat-value {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.achievements-grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 10px;
    max-height: 50vh;
    overflow-y: auto;
}

.achievements-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty-achievements {
    padding: 10px;
    color: var(--text-dim);
    grid-column: 1 / -1;
}

.achievement-item {
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
    pointer-events: auto;
    visibility: visible;
    display: block;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    box-sizing: border-box;
    overflow: visible;
    line-height: 1.5;
}

.achievement-item.unlocked {
    background: rgba(60, 227, 197, 0.2);
}

.achievement-item.locked {
    background: rgba(0, 0, 0, 0.3);
}

.achievement-label {
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin-bottom: 6px;
    font-weight: 600;
    line-height: 1.5;
    display: block;
    white-space: normal;
}

.achievement-desc {
    font-size: 11px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    line-height: 1.5;
    color: var(--text-dim);
    display: block;
    white-space: normal;
    margin-bottom: 4px;
}

.achievement-progress {
    margin-top: 8px;
}

.achievement-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.achievement-progress-text {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
}

.text-success {
    color: var(--success);
}

.text-dim {
    color: var(--text-dim);
}

.font-bold {
    font-weight: bold;
}

/* Utility Classes */
.mb-0 {
    margin-bottom: 0 !important;
}

.mb-10 {
    margin-bottom: 10px !important;
}

.mb-15 {
    margin-bottom: 15px !important;
}

.mt-30 {
    margin-top: 30px !important;
}

.text-center {
    text-align: center !important;
}

/* Visibility Classes */
.force-visible-important {
    margin-top: 80px !important;
    padding: 20px !important;
    max-width: 1400px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    position: relative !important;
    z-index: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
    display: block !important;
}

.force-visible-relative {
    position: relative !important;
    width: 100% !important;
    min-height: 400px !important;
    display: block !important;
    visibility: visible !important;
    z-index: 1 !important;
    pointer-events: auto !important;
}

.force-visible-block {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 1 !important;
    pointer-events: auto !important;
}

.content-list-visible {
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
    max-height: 70vh !important;
    overflow-y: auto !important;
    padding: 10px !important;
    position: relative !important;
    z-index: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
    width: 100% !important;
}

/* Feature Indicator Classes */
.lock-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    font-size: 16px;
    z-index: 10;
}

.feature-tooltip {
    position: absolute;
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    font-size: 14px;
    z-index: 10000;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    max-width: 300px;
}

.custom-tooltip {
    position: absolute;
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
    z-index: 10000;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    max-width: 300px;
    display: none;
    opacity: 0;
    transition: opacity 0.2s;
}

/* Celebration Animation Classes */
.celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: var(--z-effects);
    background: transparent;
}

.celebration-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.celebration {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: celebrationFadeIn 0.5s ease-out;
}

.celebration-content {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #fbbf24;
    border-radius: 12px;
    padding: 20px;
    color: white;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
    backdrop-filter: blur(5px);
    max-width: 300px;
    animation: celebrationPulse 2s ease-in-out infinite;
}

.celebration-title {
    font-size: 24px;
    margin-bottom: 10px;
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.8);
}

.celebration-description {
    font-size: 14px;
    margin-bottom: 15px;
    color: #f3f4f6;
}

.celebration-icon {
    font-size: 48px;
    margin-bottom: 15px;
    animation: celebrationBounce 1s ease-in-out infinite;
}

.celebration-progress {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 15px;
}

.celebration-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
    border-radius: 2px;
    animation: celebrationProgressFill 2s ease-in-out;
}

.celebration-reward {
    margin-top: 15px;
    padding: 10px;
    background: rgba(251, 191, 36, 0.2);
    border-radius: 8px;
    font-size: 16px;
    color: #fbbf24;
}

@keyframes celebrationFadeIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

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

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

@keyframes celebrationPulse {

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

    50% {
        transform: scale(1.05);
    }
}

@keyframes celebrationBounce {

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

    50% {
        transform: translateY(-10px);
    }
}

@keyframes celebrationProgressFill {
    0% {
        width: 0%;
    }

    100% {
        width: 100%;
    }
}

.celebration-rare {
    border-color: #a855f7;
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.7);
}

.celebration-rare .celebration-title {
    color: #a855f7;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.8);
}

.celebration-rare .celebration-progress-fill {
    background: linear-gradient(90deg, var(--color-witch-500), var(--color-glitch-500));
}

.celebration-epic {
    border-color: #dc2626;
    box-shadow: 0 0 40px rgba(220, 38, 38, 0.8);
}

.celebration-epic .celebration-title {
    color: #dc2626;
    text-shadow: 0 0 15px rgba(220, 38, 38, 0.8);
}

.celebration-epic .celebration-progress-fill {
    background: linear-gradient(90deg, #dc2626, #b91c1c);
}

.celebration-legendary {
    border-color: #fbbf24;
    box-shadow: 0 0 50px rgba(251, 191, 36, 0.9);
    animation: legendaryGlow 2s ease-in-out infinite;
}

.celebration-legendary .celebration-title {
    color: #fbbf24;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.9);
}

.celebration-legendary .celebration-progress-fill {
    background: linear-gradient(90deg, #fbbf24, #f59e0b, #d97706);
}

@keyframes legendaryGlow {

    0%,
    100% {
        box-shadow: 0 0 50px rgba(251, 191, 36, 0.9);
    }

    50% {
        box-shadow: 0 0 80px rgba(251, 191, 36, 1);
    }
}

.balance-test-panel {
    position: fixed;
    top: 100px;
    right: 20px;
    background: var(--bg-card);
    padding: 20px;
    border: 2px solid var(--border);
    z-index: 10000;
    display: none;
}

.sr-only {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.element-fade-indicator {
    width: 40px;
    height: 3px;
    background: currentColor;
    border-radius: 2px;
    opacity: 0.4;
    margin-top: 4px;
    pointer-events: none;
    display: none;
}

.fatal-error-display {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: red;
    color: white;
    padding: 20px;
    z-index: var(--z-critical);
}

/* END utilities.css */
/* START containment.css */
/**
 * CSS Containment for Paint Optimization
 * Week 2, Day 4 Optimization
 * 
 * Uses CSS containment to isolate rendering work and improve performance
 * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Containment
 */

/* Tab panels - contain layout and paint */
.tab-panel,
.tab-pane {
    contain: layout style paint;
    content-visibility: auto;
}

/* Workstation cards - contain layout and paint */
.workstation-card,
.upgrade-card,
.ingredient-card {
    contain: layout style paint;
}

/* Modal containers - contain layout, style, and paint */
.modal,
.modal-overlay,
.modal-content {
    contain: layout style paint;
}

/* HUD elements - contain layout and paint */
.hud-element,
.hud-panel,
.hud-counter {
    contain: layout style paint;
}

/* Inventory grid - contain layout and paint */
.inventory-grid,
.inventory-item {
    contain: layout style paint;
}

/* Meditation canvas - contain layout, style, and paint */
#meditation-canvas,
.meditation-tower {
    contain: layout style paint;
}

/* Particle system canvas - contain layout, style, and paint */
#sparkle-canvas {
    contain: layout style paint;
}

/* Notification system - contain layout, style, and paint */
.notification,
.notification-container {
    contain: layout style paint;
}

/* Floating text - contain layout, style, and paint */
.floating-text {
    contain: layout style paint;
}

/* Stats panels - contain layout and paint */
.stats-panel,
.stats-row {
    contain: layout style paint;
}

/* Achievement cards - contain layout and paint */
.achievement-card,
.achievement-grid {
    contain: layout style paint;
}

/* Daily ritual items - contain layout and paint */
.daily-ritual-item,
.daily-ritual-list {
    contain: layout style paint;
}

/* Experiment recipes - contain layout and paint */
.recipe-card,
.recipe-grid {
    contain: layout style paint;
}

/* Inscription upgrades - contain layout and paint */
.inscription-card,
.inscription-grid {
    contain: layout style paint;
}

/* Content visibility optimization for off-screen tabs */
.tab-panel:not(.active) {
    content-visibility: auto;
    contain-intrinsic-size: 0 500px; /* Estimated size for layout */
}

/* Optimize scrolling containers */
.scrollable-container {
    contain: layout style paint;
    content-visibility: auto;
}

/* Optimize animation containers */
.animated-container {
    contain: layout style paint;
    will-change: transform, opacity;
}

/* Optimize frequently updated elements */
.dynamic-content {
    contain: layout style paint;
}

/* Strict containment for isolated components */
.isolated-component {
    contain: strict; /* layout + style + paint + size */
}


/* END containment.css */ /* Week 2: CSS containment for paint optimization */
/* START loading.css */
/**
 * Loading States Styles
 * Week 3, Day 4-5 Optimization
 */

/* Loading Indicator */
.loading-indicator {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.loading-indicator.active {
    opacity: 1;
    pointer-events: auto;
}

.loading-indicator.hiding {
    opacity: 0;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 18, 0.8);
    backdrop-filter: blur(4px);
}

/* Loading Content */
.loading-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    min-width: 200px;
}

/* Loading Spinner */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-dim);
    border-top-color: var(--color-code);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Loading Message */
.loading-message {
    color: var(--color-code);
    font-family: var(--font-mono);
    font-size: 14px;
    text-align: center;
    white-space: nowrap;
}

/* Position Variants */
.loading-indicator.loading-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.loading-indicator.loading-top {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.loading-indicator.loading-bottom {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

/* Skeleton Loader */
.skeleton-loader {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: var(--bg-panel);
    border-radius: 8px;
}

.skeleton-line {
    height: 16px;
    background: linear-gradient(
        90deg,
        var(--bg-panel) 0%,
        rgba(255, 255, 255, 0.05) 50%,
        var(--bg-panel) 100%
    );
    background-size: 200% 100%;
    border-radius: 4px;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-line.medium {
    width: 80%;
}

.skeleton-line.long {
    width: 100%;
}

.skeleton-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(
        90deg,
        var(--bg-panel) 0%,
        rgba(255, 255, 255, 0.05) 50%,
        var(--bg-panel) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-rectangle {
    height: 100px;
    border-radius: 8px;
    background: linear-gradient(
        90deg,
        var(--bg-panel) 0%,
        rgba(255, 255, 255, 0.05) 50%,
        var(--bg-panel) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Skeleton Grid */
.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.skeleton-card {
    padding: 16px;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: 8px;
}

.skeleton-card .skeleton-line {
    margin-bottom: 8px;
}

.skeleton-card .skeleton-line:last-child {
    margin-bottom: 0;
}


/* END loading.css */ /* Week 3: Loading states and skeleton screens */
/* START aesthetic-v2.css */
/**
 * Aesthetic v2 — Hex Lattice Terminal
 * Anti-slop visual pass: sector instrument deck, not generic cyan glass SaaS.
 * Loaded after components; overrides surface chrome without breaking tier-0 mono.
 */

/* —— Page frame: scanline depth without animation tax —— */
body:not(.tier-0) {
    background-color: var(--ky-void);
    background-image:
        radial-gradient(ellipse 120% 70% at 50% -10%, color-mix(in srgb, var(--ky-cyan) 7%, transparent), transparent 50%),
        radial-gradient(ellipse 60% 40% at 100% 100%, color-mix(in srgb, var(--ky-amber) 4%, transparent), transparent 45%),
        linear-gradient(180deg, var(--ky-void) 0%, var(--ky-void-depth) 100%);
}

/* —— Surface lattice (main board, not tier-0 void) —— */
body:not(.tier-0) .tabs-content,
body:not(.tier-0) .tab-panels-container {
    background-image:
        linear-gradient(color-mix(in srgb, var(--ky-line) 28%, transparent) 1px, transparent 1px),
        linear-gradient(90deg, color-mix(in srgb, var(--ky-line) 28%, transparent) 1px, transparent 1px),
        radial-gradient(ellipse 80% 50% at 50% 0%, color-mix(in srgb, var(--ky-cyan) 5%, transparent), transparent 55%);
    background-size: 28px 28px, 28px 28px, 100% 100%;
    background-color: color-mix(in srgb, var(--ky-void-depth) 92%, var(--ky-midnight));
}

/* HUD — sector address bar, not floating glass blob */
.hud {
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--ky-basalt-elevated) 88%, transparent), var(--ky-basalt));
    border-bottom: 1px solid color-mix(in srgb, var(--ky-cyan) 22%, var(--ky-line));
    box-shadow:
        0 1px 0 color-mix(in srgb, var(--ky-void) 80%, transparent),
        0 12px 32px color-mix(in srgb, var(--ky-void) 40%, transparent);
    backdrop-filter: none;
}

.hud .compile-goal-rail {
    background: color-mix(in srgb, var(--ky-void) 55%, transparent);
    border-color: color-mix(in srgb, var(--ky-green) 45%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ky-green) 12%, transparent);
    border-radius: 1px;
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
}

/* Resource counters in HUD — tabular instrument readouts */
.hud .resource-count,
.hud .ab-display,
.hud [data-resource],
#ab-display,
.resource-value {
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}

/* Sidebar — instrument cluster */
.sidebar {
    background:
        linear-gradient(90deg, var(--ky-void) 0%, var(--ky-void-depth) 40%, var(--ky-void-depth) 100%);
    border-right: 1px solid color-mix(in srgb, var(--ky-amber) 18%, var(--ky-line));
    box-shadow: inset -1px 0 0 color-mix(in srgb, var(--ky-void) 50%, transparent);
}

.sidebar-header h3 {
    font-family: var(--font-mono);
    letter-spacing: 0.14em;
    color: var(--ky-steel);
    text-transform: uppercase;
    font-size: 0.72rem;
}

/* Resource rows — diegetic gauges */
#resource-monitor .resource-item,
.sidebar .resource-row,
.resource-list-item {
    border-left: 2px solid color-mix(in srgb, var(--ky-steel) 50%, transparent);
    padding-left: 0.5rem;
    margin-bottom: 0.35rem;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

#resource-monitor .resource-item:hover,
.sidebar .resource-row:hover {
    border-left-color: color-mix(in srgb, var(--ky-amber) 55%, var(--ky-cyan));
    background: color-mix(in srgb, var(--ky-basalt) 40%, transparent);
}

/* Element-tinted gauge edges when data-element present */
.resource-item[data-element="fire"],
.resource-row[data-element="fire"] {
    border-left-color: color-mix(in srgb, #ff8a5c 65%, transparent);
}
.resource-item[data-element="water"],
.resource-row[data-element="water"] {
    border-left-color: color-mix(in srgb, var(--ky-cyan) 55%, transparent);
}
.resource-item[data-element="air"],
.resource-row[data-element="air"] {
    border-left-color: color-mix(in srgb, var(--ky-mist) 60%, transparent);
}
.resource-item[data-element="crystal"],
.resource-row[data-element="crystal"] {
    border-left-color: color-mix(in srgb, #c4a1ff 55%, transparent);
}
.resource-item[data-element="aether"],
.resource-row[data-element="aether"] {
    border-left-color: color-mix(in srgb, var(--ky-amber) 55%, transparent);
}

/* Cards — sector modules, not SaaS glass cards */
.card,
.workstation-card {
    background:
        linear-gradient(145deg,
            color-mix(in srgb, var(--ky-basalt-elevated) 90%, transparent) 0%,
            color-mix(in srgb, var(--ky-basalt) 95%, transparent) 100%);
    border: 1px solid color-mix(in srgb, var(--ky-line) 90%, var(--ky-steel));
    border-radius: 2px 10px 2px 10px;
    box-shadow:
        inset 0 1px 0 color-mix(in srgb, var(--ky-crystal) 6%, transparent),
        0 8px 24px color-mix(in srgb, var(--ky-void) 55%, transparent);
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

.card:hover,
.workstation-card:hover {
    border-color: color-mix(in srgb, var(--ky-amber) 40%, var(--ky-cyan));
    box-shadow:
        inset 0 1px 0 color-mix(in srgb, var(--ky-crystal) 10%, transparent),
        0 10px 28px color-mix(in srgb, var(--ky-void) 60%, transparent),
        0 0 0 1px color-mix(in srgb, var(--ky-amber) 20%, transparent);
    transform: translateY(-1px);
}

/* Owned / active module: hard edge, amber ridge */
.workstation-card.owned,
.workstation-card[data-owned="true"],
.card.owned {
    border-color: color-mix(in srgb, var(--ky-amber) 45%, var(--ky-line));
    box-shadow:
        inset 3px 0 0 color-mix(in srgb, var(--ky-amber) 70%, transparent),
        inset 0 1px 0 color-mix(in srgb, var(--ky-crystal) 8%, transparent),
        0 8px 24px color-mix(in srgb, var(--ky-void) 55%, transparent);
}

.card-title,
.workstation-card h3,
.workstation-card .card-title {
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--ky-crystal);
    text-shadow: none;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.card-desc,
.card-description,
.workstation-card .description {
    color: color-mix(in srgb, var(--ky-mist) 85%, var(--ky-steel));
    font-size: 0.78rem;
    line-height: 1.45;
}

/* Role badges — strong sector tags */
.pipeline-role-badge {
    border-radius: 1px;
    letter-spacing: 0.12em;
    font-weight: 700;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    text-transform: uppercase;
    padding: 0.15rem 0.4rem;
    background: color-mix(in srgb, var(--ky-void) 70%, transparent);
}

.pipeline-role-badge[data-role="capture"] {
    color: #ff8a5c;
    border: 1px solid color-mix(in srgb, #ff8a5c 55%, transparent);
}
.pipeline-role-badge[data-role="store"] {
    color: var(--ky-amber);
    border: 1px solid color-mix(in srgb, var(--ky-amber) 50%, transparent);
}
.pipeline-role-badge[data-role="bind"] {
    color: #c4a1ff;
    border: 1px solid color-mix(in srgb, #c4a1ff 50%, transparent);
}
.pipeline-role-badge[data-role="compile"] {
    color: var(--ky-green);
    border: 1px solid color-mix(in srgb, var(--ky-green) 55%, transparent);
}
.pipeline-role-badge[data-role="shield"] {
    color: var(--ky-mist);
    border: 1px solid color-mix(in srgb, var(--ky-steel) 60%, transparent);
}

/* Pipeline HUD — instrument ribbon */
.pipeline-role-hud {
    background: color-mix(in srgb, var(--ky-void) 72%, transparent);
    border: 1px solid color-mix(in srgb, var(--ky-cyan) 28%, var(--ky-line));
    border-radius: 2px;
    box-shadow: inset 0 0 20px color-mix(in srgb, var(--ky-void) 50%, transparent);
    padding: 0.35rem 0.5rem;
    gap: 0.35rem;
}

.pipeline-role-chip {
    border-radius: 1px;
    background: color-mix(in srgb, var(--ky-basalt) 80%, transparent);
    border: 1px solid color-mix(in srgb, var(--ky-steel) 45%, transparent);
    color: var(--ky-crystal);
    font-family: var(--font-mono);
    letter-spacing: 0.06em;
    font-size: 0.65rem;
    text-transform: uppercase;
    padding: 0.2rem 0.45rem;
}

.pipeline-role-chip[data-role="capture"] { border-color: color-mix(in srgb, #ff8a5c 50%, transparent); }
.pipeline-role-chip[data-role="store"] { border-color: color-mix(in srgb, var(--ky-amber) 50%, transparent); }
.pipeline-role-chip[data-role="bind"] { border-color: color-mix(in srgb, #c4a1ff 50%, transparent); }
.pipeline-role-chip[data-role="compile"] { border-color: color-mix(in srgb, var(--ky-green) 50%, transparent); }
.pipeline-role-chip[data-role="shield"] { border-color: color-mix(in srgb, var(--ky-steel) 55%, transparent); }

.pipeline-role-count {
    color: var(--ky-amber);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

/* EXEC — hex core, not generic neon orb */
.btn-cast {
    border-radius: 12% / 18%;
    clip-path: polygon(
        50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%
    );
    border: 2px solid color-mix(in srgb, var(--ky-amber) 55%, var(--ky-cyan));
    background:
        radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--ky-cyan) 18%, transparent), transparent 55%),
        color-mix(in srgb, var(--ky-basalt) 88%, var(--ky-void));
    box-shadow:
        0 0 0 1px color-mix(in srgb, var(--ky-void) 80%, transparent),
        0 0 28px color-mix(in srgb, var(--ky-amber) 18%, transparent),
        inset 0 0 18px color-mix(in srgb, var(--ky-void) 40%, transparent);
    letter-spacing: 0.18em;
    color: var(--ky-crystal);
    font-family: var(--font-mono);
    font-weight: 700;
    text-transform: uppercase;
}

.btn-cast::before {
    border-style: solid;
    border-color: color-mix(in srgb, var(--ky-steel) 55%, transparent);
    border-radius: 12% / 18%;
    clip-path: polygon(
        50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%
    );
    animation: rotate 18s linear infinite;
    opacity: 0.55;
}

.btn-cast::after {
    border-radius: 12% / 18%;
    clip-path: polygon(
        50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%
    );
    border-color: color-mix(in srgb, var(--ky-amber) 30%, transparent);
    opacity: 0.45;
}

.btn-cast:hover {
    background:
        radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--ky-amber) 22%, transparent), transparent 50%),
        color-mix(in srgb, var(--ky-basalt) 75%, var(--ky-midnight));
    box-shadow:
        0 0 32px color-mix(in srgb, var(--ky-amber) 28%, transparent),
        inset 0 0 20px color-mix(in srgb, var(--ky-cyan) 12%, transparent);
    color: var(--ky-amber);
    border-color: var(--ky-amber);
}

.btn-cast:focus-visible {
    outline: 2px solid var(--ky-amber);
    outline-offset: 4px;
}

.btn-cast:active {
    transform: scale(0.97);
    box-shadow:
        0 0 16px color-mix(in srgb, var(--ky-amber) 35%, transparent),
        inset 0 0 24px color-mix(in srgb, var(--ky-void) 50%, transparent);
}

/* Control deck */
.control-deck {
    background:
        linear-gradient(0deg, var(--ky-void) 0%, color-mix(in srgb, var(--ky-basalt) 90%, transparent) 100%);
    border-top: 1px solid color-mix(in srgb, var(--ky-amber) 22%, var(--ky-line));
    box-shadow: 0 -8px 24px color-mix(in srgb, var(--ky-void) 45%, transparent);
}

/* Tabs — sector address strip */
.tab-btn,
.tab-button {
    font-family: var(--font-mono);
    letter-spacing: 0.06em;
    border-radius: 1px 1px 0 0;
    text-transform: uppercase;
    font-size: 0.72rem;
    color: var(--ky-steel);
    border-bottom: 2px solid transparent;
    transition: color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.tab-btn:hover,
.tab-button:hover {
    color: var(--ky-mist);
}

.tab-btn.active,
.tab-button.active,
.tab-btn[aria-selected="true"],
.tab-button[aria-selected="true"] {
    border-bottom-color: var(--ky-amber);
    color: var(--ky-crystal);
    box-shadow: inset 0 -2px 0 var(--ky-amber);
    background: color-mix(in srgb, var(--ky-basalt) 50%, transparent);
}

/* Buttons CRAFT / MAX / primary */
.workstation-card button,
.btn-primary,
.craft-btn,
.btn-craft {
    border-radius: 1px;
    font-family: var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.7rem;
    border: 1px solid color-mix(in srgb, var(--ky-cyan) 40%, var(--ky-line));
    background: color-mix(in srgb, var(--ky-basalt-elevated) 90%, var(--ky-void));
    color: var(--ky-crystal);
    transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.workstation-card button:hover,
.btn-primary:hover,
.craft-btn:hover,
.btn-craft:hover {
    border-color: var(--ky-amber);
    color: var(--ky-amber);
    background: color-mix(in srgb, var(--ky-basalt) 70%, var(--ky-midnight));
}

.workstation-card button:disabled,
.btn-primary:disabled,
.craft-btn:disabled {
    opacity: 0.4;
    border-color: var(--ky-steel);
    color: var(--ky-steel);
    cursor: not-allowed;
}

/*
 * Story / modal CTAs use btn-primary + story-button.
 * Must keep high-contrast amber fill + near-void ink (WCAG AA) —
 * do not inherit the dark instrument-button chrome above.
 */
.story-button,
.btn-primary.story-button,
#close-story-intro {
    background: var(--ky-amber) !important;
    border: 1px solid color-mix(in srgb, var(--ky-amber) 80%, var(--ky-crystal)) !important;
    color: var(--ky-void) !important;
    font-size: 0.9rem;
    letter-spacing: 0.06em;
    padding: 0.75rem 1.5rem;
    min-height: 48px;
}

.story-button:hover,
.btn-primary.story-button:hover,
#close-story-intro:hover {
    background: color-mix(in srgb, var(--ky-amber) 85%, var(--ky-crystal)) !important;
    color: var(--ky-void) !important;
    border-color: var(--ky-crystal) !important;
}

.story-button:focus-visible,
#close-story-intro:focus-visible {
    outline: 2px solid var(--ky-cyan);
    outline-offset: 3px;
}

/* Secondary / ghost */
.btn-secondary,
.btn-ghost {
    border-radius: 1px;
    font-family: var(--font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 0.68rem;
    border: 1px solid color-mix(in srgb, var(--ky-steel) 50%, transparent);
    background: transparent;
    color: var(--ky-mist);
}

/* System log — terminal feed */
#system-log,
.system-log {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    line-height: 1.4;
    color: color-mix(in srgb, var(--ky-green) 75%, var(--ky-mist));
    border-top: 1px dashed color-mix(in srgb, var(--ky-steel) 40%, transparent);
    padding-top: 0.5rem;
}

#system-log .log-entry,
.system-log .log-entry {
    border-left: 2px solid color-mix(in srgb, var(--ky-green) 35%, transparent);
    padding-left: 0.4rem;
    margin-bottom: 0.2rem;
}

/* Affinity foreshadow */
.affinity-foreshadow {
    font-family: var(--font-mono);
    color: color-mix(in srgb, var(--ky-mist) 90%, transparent);
    border-left: 2px solid color-mix(in srgb, var(--ky-amber) 55%, transparent);
    padding-left: 0.5rem;
    font-size: 0.72rem;
    letter-spacing: 0.03em;
}

/* Inventory grid cells */
#inventory-list > *,
.inventory-item,
.inventory-slot {
    border-radius: 2px;
    border: 1px solid color-mix(in srgb, var(--ky-line) 80%, transparent);
    background: color-mix(in srgb, var(--ky-basalt) 88%, transparent);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

#inventory-list > *:hover,
.inventory-item:hover {
    border-color: color-mix(in srgb, var(--ky-cyan) 40%, var(--ky-line));
}

/* Toasts — hard instrument plaques (pairs with maxVisible=2) */
.toast,
.notification,
.notification-toast,
.toast-item {
    border-radius: 1px 6px 1px 6px;
    border: 1px solid color-mix(in srgb, var(--ky-cyan) 35%, var(--ky-line));
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--ky-basalt-elevated) 92%, transparent),
            color-mix(in srgb, var(--ky-void) 88%, transparent));
    box-shadow:
        0 8px 24px color-mix(in srgb, var(--ky-void) 60%, transparent),
        inset 0 1px 0 color-mix(in srgb, var(--ky-crystal) 8%, transparent);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
}

.toast.success,
.notification.success {
    border-color: color-mix(in srgb, var(--ky-green) 50%, transparent);
}
.toast.warning,
.notification.warning {
    border-color: color-mix(in srgb, var(--ky-amber) 50%, transparent);
}
.toast.error,
.notification.error {
    border-color: color-mix(in srgb, var(--ky-red) 50%, transparent);
}

/* Modal / overlay panels */
.modal,
.modal-content,
.overlay-panel,
.dialog {
    border-radius: 2px 12px 2px 12px;
    border: 1px solid color-mix(in srgb, var(--ky-line) 90%, var(--ky-steel));
    background:
        linear-gradient(160deg,
            color-mix(in srgb, var(--ky-basalt-elevated) 95%, transparent),
            var(--ky-void-depth));
    box-shadow:
        0 24px 64px color-mix(in srgb, var(--ky-void) 70%, transparent),
        inset 0 1px 0 color-mix(in srgb, var(--ky-crystal) 6%, transparent);
}

.modal-header,
.dialog-header {
    font-family: var(--font-mono);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-bottom: 1px solid color-mix(in srgb, var(--ky-line) 70%, transparent);
    color: var(--ky-crystal);
}

/* Progress / bars — instrument meters */
.progress-bar,
.progress,
.meter,
.storage-bar,
.fade-meter {
    border-radius: 1px;
    background: color-mix(in srgb, var(--ky-void) 80%, transparent);
    border: 1px solid color-mix(in srgb, var(--ky-steel) 40%, transparent);
    overflow: hidden;
}

.progress-bar > *,
.progress-fill,
.meter-fill,
.storage-bar-fill {
    border-radius: 0;
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--ky-cyan) 70%, transparent),
        color-mix(in srgb, var(--ky-amber) 55%, transparent));
}

/* Prestige / chapter callouts */
.prestige-panel,
.chapter-banner,
.storylet-banner {
    border-left: 3px solid color-mix(in srgb, var(--ky-amber) 70%, transparent);
    background: color-mix(in srgb, var(--ky-basalt) 70%, transparent);
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
}

/* SHARE / heal ceremony surfaces */
.share-restore,
.heal-ceremony,
[data-ceremony="SYSTEM_RESTORE"] {
    border: 1px solid color-mix(in srgb, var(--ky-green) 45%, transparent);
    box-shadow: 0 0 24px color-mix(in srgb, var(--ky-green) 12%, transparent);
}

/* Focus rings — keyboard instrument use */
:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--ky-amber) 80%, var(--ky-cyan));
    outline-offset: 2px;
}

/* Scrollbars — thin terminal */
body:not(.tier-0) ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
body:not(.tier-0) ::-webkit-scrollbar-track {
    background: var(--ky-void);
}
body:not(.tier-0) ::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--ky-steel) 55%, var(--ky-basalt));
    border-radius: 1px;
}
body:not(.tier-0) ::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--ky-amber) 40%, var(--ky-steel));
}

/* Tier-0: keep mono — suppress chromatic lattice */
body.tier-0 {
    background-image: none;
    background-color: var(--ky-void);
}

body.tier-0 .tabs-content,
body.tier-0 .tab-panels-container {
    background-image: none;
    background-color: var(--ky-void);
}

body.tier-0 .btn-cast {
    clip-path: none;
    border-radius: 50%;
    border-color: var(--ky-steel);
    color: var(--ky-crystal);
    box-shadow: none;
    background: var(--ky-void-depth);
}

body.tier-0 .btn-cast::before,
body.tier-0 .btn-cast::after {
    clip-path: none;
    border-radius: 50%;
    animation: none;
}

body.tier-0 .card,
body.tier-0 .workstation-card {
    background: var(--ky-void-depth);
    border-color: var(--ky-steel);
    box-shadow: none;
    border-radius: 0;
}

body.tier-0 .pipeline-role-chip,
body.tier-0 .pipeline-role-badge {
    color: var(--ky-crystal) !important;
    border-color: var(--ky-steel) !important;
}

body.tier-0 .toast,
body.tier-0 .notification {
    border-radius: 0;
    border-color: var(--ky-steel);
    background: var(--ky-void-depth);
    box-shadow: none;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .btn-cast::before {
        animation: none;
    }
    .card:hover,
    .workstation-card:hover {
        transform: none;
    }
    .btn-cast:active {
        transform: none;
    }
}

/* Narrow: denser instrument stack */
@media (max-width: 640px) {
    body:not(.tier-0) .tabs-content,
    body:not(.tier-0) .tab-panels-container {
        background-size: 20px 20px, 20px 20px, 100% 100%;
    }

    .card,
    .workstation-card {
        border-radius: 2px 6px 2px 6px;
    }

    .btn-cast {
        letter-spacing: 0.1em;
    }
}


/* Prestige ascend band interrupt (overall S+ product) */
.pipeline-prestige-interrupt {
    letter-spacing: 0.04em;
    color: var(--ky-crystal);
    border-left: 2px solid color-mix(in srgb, var(--ky-amber) 70%, transparent);
}
body.tier-0 .pipeline-prestige-interrupt {
    color: var(--ky-crystal);
    border-left-color: var(--ky-steel);
}

.pipeline-role-meta[data-storage-pressure="overcap"] {
    color: var(--ky-amber);
}

/* END aesthetic-v2.css */ /* Hex lattice terminal — anti-slop surface pass */

/* Glitch effects - lazy loaded via JavaScript when design tier > 0 */
/* /* START glitch-effects.css */
/* ============================================
   Glitch Effects System - Progressive UI Stabilization
   All effects are CSS-only for performance
   Lazy-loaded to reduce initial CSS parse time
   ============================================ */

/* 1. SCREEN TEARING / HORIZONTAL GLITCH LINES */
/* Tier 0-3: Progressive reduction, Tier 4: None */
body.tier-0::before,
body.tier-1::before,
body.tier-2::before,
body.tier-3::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: var(--z-atmosphere);
    mix-blend-mode: screen;
    will-change: transform;
    contain: strict;
    background-image: none;
}

/* Tier 0: Heavy, frequent, monochrome */
body.tier-0::before {
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 255, 255, 0.3) 2px,
        rgba(255, 255, 255, 0.3) 4px
    );
    animation: screenTearHeavy 0.08s infinite;
    z-index: var(--z-atmosphere);
    display: block;
    visibility: visible;
    opacity: 1;
}

/* Tier 1: Heavy, frequent, colored */
body.tier-1::before {
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 45, 170, 0.4) 2px,
        rgba(255, 45, 170, 0.4) 4px
    );
    animation: screenTearHeavy 0.1s infinite;
    z-index: var(--z-atmosphere);
    display: block;
    visibility: visible;
    opacity: 1;
}

/* Tier 2: Moderate, less frequent */
body.tier-2::before {
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 4px,
        rgba(255, 45, 170, 0.1) 4px,
        rgba(255, 45, 170, 0.1) 8px
    );
    animation: screenTearModerate 0.3s infinite;
    z-index: var(--z-atmosphere);
}

/* Tier 3: Light, rare */
body.tier-3::before {
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 6px,
        rgba(255, 45, 170, 0.05) 6px,
        rgba(255, 45, 170, 0.05) 12px
    );
    animation: screenTearLight 1s infinite;
    z-index: var(--z-atmosphere);
}

/* Tier 4: None */
body.tier-4::before {
    display: none;
}

@keyframes screenTearHeavy {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    50% { transform: translateX(2px); }
    75% { transform: translateX(-1px); }
}

@keyframes screenTearModerate {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(1px); }
}

@keyframes screenTearLight {
    0%, 100% { transform: translateX(0); opacity: 0; }
    50% { transform: translateX(0.5px); opacity: 1; }
}

/* 2. CHROMATIC ABERRATION (RGB Channel Separation) - Optimized */
/* Use CSS containment for better performance */
body.tier-1 *:not(script):not(style):not(::before):not(::after) {
    filter: drop-shadow(2px 0 0 rgba(255, 0, 0, 0.5))
            drop-shadow(-2px 0 0 rgba(0, 255, 255, 0.5));
    animation: chromaticAberrationHeavy 0.3s infinite;
}

body.tier-2 *:not(script):not(style):not(::before):not(::after) {
    filter: drop-shadow(1px 0 0 rgba(255, 0, 0, 0.3))
            drop-shadow(-1px 0 0 rgba(0, 255, 255, 0.3));
    animation: chromaticAberrationModerate 0.5s infinite;
}

body.tier-3 *:not(script):not(style):not(::before):not(::after) {
    filter: drop-shadow(0.5px 0 0 rgba(255, 0, 0, 0.2))
            drop-shadow(-0.5px 0 0 rgba(0, 255, 255, 0.2));
    animation: chromaticAberrationLight 1s infinite;
}

body.tier-4 *:not(script):not(style):not(::before):not(::after) {
    filter: none;
}

@keyframes chromaticAberrationHeavy {
    0%, 100% { filter: drop-shadow(2px 0 0 rgba(255, 0, 0, 0.5)) drop-shadow(-2px 0 0 rgba(0, 255, 255, 0.5)); }
    50% { filter: drop-shadow(3px 0 0 rgba(255, 0, 0, 0.6)) drop-shadow(-3px 0 0 rgba(0, 255, 255, 0.6)); }
}

@keyframes chromaticAberrationModerate {
    0%, 100% { filter: drop-shadow(1px 0 0 rgba(255, 0, 0, 0.3)) drop-shadow(-1px 0 0 rgba(0, 255, 255, 0.3)); }
    50% { filter: drop-shadow(1.5px 0 0 rgba(255, 0, 0, 0.4)) drop-shadow(-1.5px 0 0 rgba(0, 255, 255, 0.4)); }
}

@keyframes chromaticAberrationLight {
    0%, 100% { filter: drop-shadow(0.5px 0 0 rgba(255, 0, 0, 0.2)) drop-shadow(-0.5px 0 0 rgba(0, 255, 255, 0.2)); }
    50% { filter: drop-shadow(0.75px 0 0 rgba(255, 0, 0, 0.25)) drop-shadow(-0.75px 0 0 rgba(0, 255, 255, 0.25)); }
}

/* 3. SCANLINES - Optimized with contain */
body.tier-0::after,
body.tier-1::after,
body.tier-2::after,
body.tier-3::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
    contain: strict;
}

/* Tier 0: Heavy scanlines */
body.tier-0::after {
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    animation: scanline 8s linear infinite;
}

/* Tier 1: Moderate scanlines */
body.tier-1::after {
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
    animation: scanline 10s linear infinite;
}

/* Tier 2: Light scanlines */
body.tier-2::after {
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.05),
        rgba(0, 0, 0, 0.05) 1px,
        transparent 1px,
        transparent 3px
    );
    animation: scanline 12s linear infinite;
}

/* Tier 3: Very light scanlines */
body.tier-3::after {
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.02),
        rgba(0, 0, 0, 0.02) 1px,
        transparent 1px,
        transparent 4px
    );
    animation: scanline 15s linear infinite;
}

/* Tier 4: None */
body.tier-4::after {
    display: none;
}

@keyframes scanline {
    0% { transform: translateY(0); }
    100% { transform: translateY(100%); }
}

/* Performance optimization: Pause animations when tab is hidden */
@media (prefers-reduced-motion: reduce) {
    body.tier-0::before,
    body.tier-1::before,
    body.tier-2::before,
    body.tier-3::before,
    body.tier-0::after,
    body.tier-1::after,
    body.tier-2::after,
    body.tier-3::after {
        animation: none;
    }
}

/* END glitch-effects.css */ */

/* ===========================================
   Additional styles that couldn't be modularized
   (Specific to game features)
   =========================================== */

/* Night sky background */
.night-sky-stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(2px 2px at 20% 30%, white, transparent),
        radial-gradient(2px 2px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 50% 50%, white, transparent),
        radial-gradient(1px 1px at 80% 10%, white, transparent),
        radial-gradient(2px 2px at 90% 60%, white, transparent),
        radial-gradient(1px 1px at 33% 80%, white, transparent),
        radial-gradient(1px 1px at 10% 90%, white, transparent);
    background-size: 200% 200%, 200% 200%, 200% 200%, 200% 200%, 200% 200%, 200% 200%, 200% 200%;
    background-position: 0 0, 40% 40%, 20% 20%, 80% 80%, 10% 10%, 70% 70%, 30% 30%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.3;
}

/* Sparkle canvas */
.sparkle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.6;
}

/* Particle canvas (for celebration effects) */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: var(--z-effects);
}

/* Virtual scroll viewport */
.virtual-scroll-inner {
    position: relative;
}

.virtual-scroll-viewport {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
}

/* Meditation grid */
.meditation-grid-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 1;
}

#meditation-canvas {
    width: 100%;
    height: 100%;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-dark);
}

.meditation-main {
    display: flex;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.meditation-sidebar {
    flex: 1;
    min-width: 250px;
}

/* Experiment result box */
.result-box {
    padding: var(--spacing-lg);
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 8px;
    margin: var(--spacing-md) 0;
}

.result-box.success {
    border-color: var(--success);
}

.result-box.error {
    border-color: var(--error);
}

/* Recipe list */
#recipe-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

/* Achievement popup */
.achievement-popup {
    position: fixed;
    top: 100px;
    right: var(--spacing-lg);
    background: var(--bg-card);
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: var(--spacing-lg);
    box-shadow: 0 10px 40px rgba(255, 215, 110, 0.3); /* Gold glow - keep for achievement popups */
    z-index: 2000;
    animation: slideInRight 0.5s ease-out;
    max-width: 350px;
}

.achievement-popup-title {
    font-family: 'Orbitron', monospace;
    font-size: 18px;
    color: var(--accent);
    margin-bottom: var(--spacing-sm);
}

.achievement-popup-description {
    font-size: 14px;
    color: var(--text-dim);
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: var(--spacing-md);
    text-align: center;
}

.stat-value {
    font-family: 'Orbitron', monospace;
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    display: block;
    margin-bottom: var(--spacing-sm);
}

.stat-label {
    font-size: 14px;
    color: var(--text-dim);
}

/* Performance optimization classes */
.contain-layout {
    contain: layout;
}

.contain-paint {
    contain: paint;
}

.contain-strict {
    contain: strict;
}

/* Visibility utilities */
.hidden {
    display: none;
}

.invisible {
    visibility: hidden;
}

.visible {
    visibility: visible;
}

/* Text utilities */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.text-primary {
    color: var(--primary);
}

.text-success {
    color: var(--success);
}

.text-error {
    color: var(--error);
}

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

/* Critical CSS - Essential styles for above-the-fold content (Moved from index.html) */
/* Note: All color variables are now defined in styles/theme.css - single source of truth */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

body {
    font-family: 'Rajdhani', sans-serif;
    font-size: 16px;
    color: var(--text);
    background: var(--bg-dark);
    min-height: 100vh
}

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite
}

@keyframes spin {
    to {
        transform: rotate(360deg)
    }
}

.hud {
    position: sticky;
    top: 0;
    background: var(--bg-panel-trans);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 12px;
    z-index: 50
}

.main-game {
    max-width: none;
    margin: 0;
    padding: 0
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0
}
