/* TCG Pack Simulator Styles */

/* CSS Custom Properties for Theming */
:root {
    /* Default Theme (Dark Mode) */
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --bg-quaternary: #4b5563;
    --text-primary: #ffffff;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --accent-primary: #9333ea;
    --accent-secondary: #ec4899;
    --accent-tertiary: #3b82f6;
    --border-primary: #4b5563;
    --border-secondary: #6b7280;
    --success: #10b981;
    --warning: #f5ca0b;
    --error: #ef4444;
    --info: #60a5fa;
    --highlight: rgba(147, 51, 234, 0.3);
    --shadow: rgba(0, 0, 0, 0.3);
}

/* Matrix/UNIX Theme */
[data-theme="matrix"] {
    --bg-primary: #000000;
    --bg-secondary: #001100;
    --bg-tertiary: #002200;
    --bg-quaternary: #003300;
    --text-primary: #00ff00;
    --text-secondary: #00cc00;
    --text-muted: #008800;
    --accent-primary: #00ff00;
    --accent-secondary: #00aa00;
    --accent-tertiary: #088d08;
    --border-primary: #003300;
    --border-secondary: #006600;
    --success: #00ff00;
    --warning: #ffff00;
    --error: #ff0000;
    --info: #00ffff;
    --highlight: rgba(0, 255, 0, 0.3);
    --shadow: rgba(0, 255, 0, 0.2);
}

/* Outrun/Synthwave Theme */
[data-theme="outrun"] {
    --bg-primary: #0f0515;
    --bg-secondary: #1a0a2a;
    --bg-tertiary: #2a1540;
    --bg-quaternary: #3a2055;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #b0b0b0;
    --accent-primary: #ff0080;
    --accent-secondary: #00ffff;
    --accent-tertiary: #ff4080;
    --border-primary: #3a2055;
    --border-secondary: #ff0080;
    --success: #00ffaa;
    --warning: #ffaa00;
    --error: #ff4040;
    --info: #40a0ff;
    --highlight: rgba(255, 0, 128, 0.3);
    --shadow: rgba(255, 0, 128, 0.4);
}

/* Windows 95 Theme */
[data-theme="windows95"] {
    --bg-primary: #c0c0c0;
    --bg-secondary: #b3aeae;
    --bg-tertiary: #e0e0e0;
    --bg-quaternary: #d0d0d0;
    --text-primary: #000000;
    --text-secondary: #000000;
    --text-muted: #404040;
    --accent-primary: #000080;
    --accent-secondary: #008080;
    --accent-tertiary: #000080;
    --border-primary: #808080;
    --border-secondary: #000000;
    --success: #008000;
    --warning: #808000;
    --error: #800000;
    --info: #000080;
    --highlight: rgba(0, 0, 128, 0.2);
    --shadow: rgba(0, 0, 0, 0.3);
}

/* Light Mode Theme */
[data-theme="light"] {
    --bg-primary: #f0fdff;
    --bg-secondary: #e3f1ff;
    --bg-tertiary: #e2e8f0;
    --bg-quaternary: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #1e293b;
    --text-muted: #475569;
    --accent-primary: #7c3aed;
    --accent-secondary: #db2777;
    --accent-tertiary: #2563eb;
    --border-primary: #cbd5e1;
    --border-secondary: #94a3b8;
    --success: #059669;
    --warning: #d97706;
    --error: #dc2626;
    --info: #2563eb;
    --highlight: rgba(124, 58, 237, 0.1);
    --shadow: rgba(0, 0, 0, 0.1);
}

/* Cotton Candy Theme */
[data-theme="cotton-candy"] {
    --bg-primary: #fdf2f8;
    --bg-secondary: #fce7f3;
    --bg-tertiary: #e879f9;
    --bg-quaternary: #d946ef;
    --text-primary: #701a75;
    --text-secondary: #86198f;
    --text-muted: #a21caf;
    --accent-primary: #ec4899;
    --accent-secondary: #a855f7;
    --accent-tertiary: #06b6d4;
    --border-primary: #f9a8d4;
    --border-secondary: #ec4899;
    --success: #059669;
    --warning: #d97706;
    --error: #dc2626;
    --info: #2563eb;
    --highlight: rgba(236, 72, 153, 0.2);
    --shadow: rgba(236, 72, 153, 0.3);
}

/* Sunset Theme */
[data-theme="sunset"] {
    --bg-primary: #1e1b3b;
    --bg-secondary: #2d2649;
    --bg-tertiary: #3c3158;
    --bg-quaternary: #4b3c66;
    --text-primary: #fbbf24;
    --text-secondary: #f59e0b;
    --text-muted: #d97706;
    --accent-primary: #f59e0b;
    --accent-secondary: #ef4444;
    --accent-tertiary: #fb923c;
    --border-primary: #4b3c66;
    --border-secondary: #f59e0b;
    --success: #10b981;
    --warning: #fbbf24;
    --error: #ef4444;
    --info: #06b6d4;
    --highlight: rgba(245, 158, 11, 0.3);
    --shadow: rgba(251, 191, 36, 0.4);
}

/* Storm Theme */
[data-theme="storm"] {
    --bg-primary: #0f1419;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-quaternary: #475569;
    --text-primary: #f1f5f9;
    --text-secondary: #e2e8f0;
    --text-muted: #cbd5e1;
    --accent-primary: #06b6d4;
    --accent-secondary: #0ea5e9;
    --accent-tertiary: #8b5cf6;
    --border-primary: #475569;
    --border-secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #06b6d4;
    --highlight: rgba(6, 182, 212, 0.3);
    --shadow: rgba(6, 182, 212, 0.2);
}

/* Base Styles */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Title */
.title{
    color:var(--accent-primary)
}

/* Tab Navigation Styles */
.tab-btn {
    transition: all 0.3s ease;
    position: relative;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-tertiary));
    box-shadow: 0 4px 14px 0 var(--highlight);
    color: var(--text-primary);
}

.tab-btn:hover:not(.active) {
    background-color: var(--bg-quaternary);
    color: var(--text-primary);
}

.tab-content {
    animation: fadeIn 0.3s ease-in-out;
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 1.5rem;
}

.tab-content.hidden {
    display: none;
}

/* Universal container styling for theme support */
.theme-container {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

/* Input and form elements */
input[type="text"], input[type="number"], select, textarea {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-primary) !important;
}

input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 0 2px var(--highlight) !important;
    outline: none;
}

/* Button styling for consistency */
.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: var(--text-primary);
    border: none;
}

.btn-secondary {
    background-color: var(--bg-quaternary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

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

.btn-danger {
    background-color: var(--error);
    color: var(--text-primary);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Card Styles */
.card-container {
    perspective: 1000px;
}

.card {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card-container.flipped .card {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 0.5rem;
    border: 2px solid var(--border-primary);
}

.card-front {
    transform: rotateY(180deg);
    background-color: var(--bg-secondary);
}

.card-front:hover {
    transform: rotateY(180deg) translateY(-10px) rotateX(5deg);
    box-shadow: 0 20px 25px -5px var(--shadow), 0 8px 10px -6px var(--shadow);
}

.card-back {
    background: var(--bg-tertiary);
    border: 4px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.card-back:hover {
    transform: translateY(-5px);
    background: var(--bg-quaternary);
}

.card-back-logo {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-muted);
}

/* Foil Card Effects */
.card-face.foil {
    box-shadow: 0 0 15px 5px rgba(255, 215, 0, 0.6);
    overflow: hidden;
}

.card-face.foil::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.1) 35%, rgba(255,255,255,0.5) 50%, rgba(255,255,255,0.1) 65%, rgba(255,255,255,0.1) 100%);
    transform: rotate(30deg);
    animation: foil-sheen 3s infinite linear;
    pointer-events: none;
    z-index: 10;
}

@keyframes foil-sheen {
    0% { transform: translateX(-75%) translateY(-75%) rotate(30deg); }
    100% { transform: translateX(75%) translateY(75%) rotate(30deg); }
}

/* Card Rarity Colors - Using theme variables as base, with specific rarity colors */
.rarity-common { border-color: var(--text-muted); }
.rarity-uncommon { border-color: var(--info); }
.rarity-rare { border-color: var(--warning); }
.rarity-mythic { border-color: var(--accent-secondary); }

/* Glyph Art Styles */
.card-art-area {
    position: relative;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.15), rgba(255,255,255,0.02));
    border: 1px solid rgba(255,255,255,0.1);
}

.rarity-common .card-art-area {
    background: radial-gradient(circle at 30% 30%, rgba(107, 114, 128, 0.2), rgba(107, 114, 128, 0.05));
    border-color: rgba(107, 114, 128, 0.3);
}

.rarity-uncommon .card-art-area {
    background: radial-gradient(circle at 30% 30%, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.05));
    border-color: rgba(16, 185, 129, 0.3);
}

.rarity-rare .card-art-area {
    background: radial-gradient(circle at 30% 30%, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.05));
    border-color: rgba(59, 130, 246, 0.3);
}

.rarity-mythic .card-art-area {
    background: radial-gradient(circle at 30% 30%, rgba(245, 158, 11, 0.3), rgba(239, 68, 68, 0.1));
    border-color: rgba(245, 158, 11, 0.4);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

.glyph-art {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.glyph-element {
    transition: all 0.3s ease;
    text-shadow: 0 0 3px currentColor;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Art style specific enhancements */
.glyph-art-organic .glyph-element {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.glyph-art-geometric .glyph-element {
    font-weight: 900;
    text-shadow: 0 0 5px currentColor;
}

.glyph-art-mystical .glyph-element {
    filter: drop-shadow(0 0 8px currentColor) blur(0.5px);
    animation: mystical-pulse 4s ease-in-out infinite alternate;
}

.glyph-art-technical .glyph-element {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-shadow: 0 0 2px currentColor;
}

/* Animates opacity only. It previously animated `filter` as well, which is not a
   compositable property, so every visible glyph element repainted on every frame --
   a continuous GPU/CPU load even with the app sitting idle. The static drop-shadow and
   blur are still applied by the rule above; only the pulse is animated. */
@keyframes mystical-pulse {
    0% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Hover effects for glyph art */
.card-face:hover .glyph-art .glyph-element {
    transform: scale(1.1);
}

.rarity-mythic .card-face:hover .glyph-art .glyph-element {
    animation: mythic-glow 2s ease-in-out infinite alternate;
}

@keyframes mythic-glow {
    0% { text-shadow: 0 0 3px currentColor; }
    100% { text-shadow: 0 0 8px currentColor, 0 0 12px currentColor; }
}

/* Foil effects for glyph art */
.card-face.foil .glyph-art .glyph-element {
    animation: foil-glyph-shine 3s ease-in-out infinite;
}

@keyframes foil-glyph-shine {
    0%, 100% { text-shadow: 0 0 3px currentColor; }
    50% { text-shadow: 0 0 8px currentColor, 0 0 15px rgba(255, 215, 0, 0.8); }
}

/* Pack Styles */
.pack {
    cursor: pointer;
    transition: transform 0.2s ease-in-out;
    background-color: var(--bg-tertiary);
    border: 2px solid var(--border-primary);
}

.pack:hover {
    transform: scale(1.05);
    border-color: var(--border-secondary);
}

/* Weekly Pack Special Effects */
.pack.weekly-pack {
    animation: weekly-glow 2s ease-in-out infinite alternate;
}

@keyframes weekly-glow {
    from {
        box-shadow: 0 0 10px var(--highlight), 0 0 20px var(--accent-secondary);
    }
    to {
        box-shadow: 0 0 20px var(--accent-primary), 0 0 30px var(--accent-secondary);
    }
}

/* Pack Opening Modal */
#pack-opening-modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 50;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.8);
    align-items: center;
    justify-content: center;
}

.pack-art-container {
    position: relative;
    width: 200px;
    height: 300px;
    user-select: none;
}

.pack-art {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: var(--bg-tertiary);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-primary);
    border: 4px solid var(--border-primary);
    overflow: hidden;
    cursor: grab;
}

.pack-art-back {
    z-index: 1;
}

.pack-art-front {
    z-index: 2;
    clip-path: inset(0 0 0 0); /* Initially fully visible */
    transition: clip-path 0.1s linear;
}

.pack-art-front:active {
    cursor: grabbing;
}

.pack-art-tear-off {
    z-index: 3;
    clip-path: inset(0 100% 0 0);
    height: 10%;
    pointer-events: none;
}

.pack-opening-text {
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 1rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--bg-quaternary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-secondary);
}

/* Market-specific styles */
.sell-card-btn {
    opacity: 0;
    transition: opacity 0.2s ease;
    background-color: var(--accent-primary);
    color: var(--text-primary);
}

.card-face:hover .sell-card-btn {
    opacity: 1;
}

.portfolio-card {
    transition: all 0.2s ease;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
}

.portfolio-card:hover {
    transform: translateX(5px);
    background-color: var(--bg-tertiary);
    border-color: var(--border-secondary);
}

.hot-card-item {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
}

.hot-card-item:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-secondary);
}

.hot-card-event {
    background-color: var(--accent-secondary);
    color: var(--bg-secondary)
}

/* Achievement notification animation */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.achievement-slide-in {
    animation: slideInRight 0.5s ease-out;
}

/* Market trend indicators */
.trend-rising {
    color: var(--success);
}

.trend-falling {
    color: var(--error);
}

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

/* Hot card glow effect */
.hot-card {
    box-shadow: 0 0 10px var(--warning);
    border: 1px solid var(--warning);
}

/* Player stats bar - positioned discreetly in top left */
#player-stats-bar {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 8px 12px !important;
    margin: 0 !important;
    font-size: 0.8rem;
    opacity: 0.9;
    transition: opacity 0.3s ease;
    max-width: 700px;
    gap: 8px;
}

#player-stats-bar:hover {
    opacity: 1;
}

#player-stats-bar > div {
    font-size: 0.75rem;
    margin: 0;
    padding: 2px 4px;
}

/* Weekly notification positioned in top right corner of pack section */
#pack-selection {
    position: relative;
}

#weekly-set-notification {
    position: absolute;
    top: 15px;
    right: 15px;
    margin: 0 !important;
    padding: 8px 12px !important;
    font-size: 0.8rem;
    max-width: 200px;
    z-index: 10;
    opacity: 0.95;
    transition: opacity 0.3s ease;
}

#weekly-set-notification:hover {
    opacity: 1;
}

#weekly-set-notification h3 {
    font-size: 0.9rem !important;
    margin-bottom: 4px !important;
}

#weekly-set-notification p {
    font-size: 0.7rem !important;
    margin: 2px 0 !important;
}

#weekly-set-notification div {
    font-size: 0.65rem !important;
    margin-top: 2px !important;
}

/* Player stats bar responsive */
@media (max-width: 768px) {
    #player-stats-bar {
        position: relative;
        top: auto;
        left: auto;
        max-width: none;
        width: 100%;
        margin: 16px 0 !important;
        flex-direction: column;
        gap: 2px;
    }
    
    #player-stats-bar > div {
        justify-content: center;
        font-size: 0.8rem;
    }
    
    #weekly-set-notification {
        position: relative;
        top: auto;
        right: auto;
        max-width: none;
        margin: 0 0 16px 0 !important;
    }
}

/* Market modal responsiveness */
@media (max-width: 640px) {
    #sell-card-modal .bg-gray-800 {
        width: 95%;
        margin: 0 auto;
    }
    
    #price-chart-modal .bg-gray-800 {
        width: 95%;
        margin: 0 auto;
    }
}

/* Portfolio controls styling */
.portfolio-controls {
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .portfolio-controls {
        flex-direction: column;
    }
    
    .portfolio-controls input,
    .portfolio-controls select {
        width: 100%;
    }
}

/* Chart button styling */
.chart-btn, .hot-card-chart-btn {
    transition: all 0.2s ease;
}

.chart-btn:hover, .hot-card-chart-btn:hover {
    transform: scale(1.05);
}

/* Chart timeframe buttons */
.chart-timeframe-btn {
    transition: all 0.2s ease;
}

.chart-timeframe-btn.active {
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Card hover effects for charts */
.chart-card-trigger:hover {
    background-color: rgba(59, 130, 246, 0.1);
    border-radius: 0.375rem;
}

/* Portfolio search/filter enhancements */
#portfolio-search:focus,
#portfolio-sort:focus,
#portfolio-filter:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Hot cards clickable styling */
.hot-cards-list [data-set-id]:hover {
    background-color: rgba(59, 130, 246, 0.1);
    cursor: pointer;
}

/* Chart modal backdrop blur */
#price-chart-modal {
    backdrop-filter: blur(4px);
}

/* Profile Modal Styles */
#profile-modal {
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}

#profile-modal .bg-gray-800 {
    animation: slideUp 0.3s ease-out;
    box-shadow: 0 25px 50px -12px var(--shadow);
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-primary);
}

#profile-portrait {
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-quaternary));
    border: 3px solid var(--border-secondary);
    transition: all 0.3s ease;
}

#profile-portrait:hover {
    transform: scale(1.05);
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px var(--highlight);
}

.profile-stat-card {
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-quaternary));
    transition: all 0.3s ease;
    border: 1px solid var(--border-primary);
}

.profile-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px -8px var(--shadow);
    border-color: var(--border-secondary);
}

#networth-chart {
    background: rgba(17, 24, 39, 0.5);
    border-radius: 0.5rem;
    background-color: var(--bg-primary) !important;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Profile button styling */
#profile-btn {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    transition: all 0.3s ease;
    box-shadow: 0 4px 14px 0 var(--highlight);
}

#profile-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px 0 var(--highlight);
}

/* Theme Selector Styles */
.theme-selector {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.theme-selector h3 {
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
}

.theme-option {
    padding: 0.75rem;
    border: 2px solid var(--border-primary);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    font-size: 0.875rem;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
}

.theme-option:hover {
    border-color: var(--border-secondary);
    transform: translateY(-1px);
}

.theme-option.active {
    border-color: var(--accent-primary);
    background-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: 0 0 10px var(--highlight);
}

.theme-preview {
    width: 100%;
    height: 24px;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-primary);
}

/* Theme preview colors */
.theme-preview.default { background: linear-gradient(90deg, #111827, #9333ea, #ec4899); }
.theme-preview.matrix { background: linear-gradient(90deg, #000000, #00ff00, #008800); }
.theme-preview.outrun { background: linear-gradient(90deg, #0f0515, #ff0080, #00ffff); }
.theme-preview.windows95 { background: linear-gradient(90deg, #c0c0c0, #000080, #008080); }
.theme-preview.light { background: linear-gradient(90deg, #ffffff, #7c3aed, #db2777); }
.theme-preview.cotton-candy { background: linear-gradient(90deg, #fdf2f8, #ec4899, #a855f7); }
.theme-preview.sunset { background: linear-gradient(90deg, #1e1b3b, #f59e0b, #ef4444); }
.theme-preview.storm { background: linear-gradient(90deg, #0f1419, #06b6d4, #8b5cf6); }

/* Enhanced readability for all themes */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
}

/* Ensure proper contrast for interactive elements */
button {
    transition: all 0.2s ease;
}

button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Input focus states for better accessibility */
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Card text contrast improvements */
.card-face {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Enhanced modal backdrop for all themes */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

/* Theme-specific text contrast fixes */
[data-theme="matrix"] .text-yellow-400,
[data-theme="matrix"] .text-blue-400,
[data-theme="matrix"] .text-purple-400 {
    color: var(--accent-primary) !important;
}

[data-theme="outrun"] .text-gray-400 {
    color: var(--text-secondary) !important;
}

[data-theme="windows95"] .text-purple-400,
[data-theme="windows95"] .text-pink-600 {
    color: var(--accent-primary) !important;
}

[data-theme="light"] .text-white {
    color: var(--text-primary) !important;
}

/* Card name and collection text readability fixes */
[data-theme="light"] .card-face,
[data-theme="cotton-candy"] .card-face {
    color: var(--text-primary) !important;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.8);
}

[data-theme="light"] .portfolio-card,
[data-theme="cotton-candy"] .portfolio-card {
    color: var(--text-primary) !important;
}

[data-theme="light"] .portfolio-card .text-gray-400,
[data-theme="cotton-candy"] .portfolio-card .text-gray-400 {
    color: var(--text-muted) !important;
}

/* Chart text improvements for light themes */
[data-theme="light"] #networth-chart,
[data-theme="cotton-candy"] #networth-chart {
    background-color: var(--bg-secondary) !important;
}

/* Market card list text contrast */
[data-theme="light"] .hot-cards-list [data-set-id],
[data-theme="cotton-candy"] .hot-cards-list [data-set-id] {
    color: var(--text-primary) !important;
}

/* Collection grid card text */
[data-theme="light"] #collection-display .card-face,
[data-theme="cotton-candy"] #collection-display .card-face {
    background-color: var(--bg-quaternary) !important;
    color: var(--text-primary) !important;
    border: 2px solid var(--border-secondary) !important;
}

/* Portfolio search and filter improvements */
[data-theme="light"] #portfolio-search::placeholder,
[data-theme="cotton-candy"] #portfolio-search::placeholder {
    color: var(--text-muted) !important;
}

/* Matrix theme specific fixes to prevent light green on light green */
[data-theme="matrix"] .bg-green-600,
[data-theme="matrix"] .bg-green-700 {
    background-color: var(--bg-quaternary) !important;
}

[data-theme="matrix"] .text-green-400,
[data-theme="matrix"] .text-green-500 {
    color: var(--text-primary) !important;
}

/* Matrix theme button text contrast fixes */
[data-theme="matrix"] #buy-pack-btn,
[data-theme="matrix"] #buy-box-btn {
    background-color: var(--bg-quaternary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-secondary) !important;
}

[data-theme="matrix"] #weekly-set-notification {
    background: var(--bg-quaternary) !important;
    border: 1px solid var(--border-secondary) !important;
}

[data-theme="matrix"] #weekly-set-notification h3,
[data-theme="matrix"] #weekly-set-notification p,
[data-theme="matrix"] #weekly-set-notification div {
    color: var(--text-primary) !important;
}

/* Matrix theme player stats bar */
[data-theme="matrix"] #player-stats-bar {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-secondary) !important;
}

/* Chart text readability improvements for all themes */
canvas {
    color: var(--text-primary) !important;
}

/* Chart.js tooltip styling override */
.chartjs-tooltip {
    background-color: var(--bg-quaternary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-secondary) !important;
}

/* Force chart text colors to be readable */
[data-theme="light"] canvas,
[data-theme="cotton-candy"] canvas {
    filter: none !important;
}

/* Ensure chart container backgrounds are properly themed */
#networth-chart {
    background-color: var(--bg-primary) !important;
}

#price-chart {
    background-color: var(--bg-primary) !important;
}

/* Ensure tooltips and overlays are readable */
.tooltip, .overlay-text {
    background-color: var(--bg-quaternary);
    color: var(--text-primary);
    border: 1px solid var(--border-secondary);
}

/* Responsive chart container */
@media (max-width: 768px) {
    #price-chart {
        height: 250px !important;
    }
    
    #chart-stats {
        grid-template-columns: 2fr 2fr;
        gap: 1rem;
    }
    
    #profile-modal .bg-gray-800 {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    #networth-chart {
        height: 200px !important;
    }
}

/* Chart Timeframe Button Styles */
.chart-timeframe-btn {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-secondary);
}

.chart-timeframe-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.chart-timeframe-btn.active {
    background-color: var(--accent-primary);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

/* Reset Confirmation Modal Styles */
.reset-confirmation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.reset-confirmation-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    margin: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-primary);
}

.reset-confirmation-content h3 {
    margin-top: 0;
    color: var(--error);
    text-align: center;
    font-size: 1.5em;
    margin-bottom: 20px;
}

.reset-confirmation-content p {
    margin-bottom: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.reset-confirmation-content ul {
    margin: 15px 0;
    padding-left: 20px;
    color: var(--text-secondary);
}

.reset-confirmation-content li {
    margin-bottom: 5px;
}

.reset-confirmation-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

.reset-confirmation-buttons .btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    transition: all 0.3s ease;
    min-width: 120px;
}

.reset-confirmation-buttons .btn-danger {
    background: var(--error);
    color: white;
}

.reset-confirmation-buttons .btn-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(239, 68, 68, 0.4);
}

.reset-confirmation-buttons .btn-secondary {
    background: var(--bg-quaternary);
    color: var(--text-primary);
    border: 1px solid var(--border-secondary);
}

.reset-confirmation-buttons .btn-secondary:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(75, 85, 99, 0.4);
}

/* Auto-Complete Dropdown Styles */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 10px 25px var(--shadow);
}

.autocomplete-dropdown.hidden {
    display: none;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-primary);
    transition: background-color 0.2s ease;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.bg-gray-700 {
    background: var(--bg-tertiary);
}

.autocomplete-item .card-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.autocomplete-item .card-details {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.autocomplete-item .rarity-common {
    color: var(--text-muted);
}

.autocomplete-item .rarity-uncommon {
    color: var(--success);
}

.autocomplete-item .rarity-rare {
    color: var(--accent-tertiary);
}

.autocomplete-item .rarity-mythic {
    color: var(--accent-primary);
}

/* Smooth scrollbar for autocomplete */
.autocomplete-dropdown::-webkit-scrollbar {
    width: 6px;
}

.autocomplete-dropdown::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 3px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--border-primary);
}

/* Update Notification Banner */
.update-banner {
    position: sticky;
    top: 0;
    z-index: 1000;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.update-banner a:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Sell All Button - Always bright red regardless of theme */
#sell-all-btn {
    background-color: #dc2626 !important;
    color: white !important;
    border: 2px solid #b91c1c !important;
    font-weight: bold !important;
    font-size: 1.125rem !important;
    padding: 12px 24px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) !important;
    user-select: none !important;
}

#sell-all-btn:hover {
    background-color: #b91c1c !important;
    border-color: #991b1b !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.6) !important;
}

#sell-all-btn:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.5) !important;
}

.update-banner button:hover {
    transform: translateY(-1px);
}

/* Responsive update banner */
@media (max-width: 768px) {
    .update-banner div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .update-banner div[style*="display: flex"] > div:last-child {
        flex-direction: row !important;
        justify-content: center !important;
    }
}

/* Sell Modal Step-based Design */
.modal-step {
    transition: opacity 0.3s ease-in-out;
}

.modal-step.hidden {
    display: none;
}

.sell-method-btn {
    transition: all 0.2s ease;
    border: 1px solid var(--border-primary) !important;
}

.sell-method-btn:hover {
    background-color: var(--bg-quaternary) !important;
    border-color: var(--accent-primary) !important;
    transform: translateY(-1px);
}

.sell-method-btn:active {
    transform: translateY(0);
}

#modal-back-btn {
    transition: all 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#modal-back-btn:hover {
    background-color: var(--bg-quaternary) !important;
    transform: translateX(-2px);
}
/* ---------------------------------------------------------------------------
   Idle cost containment for the collection grid.

   The grid can hold well over a hundred cards, each containing ~14 absolutely
   positioned, transformed, blurred glyph elements, several of which run infinite
   animations. Every one of those stayed live even while scrolled out of view.
   content-visibility lets the browser skip rendering (and animating) off-screen
   cards entirely; contain-intrinsic-size keeps the scrollbar honest by giving
   skipped cards their real height (h-40 = 10rem).
   --------------------------------------------------------------------------- */
#collection-display {
    contain: content;
}

#collection-display .card-face {
    content-visibility: auto;
    contain-intrinsic-size: auto 10rem;
}

/* Respect the OS "reduce motion" setting: stop the continuous glyph animations. */
@media (prefers-reduced-motion: reduce) {
    .glyph-art-mystical .glyph-element,
    .card-face.foil .glyph-art .glyph-element,
    .rarity-mythic .card-face:hover .glyph-art .glyph-element {
        animation: none;
    }
}

/* ---------------------------------------------------------------------------
   Set Creator
   --------------------------------------------------------------------------- */

.creator-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

/* The rail stacks above the editor on narrow windows rather than squeezing both. */
@media (max-width: 900px) {
    .creator-layout { grid-template-columns: minmax(0, 1fr); }
}

.creator-rail { position: sticky; top: 1rem; }

.creator-set-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name pill" "meta pill";
    gap: 0.15rem 0.5rem;
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    background-color: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.creator-set-row:hover { border-color: var(--accent-primary); }
.creator-set-row.is-active {
    border-color: var(--accent-primary);
    background-color: var(--bg-tertiary, var(--bg-secondary));
}

.creator-set-name {
    grid-area: name;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.creator-set-meta { grid-area: meta; font-size: 0.75rem; color: var(--text-secondary); }

.creator-pill {
    grid-area: pill;
    align-self: center;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
}
.creator-pill-draft { background-color: rgba(148, 163, 184, 0.25); color: #cbd5e1; }
.creator-pill-published { background-color: rgba(34, 197, 94, 0.25); color: #86efac; }
.creator-pill-broken { background-color: rgba(239, 68, 68, 0.25); color: #fca5a5; }

.creator-editor { min-width: 0; }

.creator-input {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}
.creator-input:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: -1px;
}

.creator-rules {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
}
.creator-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; }
.creator-field > span { color: var(--text-secondary); }
.creator-field > input { padding: 0.4rem 0.6rem; border-radius: 0.4rem; }

.creator-economy { font-size: 0.85rem; }
.creator-ev {
    display: inline-block;
    padding: 0.4rem 0.7rem;
    border-radius: 0.5rem;
    border-left: 3px solid transparent;
}
.creator-ev-good { background-color: rgba(34, 197, 94, 0.12); border-left-color: #22c55e; }
.creator-ev-warn { background-color: rgba(234, 179, 8, 0.12); border-left-color: #eab308; }
.creator-ev-bad { background-color: rgba(239, 68, 68, 0.12); border-left-color: #ef4444; }
.creator-ev-unknown { background-color: rgba(148, 163, 184, 0.12); border-left-color: #94a3b8; }

/* Four card lists side by side; they wrap to two columns, then one, as the window narrows. */
.creator-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.75rem;
}
.creator-rarity-col { display: flex; flex-direction: column; min-width: 0; }
.creator-col-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}
.creator-col-count {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    font-weight: 500;
}
.creator-col-count.is-short { color: #fca5a5; }

.rarity-dot { width: 0.6rem; height: 0.6rem; border-radius: 999px; display: inline-block; }
.rarity-dot.rarity-common { background-color: #9ca3af; }
.rarity-dot.rarity-uncommon { background-color: #34d399; }
.rarity-dot.rarity-rare { background-color: #60a5fa; }
.rarity-dot.rarity-mythic { background-color: #f59e0b; }

.creator-card-list {
    width: 100%;
    min-height: 190px;
    resize: vertical;
    padding: 0.5rem 0.6rem;
    border-radius: 0.5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}
.creator-card-list:focus { outline: 2px solid var(--accent-primary); outline-offset: -1px; }
/* Published sets lock their names: they key the collection, prices and art. */
.creator-card-list.is-locked { opacity: 0.65; cursor: not-allowed; }

.creator-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.6rem;
}

.creator-problem {
    display: block;
    width: 100%;
    text-align: left;
    font-size: 0.8rem;
    padding: 0.45rem 0.7rem;
    margin-bottom: 0.35rem;
    border-radius: 0.4rem;
    border-left: 3px solid transparent;
    cursor: pointer;
    color: var(--text-primary);
}
.creator-problem-error { background-color: rgba(239, 68, 68, 0.12); border-left-color: #ef4444; }
.creator-problem-warning { background-color: rgba(234, 179, 8, 0.12); border-left-color: #eab308; }
.creator-problem:hover { filter: brightness(1.25); }

.creator-ok { font-size: 0.8rem; color: #86efac; }
.creator-warn { color: #fca5a5; }

.creator-banner {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    background-color: rgba(239, 68, 68, 0.12);
    border-left: 3px solid #ef4444;
}

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