/* === Базовые переменные (только для игры Косынка) === */
:root {
    --primary-green: #1a472a;
    --secondary-green: #2d5a3d;
    --accent-gold: #ffd700;
    --accent-gold-dark: #e6c200;
    --card-red: #d40000;
    --card-black: #1a1a1a;
    --card-bg: #ffffff;
    --card-back-gradient-1: #1a3a6a;
    --card-back-gradient-2: #2a5a9a;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.5);
    --card-width: 75px;
    --card-height: 105px;
    --card-radius: 8px;
    --column-gap: 8px;
    --transition-fast: 0.15s;
    --transition-normal: 0.3s;
    --transition-slow: 0.5s;
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* === Безопасный сброс ТОЛЬКО для игры === */
.solitaire-wrapper * {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* === Фон и обертка игры (заменяет глобальный body) === */
.solitaire-wrapper {
    font-family: var(--font-main);
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--secondary-green) 100%);
    background-attachment: fixed;
    min-height: 80vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 10px;
    color: white;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    width: 100%;
}


/* === Фоновые частицы === */
.bg-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-particles::before,
.bg-particles::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.08) 0%, transparent 70%);
    animation: floatBg 20s ease-in-out infinite;
}

.bg-particles::before {
    top: -200px;
    left: -200px;
}

.bg-particles::after {
    bottom: -200px;
    right: -200px;
    animation-delay: -10s;
}

@keyframes floatBg {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(100px, 100px) scale(1.2); }
}

/* === Главное приложение === */
.solitaire-game-board {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 15px;
    max-width: 1000px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 1;
}

/* === Header === */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 10px;
    flex-wrap: wrap;
    gap: 15px;
}

.logo {
    display: flex;
    flex-direction: column;
}

.logo h1 {
    font-size: 26px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
    background: linear-gradient(135deg, #fff 0%, var(--accent-gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo .subtitle {
    font-size: 12px;
    opacity: 0.7;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* === Кнопки === */
.btn {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
    overflow: hidden;
    user-select: none;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.25);
    box-shadow: var(--shadow-md);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn .icon {
    font-size: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--secondary-green), var(--primary-green));
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #3a7049, var(--secondary-green));
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
}

.btn-gold {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dark));
    color: var(--primary-green);
    border-color: var(--accent-gold);
    font-weight: 700;
}

.btn-gold:hover:not(:disabled) {
    background: linear-gradient(135deg, #ffe44d, var(--accent-gold));
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

.btn-danger {
    background: linear-gradient(135deg, #d44, #a22);
    border-color: #d44;
}

.btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #e55, #b33);
}

/* === Статистика в хедере === */
.stats-panel {
    display: flex;
    gap: 8px;
    margin-left: 8px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 6px 12px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.stat-icon {
    font-size: 14px;
    opacity: 0.8;
}

.stat-value {
    font-weight: 700;
    font-size: 15px;
    color: var(--accent-gold);
    font-variant-numeric: tabular-nums;
}

.stat-label {
    opacity: 0.7;
    font-size: 11px;
    text-transform: lowercase;
}

/* === Игровое поле === */
#game-board {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 15px;
    padding: 15px;
    min-height: 500px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* === Верхняя панель === */
#top-panel {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    padding: 0 5px;
    align-items: flex-start;
    min-height: 130px;
    flex-wrap: nowrap;
}

#stock-waste {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.slot {
    width: var(--card-width);
    height: var(--card-height);
    flex-shrink: 0;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.slot-label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    opacity: 0.5;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

#stock {
    cursor: pointer;
    transition: transform var(--transition-fast);
}

#stock:hover {
    transform: scale(1.03);
}

#stock .recycle-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    opacity: 0.7;
    color: white;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    pointer-events: none;
}

#foundations {
    display: flex;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

.foundation {
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: var(--card-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    color: rgba(255, 255, 255, 0.3);
    transition: all var(--transition-normal);
    position: relative;
}

.foundation.has-card {
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.5);
}

.foundation.highlight {
    border-color: var(--accent-gold);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.7);
    transform: scale(1.05);
    background: rgba(255, 215, 0, 0.1);
}

.foundation-symbol {
    pointer-events: none;
    user-select: none;
}

/* === Карты === */
.card {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: var(--card-radius);
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-weight: bold;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    user-select: none;
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.card .card-corner {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    padding: 4px;
    font-size: 14px;
    gap: 1px;
}

.card .card-corner.top {
    align-self: flex-start;
}

.card .card-corner.bottom {
    align-self: flex-end;
    transform: rotate(180deg);
}

.card .card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    opacity: 0.9;
}

.card.back {
    background: linear-gradient(135deg, var(--card-back-gradient-1), var(--card-back-gradient-2));
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: default;
}

.card.back::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    background:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 8px,
            rgba(255, 255, 255, 0.04) 8px,
            rgba(255, 255, 255, 0.04) 16px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 8px,
            rgba(255, 255, 255, 0.04) 8px,
            rgba(255, 255, 255, 0.04) 16px
        );
}

.card.back::after {
    content: '♠';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    opacity: 0.6;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.card.red {
    color: var(--card-red);
}

.card.black {
    color: var(--card-black);
}

.card.face-up {
    cursor: grab;
}

.card.face-up:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.card.face-up:active {
    cursor: grabbing;
}

.card.selected {
    box-shadow: 0 0 0 3px var(--accent-gold), var(--shadow-md);
    transform: translateY(-4px);
}

.card.hint {
    animation: hintPulse 0.8s ease-in-out infinite;
}

/* === Колонки === */
#columns {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--column-gap);
    padding: 0 5px;
}

.column {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px;
    border-radius: var(--card-radius);
    background: rgba(255, 255, 255, 0.03);
    position: relative;
    transition: all var(--transition-normal);
    border: 2px solid transparent;
}

.column.highlight {
    background: rgba(255, 215, 0, 0.15);
    border-color: var(--accent-gold);
    box-shadow: inset 0 0 15px rgba(255, 215, 0, 0.3), 0 0 20px rgba(255, 215, 0, 0.3);
}

.column .card {
    width: var(--card-width);
    height: var(--card-height);
    flex-shrink: 0;
}

.column .card.face-down {
    margin-bottom: -75px;
}

.column .card.face-up {
    margin-bottom: -60px;
}

.column .card:last-child {
    margin-bottom: 0;
}

/* === Drag clone === */
#drag-clone {
    position: fixed;
    pointer-events: none;
    z-index: 99999;
    opacity: 0.95;
    transform: rotate(2deg);
    display: flex;
    flex-direction: column;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4));
}

#drag-clone .card {
    margin-bottom: -60px;
    box-shadow: var(--shadow-md);
}

#drag-clone .card:last-child {
    margin-bottom: 0;
}

/* === Overlay === */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

/* === Win overlay === */
.win-content {
    background: linear-gradient(135deg, var(--accent-gold) 0%, #ffaa00 100%);
    padding: 40px 50px;
    border-radius: 20px;
    text-align: center;
    box-shadow: var(--shadow-xl);
    animation: winAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 500px;
    width: 100%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.win-trophy {
    font-size: 80px;
    margin-bottom: 10px;
    animation: trophyBounce 1s ease-in-out infinite;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3));
}

@keyframes trophyBounce {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
}

.win-content h2 {
    font-size: 38px;
    color: var(--primary-green);
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.win-subtitle {
    font-size: 16px;
    color: rgba(45, 90, 61, 0.8);
    margin-bottom: 25px;
}

.win-stats {
    display: flex;
    justify-content: space-around;
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    backdrop-filter: blur(5px);
}

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

.win-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-green);
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}

.win-stat-label {
    font-size: 12px;
    color: rgba(45, 90, 61, 0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.win-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.win-buttons .btn {
    padding: 12px 24px;
    font-size: 15px;
}

/* === Modal === */
.modal-content {
    background: linear-gradient(135deg, #2d5a3d 0%, #1a472a 100%);
    padding: 30px;
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    animation: modalAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.modal-header h2 {
    font-size: 24px;
    color: white;
}

.modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.08);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all var(--transition-fast);
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
}

.stat-card-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.stat-card-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-gold);
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}

.stat-card-label {
    font-size: 11px;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#reset-stats {
    width: 100%;
    padding: 10px;
}

/* === Toast === */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--accent-gold);
    animation: toastSlideIn 0.3s ease-out;
    font-size: 14px;
    min-width: 200px;
    max-width: 350px;
    pointer-events: auto;
}

.toast.success {
    border-left-color: #4ade80;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.info {
    border-left-color: #60a5fa;
}

.toast.fade-out {
    animation: toastSlideOut 0.3s ease-in forwards;
}

/* === Footer === */
footer {
    margin-top: 15px;
    text-align: center;
    padding: 10px;
}

.footer-hint {
    font-size: 12px;
    opacity: 0.6;
    letter-spacing: 0.5px;
}

/* === Confetti === */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    z-index: 2001;
    pointer-events: none;
    will-change: transform, opacity;
}

/* === Responsive === */
@media (max-width: 900px) {
    :root {
        --card-width: 65px;
        --card-height: 91px;
    }

    .logo h1 {
        font-size: 22px;
    }

    .column .card.face-down {
        margin-bottom: -65px;
    }

    .column .card.face-up {
        margin-bottom: -52px;
    }

    #drag-clone .card {
        margin-bottom: -52px;
    }
}

@media (max-width: 768px) {
    :root {
        --card-width: 55px;
        --card-height: 78px;
        --column-gap: 6px;
    }

    body {
        padding: 5px;
    }

    #app {
        padding: 10px;
        border-radius: 15px;
    }

    header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .logo {
        align-items: center;
    }

    .controls {
        justify-content: center;
    }

    .btn .label {
        display: none;
    }

    .btn {
        padding: 8px 10px;
    }

    .stats-panel {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }

    .card .card-corner {
        font-size: 11px;
        padding: 2px;
    }

    .card .card-center {
        font-size: 22px;
    }

    .card.back::after {
        font-size: 20px;
    }

    .column .card.face-down {
        margin-bottom: -58px;
    }

    .column .card.face-up {
        margin-bottom: -45px;
    }

    #drag-clone .card {
        margin-bottom: -45px;
    }

    #top-panel {
        gap: 8px;
    }

    #foundations {
        gap: 5px;
    }

    .foundation {
        font-size: 24px;
    }

    .footer-hint {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    :root {
        --card-width: 42px;
        --card-height: 60px;
        --column-gap: 4px;
    }

    .card .card-corner {
        font-size: 9px;
        padding: 1px;
    }

    .card .card-center {
        font-size: 16px;
    }

    .card.back::after {
        font-size: 14px;
    }

    .column .card.face-down {
        margin-bottom: -44px;
    }

    .column .card.face-up {
        margin-bottom: -34px;
    }

    #drag-clone .card {
        margin-bottom: -34px;
    }

    #top-panel {
        gap: 5px;
    }

    #foundations {
        gap: 3px;
    }

    .foundation {
        font-size: 18px;
    }

    .slot-label {
        display: none;
    }

    .win-content {
        padding: 25px 20px;
    }

    .win-content h2 {
        font-size: 28px;
    }

    .win-trophy {
        font-size: 60px;
    }

    .win-stat-value {
        font-size: 22px;
    }
}

@media (max-height: 700px) {
    .column .card.face-down {
        margin-bottom: -80px;
    }

    .column .card.face-up {
        margin-bottom: -65px;
    }

    #drag-clone .card {
        margin-bottom: -65px;
    }
}

@media (max-width: 400px) and (max-height: 700px) {
    .column .card.face-down {
        margin-bottom: -48px;
    }

    .column .card.face-up {
        margin-bottom: -38px;
    }

    #drag-clone .card {
        margin-bottom: -38px;
    }
}

/* === Модалка тем === */
.modal-large {
    max-width: 700px;
}

.themes-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.theme-tab {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    flex: 1;
}

.theme-tab:hover {
    background: rgba(255, 255, 255, 0.1);
}

.theme-tab.active {
    background: var(--accent-gold);
    color: var(--primary-green);
}

.theme-tab-content {
    display: none;
}

.theme-tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

.theme-tab-content h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--accent-gold);
}

.themes-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding: 5px;
}

.figure-preview {
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    text-align: center;
}

.preview-cards {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.preview-card {
    width: 60px;
    height: 84px;
    background: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 2px solid #ddd;
}

.preview-card.jack {
    color: #d40000;
}

.preview-card.queen {
    color: #1a1a1a;
}

.preview-card.king {
    color: #d40000;
}

.preview-card.ace {
    color: #1a1a1a;
    font-size: 32px;
}

/* Скроллбар для списков тем */
.themes-list::-webkit-scrollbar {
    width: 8px;
}

.themes-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.themes-list::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.3);
    border-radius: 4px;
}

.themes-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.5);
}
