/* ==================== Tokens ==================== */
:root {
    --bg: #fdf6ff;
    --surface: #ffffff;
    --text: #241a3d;
    --text-muted: #6b5f85;
    --text-faint: #a599c0;
    --border: #ecdcff;

    --purple: #7c3aed;
    --purple-dark: #5b21b6;
    --pink: #ec4899;
    --yellow: #f59e0b;
    --teal: #14b8a6;
    --green: #16a34a;
    --red: #ef4444;
    --red-soft: #fde2e2;
    --green-soft: #dcfce8;

    --radius-sm: 0.8rem;
    --radius-md: 1.25rem;
    --radius-lg: 2rem;
    --radius-pill: 999px;

    --shadow-sm: 0 2px 0 rgba(36, 26, 61, 0.06);
    --shadow-sticker: 0 4px 0 rgba(36, 26, 61, 0.10), 0 10px 20px -8px rgba(124, 58, 237, 0.18);
    --shadow-sticker-lg: 0 6px 0 rgba(36, 26, 61, 0.10), 0 16px 32px -10px rgba(124, 58, 237, 0.2);
    --shadow-pop: 0 18px 36px -12px rgba(124, 58, 237, 0.28);

    --font-display: 'Fredoka', system-ui, sans-serif;
    --font-body: 'Nunito', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', Consolas, monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.section-title {
    font-size: 1.3rem;
    margin: 2rem 0 1rem;
}

.section-title.no-margin { margin: 0; }

.count-pill {
    display: inline-block;
    background: var(--purple);
    color: white;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 800;
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-pill);
    vertical-align: middle;
    margin-left: 0.4rem;
}

/* ==================== Header ==================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(253, 246, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 3px solid var(--border);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.8rem 1.5rem;
    max-width: 1280px;
    margin: 0 auto;
}

.logo {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo strong { color: var(--purple); }

.logo-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    background: var(--purple);
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
}

.nav-links {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.nav-user {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-right: 0.2rem;
}

.nav-avatar, .author-avatar, .user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: var(--purple);
    color: white;
    font-size: 0.75rem;
    font-weight: 800;
    flex-shrink: 0;
}

.nav-btn {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius-pill);
    background: var(--surface);
    border: 2px solid var(--border);
    transition: all 0.15s ease;
}

.nav-btn:hover { transform: translateY(-2px); }

.nav-btn-primary {
    background: var(--purple);
    color: white;
    border-color: var(--purple-dark);
    box-shadow: var(--shadow-sm);
}

.nav-btn-primary:hover { background: var(--purple-dark); }

.nav-btn-ghost {
    background: none;
    border-color: transparent;
    color: var(--text-muted);
}

.nav-btn-ghost:hover { background: var(--surface); border-color: var(--border); }

/* User avatar dropdown menu */
.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 0.3rem 0.9rem 0.3rem 0.3rem;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text);
    transition: border-color 0.15s ease;
}

.user-menu-trigger:hover { border-color: var(--purple); transform: none; }

.user-menu-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-caret { font-size: 0.7rem; color: var(--text-faint); transition: transform 0.15s ease; }
.user-menu.open .user-menu-caret { transform: rotate(180deg); }

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 0.6rem);
    right: 0;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-pop);
    padding: 0.5rem;
    min-width: 190px;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 60;
}

.user-menu.open .user-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-dropdown a {
    display: block;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 0.87rem;
}

.user-menu-dropdown a:hover { background: var(--bg); }
.user-menu-dropdown a.user-menu-danger { color: var(--red); }
.user-menu-dropdown a.user-menu-danger:hover { background: var(--red-soft); }

.user-menu-divider {
    height: 2px;
    background: var(--border);
    margin: 0.3rem 0.2rem;
}

/* ==================== Hero ==================== */
.hero {
    position: relative;
    overflow: hidden;
    padding: 3.5rem 0 3rem;
    background: linear-gradient(180deg, #f3e8ff 0%, var(--bg) 100%);
}

.hero-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(2px);
    opacity: 0.5;
    z-index: 0;
}

.hero-blob-1 { width: 220px; height: 220px; background: var(--yellow); top: -60px; left: -60px; opacity: 0.35; }
.hero-blob-2 { width: 260px; height: 260px; background: var(--teal); bottom: -100px; right: -60px; opacity: 0.3; }
.hero-blob-3 { width: 140px; height: 140px; background: var(--pink); top: 30%; right: 15%; opacity: 0.25; }

.hero-inner {
    position: relative;
    z-index: 1;
    text-align: center;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 0.7rem;
}

.hero-sub {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 520px;
    margin: 0 auto 1.75rem;
}

.hero-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 480px;
    margin: 0 auto 1.5rem;
    background: var(--surface);
    border: 3px solid var(--text);
    border-radius: var(--radius-pill);
    padding: 0.4rem 0.4rem 0.4rem 1.2rem;
    box-shadow: var(--shadow-sticker);
}

.hero-search .search-icon { opacity: 0.5; }

.hero-search input {
    border: none;
    flex: 1;
    background: none;
    font-size: 0.95rem;
    padding: 0.4rem 0;
}

.hero-search input:focus { outline: none; box-shadow: none; }

.hero-search button {
    background: var(--purple);
    color: white;
    border: none;
    padding: 0.6rem 1.3rem;
    border-radius: var(--radius-pill);
    font-family: var(--font-display);
    font-weight: 600;
    cursor: pointer;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 700;
}

.hero-stat strong {
    font-size: 1.3rem;
    color: var(--purple);
    font-family: var(--font-display);
    margin-right: 0.25rem;
}

.btn-cta {
    display: inline-block;
    background: var(--pink);
    color: white;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    padding: 0.9rem 1.8rem;
    border-radius: var(--radius-pill);
    text-decoration: none;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 0 #be185d;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-cta:hover { transform: translateY(-2px); }
.btn-cta:active { transform: translateY(4px); box-shadow: 0 2px 0 #be185d; }

.btn-cta-small {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    box-shadow: 0 4px 0 #be185d;
}

/* ==================== App shell: sidebar + main (catalog page) ==================== */
.app-shell {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.75rem 1.5rem 3rem;
    display: grid;
    grid-template-columns: 230px 1fr;
    gap: 2rem;
    align-items: start;
}

.sidebar {
    position: sticky;
    top: 5.5rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sidebar-link {
    --tile-color: #7c3aed;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.92rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.sidebar-link-icon { font-size: 1.15rem; width: 1.5rem; text-align: center; }

.sidebar-link:hover { background: var(--surface); color: var(--text); }

.sidebar-link.active {
    background: color-mix(in srgb, var(--tile-color) 14%, white);
    color: var(--tile-color);
}

.catalog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.catalog-header h1 { font-size: 1.5rem; }

/* Категории на мобильных — горизонтальная лента вместо боковой панели */
.mobile-category-chips {
    display: none;
    gap: 0.6rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.mobile-category-chips::-webkit-scrollbar { display: none; }

/* ==================== Icon grid (square app-icon style tiles) ==================== */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1.5rem 1.1rem;
    margin-top: 1rem;
}

.icon-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: inherit;
    gap: 0.5rem;
}

.icon-tile-square {
    --tile-color: #7c3aed;
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: linear-gradient(135deg, var(--tile-color), color-mix(in srgb, var(--tile-color) 55%, white));
    border: 3px solid var(--text);
    box-shadow: var(--shadow-sticker);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.icon-tile:hover .icon-tile-square {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 8px 0 rgba(36, 26, 61, 0.1), 0 20px 30px -12px rgba(124, 58, 237, 0.3);
}

.icon-tile-badge {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    width: 1.9rem;
    height: 1.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 50%;
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
    z-index: 2;
}

.icon-tile-title {
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.icon-tile-author {
    font-size: 0.72rem;
    color: var(--text-faint);
    font-weight: 700;
}

/* ==================== Mobile bottom tab bar ==================== */
.mobile-tabbar {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    background: var(--surface);
    border-top: 3px solid var(--border);
    padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
    align-items: center;
}

.mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    text-decoration: none;
    color: var(--text-faint);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.3rem 0.9rem;
    border-radius: var(--radius-sm);
    min-width: 4rem;
}

.mobile-tab-icon { font-size: 1.3rem; }

.mobile-tab.active { color: var(--purple); }

.mobile-tab-cta {
    background: var(--pink);
    color: white;
    border-radius: var(--radius-lg);
    margin-top: -1.4rem;
    padding: 0.6rem 1rem;
    box-shadow: 0 6px 14px -4px rgba(236, 72, 153, 0.5);
}

.mobile-tab-cta .mobile-tab-icon { font-size: 1.5rem; }
.category-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.category-tile {
    --tile-color: #7c3aed;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    background: var(--surface);
    border: 3px solid var(--border);
    color: var(--text);
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 0.9rem;
    transition: all 0.15s ease;
    flex-shrink: 0;
    white-space: nowrap;
}

.category-tile-icon { font-size: 1.15rem; }

.category-tile:hover {
    border-color: var(--tile-color);
    transform: translateY(-2px);
}

.category-tile.active {
    background: var(--tile-color);
    border-color: var(--tile-color);
    color: white;
    box-shadow: var(--shadow-sticker);
}

/* ==================== Toolbar / sort ==================== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1.5rem 0 0.5rem;
}

.sort-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 700;
    white-space: nowrap;
}

.sort-control select {
    width: auto;
    padding: 0.5rem 2rem 0.5rem 0.9rem;
}

/* ==================== Game grid / cards ==================== */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.games-grid-compact {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.game-card {
    --card-color: #7c3aed;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 3px solid var(--text);
    box-shadow: var(--shadow-sticker-lg);
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.game-card:hover {
    transform: translateY(-4px) rotate(-0.4deg);
    box-shadow: 0 8px 0 rgba(36, 26, 61, 0.1), 0 20px 36px -12px rgba(124, 58, 237, 0.25);
}

.game-card-thumb {
    position: relative;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--card-color), color-mix(in srgb, var(--card-color) 60%, white));
    overflow: hidden;
    text-decoration: none;
}

.live-preview-frame {
    width: 400%;
    height: 400%;
    transform: scale(0.25);
    transform-origin: top left;
    pointer-events: none;
    background: white;
}

.live-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.game-card-thumb-icon {
    font-size: 3rem;
}

.play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(36, 26, 61, 0.35);
    color: white;
    font-size: 1.8rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.game-card:hover .play-overlay { opacity: 1; }

.game-card-body {
    padding: 1.15rem 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.game-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
}

.game-card p {
    color: var(--text-muted);
    font-size: 0.86rem;
    margin-bottom: 0.85rem;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.game-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.play-count {
    font-size: 0.78rem;
    color: var(--text-faint);
    font-weight: 800;
}

.game-card .author {
    font-size: 0.78rem;
    color: var(--text-faint);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.badge {
    display: inline-block;
    background: color-mix(in srgb, var(--card-color, var(--purple)) 15%, white);
    color: var(--card-color, var(--purple));
    padding: 0.22rem 0.7rem;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 800;
}

/* ==================== Empty state ==================== */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
}

.empty-icon { font-size: 3rem; margin-bottom: 1rem; }

.empty-state .btn-outline, .empty-state .btn-cta {
    display: inline-block;
    margin-top: 1rem;
    text-decoration: none;
}

/* ==================== Pagination ==================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.25rem;
    margin: 3rem 0 1rem;
}

.page-btn {
    text-decoration: none;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius-pill);
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.page-btn:hover { border-color: var(--purple); color: var(--purple); }
.page-btn.disabled { pointer-events: none; opacity: 0.4; }
.page-info { font-size: 0.85rem; color: var(--text-muted); font-weight: 700; }

/* ==================== Buttons & forms ==================== */
button, .btn {
    font-family: var(--font-display);
    background: var(--text);
    color: white;
    border: none;
    padding: 0.6rem 1.3rem;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.1s ease;
}

button:hover { transform: translateY(-1px); }
button:active { transform: translateY(1px); }

.btn-block { width: 100%; }

.btn-outline {
    background: var(--surface);
    border: 2px solid var(--border);
    color: var(--text);
}

.btn-outline:hover { border-color: var(--purple); color: var(--purple); }

.btn-danger { background: var(--red); }
.btn-danger:hover { background: #c53a3e; }

.btn-small { padding: 0.4rem 0.9rem; font-size: 0.82rem; }

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-muted);
    margin-top: 1rem;
    margin-bottom: 0.4rem;
}

input, textarea, select {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.95rem;
    background: var(--surface);
    color: var(--text);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--purple);
    box-shadow: 0 0 0 4px #ede4ff;
}

.code-field {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    background: #1e1533;
    color: #e9e3f5;
    border-color: #1e1533;
    width: 100%;
    height: 320px;
    resize: vertical;
}

.form-error {
    background: var(--red-soft);
    color: #b91c1c;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    margin: 1rem 0;
    font-weight: 700;
}

.hidden { display: none !important; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ==================== Auth card ==================== */
.auth-wrap {
    position: relative;
    overflow: hidden;
    min-height: calc(100vh - 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-blob { position: absolute; border-radius: 50%; z-index: 0; }
.auth-blob-1 { width: 260px; height: 260px; background: #fde68a; opacity: 0.4; top: -80px; left: -80px; }
.auth-blob-2 { width: 220px; height: 220px; background: #99f6e4; opacity: 0.4; bottom: -80px; right: -60px; }

.auth-card {
    position: relative;
    z-index: 1;
    background: var(--surface);
    border: 3px solid var(--text);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sticker-lg);
    padding: 2.5rem;
    max-width: 380px;
    width: 100%;
    text-align: center;
}

.auth-icon { font-size: 2.4rem; margin-bottom: 0.5rem; }
.auth-card h2 { margin-bottom: 0.3rem; }
.auth-sub { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1rem; }
.auth-card form { text-align: left; }
.auth-card .btn-block { margin-top: 1.5rem; }

.auth-back {
    display: inline-block;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 700;
}

.auth-back:hover { color: var(--purple); }

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 200;
    display: flex;
    align-items: center;
    padding: 0.85rem 1.3rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 800;
    box-shadow: var(--shadow-pop);
    animation: toast-in 0.25s ease;
    max-width: calc(100vw - 3rem);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

.toast-success { background: var(--green-soft); color: #15803d; }
.toast-error { background: var(--red-soft); color: #b91c1c; }

.toast.fade-out {
    opacity: 0;
    transform: translateY(-12px);
}

/* ==================== Admin: tabs, dashboard ==================== */
.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.tab {
    font-family: var(--font-display);
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    background: var(--surface);
    border: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.88rem;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: var(--radius-pill);
}

.tab:hover { border-color: var(--purple); color: var(--purple); }

.tab.active {
    background: var(--text);
    border-color: var(--text);
    color: white;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.dash-hello { margin-bottom: 1.75rem; }
.dash-hello p { color: var(--text-muted); font-weight: 700; }

.dash-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.dash-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.3rem;
    background: var(--surface);
    border: 3px solid var(--text);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1rem;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow-sticker);
    transition: transform 0.15s ease;
}

.dash-action:hover { transform: translateY(-4px); }

.dash-action-primary {
    background: var(--purple);
    color: white;
    border-color: var(--purple-dark);
}

.dash-action-icon { font-size: 2rem; }
.dash-action-title { font-family: var(--font-display); font-weight: 600; }
.dash-action-sub { font-size: 0.78rem; opacity: 0.75; font-weight: 700; }

.stats-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--surface);
    border: 3px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.1rem 1.5rem;
    display: flex;
    flex-direction: column;
    min-width: 140px;
}

.stat-num { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; color: var(--purple); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 700; }

/* Admin game card actions */
.admin-game-card .game-card-body { gap: 0.5rem; }
.admin-game-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.icon-btn {
    background: var(--bg);
    border: 2px solid var(--border);
    text-decoration: none;
    cursor: pointer;
    font-size: 1rem;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--text);
}

.icon-btn:hover { border-color: var(--purple); }
.delete-btn:hover { background: var(--red-soft); border-color: var(--red); }

.user-list { list-style: none; max-width: 620px; margin-top: 1rem; }
.user-list li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 0;
    border-bottom: 2px solid var(--border);
    font-weight: 700;
}
.user-list li:last-child { border-bottom: none; }

.user-list-names {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    flex: 1;
    min-width: 0;
}

.user-list-username {
    font-size: 0.76rem;
    color: var(--text-faint);
    font-weight: 700;
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

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

.delete-link {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--red);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0.3rem 0.6rem;
}
.delete-link:hover { background: var(--red-soft); border-radius: var(--radius-sm); }

/* ==================== Editor page ==================== */
.editor-card {
    background: var(--surface);
    border: 3px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
}

.editor-card h2 { font-size: 1.15rem; margin-bottom: 0.3rem; }

.editor-basics {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1.75rem;
    margin-top: 1rem;
}

@media (max-width: 800px) {
    .editor-basics { grid-template-columns: 1fr; }
}

.category-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.category-option {
    --tile-color: #7c3aed;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border: 3px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.88rem;
    transition: all 0.15s ease;
}

.category-option input { position: absolute; opacity: 0; width: 0; height: 0; }

.category-option:hover { border-color: var(--tile-color); }

.category-option.selected {
    background: var(--tile-color);
    border-color: var(--tile-color);
    color: white;
}

.category-option-icon { font-size: 1.1rem; }

.editor-split {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
    align-items: start;
}

@media (max-width: 900px) {
    .editor-split { grid-template-columns: 1fr; }
}

.code-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.code-tab {
    font-family: var(--font-display);
    background: var(--bg);
    border: 2px solid var(--border);
    color: var(--text-muted);
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.code-tab:hover { border-color: var(--purple); color: var(--purple); }

.code-tab.active {
    background: var(--purple);
    border-color: var(--purple);
    color: white;
}

.code-panel { display: none; }
.code-panel.active { display: block; }

.editor-preview-label {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.wizard-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    line-height: 1.5;
    font-weight: 600;
}

.wizard-preview {
    border: 3px solid var(--text);
    border-radius: var(--radius-md);
    overflow: hidden;
    height: 320px;
    background: white;
}

.wizard-preview iframe { width: 100%; height: 100%; border: none; }

.editor-save-bar {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 0 2rem;
}

/* ==================== Confirm modal ==================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(36, 26, 61, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal-box {
    background: var(--surface);
    border: 3px solid var(--text);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    max-width: 380px;
    width: 100%;
    box-shadow: var(--shadow-sticker-lg);
}

.modal-box p { margin-bottom: 1.5rem; font-size: 0.95rem; font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }

/* ==================== Footer ==================== */
.site-footer {
    margin-top: 3rem;
    padding: 2rem 0;
    text-align: center;
    color: var(--text-faint);
    font-size: 0.82rem;
    font-weight: 700;
    border-top: 3px solid var(--border);
}

/* ==================== Responsive ==================== */
@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
        padding: 1.25rem 1rem 2rem;
    }
    .sidebar { display: none; }
    .mobile-category-chips { display: flex; }
}

@media (max-width: 640px) {
    .container { padding: 1.25rem 1rem; }
    .navbar { padding: 0.7rem 1rem; }
    .games-grid { grid-template-columns: 1fr; }
    .icon-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 1.1rem 0.75rem; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .sort-control { justify-content: space-between; }
    .hero { padding: 2.5rem 0 2rem; }
    .dash-actions { grid-template-columns: repeat(2, 1fr); }

    body:not(.game-page) { padding-bottom: 4.75rem; } /* место под нижнюю мобильную навигацию */
    .mobile-tabbar { display: flex; }
    .user-menu-name { display: none; } /* на телефоне в шапке оставляем только аватар */
}
