:root {
    --bg-page: #040b18;
    --bg-panel: rgba(9, 16, 32, 0.92);
    --bg-card: rgba(13, 24, 46, 0.9);
    --border-soft: rgba(96, 205, 255, 0.16);
    --border-strong: rgba(96, 205, 255, 0.3);
    --text-primary: #e7f4ff;
    --text-muted: rgba(181, 203, 232, 0.76);
    --accent-primary: #63f0ff;
    --accent-success: #70ffb2;
    --accent-warning: #ffc95a;
    --accent-critical: #ff7a88;
    --tile-a: rgba(25, 42, 74, 0.94);
    --tile-b: rgba(28, 52, 86, 0.94);
    --tile-c: rgba(36, 56, 102, 0.94);
    --tile-d: rgba(22, 68, 94, 0.94);
    --tile-e: rgba(54, 44, 102, 0.94);
    --shadow-soft: 0 28px 80px rgba(2, 8, 22, 0.6);
    --shadow-hover: 0 34px 90px rgba(8, 18, 38, 0.7);
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    font-family: "Inter", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 12%, rgba(99, 240, 255, 0.18), transparent 55%),
        radial-gradient(circle at 82% 18%, rgba(255, 118, 194, 0.16), transparent 60%),
        linear-gradient(180deg, #020713 0%, #050f22 38%, #040b18 100%);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 32px 24px;
}

.shell {
    width: min(1100px, 100%);
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.masthead {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    padding: 28px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 24px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-soft);
    backdrop-filter: blur(10px);
}

.masthead__body {
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.masthead__subtitle {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.5;
}

.masthead__meta {
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: flex-end;
}

.stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(80px, 1fr));
    gap: 12px;
}

.stat {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    border: 1px solid var(--border-soft);
    text-align: center;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.stat__label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stat__value {
    font-size: 1.25rem;
    font-weight: 600;
}

.actions {
    display: flex;
    gap: 12px;
}

.btn {
    border: 1px solid var(--border-strong);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.btn:hover,
.btn:focus-visible {
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn--primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #041421;
    font-weight: 600;
}

.lang-switch {
    display: flex;
    gap: 8px;
}

.lang-btn {
    border: 1px solid var(--border-soft);
    background: rgba(9, 16, 32, 0.6);
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.lang-btn.is-active {
    background: var(--accent-primary);
    color: #041421;
    border-color: var(--accent-primary);
    font-weight: 600;
}

.layout {
    display: grid;
    grid-template-columns: 1.4fr 0.9fr;
    gap: 28px;
}

.panel {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel__header h2,
.card__header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.panel__header p {
    margin: 6px 0 0;
    color: var(--text-muted);
    line-height: 1.5;
}

.board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-soft);
    background: var(--bg-card);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.board--target {
    grid-template-columns: repeat(3, 1fr);
}

.tile {
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    background: var(--bg-panel);
}

.tile[data-type="a"] { background: var(--tile-a); }
.tile[data-type="b"] { background: var(--tile-b); }
.tile[data-type="c"] { background: var(--tile-c); }
.tile[data-type="d"] { background: var(--tile-d); }
.tile[data-type="e"] { background: var(--tile-e); }

.tile.is-selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(93, 122, 137, 0.25);
}

.tile.is-match {
    border-color: var(--accent-success);
}

.tile.is-mismatch {
    border-color: var(--accent-critical);
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 18px;
    border: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.target {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.telemetry {
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 0.95rem;
}

.telemetry__row {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
}

.telemetry__row dd {
    margin: 0;
    font-weight: 600;
    color: var(--text-primary);
}

.telemetry__note {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.status-bar {
    background: var(--bg-panel);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    border: 1px solid var(--border-soft);
    font-size: 0.95rem;
    color: var(--text-muted);
    box-shadow: var(--shadow-soft);
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(47, 42, 37, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 20;
}

.overlay.hidden {
    display: none;
}

.overlay__panel {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 420px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 18px;
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-hover);
}

.overlay__title {
    margin: 0;
    font-size: 1.5rem;
    text-align: center;
}

.overlay__stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 1rem;
    color: var(--text-muted);
}

.overlay__stats strong {
    color: var(--text-primary);
}

.overlay__actions {
    display: flex;
    justify-content: center;
    gap: 14px;
}

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

    .panel {
        padding: 20px;
    }

    .board {
        gap: 8px;
    }
}

@media (max-width: 720px) {
    body {
        padding: 20px 16px;
    }

    .masthead {
        padding: 22px;
    }

    .masthead__meta {
        align-items: flex-start;
    }

    .stats {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
        width: 100%;
    }

    .actions {
        width: 100%;
        flex-direction: column;
    }

    .layout {
        gap: 20px;
    }

    .board {
        padding: 10px;
        gap: 6px;
    }
}
