/* Shared design system for "Тренажёры и игры" (number-systems games family):
   bug-hunter, byte-speedrun, hex-hunter, step-battle, plus the shell nav
   injected into the calculator page too. Its own copy, standalone from
   ../css/shared.css — same convention as the rest of the site (each
   top-level tool is a standalone static subsystem). Visually distinct from
   the plain calculator skin on purpose: graph-paper background, tracked
   uppercase monospace labels, diamond bullets, navy ink, orange accent for
   streaks/records — matches the reference design the games were built from. */

:root {
    --bg: #faf9f5;
    --surface: #ffffff;
    --surface-2: #eef1f7;
    --ink: #0f1b2d;
    --text: #1b2430;
    --muted: #667085;
    --border: #e3e7ef;
    --border-strong: #cdd4e0;
    --primary: #2f66f3;
    --primary-dark: #1f4fce;
    --danger: #c62828;
    --success: #1fb15f;
    --accent: #e8982b;
    --accent-bg: #fff6e4;
    --accent-border: #f0ce93;
    --shadow: 0 1px 3px rgba(20, 30, 60, 0.08);
    --shadow-lg: 0 8px 30px rgba(20, 30, 60, 0.16);
    --r: 12px;
    --r-lg: 18px;
    --grid-line: rgba(47, 102, 243, 0.07);
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    background:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
        var(--bg);
    background-size: 24px 24px, 24px 24px, auto;
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
a { color: var(--primary); }
button { font-family: inherit; }

.kicker-diamond {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--mono);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary);
}
.kicker-diamond::before { content: "◆"; font-size: 9px; color: var(--accent); }

.label-mono {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ---------- Shell nav (injected on the calculator + every game) ---------- */

#games-shell-nav { flex: 0 0 auto; }
.shell-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.shell-logo { font-family: var(--mono); font-weight: 700; font-size: 16px; color: var(--ink); text-decoration: none; }
.shell-logo span { color: var(--primary); }
.shell-subtitle { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.shell-subtitle a { color: var(--muted); text-decoration: none; }
.shell-subtitle a:hover { color: var(--primary); text-decoration: underline; }
.shell-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.shell-sound {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    border-radius: var(--r);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: pointer;
}
.shell-sound.on { color: var(--primary); border-color: var(--primary); }

.shell-streak {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--r);
    border: 1px solid var(--accent-border);
    background: var(--accent-bg);
    font-family: var(--mono);
}
.shell-streak .n { font-size: 16px; font-weight: 700; color: var(--accent); }
.shell-streak .l { font-size: 9.5px; letter-spacing: 0.07em; text-transform: uppercase; color: #8a6a2a; line-height: 1.2; }

.shell-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font-size: 15px;
}
.shell-icon-btn:hover { border-color: var(--primary); color: var(--primary); }

.shell-tabs {
    display: flex;
    gap: 2px;
    padding: 0 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.shell-tab {
    display: flex;
    align-items: baseline;
    gap: 7px;
    padding: 12px 16px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
}
.shell-tab .num { font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--border-strong); }
.shell-tab:hover { color: var(--text); }
.shell-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.shell-tab.active .num { color: var(--primary); }

@media (max-width: 700px) {
    .shell-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 16px; overflow-x: visible; }
    .shell-tab { border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; white-space: normal; }
    .shell-tab.active { background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
}

/* ---------- Page shell ---------- */

main.game-main { flex: 1 1 auto; padding: 28px 24px 60px; display: flex; justify-content: center; }
.game-wrap { width: 100%; max-width: 880px; }

.game-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    padding: 22px 26px;
    margin-bottom: 20px;
}
.game-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.game-title { font-size: 26px; font-weight: 800; color: var(--ink); margin: 6px 0 0 0; letter-spacing: -0.01em; }
.game-desc { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 10px 0 0 0; }

.stat-box {
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 8px 14px;
    min-width: 72px;
    text-align: center;
}
.stat-box .label-mono { display: block; margin-bottom: 2px; }
.stat-box .value { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--ink); }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--r);
    border: 1px solid var(--border-strong);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text);
    background: var(--surface-2);
}

.legend-chips { display: flex; gap: 14px; flex-wrap: wrap; margin: 14px 0 0 0; padding: 0; list-style: none; }
.legend-chips li { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.legend-chips li::before { content: "◆"; font-size: 8px; color: var(--primary); }

.btn-game {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: var(--r);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}
.btn-game:hover { border-color: var(--primary); color: var(--primary); }
.btn-game:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-game.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-game.primary:hover { background: var(--primary-dark); color: #fff; }
.btn-game.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.segmented-game { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r); overflow: hidden; }
.segmented-game button {
    border: none;
    background: var(--surface);
    padding: 10px 16px;
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    border-right: 1px solid var(--border-strong);
}
.segmented-game button:last-child { border-right: none; }
.segmented-game button.active { background: var(--primary); color: #fff; }

/* Grid-paper stage area (column-math board backdrop) */
.stage-grid {
    border: 1px solid var(--border);
    border-radius: var(--r);
    background:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
        var(--surface);
    background-size: 20px 20px, 20px 20px, auto;
    padding: 28px 16px;
    display: flex;
    justify-content: center;
    overflow-x: auto;
}

.feedback-line {
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: var(--r);
    font-size: 13.5px;
    line-height: 1.5;
}
.feedback-line.info { background: #eaf0ff; color: #1b3a9c; }
.feedback-line.good { background: #e8f8ef; color: #136b3a; }
.feedback-line.bad { background: #fdecec; color: #8a1f1f; }

@keyframes shake-x {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}
.shake { animation: shake-x 0.3s ease; }

@keyframes pop-in {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.pop { animation: pop-in 0.22s ease; }

@media (max-width: 600px) {
    main.game-main { padding: 18px 14px 40px; }
    .game-card { padding: 16px 16px; }
    .game-title { font-size: 21px; }
}
