/* Reset и базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Шрифт ARCO */
@font-face {
    font-family: 'ARCO';
    src: url('../fonts/ARCO.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

body {
    font-family: 'ARCO', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    touch-action: manipulation;
}

/* Бумажная текстура с цветовым оверлеем */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../images/paper-texture.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.4;
    z-index: -1;
    pointer-events: none;
}

/* Экраны */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
}

/* Главный экран */
#main-screen {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

/* Большая надпись БУКВАЧ на фоне с левитацией */
.floating-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    pointer-events: none;
    display: flex;
    white-space: nowrap;
}

.float-letter {
    font-size: clamp(8rem, 30vw, 20rem);
    font-weight: 900;
    color: var(--text-primary);
    opacity: 0.08;
    display: inline-block;
    margin-left: -0.15em;
}

.float-letter:first-child {
    margin-left: 0;
}

/* Плавающие облака с правилами */
.rule-cloud {
    position: absolute;
    background: rgba(var(--card-bg-rgb), 0.5);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(var(--text-primary-rgb), 0.15);
    border-radius: 20px;
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    z-index: 1;
    pointer-events: none;
    animation: cloudFloat 8s ease-in-out infinite;
    animation-delay: var(--float-delay);
    white-space: nowrap;
}

.rule-cloud-1 {
    top: 15%;
    left: 5%;
}

.rule-cloud-2 {
    top: 25%;
    right: 5%;
}

.rule-cloud-3 {
    bottom: 25%;
    left: 8%;
}

@media (max-width: 768px) {
    .rule-cloud {
        font-size: 0.7rem;
        padding: 0.5rem 0.9rem;
    }
}

@media (max-width: 480px) {
    .rule-cloud {
        display: none;
    }
}

.container {
    max-width: 500px;
    width: 100%;
    text-align: center;
    position: relative;
    z-index: 1;
}

.logo {
    display: none;
}

.menu-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.menu-card {
    background: rgba(var(--card-bg-rgb), 0.5);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(var(--text-primary-rgb), 0.15);
    border-radius: 20px;
    padding: 1.5rem 2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    max-width: fit-content;
    margin: 0 auto;
}

.menu-card:hover {
    transform: translateY(-2px);
    background: rgba(var(--card-bg-rgb), 0.7);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.menu-card:active {
    transform: translateY(0);
}

.menu-title {
    font-family: 'ARCO', 'Inter', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-color);
}

.menu-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.stats {
    padding: 1rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.theme-switcher {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin: 1.5rem 0;
}

.theme-btn {
    background: rgba(var(--card-bg-rgb), 0.4);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-width: 80px;
}

.theme-btn:hover {
    transform: translateY(-2px);
    background: rgba(var(--card-bg-rgb), 0.6);
}

.theme-btn.active {
    border-color: var(--accent-color);
    background: rgba(var(--card-bg-rgb), 0.8);
    box-shadow: 0 0 12px rgba(var(--accent-color-rgb, 91, 124, 153), 0.3);
}

.theme-icon {
    font-size: 1.5rem;
}

.theme-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.bottom-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

.icon-button {
    background: rgba(var(--card-bg-rgb), 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 12px;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
}

.icon-button:hover {
    transform: translateY(-2px);
    background: rgba(var(--card-bg-rgb), 0.6);
}

/* Игровой экран */
#game-screen {
    flex-direction: column;
}

.game-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: transparent;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-button,
.pause-button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.5rem;
}

.game-mode {
    font-size: 1.1rem;
    font-weight: 600;
}

.timer {
    font-size: 1.3rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    width: 4.5rem;
    text-align: center;
    display: inline-block;
}

.game-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    gap: 1.5rem;
}

/* Подсказка диагонального слова */
.diagonal-hint {
    display: none;
}

.hint-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hint-word {
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: 0.3em;
    color: var(--accent-color);
    font-variant-numeric: tabular-nums;
}

/* Подсказки */
.hint-button {
    background: rgba(var(--card-bg-rgb), 0.4);
    backdrop-filter: blur(10px);
    color: var(--accent-color);
    border: 1px solid rgba(var(--accent-color-rgb, 91, 124, 153), 0.3);
    border-radius: 12px;
    padding: 0.4rem 0.8rem;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.hint-button:hover:not(:disabled) {
    background: rgba(var(--card-bg-rgb), 0.6);
    border-color: rgba(var(--accent-color-rgb, 91, 124, 153), 0.5);
    transform: translateY(-1px);
}

.hint-button:active:not(:disabled) {
    transform: translateY(0);
}

.hint-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.hint-button.active {
    background: linear-gradient(135deg, #52c234 0%, #47a82c 100%);
    box-shadow: 0 4px 12px rgba(82, 194, 52, 0.3);
}

#hint-count {
    background: rgba(255, 255, 255, 0.3);
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    min-width: 1.2rem;
    text-align: center;
    font-size: 1rem;
}

/* Сетка */
.grid {
    display: grid;
    gap: 12px;
    padding: 1rem;
}

.grid[data-size="4"] {
    grid-template-columns: repeat(4, 1fr);
}

.grid[data-size="5"] {
    grid-template-columns: repeat(5, 1fr);
}

.grid[data-size="6"] {
    grid-template-columns: repeat(6, 1fr);
}

.grid[data-size="7"] {
    grid-template-columns: repeat(7, 1fr);
}

.cell {
    aspect-ratio: 1;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.8rem;
    font-weight: 700;
    text-transform: uppercase;
    transition: all 0.15s ease;
    width: 100%;
    min-width: 60px;
    max-width: 180px;
    position: relative;
    color: var(--text-primary);
}

/* Бейджик-шестиугольник только для fixed и diagonal ячеек */
.cell.fixed::before {
    content: '';
    position: absolute;
    inset: 10%;
    background: var(--fixed-cell-bg);
    clip-path: polygon(
        25% 5%, 75% 5%,
        95% 25%, 95% 75%,
        75% 95%, 25% 95%,
        5% 75%, 5% 25%
    );
    z-index: -1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.cell.fixed {
    color: var(--accent-color);
}

.cell.diagonal::before {
    content: '';
    position: absolute;
    inset: 10%;
    background: var(--accent-color);
    clip-path: polygon(
        25% 5%, 75% 5%,
        95% 25%, 95% 75%,
        75% 95%, 25% 95%,
        5% 75%, 5% 25%
    );
    z-index: -1;
    box-shadow: 0 4px 16px rgba(var(--accent-color-rgb, 91, 124, 153), 0.4);
}

.cell.diagonal {
    color: white;
    font-weight: 900;
}

/* Тире для пустых ячеек */
.cell:empty:not(.diagonal):not(.fixed):not(.active)::after {
    content: '—';
    position: absolute;
    font-size: 0.5em;
    color: var(--text-secondary);
    opacity: 0.3;
}

/* Подчеркивание для активной ячейки - только если пустая */
.cell.active:empty::after {
    content: '_';
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7em;
    color: var(--accent-color);
    animation: blink 1s ease-in-out infinite;
}

/* Состояния букв - подсветка цветом */
.cell.correct {
    color: var(--success-color);
    font-weight: 900;
}

.cell.present {
    color: var(--present-color);
    font-weight: 900;
}

.cell.wrong {
    color: var(--error-color);
}

/* Ячейки доступные для подсказки */
.cell.hintable {
    cursor: pointer;
}

.cell.hintable::before {
    content: '';
    position: absolute;
    inset: 10%;
    background: rgba(247, 183, 49, 0.2);
    clip-path: polygon(
        25% 5%, 75% 5%,
        95% 25%, 95% 75%,
        75% 95%, 25% 95%,
        5% 75%, 5% 25%
    );
    z-index: -1;
    animation: pulse-hint 1.5s ease-in-out infinite;
}

.cell.hintable:hover::before {
    background: rgba(247, 183, 49, 0.4);
    transform: scale(1.05);
}

@keyframes pulse-hint {
    0%, 100% {
        box-shadow: 0 0 0 rgba(247, 183, 49, 0.4);
    }
    50% {
        box-shadow: 0 0 12px rgba(247, 183, 49, 0.6);
    }
}

/* Клавиатура */
.keyboard {
    padding: 1rem;
    background: transparent;
}

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

.key {
    flex: 1;
    max-width: 60px;
    min-height: 52px;
    background: rgba(var(--card-bg-rgb), 0.3);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.1s ease;
    color: var(--text-primary);
}

.key:hover {
    background: rgba(var(--card-bg-rgb), 0.5);
    border-color: rgba(var(--text-primary-rgb), 0.2);
}

.key:active {
    transform: scale(0.95);
}

.key.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.key.disabled:hover {
    background: var(--key-bg);
}

.key-wide {
    flex: 3;
    max-width: 140px;
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h2 {
    font-family: 'ARCO', 'Inter', sans-serif;
    margin-bottom: 1.5rem;
    font-size: 2rem;
}

.result-stats {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

/* Правила игры */
.rules-content {
    max-width: 500px;
    text-align: left;
}

.rules-text {
    max-height: 60vh;
    overflow-y: auto;
    margin-bottom: 1.5rem;
}

.rules-text p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.rules-text ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 1.5rem;
}

.rules-text li {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

/* Выбор размера */
.size-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.size-card {
    background: var(--card-bg);
    border: 2px solid var(--text-secondary);
    border-radius: 12px;
    padding: 1.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.size-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.3);
}

.size-card:active {
    transform: translateY(-2px);
}

.size-icon {
    font-family: 'ARCO', 'Inter', sans-serif;
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--accent-color);
    line-height: 1;
}

.size-label {
    font-family: 'ARCO', 'Inter', sans-serif;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Кнопки */
.button {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0.25rem;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--text-secondary);
}

.button:hover {
    transform: translateY(-2px);
}

.button.primary {
    background: var(--accent-color);
    color: white;
    border: none;
}

/* Уведомления */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 1rem 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: bottom 0.3s ease;
    z-index: 2000;
}

.toast.show {
    bottom: 2rem;
}

/* Адаптивность */
@media (max-width: 768px) {
    .logo {
        font-size: 2.5rem;
    }

    .cell {
        font-size: 3rem;
        max-width: 140px;
    }

    .key {
        font-size: 1.1rem;
        min-height: 48px;
    }

    .grid {
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 2rem;
        margin-bottom: 2rem;
    }

    .cell {
        font-size: 2.4rem;
        max-width: 95px;
        min-width: 55px;
    }

    .key {
        font-size: 1rem;
        min-height: 46px;
        max-width: 48px;
    }

    .grid {
        gap: 8px;
    }
}
