:root {
    --primary-color: #f4d144;  /* Яркий синий */
    --secondary-color: #ff7675;  /* Розово-красный */
    --accent-color: #55efc4;  /* Кибер-бирюзовый */
    --background-color: #232730;  /* Темный фон */
    --card-background: #2d3436;  /* Серо-угольный */
    --text-color: #f5f6fa;  /* Почти белый текст */
    --shadow: 0 12px 6px #1d212a;  /* Тень */
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-tap-highlight-color: transparent; /* Для Chrome/Safari */
    tap-highlight-color: transparent; /* Для других браузеров */
}
*:focus {
    outline: none;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    background-image: url('/assets/back.webp');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.hidden {
    display: none !important;
}

.app-container {
    max-width: 100vw;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}

.title {
    width: 100%;
    max-width: 280px;
    margin: 20px auto;
    text-align: left;
}
.title h1 {
    font-size: 48px;
    line-height: 61px;
    color: #f6f9fa;
}
.title h2 {
    margin-top: 18px;
    font-size: 16px;
    line-height: 20px;
    font-weight: normal;
    color: #888c91;
}
.title h2 b {
    color: var(--primary-color);
}

.app-header, .game-header {
    text-align: center;
    padding: 1.5rem;
    background-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow);
}

.app-header h1 {
    font-size: 1.8rem;
}

.main-menu {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 2rem;
}

.menu-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 300px;
}

.menu-options .btn-primary, .menu-options .btn-secondary {
    min-width: 70%;
    padding: 0.8rem 2rem;
}


.btn-primary, .btn-secondary, .btn-danger {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    margin-top: 10px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--background-color);
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    background-color: var(--primary-color);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
}

.btn-primary:disabled:hover {
    background-color: #cccccc;
}

.btn-secondary {
    background-color: var(--card-background);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background-color: var(--card-background);
    transform: translateY(-2px);
}

input[type="text"], input[type="number"] {
    padding: 0.8rem 1rem;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    width: 100%;
    transition: var(--transition);
    background-color: rgba(255, 255, 255, 0.7);
}

input[type="text"]:focus, input[type="number"]:focus {
    border-color: var(--primary-color);
    outline: none;
}

.collection-slider {
    width: 100%;
    max-width: 300px; /* Фиксируем максимальную ширину контейнера */
    position: relative;
    margin: 1.5rem auto; /* Центрируем слайдер */
    overflow: hidden;
    box-shadow: var(--shadow);
    border-radius: 10px;
}

.slider-container {
    display: flex;
    transition: transform 0.5s ease;
    width: 100%;
    height: 400px; /* Фиксируем высоту контейнера */
}

.slide {
    min-width: 100%;
    width: 100%;
    flex-shrink: 0;
    position: relative;
    height: 100%; /* Занимаем всю высоту контейнера */
}

.slide img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Картинка заполняет слайд с сохранением пропорций */
    display: block;
}

/* Остальные стили без изменений */
.slide h3 {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 1rem;
    text-align: center;
    margin: 0;
}

.slider-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.7);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
}

.slider-nav:hover {
    background: white;
}

.slider-nav.prev {
    left: 10px;
}

.slider-nav.next {
    right: 10px;
}

/* Стрелки с помощью псевдоэлементов */
.slider-nav::before {
    content: "";
    display: block;
    width: 10px;
    height: 10px;
    border-left: 2px solid var(--background-color);
    border-bottom: 2px solid var(--background-color);
    position: absolute;
    top: 50%;
    left: 50%;
}

.slider-nav.prev::before {
    transform: translate(-40%, -50%) rotate(45deg);
}

.slider-nav.next::before {
    transform: translate(-60%, -50%) rotate(225deg);
}

.pin-code {
    font-size: 2.5rem;
    font-weight: bold;
    letter-spacing: 5px;
    text-align: center;
    margin-top: 1rem;
    margin-bottom: .4rem;
    color: var(--primary-color);
    background: #60656f;
    padding: 1rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.pin-input {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 300px;
    margin-top: 1rem;
}

.joinGameSection, .gamePinSection {
    width: 100%;
    max-width: 300px;
}

.gamePinSection p {
    color: #888c91;
}
.gamePinSection .btn-primary {
    margin-top: 1.5rem;
}

/* Game Page Styles */
.game-container {
    padding: 0;
}

.game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--primary-color);
    color: var(--background-color);
    box-shadow: var(--shadow);
}

.game-info {
    display: flex;
    flex-direction: column;
    align-items: start;
}

.collection-name {
    font-weight: bold;
    font-size: 1.1rem;
}

.game-pin {
    font-size: 17px;
    opacity: 0.8;
    line-height: 16px;
}

.player-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 28px;
    position: relative;
    padding-left: 40px;
    color: var(--background-color);
}

.player-count::before {
    content: "";
    display: block;
    width: 40px;
    height: 40px;
    margin-top: 3px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M16 11c1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3 1.34 3 3 3zm-8 0c1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3 1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V18h14v-1.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V18h6v-1.5c0-2.33-4.67-3.5-7-3.5z"/></svg>');
    background-repeat: no-repeat;
}

.game-board {
    width: 100%;
    flex: 1;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cards-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

@media (min-width: 500px) {
    .cards-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.card {
    aspect-ratio: 2/3;
    perspective: 1000px;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

/* Карты изначально повернуты лицом (flipped) */
.card.flipped .card-inner {
    transform: rotateY(0deg);
}

/* Когда flipped убран - карта повернута рубашкой */
.card:not(.flipped) .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-front {
    background: var(--card-background);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-front img {
    width: calc(100% - 6px);
    height: calc(100% - 6px);
    margin: 3px;
    border-radius: 5px;
}

.card-back {
    position: relative;
    background: var(--card-background);
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: start;
    padding: 5px;
}

.card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
}

.card-back h3 {
    position: absolute;
    bottom: 5px;
    left: 5px;
    border-radius: 0 0 5px 5px;
    width: calc(100% - 10px);
    background: rgba(0, 0, 0, 0.7);
    font-size: 0.7rem;
    text-align: center;
    margin-top: 5px;
    color: #fff;
    padding: 10px 5px;
    word-break: break-word;
    line-height: 13px;
}

#createGameSection h2 {
    width: 100%;
    text-align: center;
}

#gamePinSection p {
    line-height: 20px;
}

.bottomPanel {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    align-self: center;
    text-align: center;
    margin-top: auto;
}

.bottomPanel .counter {
    width: 100%;
    font-weight: bold;
}
.bottomPanel .counter span {
    font-size: 2rem;
}

.player-card {
    align-self: center;
    width: 150px;
    min-width: 150px;
    text-align: center;
    margin: 0 5px;
}

.player-card .card {
    max-width: 100%;
    margin-bottom: 0.5rem;
    cursor: pointer; /* Добавляем курсор-указатель */
}

.player-card .card h3 {
    font-size: 13px;
    padding: 7px 4px;
}

.game-status {
    text-align: center;
    padding: 1rem;
    background-color: white;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 200px;
}

.btn-danger:hover {
    background-color: #c82333;
    transform: translateY(-2px);
}

/* Добавляем плавную анимацию при клике */
.player-card .card .card-inner {
    transition: transform 0.6s ease;
}

.card-state-indicator {
    font-size: 0.8rem;
    color: var(--primary-color);
    margin-top: 5px;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.player-card:hover .card-state-indicator {
    opacity: 1;
}

.player-card p {
    font-weight: bold;
    color: var(--primary-color);
}

.game-status {
    width: 100%;
	display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: center;
    padding: 1rem;
    background-color: var(--card-background);
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
}
.game-status .btn-primary, .game-status .btn-secondary, .game-status .btn-danger {
	margin-top: 0;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

/* Flip animation */
.flip-animation {
    animation: flip 0.6s ease-out;
}

@keyframes flip {
    0% { transform: rotateY(0); }
    50% { transform: rotateY(90deg); opacity: .9; }
    100% { transform: rotateY(180deg); opacity: .6; }
}

@keyframes cardAppear {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.card {
    opacity: 0;
    animation: cardAppear 0.3s ease-out forwards;
}
.card.flipped {
    opacity: .7!important;
}


/* Задержка для каждой карты */
.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(4) { animation-delay: 0.4s; }
.card:nth-child(5) { animation-delay: 0.5s; }
.card:nth-child(6) { animation-delay: 0.6s; }
.card:nth-child(7) { animation-delay: 0.7s; }
.card:nth-child(8) { animation-delay: 0.8s; }
.card:nth-child(9) { animation-delay: 0.9s; }
.card:nth-child(10) { animation-delay: 1s; }
.card:nth-child(11) { animation-delay: 1.1s; }
.card:nth-child(12) { animation-delay: 1.2s; }
.card:nth-child(13) { animation-delay: 1.3s; }
.card:nth-child(14) { animation-delay: 1.4s; }
.card:nth-child(15) { animation-delay: 1.5s; }
.card:nth-child(16) { animation-delay: 1.6s; }
.card:nth-child(17) { animation-delay: 1.7s; }
.card:nth-child(18) { animation-delay: 1.8s; }
.card:nth-child(19) { animation-delay: 1.9s; }
.card:nth-child(20) { animation-delay: 2s; }
.card:nth-child(21) { animation-delay: 2.1s; }
.card:nth-child(22) { animation-delay: 2.2s; }
.card:nth-child(23) { animation-delay: 2.3s; }
.card:nth-child(24) { animation-delay: 2.4s; }
.card:nth-child(25) { animation-delay: 2.5s; }
.card:nth-child(26) { animation-delay: 2.6s; }

/* Responsive adjustments */
@media (max-width: 600px) {
    .app-header h1 {
        font-size: 1.5rem;
    }
    
    .slide h3 {
        font-size: 1rem;
        padding: 0.5rem;
    }
    
    .pin-code {
        font-size: 2rem;
        padding: 0.8rem;
    }

    .cards-grid {
        gap: 5px;
    }
    .card-back {
        padding: 3px;
    }
    .card-back h3 {
        font-size: 9px;
        left: 3px;
        bottom: 3px;
        line-height: 10px;
        width: calc(100% - 6px);
        padding: 5px 3px;
    }
}

#myScore, #playerScore {
    display: inline-block;
    transition: transform 0.2s ease-out;
    transform-origin: center bottom;
}

.swal2-container button {
    background-color: var(--primary-color);
    color: var(--background-color);
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 200px;
}
.swal2-container button.swal2-cancel {
    background-color: transparent;
    color: var(--background-color);
    border: 2px solid var(--primary-color);
    padding: 0.6rem 1.3rem;
}
.swal2-styled:focus {
    outline: none !important;
    box-shadow: none !important;
}