/* DotA 2 Spy Game - CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    color: #fff;
    height: 100vh;
    margin: 0;
    padding: 0;
    position: relative;
    overflow: hidden;
}

#main-content {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* DotA 2-themed background elements */
body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(240, 74, 38, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(240, 74, 38, 0.05) 0%, transparent 20%);
    z-index: -1;
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    margin: 0;
    position: absolute;
    top: 40px;
    left: 0;
    right: 0;
    padding: 20px 0;
    z-index: 2;
    background: inherit;
}

h1 {
    font-size: 2.8rem;
    color: #f04a26; /* DotA red */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 5px;
    letter-spacing: 1px;
    font-weight: bold;
    position: relative;
    text-transform: uppercase;
    font-family: 'Arial', sans-serif;
    letter-spacing: 2px;
}

h1::after {
    content: "";
    display: block;
    width: 250px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #f04a26, transparent);
    margin: 15px auto;
    border-radius: 2px;
}

h1 span {
    display: block;
    font-size: 1.5rem;
    color: #e0e0e0; /* White color like the game started text */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    margin-top: 8px;
    letter-spacing: 1px;
    font-family: Arial, sans-serif;
    text-transform: uppercase;
}

h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: #e0e0e0;
    text-shadow: 0 0 5px rgba(224, 224, 224, 0.3);
}

.screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: auto;
    margin: 0 auto;
}

.screen.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

.player-count-selection {
    text-align: center;
    background: rgba(30, 30, 30, 0.8);
    padding: 40px;
    border-radius: 10px;
    border: 2px solid #f04a26;
    box-shadow: 0 0 20px rgba(240, 74, 38, 0.3);
    width: 100%;
    max-width: 500px;
}

.player-range {
    margin: 30px 0;
}

#playerCountSlider {
    width: 100%;
    height: 10px;
    -webkit-appearance: none;
    background: #333;
    border-radius: 5px;
    outline: none;
    margin-bottom: 10px;
}

#playerCountSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #f04a26;
    cursor: pointer;
}

#playerCountDisplay {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #f04a26;
    margin-top: 10px;
}

.btn {
    background: linear-gradient(to bottom, #f04a26, #b02a16);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.2rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    margin: 10px;
    border: 2px solid #f04a26;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.btn:hover {
    background: linear-gradient(to bottom, #ff5c33, #c0301a);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(240, 74, 38, 0.5);
}

.btn:active {
    transform: translateY(1px);
    box-shadow: 0 3px 10px rgba(240, 74, 38, 0.4);
}

.btn.disabled {
    background: linear-gradient(to bottom, #555, #333);
    border-color: #444;
    cursor: not-allowed;
    opacity: 0.6;
    pointer-events: none;
}

.card-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.player-indicator {
    margin-bottom: 20px;
    text-align: center;
    width: 100%;
}

#currentPlayer {
    font-size: 1.4rem;
    color: #f04a26;
    text-shadow: 0 0 10px rgba(240, 74, 38, 0.5);
    background: rgba(30, 30, 30, 0.7);
    padding: 8px 20px;
    border-radius: 20px;
    border: 1px solid #f04a26;
    display: inline-block;
    font-weight: bold;
    letter-spacing: 1px;
}

#currentPlayer::before {
    content: "";
    margin-right: 8px;
    display: inline-block;
    width: 24px;
    height: 24px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23ffffff'%3E%3Cpath d='M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
    vertical-align: middle;
}

.spy-card {
    width: 300px;
    height: 400px;
    margin: 20px auto;
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transition: none; /* Убираем 3D-анимацию */
}

.card-front, .card-back {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.6s;
    backface-visibility: hidden;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.card-front {
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    border: 3px solid #f04a26;
    color: #f04a26;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.card-front::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(240, 74, 38, 0.1),
        transparent
    );
    transform: rotate(45deg);
    transition: all 0.5s;
}

.card-front:hover::before {
    transform: rotate(45deg) translate(50%, 50%);
}

.card-front:hover {
    border-color: #ff5c33;
    box-shadow: 0 0 20px rgba(240, 74, 38, 0.4);
}

.card-back {
    background: linear-gradient(135deg, #3a3a3a 0%, #2a2a2a 100%);
    border: 3px solid #f04a26;
    position: absolute; /* Изменяем на absolute чтобы правильно позиционировать */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    overflow: hidden; /* Оставляем чтобы изображения не выходили за границы */
    z-index: 2; /* Увеличиваем z-index при перевороте */
}

.card-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    min-height: calc(100% - 40px);
}

.character-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    min-height: 100%;
}

.character-image-container {
    width: 100%;
    max-width: 320px;
    height: auto;
    margin-bottom: 15px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

#characterImage {
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: contain;
    object-position: center;
    border-radius: 4px;
    transition: transform 0.3s ease;
    border: none;
    max-width: 100%;
}

.character-image-container:hover #characterImage {
    transform: scale(1.05);
}

#characterName {
    font-size: 1.5rem;
    color: #f04a26;
    text-align: center;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 1px;
    margin-top: 10px;
    text-shadow: 0 0 10px rgba(240, 74, 38, 0.5);
}

.card-controls {
    margin-top: 20px;
}

.game-started {
    text-align: center;
    background: rgba(30, 30, 30, 0.8);
    padding: 40px;
    border-radius: 10px;
    border: 2px solid #f04a26;
    box-shadow: 0 0 20px rgba(240, 74, 38, 0.3);
    width: 100%;
    max-width: 500px;
}

.game-started p {
    font-size: 1.2rem;
    margin: 20px 0;
}

/* Card flip state using opacity instead of 3D transform */
.card-inner.flipped .card-front {
    opacity: 0;
    pointer-events: none;
    z-index: 1; /* Передняя сторона должна быть под задней при перевороте */
}

.card-inner.flipped .card-back {
    opacity: 1;
    pointer-events: auto;
    z-index: 2; /* Убедимся, что перевернутая сторона отображается поверх */
}

/* Увеличиваем нижний отступ для футера */
body {
    padding-bottom: 70px;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        height: 100vh; /* Установим фиксированную высоту для правильного центрирования */
        display: flex;
        flex-direction: column;
    }

    header {
        position: static;
        top: auto;
        padding: 10px 0 20px 0;
        text-align: center;
        margin: 0;
        flex-shrink: 0; /* Не сжимаем заголовок */
    }

    h1 {
        font-size: 1.8rem;
        margin-bottom: 8px;
    }

    h1::after {
        width: 200px;
        margin: 12px auto;
    }

    h1 span {
        font-size: 1.1rem;
        margin-top: 6px;
    }

    h2 {
        font-size: 1.4rem;
    }

    #main-content {
        flex: 1; /* Занимает оставшееся пространство */
        height: auto;
        min-height: auto;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center; /* Центрируем по вертикали */
        width: 100%;
    }

    .screen {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        width: 100%;
        max-width: 500px;
        padding: 15px;
        margin: 0 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center; /* Добавляем центрирование */
        min-height: auto;
        height: auto;
    }

    .player-count-selection,
    .game-started {
        padding: 25px 20px;
        width: 100%;
        max-width: 100%;
        margin: 0 auto 20px auto;
    }

    .spy-card {
        width: 250px;
        height: 350px;
        margin: 15px auto;
    }

    #characterImage {
        max-height: 200px;
    }

    .character-image-container {
        max-width: 200px;
        height: auto;
    }

    #characterName {
        font-size: 1.2rem;
        margin-top: 5px;
    }

    .btn {
        padding: 12px 20px;
        font-size: 1rem;
        margin: 8px 5px;
        min-width: 120px;
        width: auto;
        display: inline-block;
    }

    .card-controls {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        margin-top: 15px;
        width: 100%;
    }

    .card-controls .btn {
        width: 90%;
        max-width: 250px;
        margin: 5px auto !important;
    }

    #currentPlayer {
        font-size: 1.2rem;
        padding: 6px 15px;
    }

    #playerCountDisplay {
        font-size: 1.8rem;
    }

    .player-range {
        margin: 20px 0;
    }

    footer {
        font-size: 0.65rem;
        padding: 5px 10px;
        position: static;
        margin-top: 20px;
        flex-shrink: 0; /* Не сжимаем футер */
    }
}

/* Extra small devices (phones, 600px and down) */
@media (max-width: 600px) {
    body {
        padding-bottom: 80px;
    }

    .container {
        padding: 8px;
        width: 100%;
        max-width: 100%;
        height: 100vh; /* Поддерживаем фиксированную высоту */
    }

    header {
        padding: 8px 0 15px 0;
        text-align: center;
        flex-shrink: 0; /* Не сжимаем заголовок */
    }

    h1 {
        font-size: 1.6rem;
        letter-spacing: 1px;
        margin-bottom: 6px;
    }

    h1::after {
        width: 170px;
        margin: 10px auto;
    }

    h1 span {
        font-size: 0.9rem;
        margin-top: 5px;
    }

    h2 {
        font-size: 1.3rem;
    }

    #main-content {
        padding: 0; /* Убираем отступы */
        flex: 1; /* Занимает оставшееся пространство */
        align-items: center;
    }

    .screen {
        padding: 10px;
        width: 100%;
        max-width: 100%;
    }

    .player-count-selection,
    .game-started {
        padding: 20px 15px;
        margin: 0 auto 20px auto;
        width: 100%;
        max-width: 100%;
    }

    .spy-card {
        width: 200px;
        height: 300px;
        margin: 15px auto;
    }

    #characterImage {
        max-height: 160px;
    }

    .character-image-container {
        max-width: 160px;
        height: auto;
    }

    #characterName {
        font-size: 1rem;
    }

    .btn {
        padding: 10px 16px;
        font-size: 0.95rem;
        margin: 6px;
        min-width: 100px;
        width: 90%;
        max-width: 220px;
        display: block;
        text-align: center;
    }

    .card-controls {
        gap: 10px;
        margin-top: 12px;
        width: 100%;
        align-items: center;
    }

    .card-controls .btn {
        width: 90%;
        max-width: 220px;
        margin: 5px auto !important;
        display: block;
    }

    #currentPlayer {
        font-size: 1.1rem;
        padding: 5px 12px;
        width: auto;
        max-width: 90%;
    }

    #playerCountDisplay {
        font-size: 1.6rem;
    }

    footer {
        font-size: 0.6rem;
        padding: 4px 8px;
        flex-shrink: 0; /* Не сжимаем футер */
    }
}

/* Very small devices (older phones) */
@media (max-width: 480px) {
    body {
        padding-bottom: 90px;
    }

    .container {
        padding: 8px;
        height: 100vh; /* Поддерживаем фиксированную высоту */
    }

    header {
        padding: 6px 0 12px 0;
        text-align: center;
        flex-shrink: 0; /* Не сжимаем заголовок */
    }

    h1 {
        font-size: 1.4rem;
        margin-bottom: 5px;
    }

    h1::after {
        width: 150px;
        margin: 8px auto;
    }

    h1 span {
        font-size: 0.8rem;
        margin-top: 4px;
    }

    h2 {
        font-size: 1.2rem;
    }

    #main-content {
        padding: 0; /* Убираем отступы */
        flex: 1; /* Занимает оставшееся пространство */
        align-items: center;
    }

    .screen {
        padding: 8px;
        min-height: auto;
        width: 100%;
        max-width: 100%;
    }

    .player-count-selection,
    .game-started {
        padding: 18px 12px;
        margin: 0 auto 15px auto;
        width: 100%;
        max-width: 100%;
    }

    .card-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
    }

    .player-indicator {
        margin-bottom: 15px;
        width: 100%;
        text-align: center;
        flex-shrink: 0;
    }

    .spy-card {
        width: 160px;
        height: 240px;
        margin: 12px auto;
        flex-shrink: 0;
    }

    #characterImage {
        max-height: 120px;
    }

    .character-image-container {
        max-width: 120px;
        height: auto;
    }

    #characterName {
        font-size: 0.9rem;
        margin-top: 5px;
    }

    .btn {
        padding: 10px 14px;
        font-size: 0.85rem;
        min-width: 80px;
        width: 95%;
        max-width: 200px;
        margin: 5px auto;
        display: block;
        flex-shrink: 0;
    }

    .card-controls {
        gap: 8px;
        margin-top: 10px;
        align-items: center;
        width: 100%;
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
    }

    .card-controls .btn {
        width: 95%;
        max-width: 200px;
        margin: 4px auto !important;
    }

    #currentPlayer {
        font-size: 1rem;
        padding: 4px 10px;
        width: auto;
        max-width: 95%;
    }

    #playerCountDisplay {
        font-size: 1.5rem;
    }

    footer {
        font-size: 0.55rem;
        padding: 3px 6px;
        flex-shrink: 0; /* Не сжимаем футер */
    }
}

/* Additional mobile-specific fixes */
@media (max-width: 768px) {
    body {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: auto;
        overflow-x: hidden;
    }

    /* Ensure proper spacing between elements */
    .screen {
        min-height: auto;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    /* Prevent content overflow */
    .player-count-selection,
    .game-started {
        min-width: 80%;
        margin: 0 auto;
    }

    /* Ensure proper flex behavior to prevent overlapping */
    .card-container {
        flex: 1 0 auto;
        min-height: 0;
    }
}