/* =========================
   Общие настройки
========================= */
body {
    overflow-x: hidden;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background: #fff6e5;
    color: #333;
    text-align: center;
    box-sizing: border-box;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
}

*, *:before, *:after {
    box-sizing: inherit;
}

/* =========================
   Заголовки и текст
========================= */
h1, h2, h3 {
    margin: 0.5em 0;
    color: #d46a6a;
}

h1 { font-size: clamp(1.8rem, 6vw, 2.8rem); }
h2 { font-size: clamp(1.5rem, 5vw, 2.2rem); }
h3 { font-size: clamp(1.3rem, 4vw, 1.8rem); }

/* =========================
   Контейнеры и layout
========================= */
header {
    background: rgba(255, 255, 255, 0.9);
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
    top: 0;
    z-index: 50;
    backdrop-filter: none;
}

nav {
    margin-top: 0.3rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

main {
    padding: 1rem;
    min-height: calc(100vh - 140px);
}

/* =========================
   Кнопки
========================= */
.btn {
    display: inline-block;
    padding: 0.8rem 1.6rem;
    font-size: clamp(0.95rem, 3.5vw, 1.1rem);
    font-weight: 500;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-new-game {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #4caf50, #388e3c);
    color: white;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 14px;
    box-shadow:
        0 4px 12px rgba(76,175,80,0.3),
        inset 0 1px 0 rgba(255,255,255,0.25);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 90%;
    max-width: 200px;
    letter-spacing: 1px;
}

.btn-new-game::after {
    content: '';
    position: absolute;
    inset: 0;
    background: inherit;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: -1;
}

.btn-new-game:hover::after {
    opacity: 1;
    transform: scale(1.06);
}

.btn-new-game:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(76,175,80,0.45);
}

.btn-new-game:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(76,175,80,0.25);
}

/* =========================
   Overlay (общий для всех игр)
========================= */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.overlay-content {
    background: white;
    padding: 2.5rem 3rem;
    border-radius: 16px;
    text-align: center;
    max-width: 90%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.overlay.visible .overlay-content {
    transform: scale(1);
}

.overlay-content h2 {
    margin: 0 0 1rem;
    font-size: 2.2rem;
}

.overlay-win h2 { color: #28a745; }
.overlay-lose h2 { color: #dc3545; }
.overlay-draw h2  { color: #fd7e14; }

/* =========================
   Навигация и dropdown
========================= */
.nav-item {
    cursor: pointer;
    display: inline-block;
    padding: 10px 15px;
    color: #007bff;
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 5px;
    margin: 0 2px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.nav-item:hover {
    background-color: rgba(0, 123, 255, 0.1);
    color: #0056b3;
    transform: translateY(-1px);
}

.nav-item:active {
    transform: translateY(0);
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 200px;
    z-index: 1000;
    top: 100%;
    left: 0;
    padding: 0.5rem 0;
}

.dropdown-menu.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

.dropdown-item {
    cursor: pointer;
    display: block;
    padding: 0.8rem 1.2rem;
    color: #007bff;
    text-decoration: none;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: #f8f9fa;
}

/* Стили для отображения ошибок */
.error-alert {
    max-width: 600px;
    margin: 2rem auto;
    padding: 1.5rem;
    background: #ffebee;
    border: 1px solid #ffcdd2;
    border-radius: 10px;
    text-align: center;
    color: #c62828;
}

.error-alert h3 {
    margin: 0 0 1rem 0;
    font-size: 1.3rem;
    color: #c62828;
}

.error-alert p {
    margin: 0 0 1.5rem 0;
    font-size: 1.1rem;
    line-height: 1.5;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-error {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

/* Стили для flash сообщений */
.flash-messages {
    max-width: 800px;
    margin: 1rem auto;
    padding: 0 1rem;
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/*  sound */
.sound-btn {
    border: none;
    background: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.3rem 0.6rem;
}

/* Адаптивность */
@media (max-width: 768px) {
    header {
        padding: 0.6rem 0.8rem;
    }

    header h1 {
        font-size: 1.3rem;
        margin: 0.2rem 0;
    }

    nav {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .nav-item {
        padding: 8px 12px;
        font-size: 14px;
    }

    .dropdown-menu {
        left: -50px;
        min-width: 180px;
    }

    .error-alert {
        margin: 1rem;
        padding: 1rem;
    }

    .error-actions {
        flex-direction: column;
    }

    .btn-error {
        width: 100%;
        max-width: 250px;
        margin: 0 auto;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.6rem;
    }

    .btn {
        padding: 0.7rem 1.2rem;
        font-size: 0.95rem;
    }
}
