:root {
    --bg: #0f1320;
    --panel: #171c2d;
    --panel-soft: #1c2337;
    --line: #2a3450;
    --text: #eef2ff;
    --muted: #9aa6c7;
    --accent: #6ea8fe;
    --accent-2: #76e4b3;
    --danger: #ff6b6b;
    --success: #68d391;
    --warning: #f6c453;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: Inter, Arial, sans-serif;
    background: linear-gradient(180deg, #0c1020 0%, #12182a 100%);
    color: var(--text);
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
img, iframe, canvas { max-width: 100%; display: block; }

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(12px);
    background: rgba(10, 14, 24, 0.82);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.header-inner, .footer-inner, .section-head, .hero-actions, .header-actions, .game-toolbar, .task-actions, .modal-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-inner, .footer-inner {
    justify-content: space-between;
    min-height: 74px;
}

.nav {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}
.nav a {
    color: var(--muted);
}
.nav a:hover {
    color: var(--text);
}

.logo {
    font-weight: 800;
    letter-spacing: 0.06em;
    font-size: 1.25rem;
}

.site-main {
    min-height: calc(100vh - 160px);
    padding-bottom: 48px;
}

.site-footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    color: var(--muted);
}

.section {
    padding: 28px 0;
}

.section-top { margin-top: 20px; }

.hero-section {
    padding: 26px 0 12px;
}

.hero-card, .card, .stat-card, .modal-card {
    background: linear-gradient(180deg, rgba(31, 39, 62, 0.96), rgba(20, 26, 42, 0.96));
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.hero-card {
    padding: 28px;
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 24px;
}

.hero-card.center {
    text-align: center;
    max-width: 700px;
    margin: 40px auto;
}

.card {
    padding: 22px;
}

.card.subtle {
    background: var(--panel-soft);
}

.grid {
    display: grid;
    gap: 18px;
}

.cards-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.profile-grid {
    grid-template-columns: 0.8fr 1.2fr;
}

.admin-grid {
    grid-template-columns: 1fr;
    gap: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.bonus-stats {
    margin: 22px 0;
}

.stat-card {
    padding: 18px;
    text-align: center;
}

.stat-card strong, .big-balance {
    display: block;
    font-size: 2rem;
    font-weight: 800;
}

.big-balance {
    margin: 16px 0;
    color: var(--accent-2);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
    padding: 0 12px;
    background: rgba(110, 168, 254, 0.14);
    border: 1px solid rgba(110, 168, 254, 0.24);
    color: #d8e7ff;
    border-radius: 999px;
    font-size: 0.84rem;
    margin-bottom: 10px;
}

.btn {
    border: 0;
    cursor: pointer;
    border-radius: 14px;
    min-height: 44px;
    padding: 0 18px;
    background: linear-gradient(180deg, #69a8ff, #4b84e3);
    color: #08101b;
    font-weight: 700;
    transition: transform .15s ease, opacity .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}
.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.14);
}
.btn-danger {
    background: linear-gradient(180deg, #ff8e8e, #ff5f5f);
    color: #250707;
}

.balance-pill {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(118, 228, 179, 0.12);
    border: 1px solid rgba(118, 228, 179, 0.22);
    color: #d8ffef;
}

.alert {
    margin-top: 18px;
    border-radius: 14px;
    padding: 14px 16px;
    border: 1px solid transparent;
}
.alert-success {
    background: rgba(104, 211, 145, 0.12);
    border-color: rgba(104, 211, 145, 0.22);
}
.alert-error {
    background: rgba(255, 107, 107, 0.12);
    border-color: rgba(255, 107, 107, 0.24);
}
.alert-info {
    background: rgba(110, 168, 254, 0.12);
    border-color: rgba(110, 168, 254, 0.24);
}

.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid label,
.form-grid .field {
    display: grid;
    gap: 7px;
}

input, textarea, select {
    width: 100%;
    min-height: 44px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(8, 12, 20, 0.65);
    color: var(--text);
    padding: 12px 14px;
    font: inherit;
}
textarea { resize: vertical; min-height: 120px; }

.section-head {
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.stack { display: grid; gap: 18px; }

.muted {
    color: var(--muted);
}

.lead {
    font-size: 1.08rem;
    color: #dce6ff;
}

.ordered, .mini-list {
    margin: 12px 0 0;
    padding-left: 18px;
    color: var(--muted);
}

.narrow {
    max-width: 760px;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
}
th, td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-align: left;
}
th {
    color: var(--muted);
    font-weight: 600;
}
.table-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.table-actions form { margin: 0; }

.ad-slot {
    border-radius: 18px;
    min-height: 80px;
    padding: 16px;
    margin-bottom: 18px;
    background: rgba(255,255,255,0.04);
    border: 1px dashed rgba(255,255,255,0.12);
    overflow: hidden;
}
.ad-slot:empty::before {
    content: "Рекламный слот пуст. Код можно вставить в админке.";
    color: var(--muted);
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
}
.side-stack {
    display: grid;
    gap: 18px;
    align-content: start;
}

.game-shell {
    position: relative;
}

.game-frame-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #0b0f1a;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
}
.game-frame-wrap iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #0b0f1a;
}
.frame-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    text-align: center;
    background: rgba(7, 9, 15, 0.6);
    color: var(--muted);
}
.frame-overlay.hidden {
    display: none;
}

.score-panel {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.score-panel div {
    min-width: 92px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255,255,255,0.04);
}
.score-panel span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
}
.score-panel strong {
    font-size: 1.1rem;
}

.inline {
    margin: 16px 0;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 50;
}
.modal.active {
    display: block;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 7, 12, 0.75);
}
.modal-card {
    position: relative;
    z-index: 1;
    width: min(680px, calc(100% - 24px));
    margin: 8vh auto 0;
    padding: 22px;
}

.blog-content {
    white-space: pre-wrap;
}

.center {
    text-align: center;
}

.narrow .card {
    margin-top: 16px;
}

.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.task-card {
    position: relative;
}

.game-card .btn,
.task-actions .btn,
.hero-actions .btn {
    width: max-content;
}

.admin-header {
    position: static;
}

.toast-wrap {
    position: fixed;
    z-index: 70;
    right: 18px;
    bottom: 18px;
    display: grid;
    gap: 10px;
}
.toast {
    min-width: 280px;
    max-width: 360px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(14, 18, 30, 0.94);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: var(--shadow);
}
.toast.success { border-color: rgba(104, 211, 145, 0.32); }
.toast.error { border-color: rgba(255, 107, 107, 0.32); }
.toast.info { border-color: rgba(110, 168, 254, 0.32); }

@media (max-width: 980px) {
    .cards-3,
    .profile-grid,
    .game-layout,
    .hero-card {
        grid-template-columns: 1fr;
    }
    .game-layout {
        gap: 18px;
    }
}

@media (max-width: 720px) {
    .header-inner,
    .footer-inner,
    .section-head,
    .header-actions,
    .hero-actions {
        flex-direction: column;
        align-items: flex-start;
    }
    .header-actions form {
        width: 100%;
    }
    .btn, .header-actions .btn {
        width: 100%;
    }
    .stats-grid,
    .two-col {
        grid-template-columns: 1fr;
    }
    .container {
        width: min(100% - 20px, 1180px);
    }
}
