:root {
    --bg-dark: #090e1a;
    --bg-panel: #0f172a;
    --bg-card: #1e293b;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-gold: rgba(245, 158, 11, 0.4);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-gold: #f59e0b;
    --accent-emerald: #10b981;
    --accent-red: #ef4444;
    --accent-sky: #0284c7;
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* TOPBAR */
.game-topbar {
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s;
}

.back-link:hover {
    color: #fff;
}

.brand-badge {
    font-family: var(--font-mono);
    font-weight: 900;
    color: var(--accent-red);
    background: #090e1a;
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.game-logo-badge {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(15, 23, 42, 0.8));
    border: 1px solid var(--border-gold);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #fde68a;
}

.game-logo-badge span {
    color: #fff;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-pill {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 800;
}

/* ARENA GRID */
.arena-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 24px;
    flex: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* CODE PANEL */
.code-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mission-header {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-gold);
    border-radius: 12px;
    padding: 18px 20px;
}

.mission-tag {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    display: inline-block;
    margin-bottom: 8px;
}

.mission-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 8px;
}

.mission-desc {
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.6;
}

/* SELECTOR CARD */
.selector-card {
    background: #090e1a;
    border: 1.5px solid var(--border-gold);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.selector-card-header {
    background: #0f172a;
    padding: 10px 16px;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.selector-input-wrap {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    gap: 12px;
    background: #060a12;
}

.selector-prefix {
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--accent-gold);
}

.selector-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-family: var(--font-mono);
    font-size: 1.05rem;
}

.btn-fire {
    background: var(--accent-gold);
    color: #000;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-fire:hover {
    background: #fbbf24;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
}

.selector-card-footer {
    background: #0f172a;
    padding: 8px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.76rem;
    color: var(--text-muted);
}

.btn-clean {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.76rem;
    cursor: pointer;
}

/* HTML VIEWER */
.html-viewer-card {
    background: #090e1a;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.viewer-header {
    background: #0f172a;
    padding: 8px 14px;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.html-pre {
    padding: 14px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: #38bdf8;
    line-height: 1.6;
    overflow-x: auto;
    max-height: 190px;
}

.feedback-box {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.88rem;
    line-height: 1.5;
    display: none;
}

.feedback-box.success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid #10b981;
    color: #a7f3d0;
    display: block;
}

.feedback-box.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid #ef4444;
    color: #fca5a5;
    display: block;
}

/* BATTLEGROUND */
.battleground-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.battleground-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.battleground-header h3 {
    font-size: 0.92rem;
    font-weight: 800;
}

.target-counter {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    font-size: 0.74rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
}

.battleground-viewport {
    background: #060a12;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    padding: 24px;
    flex: 1;
    min-height: 340px;
    overflow: auto;
}

/* ELEMENT STYLING IN BATTLEGROUND */
.ninja-node {
    padding: 12px 16px;
    margin: 8px 0;
    border-radius: 8px;
    background: #1e293b;
    border: 2px solid transparent;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ninja-node.is-target {
    border-color: #f59e0b;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.35);
    animation: targetGlow 1.6s infinite alternate;
}

@keyframes targetGlow {
    from { box-shadow: 0 0 8px rgba(245, 158, 11, 0.2); }
    to { box-shadow: 0 0 20px rgba(245, 158, 11, 0.6); }
}

.ninja-node.hit-success {
    background: #10b981 !important;
    border-color: #34d399 !important;
    color: #042f2e !important;
    transform: scale(1.02);
}

.ninja-node.hit-wrong {
    background: #ef4444 !important;
    border-color: #f87171 !important;
    color: #fff !important;
}

.ninja-box-group {
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 8px;
    margin: 8px 0;
}

.legend-bar {
    display: flex;
    gap: 16px;
    margin-top: 14px;
    font-size: 0.74rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-dot.target { background: #f59e0b; }
.legend-dot.hit { background: #10b981; }
.legend-dot.wrong { background: #ef4444; }

/* MODAL */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background: #0f172a;
    border: 2px solid var(--accent-gold);
    border-radius: 16px;
    padding: 36px 30px;
    max-width: 520px;
    width: 90%;
    text-align: center;
}

.final-score {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--accent-gold);
    margin: 16px 0;
    font-family: var(--font-mono);
}

@media (max-width: 960px) {
    .arena-grid {
        grid-template-columns: 1fr;
    }
}
