/* ===== App Layout Styles ===== */

.app-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

/* ===== Icons =====
   App chrome loads no FontAwesome — icons come from the shared Lucide sprite
   (default/components/svg-sprite.html, included in layouts/app.html) via
   <svg class="icon"><use href="#i-…"></svg>. Sized in em so an icon tracks the
   font-size of whatever it sits in. Mirrors the .icon rule in site-uastyle.css. */
.icon {
    width: 1em;
    height: 1em;
    vertical-align: -.125em;
    flex: none;
    stroke-width: 1.75;
}

.icon-lg { width: 1.25em; height: 1.25em; }

/* Replaces FontAwesome's fa-spin. */
.icon-spin { animation: icon-spin 1s linear infinite; }

@keyframes icon-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .icon-spin { animation-duration: 2.5s; }
}

/* ===== Header ===== */
.app-header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    /* Above page-level sticky headers (e.g. deck editor's .editor-header at
       z-index 100) so the avatar dropdown overlays them instead of hiding
       behind. */
    z-index: 200;
}

.app-header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.app-logo:hover {
    color: var(--text-primary);
}

.app-logo .logo {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
}

/* Very narrow phones: drop the "PutItIn" wordmark, keep just the icon so the
   header fits. The wordmark is the unclassed <span> inside .app-logo. */
@media (max-width: 420px) {
    .app-logo span {
        display: none;
    }
}

/* App Navigation */
.app-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    color: var(--text-secondary);
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.app-nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.app-nav-link.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

/* Header Actions */
.app-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-menu-toggle:hover {
    background: var(--bg-secondary);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-avatar img[src=""],
.user-avatar img:not([src]) {
    display: none;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow-hover);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.dropdown-item.text-danger {
    color: #ef4444;
}

.dropdown-item.text-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* ===== Guest Actions ===== */
.guest-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.guest-actions .btn-login .btn-icon-mobile {
    display: none;
}

@media (max-width: 1199px) {
    .guest-actions .btn-register {
        display: none;
    }

    .guest-actions .btn-login .btn-text {
        display: none;
    }

    .guest-actions .btn-login .btn-icon-mobile {
        display: block;
    }

    .guest-actions .btn-login {
        width: 40px;
        height: 40px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
    }
}

/* ===== Зона тапа на сенсорных экранах =====
   Apple HIG и WCAG 2.5.5 просят 44×44 CSS-px. Часть кнопок — мелкие иконки
   (бургер 28×20, «открыть игроков» 34×34, копировать код 38×38), и увеличивать
   их ВИЗУАЛЬНО значило бы переделывать дизайн ради пальца.

   Поэтому растим только невидимую зону попадания: абсолютный ::before на
   44×44 (или по размеру кнопки, если она уже больше). Он позиционирован
   absolute, поэтому выпадает из flex-потока кнопки и её вёрстку не трогает —
   бургер остаётся тремя полосками, а не четырьмя. Клик по псевдоэлементу
   события отдаёт родителю, так что делать ничего больше не нужно.

   Новую мелкую кнопку помечай классом `.tap-safe`. Поимённый список ниже —
   для тех, чья разметка приходит из фрагмента БД (`header_app`) или из чужого
   шаблона, куда класс не добавить.

   НЕ вешать на элементы, стоящие вплотную друг к другу: зона шире самой
   кнопки и может воровать тапы у соседа. Для таких (напр. .card-report на
   карте) вместо этого увеличивай кнопку физически — см. report-dialog.css. */
@media (pointer: coarse) {
    .tap-safe,
    .burger-toggle,
    .menu-btn,
    .close-sidebar,
    .copy-btn {
        position: relative;
    }

    .tap-safe::before,
    .burger-toggle::before,
    .menu-btn::before,
    .close-sidebar::before,
    .copy-btn::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: max(100%, 44px);
        height: max(100%, 44px);
    }
}

/* ===== Burger Toggle ===== */
.burger-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.burger-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.burger-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.burger-toggle.active span:nth-child(2) {
    opacity: 0;
}

.burger-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

@media (max-width: 991px) {
    .burger-toggle {
        display: flex;
    }

    .app-nav {
        display: none;
    }
}

/* ===== Mobile Menu Overlay ===== */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1040;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===== Mobile Menu ===== */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    max-width: 85vw;
    height: 100%;
    background: var(--card-bg);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transition: right 0.3s ease;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-menu.open {
    right: 0;
}

.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.mobile-menu-header .logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

.mobile-menu-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.2s ease;
}

.mobile-menu-close:hover {
    background: var(--bg-tertiary);
}

.mobile-menu-close svg {
    width: 20px;
    height: 20px;
}

.mobile-menu-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.mobile-menu-nav {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
}

.mobile-menu-nav li {
    margin-bottom: 4px;
}

.mobile-menu-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: background 0.2s ease;
    font-weight: 500;
}

.mobile-menu-nav a:hover,
.mobile-menu-nav a.active {
    background: var(--bg-secondary);
}

.mobile-menu-nav a.active {
    color: var(--primary);
}

.mobile-menu-nav i {
    width: 20px;
    text-align: center;
    opacity: 0.7;
}

.mobile-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.mobile-menu-actions .btn {
    width: 100%;
    justify-content: center;
}

/* ===== Main Content ===== */
.app-main {
    flex: 1;
    padding: 32px 0;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== Lobby Header ===== */
.lobby-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}

.lobby-header-content h1 {
    font-size: 2rem;
    margin-bottom: 4px;
}

.lobby-header-content p {
    color: var(--text-secondary);
    margin: 0;
}

/* ===== Quick Actions ===== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

.quick-action-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.quick-action-card::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 100px;
    height: 100px;
    background: var(--primary);
    border-radius: 50%;
    filter: blur(50px);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.quick-action-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
}

.quick-action-card:hover::before {
    opacity: 0.15;
}

.quick-action-icon {
    width: 52px;
    height: 52px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}

.quick-action-icon.accent {
    background: rgba(6, 182, 212, 0.1);
    color: var(--accent);
}

.quick-action-icon.secondary {
    background: rgba(236, 72, 153, 0.1);
    color: var(--secondary);
}

.quick-action-content {
    flex: 1;
}

.quick-action-content h3 {
    font-size: 1rem;
    margin-bottom: 2px;
}

.quick-action-content p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
}

.quick-action-card > svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ===== Games Section ===== */
.games-section {
    margin-bottom: 40px;
}

.games-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.games-section .section-header h2 {
    font-size: 1.25rem;
    margin: 0;
}

.games-filters {
    display: flex;
    gap: 8px;
}

.filter-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ===== Games List ===== */
.games-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.game-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: all var(--transition-base);
    position: relative;
}

.game-card::before,
.game-card::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(50px);
    opacity: 0.2;
    transition: all var(--transition-slow);
    pointer-events: none;
}

.game-card::before {
    width: 120px;
    height: 120px;
    background: var(--primary);
    top: -50px;
    right: -50px;
}

.game-card::after {
    width: 80px;
    height: 80px;
    background: var(--secondary);
    bottom: -30px;
    left: -30px;
}

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
}

.game-card:hover::before {
    transform: translate(10px, 10px);
    opacity: 0.3;
}

.game-card:hover::after {
    transform: translate(-10px, -10px);
    opacity: 0.25;
}

.game-card.friend-game {
    border: 2px solid var(--secondary);
}

.friend-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    background: var(--secondary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    z-index: 1;
}

.game-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 1;
}

.game-host {
    display: flex;
    align-items: center;
    gap: 12px;
}

.host-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
}

.host-info {
    display: flex;
    flex-direction: column;
}

.host-name {
    font-weight: 600;
    color: var(--text-primary);
}

.game-mode {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.game-status {
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.game-status.waiting {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.game-status.playing {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.game-card-body {
    padding: 16px 20px;
    position: relative;
    z-index: 1;
}

.game-decks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.deck-tag {
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.game-meta {
    display: flex;
    gap: 20px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.meta-item svg {
    color: var(--text-muted);
}

.game-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    position: relative;
    z-index: 1;
}

.game-players {
    display: flex;
}

.game-players img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
    margin-left: -8px;
    background: var(--bg-tertiary);
}

.game-players img:first-child {
    margin-left: 0;
}

/* Empty / error state for the open-games list */
.games-empty {
    grid-column: 1 / -1;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--card-shadow-hover);
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-base);
}

.modal.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-content.modal-sm {
    max-width: 400px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 24px 0;
}

.modal-header h2 {
    font-size: 1.5rem;
    margin: 0;
}

.modal-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px 24px;
    border-top: 1px solid var(--border-color);
}

/* Form Sections */
.form-section {
    margin-bottom: 24px;
}

.form-section:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

/* Text inputs on app-layout pages (e.g. the "create room" modal). The .form-input
   base lives in auth.css/deck-editor.css, which those pages don't load — so define
   it here too, theme-aware via the shared tokens. */
.form-input {
    width: 100%;
    padding: 0.8rem 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.form-link {
    font-size: 0.875rem;
    color: var(--primary);
    font-weight: 600;
    display: inline-block;
    margin-top: 12px;
}

/* Mode Selector */
.mode-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.mode-option input {
    display: none;
}

.mode-option-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 16px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mode-option input:checked + .mode-option-content {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.mode-option-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    margin-bottom: 12px;
    transition: all var(--transition-fast);
}

.mode-option input:checked + .mode-option-content .mode-option-icon {
    background: var(--primary);
    color: white;
}

.mode-option-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.mode-option-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Toggle Group */
.toggle-group {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 4px;
}

.toggle-option {
    flex: 1;
}

.toggle-option input {
    display: none;
}

.toggle-option-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toggle-option input:checked + .toggle-option-btn {
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: var(--card-shadow);
}

/* Range Slider */
.range-slider {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
    transition: transform var(--transition-fast);
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Timer Options */
.timer-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.timer-option input {
    display: none;
}

.timer-option span {
    display: block;
    padding: 10px;
    text-align: center;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.timer-option input:checked + span {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

/* Decks Selector */
.decks-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.deck-checkbox input {
    display: none;
}

.deck-checkbox-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.deck-checkbox input:checked + .deck-checkbox-content {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.deck-checkbox-name {
    font-weight: 600;
}

.deck-checkbox-count {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Code Input */
.code-input-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.code-input {
    width: 200px;
    padding: 16px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    font-family: 'Quicksand', monospace;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 8px;
    text-transform: uppercase;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.code-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-primary);
}

.code-input::placeholder {
    color: var(--text-muted);
    letter-spacing: 8px;
}

.text-center {
    text-align: center;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .quick-actions {
        grid-template-columns: 1fr;
    }

    .games-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-header-container {
        height: 64px;
    }

    .user-name {
        display: none;
    }

    .lobby-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .lobby-header-actions {
        width: 100%;
    }

    .lobby-header-actions .btn {
        width: 100%;
    }

    .games-filters {
        overflow-x: auto;
        padding-bottom: 8px;
    }

    .modal-content {
        max-height: 100vh;
        border-radius: var(--radius-lg);
    }

    .mode-selector {
        grid-template-columns: 1fr;
    }

    .timer-options {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== App Footer ===== */
.app-footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 24px 0;
    margin-top: auto;
}

.app-footer-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.footer-left {
    flex: 1;
}

.footer-copyright {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.footer-center {
    display: flex;
    gap: 24px;
}

.footer-link {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-link:hover {
    color: var(--primary);
}

.footer-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* .footer-social is the flex CONTAINER of social links (styled in style.css);
   the icon styling lives on .social-link. (Removed a stray rule here that
   treated the container as a single 40x40 icon — it squished the links into
   ovals and stacked a second hover on top of .social-link:hover.) */

/* ===== Toggle Switch ===== */
.toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.toggle-item:last-child {
    border-bottom: none;
}

.toggle-info {
    flex: 1;
    min-width: 0;
}

.toggle-label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.toggle-desc {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.toggle {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

@media (max-width: 768px) {
    .app-footer-container {
        flex-direction: column;
        text-align: center;
        gap: 16px;
        padding: 0 20px;
    }

    .footer-left,
    .footer-right {
        justify-content: center;
    }

    .footer-center {
        gap: 16px;
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ===== Avatar picker + shared full-avatar lightbox ===== */
.avatar-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
}
.btn.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.avatar-shop-link {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}
.avatar-shop-link:hover { text-decoration: underline; }
.profile-avatar[data-full] { cursor: pointer; }

/* Modal shell (also reused by the lightbox open state) */
.avatar-modal,
.avatar-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.avatar-modal[hidden],
.avatar-lightbox[hidden] { display: none; }
.avatar-modal-backdrop,
.avatar-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}
.avatar-modal-dialog {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: min(680px, 100%);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}
.avatar-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}
.avatar-modal-head h3 { margin: 0; font-size: 1.15rem; }
.avatar-modal-close {
    background: none; border: none; cursor: pointer;
    font-size: 1.6rem; line-height: 1; color: var(--text-muted);
}
.avatar-modal-body {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 20px;
    padding: 20px 24px;
    overflow-y: auto;
}
.avatar-modal-hint {
    margin: 0;
    padding: 14px 24px;
    border-top: 1px solid var(--border-color);
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.avatar-modal-hint a { color: var(--primary); }

.avatar-set + .avatar-set { margin-top: 18px; }
.avatar-set-title {
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); margin-bottom: 10px;
}
.avatar-set-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 12px;
}
.avatar-thumb {
    position: relative;
    padding: 0;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 3px solid transparent;
    background: var(--bg-tertiary);
    cursor: pointer;
    overflow: hidden;
    transition: border-color .15s, transform .15s;
}
.avatar-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-thumb:hover { transform: translateY(-2px); }
.avatar-thumb.selected { border-color: var(--primary); }
.avatar-thumb.equipped { border-color: #22c55e; }
.avatar-thumb-price {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0, 0, 0, 0.55); color: #fff;
    font-size: 0.7rem; font-weight: 700; text-align: center; padding: 1px 0;
}

.avatar-preview {
    align-self: start;
    text-align: center;
    position: sticky;
    top: 0;
}
.avatar-preview img {
    width: 100%;
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
    cursor: zoom-in;
}
.avatar-preview-name { font-weight: 700; margin: 10px 0 12px; }
.avatar-picker-loading, .avatar-picker-empty {
    grid-column: 1 / -1; color: var(--text-muted); text-align: center; padding: 24px;
}

/* Full-avatar lightbox */
.avatar-lightbox-figure {
    position: relative;
    margin: 0;
    max-width: min(520px, 92vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.avatar-lightbox-figure img {
    max-width: 100%;
    max-height: 82vh;
    border-radius: var(--radius-xl);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}
.avatar-lightbox-figure figcaption {
    margin-top: 12px; color: #fff; font-weight: 600; text-align: center;
}
.avatar-lightbox-close {
    position: absolute; top: -8px; right: -8px;
    width: 40px; height: 40px; border-radius: 50%;
    background: #fff; border: none; cursor: pointer;
    font-size: 1.5rem; line-height: 1; color: #111;
}
body.avatar-lightbox-open { overflow: hidden; }

@media (max-width: 560px) {
    .avatar-modal-body { grid-template-columns: 1fr; }
    .avatar-preview { position: static; }
}

/* ===== Store (sections → sets → items) ===== */
.store-page .store-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px; margin-bottom: 8px;
}
.coin-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--bg-tertiary); border-radius: 999px;
    padding: 8px 16px; font-weight: 700; color: var(--text-primary);
}
/* Promo / gift code input */
.store-redeem {
    display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap;
}
.store-redeem-input {
    flex: 1 1 200px; max-width: 320px; padding: 8px 14px;
    border: 1px solid var(--border-color); border-radius: 999px;
    background: var(--bg-tertiary); color: var(--text-primary); font-size: 0.9rem;
}
.store-redeem-input:focus { outline: none; border-color: var(--primary); }

/* Category tabs — one shop section visible at a time */
.store-tabs {
    display: flex; gap: 8px; flex-wrap: nowrap;
    margin-top: 16px; padding-bottom: 4px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.store-tab {
    flex: 0 0 auto; padding: 8px 16px; border-radius: 999px;
    border: 1px solid var(--border-color); background: var(--bg-tertiary);
    color: var(--text-secondary); font-weight: 600; font-size: 0.9rem;
    white-space: nowrap; cursor: pointer; transition: all 0.15s ease;
}
.store-tab:hover { color: var(--text-primary); }
.store-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.store-section.is-hidden { display: none; }

.store-section { margin-top: 24px; }
.store-section-title { font-size: 1.25rem; margin: 0 0 4px; }
.store-set { margin-top: 18px; }
.store-set-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.store-set-title {
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-muted);
}
.store-set-head .store-set-title { margin-bottom: 0; }
/* margin-left:auto, not the parent's space-between: the title is omitted when it
   would repeat the section heading, and the bundle must stay right-aligned alone. */
.store-set-bundle { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.store-set-bundle-price { display: inline-flex; align-items: baseline; gap: 6px; }
.store-set-bundle-old {
    color: var(--text-muted); text-decoration: line-through; font-size: 0.85rem;
}
.store-set-bundle-new { color: var(--text-primary); font-weight: 700; }
.store-item-icon {
    display: flex; align-items: center; justify-content: center;
    height: 72px; font-size: 34px; color: var(--primary);
}
.store-item-count { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.store-item-count .store-count-value { font-weight: 700; color: var(--text-primary); }
.store-empty { color: var(--text-muted); margin-top: 12px; }
.store-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}
.store-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.store-item-thumb {
    position: relative;
    width: 96px; height: 96px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-tertiary);
    cursor: zoom-in;
}
.store-item-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* card_set packs show a square deck cover, not a round avatar face */
#card_set .store-item-thumb { width: 120px; height: 120px; border-radius: 14px; }
/* powerups + creator items show a 2:3 "power card" (art is a framed card) */
#powerup .store-item-thumb,
#creator .store-item-thumb { width: 116px; height: 174px; border-radius: 12px; }
.store-item-flag {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: #22c55e; color: #fff; font-size: 0.68rem; font-weight: 700;
    padding: 2px 0;
}
.store-item-name {
    font-weight: 600; font-size: 0.9rem; line-height: 1.3;
    /* Always reserve 2 lines so the "У тебя: {count}" row below never shifts,
       whether the name wraps to one line or two. Longer names clamp to 2. */
    min-height: 2.6em;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Avatars are recognised by their art. Their name captions are badly composed
   (stale translation keys), so hide them everywhere — shop grid + the picker
   preview. */
#avatar .store-item-name { display: none; }
.avatar-preview-name { display: none; }

/* Guest shop gate */
.store-gate { display: flex; justify-content: center; padding: 48px 20px; }
.store-gate__card {
    max-width: 460px;
    width: 100%;
    text-align: center;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #ececf2);
    border-radius: 20px;
    padding: 40px 32px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .08);
}
.store-gate__icon { font-size: 3rem; line-height: 1; margin-bottom: 12px; }
.store-gate__title { font-size: 1.5rem; font-weight: 800; color: var(--text-primary, #1a1a2e); margin-bottom: 12px; }
.store-gate__text { color: var(--text-secondary, #6b6b7b); line-height: 1.5; margin-bottom: 24px; }
.store-gate__actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.store-item-action { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.store-price {
    font-weight: 700; color: var(--text-primary);
}
.store-item.rarity-rare { border-color: #3b82f6; }
.store-item.rarity-epic { border-color: #a855f7; }
.store-item.rarity-legendary { border-color: #f59e0b; }

/* ===== My games ===== */
.lobby-header-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.my-games-list { display: flex; flex-direction: column; gap: .75rem; }
.my-game-card {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    background: var(--surface, #fff); border: 1px solid var(--border, #e5e7eb);
    border-radius: 14px; padding: 1rem 1.25rem;
}
.my-game-title { font-weight: 600; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.my-game-meta { display: flex; flex-wrap: wrap; gap: .35rem 1rem; color: var(--text-muted, #6b7280); font-size: .85rem; margin-top: .35rem; }
.my-game-actions { display: flex; gap: .5rem; flex-shrink: 0; }
.role-badge { font-size: .7rem; padding: 2px 8px; border-radius: 999px; background: var(--border, #e5e7eb); color: var(--text-muted, #6b7280); }
.role-badge.host { background: var(--primary, #7c3aed); color: #fff; }
.status-pill { font-size: .72rem; padding: 2px 10px; border-radius: 999px; background: var(--border, #e5e7eb); color: var(--text-muted, #374151); }
.status-pill.status-playing, .status-pill.status-voting, .status-pill.status-results { background: var(--success, #16a34a); color: #fff; }
.status-pill.status-finished { background: #9ca3af; color: #fff; }
.my-game-card.status-finished { opacity: .8; }
.games-empty { display: flex; flex-direction: column; align-items: center; padding: 2rem; text-align: center; color: var(--text-muted, #6b7280); }
.games-empty__cta { margin-top: 1rem; }
@media (max-width: 560px) {
    .my-game-card { flex-direction: column; align-items: stretch; }
    .my-game-actions { justify-content: flex-end; }
}

/* Room background picker (create modal) */
.bg-selector { display: flex; flex-wrap: wrap; gap: 10px; }
.bg-swatch { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; width: 76px; }
.bg-swatch input { position: absolute; opacity: 0; pointer-events: none; }
.bg-swatch-thumb { width: 72px; height: 46px; border-radius: 10px; border: 2px solid var(--border-color); transition: border-color .15s, box-shadow .15s; }
.bg-swatch-none { background: repeating-linear-gradient(45deg, var(--bg-tertiary), var(--bg-tertiary) 6px, var(--bg-secondary) 6px, var(--bg-secondary) 12px); }
.bg-swatch.is-selected .bg-swatch-thumb { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 40%, transparent); }
.bg-swatch-name { font-size: .72rem; color: var(--text-secondary); text-align: center; line-height: 1.1; }

/* Background item swatch in the shop */
.store-item-bg { width: 100%; height: 88px; border-radius: 12px; border: 1px solid var(--border-color); margin-bottom: 8px; }

/* ===== Shared player-actions menu (waiting room, game, profile) ===== */
.player-actions-menu {
    position: absolute;
    z-index: 3000;
    min-width: 168px;
    padding: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.player-actions-menu .pam-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: .92rem;
    color: var(--text-primary);
    text-decoration: none;
    text-align: left;
    cursor: pointer;
}
.player-actions-menu .pam-item:hover { background: var(--bg-tertiary, rgba(127,127,127,.12)); }
.player-actions-menu .pam-ico { font-size: 1.05rem; line-height: 1; }
/* Report sits under the constructive actions and reads as destructive, so a
   mis-tap on «В друзья» is hard to confuse with it. */
.player-actions-menu .pam-item--danger { color: var(--danger, #ef4444); }
.player-actions-menu .pam-item--danger:hover { background: var(--danger-15, rgba(239, 68, 68, .12)); }

/* Clickable player rows/cards open the actions menu */
.player-card.is-clickable,
.sidebar-player.is-clickable { cursor: pointer; }
.player-card.is-clickable:hover,
.sidebar-player.is-clickable:hover { filter: brightness(1.04); }
