:root {
    --bg: #111827;
    --panel: #1f2937;
    --text: #f9fafb;
    --muted: #9ca3af;
    
    --red: #ef4444;
    --red-dark: #b91c1c;
    --blue: #3b82f6;
    --blue-dark: #1d4ed8;
    
    --green: #10b981;
    --yellow: #fcd34d;

    /* Specificity colors */
    --c-imp: #ec4899;
    --c-inl: #f59e0b;
    --c-id:  #8b5cf6;
    --c-cls: #06b6d4;
    --c-elm: #22c55e;

    --font-ui: 'Bangers', cursive;
    --font-code: 'JetBrains Mono', monospace;
}

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

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: -apple-system, sans-serif;
    min-height: 100vh;
}

.hidden { display: none !important; }

.app {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #374151;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

@media (max-width: 600px) {
    header { flex-direction: column; gap: 1rem; }
}

h1 {
    font-family: var(--font-ui);
    font-size: 2.5rem;
    letter-spacing: 2px;
    background: linear-gradient(to right, var(--red), var(--blue));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5); /* Good enough fallback */
}

.stats {
    display: flex;
    gap: 1.5rem;
    font-family: var(--font-ui);
    font-size: 1.5rem;
}

.stat-box {
    background: #374151;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 2px solid #4b5563;
}

button {
    font-family: var(--font-ui);
    font-size: 1.2rem;
    padding: 0.5rem 1.5rem;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    background: #e5e7eb;
    color: #111827;
    transition: transform 0.1s;
}

button:active {
    transform: scale(0.95);
}

.panel {
    background: var(--panel);
    padding: 2rem;
    border-radius: 12px;
    border: 2px solid #374151;
    text-align: center;
}

.panel h2 {
    font-family: var(--font-ui);
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--yellow);
    letter-spacing: 1px;
}

.panel p {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.badgelabel {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9rem;
    color: #fff;
}
.inline { background: var(--c-inl); color: #000; }
.id { background: var(--c-id); }
.class { background: var(--c-cls); color: #000; }
.element { background: var(--c-elm); color: #000; }

#startBtn {
    background: var(--green);
    color: white;
    font-size: 1.5rem;
    margin-top: 1rem;
    box-shadow: 0 4px 0 #047857;
}

/* Arena */
.arena-header {
    text-align: center;
    margin-bottom: 2rem;
}
.arena-header h2 {
    font-family: var(--font-ui);
    font-size: 2rem;
    color: #fff;
    letter-spacing: 1px;
}

.fighters {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 2rem;
    position: relative;
}

@media (max-width: 768px) {
    .fighters { flex-direction: column; }
}

.vs-badge {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-ui);
    font-size: 3rem;
    color: var(--yellow);
    text-shadow: 0 4px 10px rgba(0,0,0,0.8);
    z-index: 10;
}

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

.card {
    flex: 1;
    background: var(--panel);
    border-radius: 16px;
    border: 4px solid transparent;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    transition: transform 0.2s;
}

.fighter-red { border-color: var(--red-dark); }
.fighter-blue { border-color: var(--blue-dark); }

.card:hover {
    transform: translateY(-5px);
}

.fighter-title {
    font-family: var(--font-ui);
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 1rem;
    letter-spacing: 1px;
}
.fighter-red .fighter-title { color: var(--red); }
.fighter-blue .fighter-title { color: var(--blue); }

.code-container {
    background: #030712;
    padding: 1.5rem;
    border-radius: 8px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
}

.code-container code {
    font-family: var(--font-code);
    font-size: 1.1rem;
    color: #e5e7eb;
    word-break: break-all;
}

.choose-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.5rem;
    color: white;
}
.fighter-red .choose-btn { background: var(--red); box-shadow: 0 4px 0 var(--red-dark); }
.fighter-blue .choose-btn { background: var(--blue); box-shadow: 0 4px 0 var(--blue-dark); }

/* Breakdown Bars */
.breakdown {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed #374151;
}

.bar-row {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.bar-row .label {
    width: 30px;
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--muted);
}

.bar-row .track {
    flex: 1;
    height: 12px;
    background: #111827;
    border-radius: 6px;
    overflow: hidden;
}

.bar-row .fill {
    height: 100%;
    width: 0%;
    transition: width 0.5s ease-out;
}
.fill.imp { background: var(--c-imp); }
.fill.inl { background: var(--c-inl); }
.fill.id { background: var(--c-id); }
.fill.cls { background: var(--c-cls); }
.fill.elm { background: var(--c-elm); }

.bar-row .val {
    width: 20px;
    text-align: right;
    font-family: var(--font-code);
    font-size: 0.9rem;
}

/* Result Overlay */
#resultOverlay {
    text-align: center;
    margin-top: 2rem;
    padding: 1.5rem;
    background: #1f2937;
    border-radius: 12px;
    border: 2px dashed #4b5563;
    animation: fadeIn 0.3s;
}

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

#resultOverlay h2 {
    font-family: var(--font-ui);
    font-size: 3rem;
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
}

#resultOverlay.correct h2 { color: var(--green); }
#resultOverlay.wrong h2 { color: var(--red); }

#resultDesc {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

#nextBtn {
    background: var(--yellow);
    color: #111827;
    box-shadow: 0 4px 0 #b45309;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: var(--panel);
    padding: 2rem;
    border-radius: 12px;
    border: 2px solid var(--blue);
    min-width: 300px;
    max-height: 80vh;
    overflow-y: auto;
}

.close-btn {
    float: right;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--red);
}

.modal h2 {
    font-family: var(--font-ui);
    color: var(--yellow);
    margin-bottom: 1rem;
    font-size: 2rem;
    letter-spacing: 1px;
}

#leaderboardList {
    list-style: none;
}

#leaderboardList li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px dashed #374151;
    font-family: var(--font-code);
}
