/* static/style.css */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    background-color: #121213;
    color: white;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-wrapper {
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-card {
    background-color: #1d1d1f;
    border: 1px solid #2f2f32;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.auth-card h1, .auth-card h2 {
    margin-bottom: 8px;
}

.auth-subtitle {
    color: #cfcfcf;
    line-height: 1.4;
    margin-bottom: 14px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.form-field label {
    font-size: 13px;
    color: #eaeaea;
}

.form-field input {
    background: #111;
    border: 1px solid #2f2f32;
    border-radius: 8px;
    padding: 10px 12px;
    color: #fff;
    font-size: 15px;
}

.field-hint {
    font-size: 12px;
    color: #cfcfcf;
}

.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.button-row.spaced {
    justify-content: space-between;
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
    color: #121213;
}

.btn.primary {
    background: #f7cd36;
    color: #121213;
}

.btn.secondary {
    background: #2f2f32;
    color: #f7cd36;
    border: 1px solid #f7cd36;
}

.btn.ghost {
    background: transparent;
    color: #f7cd36;
    border: 1px solid #3a3a3c;
}

.btn.link {
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

.btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.btn:hover:not(:disabled) {
    opacity: 0.9;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    display: none;
    z-index: 3000;
}

.toast.show {
    display: block;
}

.divider {
    margin: 12px 0;
    color: #cfcfcf;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.verification-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tg-panel {
    background: #161618;
    border: 1px dashed #3a3a3c;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tg-link-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.qr-box {
    width: 120px;
    height: 120px;
    background: #0e0e0f;
    border: 1px solid #2f2f32;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-placeholder {
    font-size: 12px;
    color: #888;
}

.qr-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.qr-inner {
    position: relative;
    width: 220px;
    height: 220px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    border: 2px solid #f7cd36;
    background: radial-gradient(circle at 20% 20%, rgba(247,205,54,0.1), transparent 40%), #0f0f12;
}

.qr-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.qr-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background: rgba(247,205,54,0.9);
    color: #121213;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 22px;
    box-shadow: 0 0 12px rgba(247,205,54,0.4);
}

.qr-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.btn.shine {
    box-shadow: 0 0 12px rgba(247,205,54,0.7);
}

.secret-word {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.secret-word-value {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 2px;
}
.checkbox-inline {
    font-size: 13px;
    color: #cfcfcf;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Поддержка безопасных областей на iPhone X и других устройствах с вырезами */
.container {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Заголовок */
header {
    padding: 10px 0;
}

.user-menu {
    position: relative;
}

.user-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: transparent;
    color: #121213;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    background-image: url('/static/icons/user.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 70% auto;
    font-size: 0;
}

.user-dropdown {
    position: absolute;
    right: 0;
    top: 40px;
    background-color: #1d1d1f;
    border: 1px solid #3a3a3c;
    border-radius: 8px;
    min-width: 180px;
    display: none;
    flex-direction: column;
    z-index: 1500;
}

.user-dropdown.show {
    display: flex;
}

.user-menu-item {
    padding: 10px 12px;
    cursor: pointer;
}

.user-menu-item:hover {
    background-color: #2a2a2c;
}

.title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.logo {
    display: flex;
    gap: 5px;
}

.logo-char {
    background-color: #f7cd36;
    color: black;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 16px;
    border-radius: 5px;
}

.icons {
    display: flex;
    gap: 12px;
    font-size: 20px;
    align-items: center;
}

.icon-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    color: transparent;
    cursor: pointer;
    user-select: none;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.fullscreen-icon {
    background-image: url('/static/icons/fullscreen.png');
}

.info-icon {
    background-image: url('/static/icons/info.png');
}

.gift-icon {
    background-image: url('/static/icons/gift.png');
}

.restart-icon {
    background-image: url('/static/icons/restart.png');
}

.menu-toggle {
    background-image: url('/static/icons/menu.png');
}

.icons .icon-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.icon-row .icon-btn,
.icon-row .user-menu {
    opacity: 0;
    transform: translateY(-10px) scale(0.9);
    pointer-events: none;
}

.icons.menu-open .icon-row .icon-btn,
.icons.menu-open .icon-row .user-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.icons.menu-collapsed .icon-row {
    pointer-events: none;
}

.icons.menu-open .icon-row .icon-btn:nth-child(1) { transition-delay: 0.15s; } /* info */
.icons.menu-open .icon-row .icon-btn:nth-child(2) { transition-delay: 0.1s; }  /* restart */
.icons.menu-open .icon-row .user-menu { transition-delay: 0.05s; }

.icons.menu-collapsed .icon-row .icon-btn:nth-child(1) { transition-delay: 0s; }
.icons.menu-collapsed .icon-row .icon-btn:nth-child(2) { transition-delay: 0.05s; }
.icons.menu-collapsed .icon-row .user-menu { transition-delay: 0.1s; }

/* Анимация переворота карточки по вертикальной оси */
@keyframes flip {
    0% {
        transform: rotateY(0deg);
    }
    45% {
        transform: rotateY(90deg);
    }
    55% {
        transform: rotateY(90deg);
    }
    100% {
        transform: rotateY(0deg);
    }
}

.letter-cell.flipping {
    animation: flip 0.6s ease-in-out forwards;
    transform-style: preserve-3d;
    backface-visibility: hidden;
}

/* Разные цвета для разных статусов при флипе */
@keyframes flip-correct {
    0% {
        transform: rotateY(0deg);
        /* Сохраняем начальные стили */
    }
    45% {
        transform: rotateY(90deg);
        /* Сохраняем начальные стили до середины переворота */
    }
    55% {
        transform: rotateY(90deg);
        background-color: #f7cd36;
        border: none;
        color: black;
    }
    100% {
        transform: rotateY(0deg);
        background-color: #f7cd36;
        border: none;
        color: black;
    }
}

@keyframes flip-partial {
    0% {
        transform: rotateY(0deg);
        /* Сохраняем начальные стили */
    }
    45% {
        transform: rotateY(90deg);
        /* Сохраняем начальные стили до середины переворота */
    }
    55% {
        transform: rotateY(90deg);
        background-color: #ffffff;
        border: none;
        color: black;
    }
    100% {
        transform: rotateY(0deg);
        background-color: #ffffff;
        border: none;
        color: black;
    }
}

@keyframes flip-incorrect {
    0% {
        transform: rotateY(0deg);
        /* Сохраняем начальные стили */
    }
    45% {
        transform: rotateY(90deg);
        /* Сохраняем начальные стили до середины переворота */
    }
    55% {
        transform: rotateY(90deg);
        background-color: #3a3a3c;
        border: none;
        color: white;
    }
    100% {
        transform: rotateY(0deg);
        background-color: #3a3a3c;
        border: none;
        color: white;
    }
}

/* Разные цвета для разных статусов при флипе - селекторы для JavaScript */
.letter-cell.flipping[style*="flip-correct"] {
    animation-name: flip-correct;
}

.letter-cell.flipping[style*="flip-partial"] {
    animation-name: flip-partial;
}

.letter-cell.flipping[style*="flip-incorrect"] {
    animation-name: flip-incorrect;
}

/* Добавляем стиль для иконки перезапуска */
.restart-icon, .gift-icon, .info-icon {
    cursor: pointer;
    font-size: 24px;
    user-select: none;
}

.restart-icon:hover, .gift-icon:hover, .info-icon:hover {
    opacity: 0.8;
}

/* Добавляем стиль для кнопки закрытия модального окна */
.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: white;
}

.modal-close:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Игровое поле */
.game-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 4px;
    overflow: hidden; /* Предотвращаем прокрутку */
}

.game-board {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 10px 0;
    flex-grow: 1;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    overflow: hidden; /* Предотвращаем прокрутку */
}

.word-row {
    display: flex;
    gap: 5px;
    justify-content: center;
    width: 100%;
}

.letter-cell {
    /* Базовый размер, который будет перезаписан из JavaScript */
    width: calc((100% - 20px) / 5);
    aspect-ratio: 1 / 1;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: min(8vw, 28px);
    font-weight: bold;
    text-transform: uppercase;
    box-sizing: border-box;
    border: 1px solid #f7cd36;
    background-color: transparent;
    transition: width 0.3s, height 0.3s, font-size 0.3s; /* Плавные переходы */
}

.letter-cell.empty {
    border: 1px solid #f7cd36;
    background-color: transparent;
}

.letter-cell.incorrect {
    background-color: #3a3a3c;
    border: none;
}

.letter-cell.correct {
    background-color: #f7cd36;
    color: black;
    border: none;
}

.letter-cell.partial {
    background-color: #ffffff;
    color: black;
    border: none;
}

/* Клавиатура */
.keyboard {
    width: 100%;
    margin-top: 10px;
    margin-bottom: 5px;
    transition: height 0.3s; /* Плавный переход */
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 8px;
    width: 100%;
}

.key {
    flex: 1;
    min-width: 0;
    /* Базовые размеры, которые будут перезаписаны из JavaScript */
    max-width: 40px;
    height: 50px;
    background-color: #121213;
    color: white;
    border: 1px solid #3a3a3c;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    padding: 0 2px;
    transition: width 0.3s, height 0.3s; /* Плавные переходы */
}

.key:hover {
    opacity: 0.8;
}

.key.correct {
    background-color: #f7cd36;
    color: black;
    border: none;
}

.key.incorrect {
    background-color: #3a3a3c;
    color: white;
    border: none;
}

.key.partial {
    background-color: #ffffff;
    color: black;
    border: none;
}

.key.special {
    max-width: 60px;
    background-color: #3a3a3c;
    border: none;
}

.special-primary {
    background-color: #3a3a3c !important;
    color: #f7cd36 !important;
    border: 1px solid #f7cd36 !important;
}

.special-secondary {
    background-color: #3a3a3c !important;
    color: #f7cd36 !important;
    border: 1px solid #f7cd36 !important;
}

.icon-key {
    background-repeat: no-repeat;
    background-position: center;
    background-size: 80% auto;
}

.enter-key {
    background-image: url('/static/icons/enter.png');
    background-size: 70% auto;
}

.backspace-key {
    background-image: url('/static/icons/backspace.png');
    background-size: 85% auto;
}

/* Стиль для активной строки */
.word-row.active .letter-cell.empty {
    border-color: #f7cd36;
}

/* Медиа-запросы для различных размеров экрана */
@media (min-width: 768px) {
    .container {
        padding: 20px;
    }

    .letter-cell {
        font-size: 28px;
    }

    .keyboard {
        margin-top: 20px;
    }

    .key {
        height: 58px;
        font-size: 18px;
        max-width: 43px;
    }

    .key.special {
        max-width: 65px;
    }

    .logo-char {
        width: 40px;
        height: 40px;
        font-size: 22px;
    }
}

/* Для небольших мобильных экранов */
@media (max-width: 350px) {
    .letter-cell {
        font-size: 7vw;
    }

    .key {
        height: 40px;
        font-size: 13px;
        max-width: 30px;
    }

    .key.special {
        max-width: 45px;
    }
}

/* Анимации */
@keyframes shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

.row-shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-30px); }
    60% { transform: translateY(-15px); }
}

.bounce {
    animation: bounce 1s ease-in-out;
}

/* Уведомления */
.message {
    position: fixed;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
    text-align: center;
    max-width: 90%;
}

.message.show {
    opacity: 1;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1001;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #121213;
    border: 2px solid #3a3a3c;
    border-radius: 10px;
    padding: 20px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative; /* Для абсолютного позиционирования кнопки закрытия */
}

.modal-title {
    color: #f7cd36;
    margin-bottom: 15px;
}

.modal-message {
    margin-bottom: 20px;
}

.modal-button {
    margin-top: 20px;
    padding: 10px 20px;
    background-color: #f7cd36;
    color: black;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

/* Фейерверк */
.firework {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    box-shadow: 0 0 10px 5px rgba(255, 255, 255, 0.8);
    animation: firework-animation 1s ease-out;
    opacity: 0;
}

@keyframes firework-animation {
    0% {
        transform: translate(0, 0) scale(0);
        opacity: 1;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(1);
        opacity: 0;
    }
}

.win-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2000;
}

.fullscreen-icon {
    cursor: pointer;
    font-size: 24px;
    user-select: none;
}

.fullscreen-icon:hover {
    opacity: 0.8;
}
