:root {
    /* Red Culture Theme - Inherited from style.css */
    --app-bg: #fdfbf7;
    --sidebar-bg: rgba(255, 248, 240, 0.8);
    --glass-border: rgba(214, 59, 29, 0.2);
    --text-primary: #8b0000;
    --text-secondary: #a05a5a;
    --accent-red: #d63b1d;
    --accent-gold: #ffb400;
    --accent-hover: #b32b12;
    --danger-red: #ff3b30;
    --success-green: #27c93f;
    --warning-orange: #ff9500;

    --shadow-sm: 0 2px 8px rgba(139, 0, 0, 0.08);
    --shadow-md: 0 8px 24px rgba(139, 0, 0, 0.12);
    --shadow-lg: 0 20px 40px rgba(139, 0, 0, 0.15);

    --font-family: "Noto Serif SC", "Outfit", serif;
    --font-title: "Ma Shan Zheng", cursive;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--app-bg);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: url('https://images.unsplash.com/photo-1533038590840-1cde6e668a91?q=80&w=2574&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
}

.app-container {
    width: 90vw;
    height: 85vh;
    max-width: 1400px;
    background: rgba(255, 252, 245, 0.85);
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 340px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.window-controls {
    display: flex;
    gap: 8px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.red {
    background: #ff5f56;
    border: 1px solid #e0443e;
}

.dot.yellow {
    background: #ffbd2e;
    border: 1px solid #dea123;
}

.dot.green {
    background: #27c93f;
    border: 1px solid #1aab29;
}

h1 {
    font-family: var(--font-title);
    font-size: 2rem;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.05em;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: -5px;
}

.highlight {
    color: var(--accent-red);
}

.controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex-grow: 1;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Checkboxes */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(255, 255, 255, 0.5);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(139, 0, 0, 0.1);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-item input {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(139, 0, 0, 0.3);
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    background: #fff;
}

.checkbox-item input:checked+.checkmark {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

.checkmark::after {
    content: '✓';
    color: white;
    font-size: 14px;
    display: none;
}

.checkbox-item input:checked+.checkmark::after {
    display: block;
}

.label-text {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Stats Box */
.stats-box {
    background: rgba(255, 255, 255, 0.6);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(139, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
}

.stat-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-row span:first-child {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.highlight-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-red);
}

/* Mission Box */
.mission-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mission-score {
    flex-grow: 1;
    background: #fff;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(139, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    color: var(--text-primary);
}

#scoreValue {
    color: var(--accent-red);
    font-size: 1.2rem;
}

/* Info Panel */
.info-panel {
    background: rgba(255, 255, 255, 0.5);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(139, 0, 0, 0.1);
}

.info-panel h3 {
    font-size: 1rem;
    color: var(--accent-red);
    margin-bottom: 6px;
    font-weight: 700;
}

.info-panel p {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-primary);
}

/* Buttons */
.actions-footer {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.apple-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: var(--font-family);
    width: 100%;
}

.action-btn {
    background: var(--accent-red);
    color: white;
    box-shadow: var(--shadow-md);
}

.action-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.warning-btn {
    background: var(--warning-orange);
    color: white;
    box-shadow: var(--shadow-md);
}

.warning-btn:hover {
    background: #e08500;
    transform: translateY(-1px);
}

.danger-btn {
    background: rgba(139, 0, 0, 0.1);
    color: var(--text-primary);
}

.danger-btn:hover {
    background: rgba(139, 0, 0, 0.2);
}

.apple-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Main Stage */
.visualizer-stage {
    flex-grow: 1;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.glass-pane {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 2rem;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.stage-header {
    text-align: center;
    margin-bottom: 2rem;
}

.stage-header h2 {
    font-size: 1.8rem;
    color: var(--accent-red);
    margin-bottom: 0.5rem;
    font-family: var(--font-title);
}

.stage-header p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

/* Mission Banner */
.mission-banner {
    background: #fff;
    border-left: 4px solid var(--warning-orange);
    padding: 12px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    animation: slideDown 0.5s ease;
    transition: all 0.3s ease;
}

.mission-banner.hidden {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
    margin-bottom: 0;
    padding: 0;
    height: 0;
}

.mission-banner.success {
    border-left-color: var(--success-green);
    background: #f0fff4;
}

.mission-icon {
    font-size: 1.5rem;
}

.mission-info {
    display: flex;
    flex-direction: column;
}

.mission-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
}

.mission-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.viz-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
}

/* Subsets Grid */
.subsets-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    align-content: flex-start;
}

.subset-box {
    background: #fff;
    border-radius: 12px;
    padding: 10px;
    min-width: 100px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    animation: fadeIn 0.5s ease forwards;
    opacity: 0;
    transform: translateY(20px);
    cursor: pointer;
    position: relative;
}

.subset-box:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-red);
}

.subset-box.full-set {
    border-color: var(--accent-gold);
    background: #fffdf5;
}

.subset-box.correct {
    border-color: var(--success-green);
    background: #f0fff4;
    animation: pulse 0.5s ease;
}

.subset-box.wrong {
    border-color: var(--danger-red);
    background: #fff5f5;
    animation: shake 0.4s ease;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.subset-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.subset-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.power-badge {
    font-size: 0.7rem;
    background: var(--accent-red);
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 700;
}

.subset-elements {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    flex-grow: 1;
    align-items: center;
}

.element-icon {
    font-size: 1.4rem;
}

.combo-title {
    font-size: 0.75rem;
    color: var(--text-primary);
    font-weight: 600;
    text-align: center;
    margin-top: 6px;
    min-height: 1.2em;
}

.empty-set-symbol {
    font-size: 1.5rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        width: 96vw;
        height: 96vh;
    }

    .sidebar {
        width: 100%;
        max-height: 45vh;
    }
}