* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg: #05060f;
    --panel: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.10);
    --cyan: #6ee7ff;
    --violet: #a78bfa;
    --gold: #fbbf24;
    --red: #ff6b6b;
    --text: #e7ecff;
    --dim: #8b95c0;
}

html, body {
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 14px;
    font-family: 'Exo 2', 'Segoe UI', system-ui, -apple-system, sans-serif;
    touch-action: none;
    overflow: auto;
}

.bg-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(600px 400px at 20% 10%, rgba(110, 231, 255, 0.10), transparent 60%),
        radial-gradient(700px 500px at 85% 85%, rgba(167, 139, 250, 0.12), transparent 60%);
}

.app {
    position: relative;
    width: 100%;
    max-width: 664px;
    background: linear-gradient(180deg, rgba(20, 26, 58, 0.55), rgba(10, 13, 32, 0.75));
    border: 1px solid var(--border);
    border-radius: 26px;
    padding: 14px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(14px);
}

/* ---------- верхняя панель ---------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 14px 8px;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    font-size: 20px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(110, 231, 255, 0.18), rgba(167, 139, 250, 0.18));
    border: 1px solid rgba(110, 231, 255, 0.25);
    box-shadow: 0 0 18px rgba(110, 231, 255, 0.15);
}

.brand-text h1 {
    font-family: 'Russo One', 'Exo 2', sans-serif;
    font-size: 16px;
    letter-spacing: 2px;
    font-weight: 400;
    background: linear-gradient(90deg, var(--cyan), var(--violet));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.sub {
    font-size: 11px;
    color: var(--dim);
}

.sub b { color: var(--cyan); font-weight: 600; }

.stats {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
}

.stat {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    font-size: 14px;
    min-width: 52px;
    justify-content: center;
}

.stat .ico { font-size: 13px; opacity: 0.9; }

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    transition: 0.15s;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.10); }

/* ---------- сцена ---------- */
.stage {
    position: relative;
}

.wavebar {
    height: 5px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
    margin: 0 2px 8px 2px;
    border: 1px solid var(--border);
    flex: 1;
}

.lvlbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 2px;
}

.lvlbar-label {
    font-family: 'Russo One', sans-serif;
    font-size: 10px;
    font-weight: 400;
    color: var(--gold);
    white-space: nowrap;
    padding-bottom: 8px;
}

.wavebar-fill {
    height: 100%;
    width: 0%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--cyan), var(--violet));
    box-shadow: 0 0 10px rgba(110, 231, 255, 0.6);
    transition: width 0.3s ease;
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 18px;
    border: 1px solid var(--border);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 0 80px rgba(60, 90, 220, 0.12);
    background: #070a18;
    touch-action: none;
    max-height: 64vh;
}

/* ---------- управление ---------- */
.controls {
    margin-top: 14px;
    display: grid;
    gap: 12px;
}

.seg {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
}

.seg-btn {
    flex: 1;
    padding: 9px 8px;
    border: none;
    border-radius: 11px;
    background: transparent;
    color: var(--dim);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: 0.15s;
}

.seg-btn.active {
    background: linear-gradient(135deg, rgba(110, 231, 255, 0.22), rgba(167, 139, 250, 0.22));
    color: var(--text);
    box-shadow: inset 0 0 0 1px rgba(110, 231, 255, 0.35);
}

.shop {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    min-width: 0;
}

.shop-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    transition: 0.15s;
    text-align: left;
}

.shop-btn:hover { background: rgba(255, 255, 255, 0.09); transform: translateY(-1px); }
.shop-btn:active { transform: translateY(0); }
.shop-btn:disabled { opacity: 0.4; pointer-events: none; }

.sb-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    font-size: 16px;
    border-radius: 11px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.02));
    border: 1px solid var(--border);
}

.sb-body { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.sb-body b { font-size: 12px; font-weight: 700; white-space: normal; overflow-wrap: break-word; }
.sb-body .cost { font-size: 10.5px; color: var(--gold); margin-top: 2px; white-space: nowrap; }

.stat b {
    font-family: 'Russo One', sans-serif;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.sb-lv {
    margin-left: auto;
    font-family: 'Russo One', sans-serif;
    font-size: 10px;
    font-weight: 400;
    color: var(--cyan);
    background: rgba(110, 231, 255, 0.10);
    border: 1px solid rgba(110, 231, 255, 0.25);
    padding: 2px 7px;
    border-radius: 99px;
    white-space: nowrap;
}

@media (max-width: 560px) {
    .shop { grid-template-columns: repeat(2, 1fr); }
    .stats { margin-left: 0; width: 100%; justify-content: flex-start; }
    .topbar { gap: 8px; }
    .app { padding: 10px; border-radius: 20px; }
}
