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

:root {
    --bg-primary: #06070d;
    --bg-secondary: #0d1120;
    --panel-bg: rgba(12, 17, 30, 0.84);
    --panel-strong: rgba(9, 13, 24, 0.96);
    --accent-cyan: #53f3ff;
    --accent-blue: #6ba7ff;
    --accent-lime: #d4ff62;
    --accent-pink: #ff70cb;
    --text-primary: #f2f8ff;
    --text-secondary: #a1b3c9;
    --text-dim: #6e7f95;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
    --cell-size: 70px;
}

body {
    min-height: 100vh;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-primary);
    background:
        radial-gradient(circle at 18% 20%, rgba(83, 243, 255, 0.16), transparent 23%),
        radial-gradient(circle at 82% 18%, rgba(255, 112, 203, 0.14), transparent 22%),
        radial-gradient(circle at 70% 80%, rgba(107, 167, 255, 0.14), transparent 24%),
        linear-gradient(180deg, #05070c 0%, #0a0f18 56%, #05070d 100%);
    overflow-x: hidden;
}

.grid-bg {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(83, 243, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(83, 243, 255, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.22;
    pointer-events: none;
}

.glow {
    position: fixed;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.18;
    pointer-events: none;
}

.glow-left {
    top: 120px;
    left: -80px;
    background: var(--accent-cyan);
}

.glow-right {
    right: -90px;
    bottom: 60px;
    background: var(--accent-pink);
}

.back-link {
    position: fixed;
    top: 20px;
    left: 20px;
    color: #00f5d4;
    text-decoration: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    padding: 10px 20px;
    border: 2px solid #00f5d4;
    background: rgba(0, 0, 0, 0.8);
    transition: all 0.3s;
    z-index: 1000;
}

.back-link:hover {
    background: #00f5d4;
    color: #0a0a0a;
    box-shadow: 0 0 20px rgba(0, 245, 212, 0.5);
}

.container {
    position: relative;
    z-index: 1;
    width: min(1420px, calc(100% - 32px));
    margin: 0 auto;
    padding: 84px 0 32px;
}

.hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: end;
    margin-bottom: 24px;
}

.eyebrow,
.section-kicker,
.metric-card span {
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.eyebrow,
.section-kicker {
    font-size: 12px;
    color: var(--accent-cyan);
}

.title {
    margin-top: 8px;
    font-size: clamp(2.8rem, 7vw, 5.1rem);
    line-height: 0.92;
    letter-spacing: -0.05em;
}

.subtitle {
    margin-top: 14px;
    max-width: 680px;
    color: var(--text-secondary);
    font-size: 1.04rem;
}

.hero-metrics {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.metric-card {
    min-width: 160px;
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(12, 18, 32, 0.92), rgba(9, 13, 24, 0.76));
    box-shadow: var(--shadow);
}

.metric-card span {
    font-size: 11px;
    color: var(--text-dim);
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 1.18rem;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(310px, 360px);
    gap: 24px;
    align-items: start;
}

.game-shell,
.side-panel {
    border-radius: 24px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(11, 15, 28, 0.95), rgba(7, 10, 18, 0.88));
    box-shadow: var(--shadow);
}

.game-shell {
    padding: 22px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar h2,
.panel-block h2 {
    margin-top: 8px;
    font-size: 1.3rem;
    letter-spacing: -0.03em;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.ghost-btn,
.primary-btn {
    border: 1px solid var(--border);
    cursor: pointer;
    font: inherit;
    transition: transform 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.ghost-btn {
    padding: 12px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.primary-btn {
    padding: 12px 18px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent-lime), #efff92);
    color: #11151d;
    font-weight: 700;
}

.ghost-btn:hover,
.primary-btn:hover {
    transform: translateY(-1px);
}

.ghost-btn:disabled,
.primary-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.board-stage {
    position: relative;
    margin-top: 18px;
    padding: 18px;
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.02)),
        linear-gradient(180deg, rgba(14, 20, 35, 0.98), rgba(8, 11, 18, 0.9));
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.board {
    position: relative;
    display: grid;
    grid-template-columns: repeat(8, var(--cell-size));
    grid-template-rows: repeat(8, var(--cell-size));
    gap: 8px;
    width: fit-content;
}

.board-cell {
    position: relative;
    width: var(--cell-size);
    height: var(--cell-size);
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, rgba(83, 243, 255, 0.08), rgba(255, 255, 255, 0.02)), #101725;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.board-cell:disabled {
    opacity: 1;
    cursor: default;
}

.board-cell::after {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    pointer-events: none;
}

.board-cell.wall {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)), #2a3240;
}

.board-cell.emitter {
    background: linear-gradient(180deg, rgba(83, 243, 255, 0.18), rgba(255, 255, 255, 0.02)), #112232;
}

.board-cell.target {
    background: linear-gradient(180deg, rgba(255, 112, 203, 0.18), rgba(255, 255, 255, 0.02)), #23122d;
}

.board-cell.target.hit {
    box-shadow: 0 0 26px rgba(212, 255, 98, 0.45), inset 0 0 22px rgba(212, 255, 98, 0.18);
}

.board-cell.mirror {
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease;
}

.board-cell.mirror:hover {
    transform: translateY(-2px);
    border-color: rgba(83, 243, 255, 0.45);
}

.cell-content {
    position: relative;
    z-index: 2;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--text-primary);
}

.mirror-symbol {
    font-size: 1.9rem;
    color: var(--accent-cyan);
    text-shadow: 0 0 18px rgba(83, 243, 255, 0.35);
}

.wall-symbol {
    font-size: 1.4rem;
    color: #b8c7d8;
}

.emitter-symbol {
    font-size: 1.5rem;
    color: var(--accent-cyan);
}

.target-symbol {
    font-size: 1.45rem;
    color: var(--accent-pink);
}

.target.hit .target-symbol {
    color: var(--accent-lime);
}

.beam-layer {
    position: absolute;
    inset: 18px;
    pointer-events: none;
    overflow: visible;
}

.side-panel {
    padding: 20px;
    position: sticky;
    top: 22px;
}

.panel-block + .panel-block {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.mission-text,
.tips-list {
    margin-top: 16px;
    color: var(--text-secondary);
}

.tips-list {
    display: grid;
    gap: 10px;
    font-size: 0.95rem;
}

.legend-list,
.log-panel {
    margin-top: 16px;
}

.legend-list {
    display: grid;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.legend-chip {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
}

.legend-chip.emitter { color: var(--accent-cyan); }
.legend-chip.mirror { color: var(--accent-cyan); }
.legend-chip.wall { color: #c2ccd8; }
.legend-chip.target { color: var(--accent-pink); }

.log-panel {
    display: grid;
    gap: 10px;
}

.log-entry {
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
}

@media (max-width: 1200px) {
    .hero {
        display: block;
    }

    .hero-metrics {
        margin-top: 18px;
        justify-content: flex-start;
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    .side-panel {
        position: static;
    }
}

@media (max-width: 860px) {
    .container {
        width: min(100% - 20px, 1420px);
        padding-top: 78px;
    }

    .game-shell,
    .side-panel {
        padding: 16px;
    }

    .toolbar {
        display: block;
    }

    .toolbar-actions {
        margin-top: 14px;
    }

    .board-stage {
        overflow-x: auto;
    }

    :root {
        --cell-size: 56px;
    }
}
