:root {
    --bg-color: #050505;
    --panel-bg: rgba(20, 20, 25, 0.7);
    --panel-border: rgba(60, 60, 80, 0.5);
    --text-main: #e0e0e0;
    --text-muted: #888;

    /* Specificity Colors */
    --color-inline: #a855f7;
    --color-id: #f59e0b;
    --color-class: #3b82f6;
    --color-element: #10b981;
    --color-imp: #ef4444;

    /* Theme Colors */
    --color-light-side: #38bdf8;
    --color-dark-side: #ef4444;
    --color-winner: #eab308;
}

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

body {
    font-family: 'Space Mono', monospace;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    padding: 2rem;
}

/* Background Effects */
.stars-bg,
.twinkling-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: -2;
}

.stars-bg {
    background: #000 url('https://www.transparenttextures.com/patterns/stardust.png') repeat top center;
}

.twinkling-bg {
    background: transparent url('https://www.transparenttextures.com/patterns/stardust.png') repeat top center;
    z-index: -1;
    animation: move-twink-back 200s linear infinite;
    opacity: 0.3;
}

@keyframes move-twink-back {
    from {
        background-position: 0 0;
    }

    to {
        background-position: -10000px 5000px;
    }
}

.app-container {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 1;
}

.app-header {
    text-align: center;
    margin-bottom: 1rem;
}

h1.glow-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem;
    font-weight: 900;
    color: #ffe81f;
    /* Star Wars Yellow */
    text-shadow: 0 0 10px rgba(255, 232, 31, 0.5), 0 0 20px rgba(255, 232, 31, 0.3);
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Legend */
.legend-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
}

.legend-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.l-badge {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #fff;
}

.l-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.l-val {
    font-weight: bold;
    font-size: 1rem;
}

.inline-score .l-badge,
.inline-score .l-val {
    color: var(--color-inline);
}

.id-score .l-badge,
.id-score .l-val {
    color: var(--color-id);
}

.class-score .l-badge,
.class-score .l-val {
    color: var(--color-class);
}

.element-score .l-badge,
.element-score .l-val {
    color: var(--color-element);
}

.imp-score .l-badge,
.imp-score .l-val {
    color: var(--color-imp);
}


/* Battle Arena */
.battle-arena {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
}

@media (min-width: 900px) {
    .battle-arena {
        flex-direction: row;
        align-items: stretch;
    }

    .contender-card {
        flex: 1;
        min-width: 0;
    }
}

.vs-badge-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem 0;
}

.vs-badge {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 900;
    background: #222;
    color: #fff;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid #444;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    position: relative;
    z-index: 10;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 0.75rem;
}

.contender-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.text-blue {
    color: var(--color-light-side);
    text-shadow: 0 0 8px var(--color-light-side);
}

.text-red {
    color: var(--color-dark-side);
    text-shadow: 0 0 8px var(--color-dark-side);
}

.score-display {
    font-size: 1.5rem;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.5);
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-variant-numeric: tabular-nums;
    display: flex;
    gap: 4px;
}

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

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

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

.input-group {
    margin-bottom: 1rem;
}

.selector-input {
    width: 100%;
    height: 80px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    color: #fff;
    font-family: 'Space Mono', monospace;
    font-size: 1rem;
    padding: 0.75rem;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

#cardA .selector-input:focus {
    border-color: var(--color-light-side);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

#cardB .selector-input:focus {
    border-color: var(--color-dark-side);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.breakdown-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    min-height: 80px;
    align-content: flex-start;
}

.token {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
}

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

.token-type {
    font-size: 0.65rem;
    text-transform: uppercase;
    opacity: 0.8;
    margin-top: 2px;
}

.token.id .token-val {
    color: var(--color-id);
}

.token.class .token-val {
    color: var(--color-class);
}

.token.element .token-val {
    color: var(--color-element);
}

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

.token.important .token-val {
    color: var(--color-imp);
}

.warning-box {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 6px;
    color: #fca5a5;
    font-size: 0.9rem;
    text-align: center;
}

.warning-box.hidden {
    display: none;
}

/* Results */
.results-panel {
    text-align: center;
    padding: 2rem;
}

.results-title {
    font-family: 'Orbitron', sans-serif;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.battle-text {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    min-height: 2rem;
}

.battle-text .winner-a {
    color: var(--color-light-side);
    text-shadow: 0 0 10px var(--color-light-side);
}

.battle-text .winner-b {
    color: var(--color-dark-side);
    text-shadow: 0 0 10px var(--color-dark-side);
}

.battle-text .tie {
    color: #a3a3a3;
}

.battle-advice {
    font-size: 0.9rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.5;
}

/* Animations */
.glow-pulse {
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0% {
        border-color: #444;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    }

    50% {
        border-color: #888;
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    }

    100% {
        border-color: #444;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    }
}

.winner-card {
    animation: celebrate 0.5s ease-out forwards;
}

@keyframes celebrate {
    0% {
        transform: scale(1);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    }

    50% {
        transform: scale(1.02);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 30px var(--color-winner);
        border-color: var(--color-winner);
    }
}