/* Мультяшная тема: толстые тёмные обводки, глянцевые панели с бликом сверху,
   «конфетные» объёмные кнопки, которые вдавливаются при нажатии, тяжёлые заголовки с обводкой и тенью,
   золотой ободок у главных окон. Цвета — подводные: бирюза, морская синь, сочная зелень, золото. */

:root {
    --bg: #0b3a6e;
    --ink: #0a1f2e;                 /* цвет всех обводок */
    --panel-top: #1f6f8f;
    --panel-bottom: #114a66;
    --panel: linear-gradient(180deg, var(--panel-top) 0%, var(--panel-bottom) 100%);
    --panel-flat: rgba(10, 52, 74, 0.92);
    --panel-border: var(--ink);
    --gold: #ffd45e;
    --gold-dark: #b9811c;
    --text: #fbfff4;
    --muted: #b9e3ea;
    --accent: #8fe85a;
    --accent-dark: #3f8f1d;
    --accent-2: #5fd8f0;
    --accent-2-dark: #1d7d9a;
    --danger: #ff6b5e;
    --danger-dark: #a32a20;
    --pink: #ff7ab8;
    --radius: 18px;
    --outline: 3px solid var(--ink);
    --pop: 0 5px 0 rgba(4, 16, 26, 0.55);
    --gloss: inset 0 2px 0 rgba(255, 255, 255, 0.35), inset 0 -4px 0 rgba(0, 0, 0, 0.18);
    --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
    --font-display: "Segoe UI Black", "Arial Black", "Trebuchet MS", sans-serif;
}

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
}

a { color: var(--gold); font-weight: 700; text-decoration: none; }
a:hover { text-decoration: underline; }

/* обводка текста для заголовков и цифр */
.toon-text, .logo, .ed-head h2, .death h2, .level-banner b, .leaderboard-title, .diet-title {
    font-family: var(--font-display);
    -webkit-text-stroke: 1px var(--ink);
    paint-order: stroke fill;
    text-shadow: 0 3px 0 var(--ink);
}

/* ---------- кнопки-конфетки ---------- */

button {
    font: 800 1rem var(--font);
    cursor: pointer;
    border: var(--outline);
    border-radius: 999px;
    padding: 0.55rem 1.4rem;
    color: #fff;
    background: linear-gradient(180deg, #b6f77f 0%, var(--accent) 45%, #5cc237 100%);
    box-shadow: var(--gloss), 0 4px 0 var(--accent-dark), 0 6px 0 var(--ink);
    text-shadow: 0 2px 0 rgba(10, 31, 46, 0.6);
    transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
button:hover { filter: brightness(1.08) saturate(1.1); transform: translateY(-1px); }
button:active { transform: translateY(4px); box-shadow: var(--gloss), 0 0 0 var(--accent-dark), 0 2px 0 var(--ink); }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.4); transform: none; }
button.secondary {
    background: linear-gradient(180deg, #9ae9ff 0%, var(--accent-2) 45%, #2fb3d4 100%);
    box-shadow: var(--gloss), 0 4px 0 var(--accent-2-dark), 0 6px 0 var(--ink);
}
button.secondary:active { box-shadow: var(--gloss), 0 0 0 var(--accent-2-dark), 0 2px 0 var(--ink); }
button.danger {
    background: linear-gradient(180deg, #ffa69b 0%, var(--danger) 45%, #e0483c 100%);
    box-shadow: var(--gloss), 0 4px 0 var(--danger-dark), 0 6px 0 var(--ink);
    color: #fff;
}

/* глянцевая панель: тёмная обводка, блик сверху, тень снизу */
.hud-panel, .game-status, .diet-card, .ed, .death, .level-banner, .game-controls, .mate-box {
    border: var(--outline);
    background: var(--panel);
    box-shadow: var(--gloss), var(--pop);
}

/* ---------- меню ---------- */

.menu {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.3rem;
    padding: 24px 16px;
    box-sizing: border-box;
    text-align: center;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.22) 0 14px, transparent 15px),
        radial-gradient(circle at 22% 30%, rgba(255, 255, 255, 0.18) 0 7px, transparent 8px),
        radial-gradient(circle at 82% 68%, rgba(255, 255, 255, 0.2) 0 18px, transparent 19px),
        radial-gradient(circle at 78% 60%, rgba(255, 255, 255, 0.16) 0 8px, transparent 9px),
        radial-gradient(circle at 70% 18%, rgba(255, 255, 255, 0.14) 0 10px, transparent 11px),
        radial-gradient(ellipse at 50% 0%, #6fd8e8 0%, #2a9bc0 30%, #0f5e93 65%, #0b3a6e 100%);
}
.menu::before, .menu::after {
    /* пушистые водоросли по краям */
    content: "";
    position: absolute;
    bottom: -40px;
    width: 340px;
    height: 340px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 40%, #8fe85a 0 22%, transparent 23%),
        radial-gradient(circle at 60% 30%, #6fd04a 0 20%, transparent 21%),
        radial-gradient(circle at 50% 65%, #5cc237 0 28%, transparent 29%);
    filter: drop-shadow(0 4px 0 var(--ink));
    opacity: 0.85;
    pointer-events: none;
}
.menu::before { left: -120px; }
.menu::after { right: -120px; transform: scaleX(-1); }
.menu > * { position: relative; z-index: 1; }

.logo {
    margin: 0;
    font-size: clamp(3.4rem, 11vw, 6.5rem);
    letter-spacing: 0.01em;
    color: #fff;
    -webkit-text-stroke: 3px var(--ink);
    text-shadow: 0 6px 0 var(--ink), 0 10px 24px rgba(0, 0, 0, 0.35);
    transform: rotate(-3deg);
    animation: logo-bob 4s ease-in-out infinite;
}
.logo span { color: var(--accent); display: inline-block; transform: rotate(4deg) translateY(4px); }
@keyframes logo-bob { 0%, 100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(-2deg) translateY(-6px); } }

.tagline {
    max-width: 34rem;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #eafcff;
    text-shadow: 0 2px 0 rgba(10, 31, 46, 0.6);
}

.join { display: flex; flex-direction: column; gap: 1.1rem; align-items: center; }
.join-row { display: flex; gap: 0.7rem; flex-wrap: wrap; justify-content: center; align-items: center; }
.join-row input {
    font: 700 1.05rem var(--font);
    padding: 0.6rem 1.1rem;
    border-radius: 999px;
    border: var(--outline);
    background: #fffdf2;
    color: var(--ink);
    min-width: 15rem;
    box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.12), 0 4px 0 var(--ink);
}
.join-row input::placeholder { color: #7a8f96; }
.join-row input:focus { outline: 3px solid var(--gold); outline-offset: 2px; }
.join-row button { font-size: 1.2rem; padding: 0.6rem 2rem; }

.diet-choice { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.diet-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 15.5rem;
    padding: 1rem 1.1rem 1.1rem;
    border-radius: var(--radius);
    text-align: left;
    cursor: pointer;
    transition: transform 0.12s;
}
.diet-card:hover { transform: translateY(-3px) rotate(-0.6deg); }
.diet-card.carn:hover { transform: translateY(-3px) rotate(0.6deg); }
.diet-card input { position: absolute; opacity: 0; pointer-events: none; }
.diet-card.herb { background: linear-gradient(180deg, #4fb05a 0%, #2b7a3c 100%); }
.diet-card.carn { background: linear-gradient(180deg, #d85a52 0%, #8e2a2a 100%); }
.diet-card:has(input:checked) { box-shadow: var(--gloss), 0 0 0 4px var(--gold), 0 0 0 7px var(--ink), 0 8px 0 rgba(4, 16, 26, 0.5); transform: translateY(-4px); }
.diet-card:has(input:focus-visible) { outline: 3px dashed var(--gold); outline-offset: 6px; }
.diet-title { font-size: 1.35rem; color: #fff; }
.diet-text { color: #f2fff0; font-size: 0.9rem; font-weight: 600; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }

.gallery-link { color: var(--gold); text-shadow: 0 2px 0 var(--ink); font-size: 1.05rem; }
.gallery-back { pointer-events: auto; display: inline-block; margin-top: 0.3rem; }

.rules {
    list-style: none;
    padding: 0.7rem 1.2rem;
    margin: 0;
    line-height: 1.9;
    font-weight: 600;
    color: #e2f7fb;
    border-radius: var(--radius);
    background: rgba(10, 31, 46, 0.35);
    border: 2px dashed rgba(255, 255, 255, 0.35);
}
.rules b { color: var(--gold); }

/* ---------- игра ---------- */

.game-root { position: fixed; inset: 0; overflow: hidden; cursor: crosshair; }
.game-root canvas { display: block; }

.game-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0.8rem 1.6rem;
    border-radius: var(--radius);
    font-weight: 800;
    display: none;
}
.game-status.visible { display: block; }

/* ---------- экран загрузки (пока грузятся скрипты, текстуры и мир) ---------- */

.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    background:
        radial-gradient(ellipse at 50% 35%, rgba(95, 216, 240, 0.35), transparent 60%),
        linear-gradient(180deg, #1a6f9a 0%, #0b3a6e 70%, #082a52 100%);
    transition: opacity 0.6s ease, visibility 0.6s;
}
.loading-screen.done { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-card { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; padding: 0 16px; text-align: center; }
.loading-title {
    font: 900 clamp(2.4rem, 8vw, 3.6rem) var(--font-display);
    color: #fff;
    -webkit-text-stroke: 2px var(--ink);
    paint-order: stroke fill;
    text-shadow: 0 4px 0 var(--ink);
    transform: rotate(-3deg);
}
.loading-title span { color: var(--accent); }
.loading-step { font-weight: 800; color: var(--muted); min-height: 1.4em; }
.loading-bar {
    width: min(320px, 80vw);
    height: 14px;
    border: var(--outline);
    border-radius: 99px;
    background: rgba(4, 16, 26, 0.45);
    overflow: hidden;
    box-shadow: var(--pop);
}
.loading-bar i {
    display: block;
    height: 100%;
    width: 5%;
    border-radius: 99px;
    background: linear-gradient(180deg, #c5ff8f, var(--accent) 55%, var(--accent-dark));
    transition: width 0.3s ease;
}
.loading-screen.failed .loading-bar { display: none; }
.loading-screen.failed .loading-step { color: var(--text); }

/* клетка-«амёба», которая дышит и переливается, пока ждём */
.loading-cell {
    position: relative;
    width: 84px;
    height: 84px;
    border: 4px solid var(--ink);
    border-radius: 50%;
    background: radial-gradient(circle at 38% 35%, #d4ffb0 0 12%, #8fe85a 40%, #3f8f1d 100%);
    box-shadow: var(--pop);
    animation: loading-wobble 2.4s ease-in-out infinite;
}
.loading-cell i {
    position: absolute;
    border-radius: 50%;
    background: rgba(20, 70, 20, 0.45);
}
.loading-cell i:nth-child(1) { width: 14px; height: 14px; left: 22px; top: 44px; }
.loading-cell i:nth-child(2) { width: 10px; height: 10px; left: 50px; top: 24px; }
.loading-cell i:nth-child(3) { width: 18px; height: 18px; left: 46px; top: 48px; background: rgba(255, 255, 255, 0.35); }
@keyframes loading-wobble {
    0%, 100% { border-radius: 50% 50% 50% 50%; transform: scale(1) rotate(0deg); }
    25% { border-radius: 58% 42% 52% 48%; transform: scale(1.05, 0.96) rotate(6deg); }
    50% { border-radius: 46% 54% 44% 56%; transform: scale(0.97, 1.04) rotate(-4deg); }
    75% { border-radius: 52% 48% 58% 42%; transform: scale(1.03, 0.98) rotate(3deg); }
}
@media (prefers-reduced-motion: reduce) { .loading-cell { animation: none; } }

.hud { position: fixed; inset: 0; pointer-events: none; user-select: none; }

.hud-panel {
    position: absolute;
    padding: 0.65rem 0.95rem 0.75rem;
    border-radius: var(--radius);
    font-weight: 700;
    text-shadow: 0 1px 0 rgba(10, 31, 46, 0.6);
}

.hud-me { top: 12px; left: 12px; min-width: 12rem; }
.hud-name { font: 900 1.15rem var(--font-display); -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; text-shadow: 0 2px 0 var(--ink); }
.hud-mass b { color: var(--accent); font: 900 1.35rem var(--font-display); -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; }
.hud-online { color: var(--muted); font-size: 0.85rem; }
.hud-diet { color: var(--muted); font-weight: 700; font-size: 0.85rem; margin-left: 0.3rem; -webkit-text-stroke: 0; }
.hud-dna b { color: var(--gold); font: 900 1.35rem var(--font-display); -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; }
.hud-evolve { pointer-events: auto; margin: 0.5rem 0 0.3rem; padding: 0.4rem 1rem; font-size: 0.95rem; }

.leaderboard { top: 12px; right: 12px; min-width: 12rem; font-size: 0.9rem; padding-top: 0.5rem; }
.leaderboard-title {
    font-size: 1.05rem;
    color: var(--gold);
    text-align: center;
    margin: -0.15rem -0.3rem 0.45rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px dashed rgba(255, 255, 255, 0.3);
}
.leaderboard ol { margin: 0; padding-left: 1.4rem; }
.leaderboard li { padding: 0.05rem 0; }
.leaderboard li::marker { color: var(--gold); font-weight: 900; }
.leaderboard li span { display: inline-flex; }
.leaderboard li span:last-child { float: right; margin-left: 1rem; color: var(--muted); }
.leaderboard li.bot { color: #d6eef2; font-weight: 600; }
.leaderboard li.me { color: var(--accent); font-weight: 900; }

.hud-help {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    color: #eafcff;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    padding: 0.3rem 0.9rem;
    border-radius: 999px;
    background: rgba(10, 31, 46, 0.45);
    text-shadow: 0 1px 0 var(--ink);
}

.death {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    text-align: center;
    padding: 1.4rem 2.3rem 1.6rem;
    border-radius: 24px;
    background: linear-gradient(180deg, #8e3a3a 0%, #5a1f26 100%);
    box-shadow: var(--gloss), 0 0 0 4px var(--gold), 0 0 0 7px var(--ink), 0 12px 0 rgba(4, 16, 26, 0.5);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    font-weight: 700;
}
.death h2 { margin: 0; font-size: 2rem; color: #ffb3a8; }
.death p { margin: 0; }
.death-note { color: #ffd9d3; font-size: 0.88rem; }
.death-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; margin-top: 0.3rem; }

/* ---------- редактор клетки ---------- */

.editor-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    box-sizing: border-box;
    background: radial-gradient(circle at 50% 40%, rgba(10, 60, 90, 0.35), rgba(4, 12, 20, 0.75));
    backdrop-filter: blur(4px);
}
.editor-host { width: min(1180px, 100%); height: min(790px, 100%); }
.ed {
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: 26px;
    box-shadow: var(--gloss), 0 0 0 4px var(--gold), 0 0 0 7px var(--ink), 0 14px 0 rgba(4, 16, 26, 0.5), 0 30px 60px rgba(0, 0, 0, 0.4);
    padding: 1rem 1.2rem;
    box-sizing: border-box;
    user-select: none;
    font-weight: 600;
}
.ed-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.ed-head h2 { margin: 0; font-size: 1.7rem; color: #fff; }
.ed-dna { font-weight: 800; text-shadow: 0 1px 0 var(--ink); }
.ed-dna b { color: var(--gold); font: 900 1.6rem var(--font-display); -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; text-shadow: 0 2px 0 var(--ink); }
.ed-main { flex: 1; min-height: 0; display: flex; gap: 1rem; margin: 0.8rem 0; }
.ed-stage {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    border-radius: 20px;
    overflow: hidden;
    border: var(--outline);
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.15), inset 0 8px 30px rgba(0, 0, 0, 0.35);
    background:
        radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.16) 0 10px, transparent 11px),
        radial-gradient(circle at 85% 75%, rgba(255, 255, 255, 0.12) 0 14px, transparent 15px),
        radial-gradient(circle at 50% 42%, #5cc8dc 0%, #2a8fb4 40%, #145a80 100%);
}
.ed-stage canvas { position: absolute; inset: 0; }
.ed-overlay { position: absolute; inset: 0; touch-action: none; }
.ed-overlay svg { display: block; }
.ed-nose { fill: #eafcff; font: 800 14px var(--font); text-anchor: end; paint-order: stroke; stroke: var(--ink); stroke-width: 3px; }
.ed-axis { stroke: rgba(255, 255, 255, 0.3); stroke-dasharray: 6 6; }
.ed-slot { fill: rgba(255, 255, 255, 0.22); stroke: var(--ink); stroke-width: 2; transition: r 0.08s; }
.ed-slot.busy { fill: rgba(255, 255, 255, 0.06); stroke: rgba(10, 31, 46, 0.4); }
.ed-slot.can { fill: rgba(143, 232, 90, 0.55); stroke: var(--ink); }
.ed-slot.hot { fill: var(--accent); stroke: var(--ink); stroke-width: 3; }
.ed-slot.hot-busy { fill: rgba(95, 216, 240, 0.7); stroke: var(--ink); stroke-width: 3; }
.ed-slot.mirror { fill: rgba(143, 232, 90, 0.45); stroke: var(--ink); stroke-dasharray: 3 3; }
.ed-slot.sel { stroke: var(--gold); stroke-width: 4; }
.ed-badge { font-size: 18px; text-anchor: middle; opacity: 0.95; pointer-events: none; }
.ed-badge.sel { font-size: 23px; opacity: 1; }
.ed-tip {
    position: absolute; display: none; pointer-events: none; padding: 0.3rem 0.65rem; border-radius: 10px;
    background: #fffdf2; color: var(--ink); border: var(--outline); font-size: 0.85rem; font-weight: 800; white-space: nowrap;
    box-shadow: 0 3px 0 var(--ink);
}
.ed-stage-tools { position: absolute; left: 10px; top: 10px; display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }
.ed-stage-tools label {
    display: flex; gap: 0.35rem; align-items: center; font-size: 0.9rem; font-weight: 800; padding: 0.3rem 0.75rem;
    border-radius: 999px; border: var(--outline); background: var(--panel); box-shadow: var(--gloss), 0 3px 0 var(--ink);
}
.ed-stage-tools input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.ed-stage-tools button { padding: 0.3rem 0.85rem; font-size: 0.88rem; }
.ed-stage-tools button:disabled { opacity: 0.5; }
.ed-hint {
    position: absolute; left: 10px; right: 10px; bottom: 8px; color: #f2fdff; font-size: 0.82rem; font-weight: 700;
    text-align: center; pointer-events: none; text-shadow: 0 1px 0 var(--ink), 0 0 6px rgba(10, 31, 46, 0.8);
}
.ed-side { flex: 0 0 340px; display: flex; flex-direction: column; gap: 0.6rem; min-height: 0; }
.ed-tabs { display: flex; gap: 0.4rem; padding: 0.25rem; border-radius: 999px; border: var(--outline); background: rgba(10, 31, 46, 0.45); }
.ed-tab {
    flex: 1; padding: 0.4rem; font-size: 0.95rem; color: #d7eef3;
    background: transparent; border: 0; box-shadow: none; text-shadow: 0 1px 0 var(--ink);
}
.ed-tab:active { transform: none; }
.ed-tab.on {
    color: #fff;
    background: linear-gradient(180deg, #ffe48f 0%, var(--gold) 50%, #e8a92e 100%);
    border: 2px solid var(--ink);
    box-shadow: var(--gloss), 0 3px 0 var(--ink);
    text-shadow: 0 2px 0 rgba(10, 31, 46, 0.7);
}
.ed-parts, .ed-colors { flex: 1; min-height: 170px; overflow-y: auto; padding: 0 6px 4px 2px; }
.ed-parts::-webkit-scrollbar, .ed-colors::-webkit-scrollbar { width: 10px; }
.ed-parts::-webkit-scrollbar-thumb, .ed-colors::-webkit-scrollbar-thumb { background: var(--gold); border: 2px solid var(--ink); border-radius: 999px; }
.ed-group { margin-bottom: 0.55rem; }
.ed-group-title {
    display: inline-block; color: var(--ink); font-size: 0.72rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.1em;
    margin: 0.35rem 0; padding: 0.1rem 0.6rem; border-radius: 999px; background: var(--gold); border: 2px solid var(--ink);
}
.ed-card {
    display: grid; grid-template-columns: 2.4rem 1fr auto; grid-template-rows: auto auto; gap: 0 0.55rem;
    width: 100%; text-align: left; margin-bottom: 0.45rem; padding: 0.5rem 0.7rem; border-radius: 14px;
    background: linear-gradient(180deg, #2a86a8 0%, #17607f 100%); color: var(--text);
    border: var(--outline); box-shadow: var(--gloss), 0 4px 0 var(--ink);
    font: 600 1rem var(--font); text-shadow: 0 1px 0 rgba(10, 31, 46, 0.6); cursor: grab;
}
.ed-card:hover { filter: brightness(1.1); transform: translateY(-2px); }
.ed-card:active { transform: translateY(2px); box-shadow: var(--gloss), 0 1px 0 var(--ink); }
.ed-card.on { background: linear-gradient(180deg, #7fd35a 0%, #3f9a2a 100%); }
.ed-card.cant { opacity: 0.65; }
.ed-card.locked { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.6); }
.ed-icon {
    grid-row: span 2; font-size: 1.5rem; align-self: center; text-align: center; width: 2.3rem; height: 2.3rem; line-height: 2.3rem;
    border-radius: 50%; background: #fffdf2; border: 2px solid var(--ink); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}
.ed-card-name { font-weight: 900; }
.ed-card-cost { color: var(--gold); font-weight: 900; text-align: right; -webkit-text-stroke: 0.5px var(--ink); }
.ed-card-desc { color: #d3eef4; font-size: 0.78rem; font-weight: 600; }
.ed-card-count { color: #d3eef4; font-size: 0.78rem; text-align: right; }
.ed-color { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.75rem; font-size: 0.92rem; font-weight: 800; }
.ed-color input[type=range] {
    -webkit-appearance: none; appearance: none; height: 16px; border-radius: 999px; border: 2px solid var(--ink);
    background: linear-gradient(to right, hsl(0,75%,55%), hsl(60,75%,55%), hsl(120,75%,55%), hsl(180,75%,55%), hsl(240,75%,55%), hsl(300,75%,55%), hsl(360,75%,55%));
}
.ed-color input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: var(--thumb, #fff); border: 3px solid var(--ink); box-shadow: 0 2px 0 var(--ink); }
.ed-color input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--thumb, #fff); border: 3px solid var(--ink); }
.ed-patterns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.4rem; margin-bottom: 0.75rem; }
.ed-patterns button {
    background: linear-gradient(180deg, #2a86a8 0%, #17607f 100%); color: var(--text); padding: 0.35rem; font-size: 0.88rem;
    box-shadow: var(--gloss), 0 3px 0 var(--ink); border-radius: 12px;
}
.ed-patterns button.on { background: linear-gradient(180deg, #ffe48f 0%, var(--gold) 50%, #e8a92e 100%); }
.ed-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 0.35rem; margin-bottom: 0.75rem; }
.ed-swatches button { height: 24px; border-radius: 8px; padding: 0; border: 2px solid var(--ink); box-shadow: 0 2px 0 var(--ink); }
.ed-stats {
    border: var(--outline); border-radius: 14px; padding: 0.45rem 0.7rem; font-size: 0.84rem; font-weight: 700;
    background: rgba(10, 31, 46, 0.4);
}
.ed-stat { display: grid; grid-template-columns: 4.8rem 1fr auto; gap: 0.5rem; align-items: center; margin: 0.18rem 0; }
.ed-stat span { color: #d3eef4; }
.ed-stat em { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.15); border: 2px solid var(--ink); overflow: hidden; }
.ed-stat em i {
    display: block; height: 100%;
    background: repeating-linear-gradient(-45deg, #a8f26f 0 6px, var(--accent) 6px 12px);
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
.ed-stat b { text-align: right; min-width: 2.6rem; color: #fff; }
.ed-stat b.wide { grid-column: 2 / 4; }
.ed-foot { display: flex; justify-content: flex-end; align-items: center; gap: 0.7rem; }
.ed-error { flex: 1; color: #ffb3a8; font-weight: 800; text-shadow: 0 1px 0 var(--ink); }
.ed-error.blink { animation: ed-blink 0.5s; }
.ed-error.info { color: #ffe08a; }
@keyframes ed-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.ed-save { font-size: 1.1rem; padding: 0.55rem 1.8rem; }
.ed-save:disabled { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 800px) {
    .ed-main { flex-direction: column; }
    .ed-side { flex: 1 1 auto; }
    .ed-stage { min-height: 300px; }
}

/* HEX-цвета */
.ed-color > span { font-size: 0.92rem; }
.ed-color-row { display: flex; gap: 0.5rem; align-items: center; }
.ed-color-row input[type=color] { width: 52px; height: 36px; padding: 0; border: var(--outline); border-radius: 10px; background: none; cursor: pointer; box-shadow: 0 3px 0 var(--ink); }
.ed-color-row input[type=text] {
    flex: 1; font: 800 1rem ui-monospace, Consolas, monospace; text-transform: uppercase; padding: 0.35rem 0.6rem;
    border-radius: 10px; border: var(--outline); background: #fffdf2; color: var(--ink); box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.12);
}
.ed-color-row input[type=text].bad { border-color: var(--danger); background: #ffe4e0; }

/* ---------- подсказки на игровом поле ---------- */

.game-ui { position: absolute; inset: 0; pointer-events: none; }
.level-banner {
    position: absolute; left: 50%; top: 16%; transform: translate(-50%, -10px) scale(0.9); text-align: center;
    padding: 0.8rem 2rem 0.9rem; border-radius: 22px; font-size: 1.15rem; font-weight: 800;
    background: linear-gradient(180deg, #2a86a8 0%, #145a80 100%);
    box-shadow: var(--gloss), 0 0 0 4px var(--gold), 0 0 0 7px var(--ink), 0 10px 0 rgba(4, 16, 26, 0.45);
    text-shadow: 0 2px 0 var(--ink);
    opacity: 0; transition: opacity 0.5s, transform 0.5s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.level-banner.visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.level-banner b { display: block; font-size: 2rem; color: var(--gold); }
.level-banner small { display: block; color: var(--muted); font-size: 0.88rem; margin-top: 0.3rem; }
.mate-box {
    position: absolute; left: 50%; bottom: 3.4rem; transform: translateX(-50%); padding: 0.45rem 1rem; border-radius: 999px;
    background: linear-gradient(180deg, #ff9ccb 0%, #c94d8a 100%); font-weight: 800; text-shadow: 0 1px 0 var(--ink);
    opacity: 0; transition: opacity 0.3s; text-align: center;
}
.mate-box.visible { opacity: 1; }
.mate-bar { display: none; width: 220px; height: 10px; margin: 0.35rem auto 0.1rem; border-radius: 999px; background: rgba(255, 255, 255, 0.25); border: 2px solid var(--ink); overflow: hidden; }
.mate-box.active .mate-bar { display: block; }
.mate-bar i { display: block; height: 100%; background: #fff0f7; transition: width 0.1s; }
.game-controls {
    position: absolute; right: 12px; bottom: 12px; display: flex; gap: 0.5rem; align-items: center; pointer-events: auto;
    padding: 0.35rem 0.8rem; border-radius: 999px; font-size: 0.88rem; font-weight: 800; text-shadow: 0 1px 0 var(--ink);
}
.game-controls label { display: flex; gap: 0.45rem; align-items: center; }
.game-controls input { width: 110px; accent-color: var(--gold); }
.cruise-val { min-width: 2.6rem; color: var(--gold); }
.sound-toggle {
    padding: 0.1rem 0.45rem; font-size: 1.1rem; background: #fffdf2; border: 2px solid var(--ink); box-shadow: 0 2px 0 var(--ink); text-shadow: none;
}
.sound-toggle:active { box-shadow: none; }
.hud-level { color: var(--gold); font-size: 0.85rem; margin-top: 0.25rem; }
.hud-progress { height: 12px; border-radius: 999px; background: rgba(10, 31, 46, 0.5); border: 2px solid var(--ink); overflow: hidden; margin: 0.3rem 0; }
.hud-progress i {
    display: block; height: 100%;
    background: repeating-linear-gradient(-45deg, #a8f26f 0 6px, var(--accent) 6px 12px);
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

@media (max-width: 1150px) {
    .hud-help { display: none; } /* иначе наезжает на ползунок скорости */
}
@media (max-width: 600px) {
    .leaderboard { font-size: 0.75rem; min-width: 8rem; }
}

/* ---------- ошибки Blazor ---------- */

.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "Произошла ошибка."; }

/* шкала энергии рывка */
.energy { display: flex; align-items: center; gap: 0.35rem; font-weight: 800; opacity: 0.75; transition: opacity 0.2s; }
.energy.ready { opacity: 1; }
.energy-bar { width: 90px; height: 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); border: 2px solid var(--ink); overflow: hidden; }
.energy-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffd23f, #fff2a0); transition: width 0.1s linear; }
.energy.wiggle .energy-bar { box-shadow: 0 0 10px #7fe8ff; }

/* ---------- новый редактор: плитки деталей и палитры ---------- */
.ed-group-title small { font-weight: 700; color: var(--ink); opacity: 0.75; text-transform: none; letter-spacing: 0; font-size: 0.7rem; margin-left: 0.3rem; }
.ed-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.ed-tile {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
    padding: 0.45rem 0.25rem 0.35rem; border-radius: 14px; border: var(--outline);
    background: linear-gradient(180deg, #4fb8d8 0%, #2a7fa6 100%); color: #fff; box-shadow: var(--gloss), 0 3px 0 var(--ink);
    cursor: pointer; font: inherit;
}
.ed-tile:hover { filter: brightness(1.1); transform: translateY(-2px); }
.ed-tile:active { transform: translateY(2px); }
.ed-tile.on { background: linear-gradient(180deg, #7fd35a 0%, #3f9a2a 100%); }
.ed-tile.cant { opacity: 0.6; }
.ed-tile.locked { opacity: 0.45; filter: grayscale(0.6); cursor: not-allowed; }
.ed-tile-icon { font-size: 1.6rem; line-height: 1.1; }
.ed-tile-name { font-weight: 900; font-size: 0.8rem; text-align: center; line-height: 1.05; }
.ed-tile-cost { color: var(--gold); font-weight: 900; font-size: 0.78rem; -webkit-text-stroke: 0.4px var(--ink); }
.ed-tile-count { position: absolute; left: 6px; top: 4px; font-weight: 900; font-size: 0.78rem; }
.ed-tile-minus {
    position: absolute; right: -6px; top: -6px; width: 22px; height: 22px; border-radius: 50%; line-height: 18px;
    background: #e8553e; border: 2px solid var(--ink); font-weight: 900; text-align: center;
}
.ed-tile-minus:hover { filter: brightness(1.2); }
.ed-color-title { font-weight: 900; margin: 0.2rem 0 0.35rem; }
.ed-patterns { grid-template-columns: repeat(3, 1fr); }
.ed-swatch.on { outline: 3px solid #fff; outline-offset: 1px; transform: scale(1.08); }

/* ---------- страница записи звуков ---------- */
.sounds-page { max-width: 980px; margin: 0 auto; padding: 1.5rem 1rem 3rem; color: var(--text); }
.sounds-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.sounds-head h1 { margin: 0; font-size: 2rem; color: #fff; }
.sounds-help { font-weight: 600; line-height: 1.45; text-shadow: 0 1px 0 var(--ink); }
.sounds-list { display: flex; flex-direction: column; gap: 0.5rem; }
.snd-row {
    display: grid; grid-template-columns: 1fr 7.5rem auto auto auto auto auto 240px; gap: 0.5rem; align-items: center;
    padding: 0.5rem 0.75rem; border-radius: 14px; border: var(--outline);
    background: linear-gradient(180deg, #2a86a8 0%, #17607f 100%); box-shadow: var(--gloss), 0 3px 0 var(--ink);
}
.snd-row.recording { background: linear-gradient(180deg, #d9584a 0%, #a3302a 100%); }
.snd-title { display: flex; flex-direction: column; }
.snd-title small { color: #d3eef4; font-weight: 600; }
.snd-state { font-size: 0.85rem; font-weight: 800; color: #ffe08a; }
.snd-row button { padding: 0.3rem 0.7rem; }
.snd-row button:disabled { opacity: 0.4; cursor: not-allowed; }
.snd-rec { min-width: 2.6rem; color: #ff5a4a; font-size: 1.1rem; }
.snd-wave { width: 240px; height: 36px; border-radius: 8px; background: rgba(10, 31, 46, 0.45); }
@media (max-width: 900px) {
    .snd-row { grid-template-columns: 1fr auto auto auto auto auto; }
    .snd-state, .snd-wave { grid-column: 1 / -1; }
}
