:root {
    --bg-dark: #090e1a;
    --bg-panel: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #060a12;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-cyan: rgba(56, 189, 248, 0.4);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-cyan: #38bdf8;
    --accent-emerald: #10b981;
    --accent-red: #ef4444;
    --accent-amber: #f59e0b;
    --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(56, 189, 248, 0.15), rgba(15, 23, 42, 0.8));
    border: 1px solid var(--border-cyan);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #bae6fd;
}

.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: 1.1fr 1fr;
    gap: 20px;
    padding: 24px;
    flex: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* MISSION SECTION */
.editor-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.tag-badge {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 800;
    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;
    margin-bottom: 12px;
}

.cke-badge {
    font-size: 0.74rem;
    color: #34d399;
    font-weight: 600;
}

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

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

.code-wrapper {
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
}

.code-prefix {
    color: #64748b;
    margin-bottom: 4px;
}

.code-textarea {
    width: 100%;
    height: 110px;
    background: transparent;
    border: none;
    outline: none;
    color: #38bdf8;
    font-family: var(--font-mono);
    font-size: 0.98rem;
    line-height: 1.6;
    resize: none;
}

.editor-footer {
    background: #0f172a;
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

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

.btn-action:hover {
    background: #7dd3fc;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.4);
}

.btn-subtle {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.88rem;
    cursor: pointer;
}

.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;
}

/* TEST ARENA SECTION */
.test-arena-section {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.arena-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.arena-top h3 {
    font-size: 0.92rem;
    font-weight: 800;
}

.status-indicator {
    font-size: 0.74rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg-card);
    color: #f59e0b;
}

.stage-container {
    background: #060a12;
    border: 1.5px dashed rgba(56, 189, 248, 0.3);
    border-radius: 12px;
    height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.stage-target {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 2px solid var(--border-cyan);
    padding: 20px 30px;
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.stage-target:hover {
    transform: scale(1.04);
    box-shadow: 0 12px 30px rgba(56, 189, 248, 0.25);
}

.stage-target.active-hit {
    background: #10b981 !important;
    border-color: #34d399 !important;
    transform: scale(0.96);
}

.target-icon {
    font-size: 2.2rem;
    margin-bottom: 6px;
}

.target-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
}

.target-sub {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* EVENT LOG */
.event-log-card {
    background: #090e1a;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 180px;
}

.log-header {
    background: #0f172a;
    padding: 8px 12px;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.clear-log-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 4px;
    cursor: pointer;
}

.log-body {
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    overflow-y: auto;
    max-height: 160px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-entry {
    color: #94a3b8;
}

.log-entry.event-fired {
    color: #38bdf8;
    font-weight: bold;
}

.log-entry.event-success {
    color: #34d399;
    font-weight: bold;
}

.log-entry.system {
    color: #64748b;
}

/* 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-content {
    background: #0f172a;
    border: 2px solid var(--accent-cyan);
    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-cyan);
    margin: 16px 0;
    font-family: var(--font-mono);
}

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