@import url('oswald.css');

@font-face {
    font-family: 'OpenSans';
    src: url('../ttf/OpenSans-VariableFont_wdth,wght.ttf') format('truetype');
}

@font-face {
    font-family: 'Montserrat';
    src: url('../ttf/Montserrat-VariableFont_wght.ttf') format('truetype');
}

@font-face {
    font-family: 'Raleway';
    src: url('../ttf/Raleway-VariableFont_wght.ttf') format('truetype');
}

:root {
    --bg-image: url('../png/desktop.png');
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    min-height: 100vh;
    background-image: var(--bg-image);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: white;
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    overflow-y: visible;
}

h1 {
    font-size: 7em;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 40px;
}

@media (max-width: 768px) {
    h1 { font-size: 5em; }
}
@media (max-width: 480px) {
    h1 { font-size: 3.5em; }
}

h2 {
    font-size: 4em;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 40px;
}
@media (max-width: 768px) {
    h2 { font-size: 2.5em; }
}
@media (max-width: 480px) {
    h2 { font-size: 1.8em; }
}

h3 {
    font-size: 2.5em;
    color: white;
    margin: 0;
}

/* Кнопки */
.button, .button_2, .button_3 {
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    transition: transform 0.3s ease;  /* было transition: all 0.3s ease */
    border: none;
    padding-bottom: 6px;  /* оставляем как есть */
}

.button {
    width: 300px;
    height: 85px;
    background-image: url("../png/btn_1_off.png");
    font-size: 2.5em;
    margin-bottom: 15px;
    line-height: 1;  /* ← Добавить */
}
.button:hover {
    transform: scale(1.05);
}

.button_2 {
    width: 180px;
    height: 109px;
    background-image: url("../png/btn_2_off.png");
    font-size: 2em;
}
.button_2:hover {
    transform: scale(1.05);
}

.button_3 {
    width: 55px;
    height: 50px;
    background-image: url("../png/btn_3_off.png");
    font-size: 3em;
}
.button_3:hover {
    transform: scale(1.05);
}

a, a:hover, a:visited, a:active, a:focus {
    text-decoration: none !important;
    outline: none;
}

/* Exit page */
.btn_group {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
    margin-top: 20px;
}

/* Settings page */
.settings-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 15px 20px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 15px;
    flex-wrap: wrap;
    gap: 15px;
}
.setting-item h3 {
    min-width: 100px;
    text-align: left;
}

#bgCarousel, #btnCarousel, #fontCarousel, #piecesCarousel {
    width: 120px;
    height: 50px;
    position: relative;
}

.carousel-inner { height: 100%; }
.carousel-item {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.carousel-number {
    font-size: 2em;
    color: white;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.carousel, .carousel-inner, .carousel-item {
    background-color: transparent !important;
}

.carousel-control-prev, .carousel-control-next {
    width: 30px;
    height: 30px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.8;
    margin-top: 25px;
}
.carousel-control-prev:hover, .carousel-control-next:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.7);
}

.pieces-preview {
    display: flex;
    gap: 10px;
    background-color: rgba(0, 0, 0, 0.3);
    padding: 5px 10px;
    border-radius: 10px;
}

.piece-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.settings-buttons {
    display: flex;
    gap: 30px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}
.settings-buttons .button_2 {
    width: 274px;
    height: 109px;
    font-size: 2em;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    margin: 0;
}
.settings-buttons .button_2:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    transform: scale(1.05);
}

.close-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

/* Guide page */
.guide-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 90%;
    max-width: 600px;
    margin: 0 auto;
}

.guide-carousel {
    width: 100%;
    max-width: 500px;
    margin-bottom: 30px;
}
.guide-carousel .carousel-inner {
    background-color: rgba(0, 0, 0, 0.7) !important;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.guide-image {
    width: 100%;
    height: auto;
    display: block;
    max-height: 400px;
    object-fit: contain;
}

.guide-text {
    font-size: 2.5em;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    background-color: rgba(0, 0, 0, 0.6);
    padding: 10px 30px;
    border-radius: 40px;
    text-align: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.guide-carousel .carousel-control-prev,
.guide-carousel .carousel-control-next {
    width: 40px;
    height: 40px;
    background-color: transparent;
    border-radius: 50%;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.8;
}
.guide-carousel .carousel-control-prev:hover,
.guide-carousel .carousel-control-next:hover {
    opacity: 1;
    background-color: transparent;
}
.guide-carousel .carousel-control-prev { left: 10px; }
.guide-carousel .carousel-control-next { right: 10px; }

.carousel-control-prev-icon,
.carousel-control-next-icon {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* Адаптив для страниц */
@media (max-width: 768px) {
    body { padding: 15px; }
    .setting-item { flex-direction: column; text-align: center; }
    .setting-item h3 { text-align: center; }
    .pieces-preview { order: 2; margin-top: 10px; }
    #piecesCarousel { order: 1; }
    .guide-text { font-size: 2em; padding: 8px 20px; }
    .guide-image { max-height: 300px; }
    .btn_group { gap: 20px; }
}

@media (max-width: 480px) {
    .button { width: 250px; height: 70px; font-size: 2em; }
    .button_2 { width: 150px; height: 90px; font-size: 1.5em; }
    .settings-buttons .button_2 { width: 200px; height: 80px; font-size: 1.5em; }
    .btn_group { gap: 15px; }
}

/* Переопределение цветов для страницы настроек */
h1, .setting-item h3, .carousel-number {
    color: white !important;
}
.setting-item {
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 15px;
    padding: 15px 20px;
    margin: 5px 0;
    width: 100%;
}
.settings-buttons .button {
    color: white !important;
}

/* Игровое поле */
.game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 20px;
}

.chess-square {
    background-size: cover;
    background-position: center;
}

.piece-container {
    pointer-events: none;
    transition: transform 0.2s ease;
}

/* Доски */
#chessBoard1 {
    background-image: url('../png/deskchess.png') !important;
}

#chessBoard2 {
    background-image: url('../png/deskchess.png') !important;
}

.chess-board {
    width: 565.2px;
    height: 565.2px;
    position: relative;
    margin: 0 auto;
    flex-shrink: 0;
    background-size: 100% 100% !important;
    background-repeat: no-repeat !important;
}

/* Контейнер для досок - горизонтальный режим (по умолчанию) */
.boards-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin-top: 40px;
    min-height: 700px;
    overflow: visible;
}

.board-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: fit-content;
    overflow: visible;
}

.board-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 565.2px;
    height: 565.2px;
    background-image: url('../png/black_screen.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.board-overlay.active-overlay {
    opacity: 0.5;
    pointer-events: auto;
}

/* Масштабирование для горизонтального режима */
@media (max-width: 1300px) {
    .chess-board {
        transform: scale(0.85);
        transform-origin: center top;
    }
    
    #chessBoard2 {
        transform: rotate(180deg) scale(0.85);
        transform-origin: center center;
        position: relative;
        top: -42px;
    }
    
    .board-overlay {
        transform: scale(0.85);
        transform-origin: center top;
    }

    html, body {
        overflow-y: hidden !important;
        height: 100vh;
        max-height: 100vh;
    }
    
    .boards-container {
        overflow: visible !important;
        max-height: none;
    }
}

/* Вертикальный режим (телефоны) */
@media (max-width: 1100px) {
    html, body {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        height: auto !important;
        min-height: 100vh;
    }
    
    body {
        padding: 20px 15px;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    
    .boards-container {
        display: flex;
        flex-direction: column;
        gap: 40px;
        overflow-y: visible;
        overflow-x: hidden;
        min-height: auto;
        margin-top: 60px;
        margin-bottom: 40px;
    }
    
    .board-wrapper {
        flex-shrink: 0;
    }
    
    .chess-board {
        transform: scale(0.85);
        transform-origin: center center;
        flex-shrink: 0;
    }
    
    #chessBoard2 {
        transform: rotate(180deg) scale(0.85);
        transform-origin: center center;
        top: 0;
    }
    
    .board-overlay {
        transform: scale(0.85);
        transform-origin: center center;
    }
}

/* Очень широкие экраны (больше 1300px) */
@media (min-width: 1301px) {
    html, body {
        overflow-y: hidden !important;
        height: 100vh;
        max-height: 100vh;
    }
    
    .boards-container {
        overflow: visible !important;
        max-height: none;
        margin-top: 20px;
    }
    
    .chess-board {
        transform: none;
        transform-origin: center center;
    }
    
    #chessBoard2 {
        transform: rotate(180deg);
        top: 0;
    }
}

/* Анимация увеличения фигур на доске */
.piece-container {
    pointer-events: none;
    transition: transform 0.2s ease;
    will-change: transform;
}

/* Увеличение только если есть фигура */
.chess-square:hover .piece-container[style*="background-image"] {
    transform: scale(1.1);
}

/* Для второй доски */
#chessBoard2 .piece-container {
    transform: rotate(180deg);
}

#chessBoard2 .chess-square:hover .piece-container[style*="background-image"] {
    transform: rotate(180deg) scale(1.1);
}

/* Анимация перелёта фигур */
.piece-clone {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

/* Уведомление ШАХ */
.check-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0px;
    font-weight: 900;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    letter-spacing: 10px;
    transition: opacity 0.3s ease-out;
}

.check-notification.show {
    opacity: 1;
}

.check-notification.animate-in {
    animation: checkPopIn 0.3s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

.check-notification.animate-out {
    animation: checkFadeOut 0.4s ease-out forwards;
}

@keyframes checkPopIn {
    0% {
        font-size: 0px;
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }
    80% {
        opacity: 1;
    }
    100% {
        font-size: 120px;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes checkFadeOut {
    0% {
        font-size: 120px;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        font-size: 120px;
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Уведомление ШАХ И МАТ */
.checkmate-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0px;
    font-weight: 900;
    z-index: 10001;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    letter-spacing: 10px;
    transition: opacity 0.3s ease-out;
    text-align: center;
}

.checkmate-notification.show {
    opacity: 1;
    pointer-events: none;
}

.checkmate-notification.animate-in {
    animation: checkmatePopIn 0.4s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

.checkmate-notification.animate-out {
    animation: checkmateFadeOut 0.4s ease-out forwards;
}

@keyframes checkmatePopIn {
    0% {
        font-size: 0px;
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
        letter-spacing: 20px;
    }
    60% {
        opacity: 1;
        letter-spacing: 15px;
    }
    100% {
        font-size: 80px;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
        letter-spacing: 10px;
    }
}

@keyframes checkmateFadeOut {
    0% {
        font-size: 80px;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
        letter-spacing: 10px;
    }
    100% {
        font-size: 80px;
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
        letter-spacing: 10px;
    }
}

/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
    @keyframes checkPopIn {
        100% {
            font-size: 60px;
        }
    }
    @keyframes checkFadeOut {
        0% {
            font-size: 60px;
        }
        100% {
            font-size: 60px;
        }
    }
    @keyframes checkmatePopIn {
        100% {
            font-size: 40px;
            letter-spacing: 5px;
        }
    }
    @keyframes checkmateFadeOut {
        0% {
            font-size: 40px;
            letter-spacing: 5px;
        }
        100% {
            font-size: 40px;
            letter-spacing: 5px;
        }
    }
}

@media (max-width: 480px) {
    .check-notification {
        letter-spacing: 5px;
    }
    .checkmate-notification {
        letter-spacing: 5px;
    }
    @keyframes checkPopIn {
        100% {
            font-size: 40px;
        }
    }
    @keyframes checkFadeOut {
        0% {
            font-size: 40px;
        }
        100% {
            font-size: 40px;
        }
    }
    @keyframes checkmatePopIn {
        100% {
            font-size: 28px;
            letter-spacing: 3px;
        }
    }
    @keyframes checkmateFadeOut {
        0% {
            font-size: 28px;
            letter-spacing: 3px;
        }
        100% {
            font-size: 28px;
            letter-spacing: 3px;
        }
    }
}

/* Внутренний магазин прямо на оверлее */
.shop-inner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 500px;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    backdrop-filter: blur(5px);
    border: 2px solid rgba(255, 215, 0, 0.5);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    z-index: 20;
}

.shop-budget {
    font-size: 64px;
    font-weight: bold;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: white;
    text-shadow: 2px 2px 4px black;
}

.shop-budget-value {
    font-family: inherit;
    font-size: 64px;
}

.shop-coin-icon {
    width: 100px;
    height: 100px;
    display: inline-block;
}

.shop-pieces {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 25px 0;
    flex-wrap: wrap;
}

.shop-piece {
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease;
    transform-origin: center center;
}

.shop-piece:hover {
    transform: scale(1.08);
}

.shop-piece-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    object-fit: contain;
    pointer-events: none;
    transition: none;
}

.shop-piece-price {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    font-weight: bold;
    font-size: 24px;
    display: flex;
    align-items: flex-end;
    gap: 0px;
    white-space: nowrap;
    color: white;
    text-shadow: 1px 1px 2px black;
    transition: none;
}

.shop-piece-square {
    width: 65px;
    height: 65px;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
}

/* Увеличение фигур в магазине */
.shop-piece:hover .shop-piece-img {
    transform: translate(-50%, -50%) scale(1.1);
}

.shop-summon-btn {
    width: 200px;
    height: 60px;
    background-image: url("../png/btn_1_off.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: none;
    color: white;
    font-size: 1.8em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
    margin-left: auto;
    margin-right: auto;
    font-family: inherit;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shop-summon-btn:hover {
    transform: scale(1.05);
}

@media (max-width: 600px) {
    .shop-inner {
        width: 90%;
        padding: 15px;
    }
    .shop-budget {
        font-size: 44px;
        gap: 3px;
    }
    .shop-budget-value {
        font-size: 44px;
    }
    .shop-coin-icon {
        width: 44px;
        height: 44px;
    }
    .shop-piece-square {
        width: 50px;
        height: 50px;
    }
    .shop-piece-img {
        width: 38px;
        height: 38px;
    }
    .shop-summon-btn {
        width: 160px;
        height: 50px;
        font-size: 1.4em;
    }
}

.floating-plus {
    position: absolute;
    right: 75px;
    top: 30px;
    font-size: 50px;
    font-weight: bold;
    opacity: 0;
    pointer-events: none;
    transition: all 0.5s ease-out;
    z-index: 100;
    font-family: inherit;
}

@media (max-width: 600px) {
    .floating-plus {
        font-size: 48px;
        left: -40px;
        top: 10px;
    }
}

.shop-piece-price {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    font-weight: bold;
    font-size: 24px;
    display: flex;
    align-items: flex-end;
    gap: 0px;
    white-space: nowrap;
    color: white;
    text-shadow: 1px 1px 2px black;
}

.shop-price-coin {
    width: 28px;
    height: 28px;
}

.shop-piece.selected-piece .shop-piece-square {
    outline: 3px solid gold;
    box-shadow: 0 0 10px gold;
    border-radius: 8px;
}

.floating-minus {
    position: absolute;
    right: 75px;
    top: 0px;
    font-size: 50px;
    font-weight: bold;
    opacity: 0;
    pointer-events: none;
    transition: all 0.5s ease-out;
    z-index: 100;
    font-family: inherit;
}

#undoButton, #redoButton {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    margin: 0;
    font-size: 30px;
    width: 55px;
    height: 50px;
}



/* Плавная анимация кулдаунов в магазине */
.cooldown-badge {
    transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.4, 1.1) !important;
    will-change: transform;
    font-family: inherit !important;
    font-weight: 900 !important;
    text-shadow: 2px 2px 0 #000000 !important;
    -webkit-font-smoothing: antialiased;
        opacity: 1 !important;
    filter: none !important;
}

/* Опционально: анимация появления для новых бейджей */
@keyframes cooldownAppear {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    60% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.cooldown-badge.cooldown-new {
    animation: cooldownAppear 0.3s cubic-bezier(0.34, 1.2, 0.64, 1) forwards !important;
}
