* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    font-family: 'Comic Sans MS', 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Игра скрыта и недоступна для взаимодействия до готовности SDK
   (п. 2.14 — язык определён, п. 1.19 — момент GameReady) */
body:not(.game-ready) #game-container {
    visibility: hidden;
    pointer-events: none;
}

body:not(.game-ready) #touch-controls {
    display: none;
}

#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body.game-ready #loading-screen {
    display: none;
}

.loader-dots span {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin: 0 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    animation: loaderBlink 1.2s infinite both;
}

.loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.loader-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loaderBlink {
    0%, 80%, 100% { opacity: 0.2; }
    40% { opacity: 1; }
}

#game-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    overflow: hidden;
    transition: transform 0.05s;
}

#game-container.shaking {
    animation: containerShake 0.4s ease;
}

@keyframes containerShake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-6px, -2px); }
    20% { transform: translate(6px, 2px); }
    30% { transform: translate(-5px, 1px); }
    40% { transform: translate(5px, -1px); }
    50% { transform: translate(-3px, 2px); }
    60% { transform: translate(3px, -1px); }
    70% { transform: translate(-2px, 1px); }
    80% { transform: translate(2px, -1px); }
}

#game-container.flash-red {
    animation: containerFlash 0.35s ease;
}

@keyframes containerFlash {
    0% { box-shadow: inset 0 0 80px rgba(255,0,0,0.5); }
    100% { box-shadow: inset 0 0 0 rgba(255,0,0,0); }
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.screen.active {
    display: flex;
}

#game-screen {
    background: none;
    overflow: hidden;
}

/* Меню */
#menu-screen {
    padding: 25px 15px;
    overflow: hidden;
    justify-content: center;
    align-items: center;
    min-height: 100%;
}

#menu-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 2px;
    margin: 0 0 10px;
}

/* Обёртка для центрирования контента на экранах */
.screen-inner {
    margin: auto 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#menu-screen h1 {
    font-size: 2.8rem;
    color: white;
    text-shadow: 3px 3px 8px rgba(0,0,0,0.3);
    margin-top: 16px;
    margin-bottom: 4px;
    animation: bounce 2s ease infinite;
}

#menu-screen p {
    font-size: 1rem;
    color: rgba(255,255,255,0.85);
    margin-bottom: 6px;
    max-width: 420px;
    text-align: center;
    line-height: 1.3;
}

/* Преимущества игры */
.features {
    margin-bottom: 4px;
    max-width: 420px;
}

.features p {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.8);
    margin: 2px 0;
    padding-left: 18px;
    position: relative;
    text-align: left;
    line-height: 1.25;
}

.features p::before {
    content: '✦';
    position: absolute;
    left: 0;
    color: #feca57;
    font-size: 0.75rem;
    top: 1px;
}

.menu-btn {
    padding: 14px 36px;
    font-size: 1.25rem;
    border: none;
    border-radius: 30px;
    background: linear-gradient(45deg, #ff6b6b, #feca57);
    color: white;
    cursor: pointer;
    margin: 5px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.menu-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}

.menu-btn:active {
    transform: scale(0.97);
}

/* Выбор режима */
.mode-select {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
}

#menu-screen .mode-select-title {
    font-size: 2.2rem;
    color: rgba(255,255,255,0.95);
    margin-bottom: 0;
    font-weight: bold;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.3);
}

/* Кнопки info (i и ?) */
.info-buttons-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
    margin-bottom: 6px;
}

.info-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    font-style: italic;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(3px);
    flex-shrink: 0;
    line-height: 1;
}

.info-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

.info-btn:active {
    transform: scale(0.95);
}

/* Подсказка о паузе на главном экране */
.pause-hint {
    margin-top: 0;
    margin-bottom: 2px;
    text-align: center;
}

.pause-hint small {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
}

/* Модалки info */
.info-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 200;
}

.info-overlay.active {
    display: block;
}

.info-modal {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 88%;
    max-width: 380px;
    max-height: 70vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 16px;
    z-index: 201;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.info-modal.active {
    display: block;
}

.info-modal-content {
    padding: 18px 16px;
    overflow-y: auto;
    max-height: calc(70vh - 20px);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.info-modal-content::-webkit-scrollbar {
    width: 4px;
}

.info-modal-content::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}

.info-modal-content h3 {
    color: white;
    font-size: 1.3rem;
    text-align: center;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.info-modal-content p {
    color: rgba(255,255,255,0.85);
    margin-bottom: 6px;
    text-align: center;
    line-height: 1.3;
}

.info-modal-content .text-ru {
    color: #85c1e9;
    font-weight: bold;
    font-size: 1.1em;
}

.info-modal-content .text-en {
    color: #f1948a;
    font-weight: bold;
    font-size: 1.1em;
}

.info-modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
    padding: 0;
}

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

.mode-buttons {
    display: flex;
    gap: 8px;
    align-items: stretch;
    width: 100%;
    max-width: 400px;
}

.mode-btn {
    padding: 10px 16px !important;
    font-size: 1rem !important;
    opacity: 0.6;
    margin: 0 !important;
    width: 100%;
    box-sizing: border-box;
}

.mode-btn.active-mode {
    opacity: 1;
    box-shadow: 0 0 20px rgba(255,255,255,0.3), 0 4px 15px rgba(0,0,0,0.25) !important;
}

.mode-desc {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.75);
    margin-top: 2px;
    margin-bottom: 0;
    text-align: center;
}

.mode-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
}

/* Кнопка смены управления */
.swap-btn {
    background: linear-gradient(45deg, #00b894, #00cec9) !important;
}

.swap-btn.swapped-active {
    background: linear-gradient(45deg, #6c5ce7, #a29bfe) !important;
}

.instructions {
    margin-top: 6px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.12);
    border-radius: 12px;
    color: white;
    text-align: center;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.08);
}

.instructions p {
    margin: 3px 0;
    font-size: 0.88rem;
}

/* Выбор уровня */
#levels-screen {
    padding: 10px;
    overflow: hidden;
    justify-content: center;
    align-items: center;
}

#levels-screen .screen-inner {
    transform-origin: center center;
}

#levels-screen h2 {
    color: white;
    font-size: 1.3rem;
    margin-bottom: 8px;
}

#levels-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px 6px;
    max-width: 400px;
    margin: 0 auto 10px;
}

.level-btn {
    width: 65px;
    height: 65px;
    border: none;
    border-radius: 12px;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.level-btn.easy {
    background: linear-gradient(45deg, #2ecc71, #27ae60);
    color: white;
}

.level-btn.medium {
    background: linear-gradient(45deg, #f39c12, #e67e22);
    color: white;
}

.level-btn.hard {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
}

.level-btn.locked {
    background: #95a5a6;
    color: #7f8c8d;
    cursor: not-allowed;
}

.level-btn:hover:not(.locked) {
    transform: scale(1.1);
}

/* Игровой HUD */
#game-hud {
    width: 100%;
    height: 44px;
    display: flex;
    align-items: center;
    padding: 10px 12px 0;
    background: transparent;
    gap: 10px;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 50;
}

#hud-lives {
    font-size: 1.1rem;
    white-space: nowrap;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    gap: 0;
    line-height: 1;
}

#hud-level {
    color: rgba(255,255,255,0.7);
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    line-height: 1.1;
}

#hud-level-text {
    display: block;
}

#hud-progress {
    color: #feca57;
    font-size: 0.9rem;
    font-weight: 900;
    white-space: nowrap;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
    display: block;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0s 0.4s;
}

#hud-progress.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease, visibility 0s 0s;
}

/* Анимация полёта прогресса в позицию HUD */
.progress-fly {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    font-size: 6rem;
    font-weight: 900;
    color: #fff;
    text-shadow:
        0 0 15px rgba(255,215,0,0.9),
        0 0 40px rgba(255,165,0,0.7),
        0 0 80px rgba(255,100,0,0.4),
        3px 3px 0 rgba(0,0,0,0.3);
    animation: progressBounce 1s cubic-bezier(0.17, 0.89, 0.32, 1.2) forwards;
}

@keyframes progressBounce {
    0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
    40% { transform: translate(-50%, -50%) scale(0.95); }
    55% { transform: translate(-50%, -50%) scale(1.1); }
    70% { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
}

@keyframes progressFlyToHud {
    0% { opacity: 1; }
    100% { transform: translate(var(--fly-x), var(--fly-y)) scale(0.3); opacity: 0; }
}

#hud-word {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: nowrap;
    overflow: hidden;
    min-width: 0;
}

#hud-word.stacked {
    flex-wrap: wrap;
    justify-content: center;
    gap: 1px 4px;
    align-content: center;
}

/* Длинные слова — расположены ниже HUD-панели */
#hud-word-float {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px 4px;
    align-content: flex-start;
    padding: 2px 8px;
    z-index: 49;
    width: 100%;
}

#hud-word-float.active {
    display: flex;
    top: 44px;
}

#hud-word-float .letter-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--cell-w, 38px);
    max-width: var(--cell-w, 50px);
    width: var(--cell-w, 38px);
    height: var(--cell-h, 44px);
    padding: 0 var(--cell-pad, 4px);
    border-radius: 7px;
    font-size: var(--cell-fs, 1.35rem);
    font-weight: bold;
    color: white;
    background: rgba(0,0,0,0.35);
    border: var(--cell-border, 2px) solid rgba(255,255,255,0.3);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    flex-shrink: 0;
}

#hud-word-float .letter-cell.collected {
    background: #2ecc71;
    border-color: #27ae60;
    transform: scale(1.08);
    box-shadow: 0 0 8px rgba(46,204,113,0.4);
}

#hud-word-float .word-space {
    width: 10px;
    flex-shrink: 0;
}

#hud-word-float .letter-sep {
    color: rgba(255,255,255,0.35);
    font-size: 0.85rem;
    margin: 0 4px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    #hud-word-float.active {
        top: 32px;
    }

    #hud-word-float .letter-cell {
        min-width: var(--cell-w, 10px);
        max-width: var(--cell-w, 24px);
        width: var(--cell-w, 10px);
        height: var(--cell-h, 14px);
        font-size: var(--cell-fs, 0.5rem);
        padding: 0 var(--cell-pad, 1px);
    }
}

#hud-word .letter-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--cell-w, 38px);
    max-width: var(--cell-w, 50px);
    width: var(--cell-w, 38px);
    height: var(--cell-h, 44px);
    padding: 0 var(--cell-pad, 4px);
    border-radius: 7px;
    font-size: var(--cell-fs, 1.35rem);
    font-weight: bold;
    color: white;
    background: rgba(0,0,0,0.35);
    border: var(--cell-border, 2px) solid rgba(255,255,255,0.3);
    backdrop-filter: blur(3px);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    transition: all 0.3s;
    flex-shrink: 0;
}

#hud-word .letter-cell.collected {
    background: #2ecc71;
    border-color: #27ae60;
    transform: scale(1.08);
    box-shadow: 0 0 8px rgba(46,204,113,0.4);
}

/* Слово собрано — мультипликационная победная анимация */
#hud-word .letter-cell.word-complete {
    animation: wordCelebrate 0.8s cubic-bezier(0.17, 0.89, 0.32, 1.49) forwards;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border-color: #FF8C00;
    box-shadow: 0 0 16px rgba(255,215,0,0.7);
    color: #333;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
    z-index: 10;
}

@keyframes wordCelebrate {
    0% { transform: scale(1.08); }
    15% { transform: scale(1.6) rotate(-5deg); }
    30% { transform: scale(1.3) rotate(4deg); }
    45% { transform: scale(1.5) rotate(-3deg); }
    60% { transform: scale(1.2) rotate(2deg); }
    75% { transform: scale(1.35) rotate(0deg); }
    100% { transform: scale(1.25); }
}

/* Салют-частицы */
.firework-particle {
    position: fixed;
    pointer-events: none;
    z-index: 1001;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    animation: fireworkBurst 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes fireworkBurst {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    30% { opacity: 1; transform: translate(var(--tx), var(--ty)) scale(1.5); }
    100% { opacity: 0; transform: translate(calc(var(--tx) * 1.5), calc(var(--ty) * 1.5 + 30px)) scale(0); }
}

/* Хвосты салюта */
.firework-trail {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    animation: trailFade 0.6s ease-out forwards;
}

@keyframes trailFade {
    0% { opacity: 0.8; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.2); }
}

/* Анимация сбора буквы */
#hud-word .letter-cell.just-collected {
    animation: letterCollect 0.6s cubic-bezier(0.17, 0.89, 0.32, 1.49);
    z-index: 10;
}

@keyframes letterCollect {
    0% { transform: scale(1); box-shadow: 0 0 8px rgba(46,204,113,0.4); }
    25% { transform: scale(3); box-shadow: 0 0 40px rgba(255,215,0,0.9), 0 0 80px rgba(255,165,0,0.5); background: #FFD700; border-color: #FFC107; }
    45% { transform: scale(2.2); box-shadow: 0 0 30px rgba(255,215,0,0.7), 0 0 60px rgba(255,165,0,0.4); }
    100% { transform: scale(1.08); box-shadow: 0 0 8px rgba(46,204,113,0.4); background: #2ecc71; border-color: #27ae60; }
}

/* Упрощённая анимация на мобильных */
@media (max-width: 768px) {
    #hud-word .letter-cell.just-collected {
        animation: letterCollectMobile 0.3s ease-out;
    }

    @keyframes letterCollectMobile {
        0% { transform: scale(1); }
        50% { transform: scale(1.3); background: #FFD700; }
        100% { transform: scale(1.08); background: #2ecc71; }
    }
}

/* Звёздочки-частицы */
.star-particle {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    font-size: 16px;
    animation: starBurst 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes starBurst {
    0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
    100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0.3) rotate(var(--rot)); }
}

/* Кольцо-эффект при сборе */
.collect-ring {
    position: fixed;
    pointer-events: none;
    z-index: 999;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid #FFD700;
    animation: ringExpand 0.5s ease-out forwards;
}

@keyframes ringExpand {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(4); opacity: 0; }
}

#hud-word .word-space {
    width: 10px;
    flex-shrink: 0;
}

#hud-word .letter-sep {
    color: rgba(255,255,255,0.35);
    font-size: 0.85rem;
    margin: 0 4px;
    flex-shrink: 0;
}

#hud-score {
    color: #feca57;
    font-size: 1.1rem;
    font-weight: bold;
    min-width: 40px;
    text-align: right;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
}

#pause-btn {
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1rem;
    cursor: pointer;
    color: white;
    backdrop-filter: blur(3px);
    transition: background 0.2s;
}

#pause-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Кнопка смены языка */
.lang-btn {
    position: fixed;
    top: 12px;
    right: 20px;
    z-index: 9999;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: bold;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 20px;
    background: rgba(0,0,0,0.35);
    color: white;
    cursor: pointer;
    backdrop-filter: blur(3px);
    transition: all 0.2s;
}

.lang-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.08);
}

/* Canvas */
#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: auto;
}

/* Завершение уровня */
#complete-screen {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    padding: 10px;
    overflow: hidden;
}

#complete-screen .screen-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 5px 0;
    width: 95%;
    max-width: 480px;
}

#complete-screen .menu-btn {
    padding: 10px 24px;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    margin: 4px;
    flex-shrink: 0;
}

#complete-screen h2 {
    color: white;
    font-size: clamp(1.6rem, 5vw, 2.2rem);
    margin-bottom: 6px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    text-align: center;
}

#complete-stats {
    background: rgba(0,0,0,0.25);
    padding: 8px 12px;
    border-radius: 12px;
    color: white;
    font-size: clamp(0.8rem, 2.2vw, 1rem);
    margin-bottom: 10px;
    text-align: center;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.15);
}

#complete-stats .speak-btn {
    transition: background 0.2s, transform 0.15s;
}

#complete-stats .speak-btn:hover {
    transform: scale(1.15);
}

/* Проигрыш */
#gameover-screen {
    background: rgba(0,0,0,0.5);
    padding: 15px;
    overflow: hidden;
    align-items: center;
    z-index: 100;
}

#gameover-screen .screen-inner {
    transform-origin: center center;
}

#gameover-screen h2 {
    color: white;
    font-size: 2.2rem;
    margin-bottom: 8px;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.3);
}

#gameover-screen p {
    color: rgba(255,255,255,0.9);
    font-size: 1rem;
    margin-bottom: 15px;
}

/* Кнопка воскрешения */
.revive-btn {
    background: linear-gradient(45deg, #f39c12, #e67e22) !important;
    font-size: 1.1rem !important;
    animation: revivePulse 2s ease-in-out infinite;
}

.revive-btn:hover {
    animation: none;
}

@keyframes revivePulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(0,0,0,0.25); }
    50% { box-shadow: 0 4px 25px rgba(243,156,18,0.6), 0 0 40px rgba(243,156,18,0.3); }
}

.revive-btn.hidden,
.hidden {
    display: none;
}

/* Пауза */
#pause-screen {
    background: rgba(0,0,0,0.5);
    padding: 15px;
    overflow: hidden;
    z-index: 100;
    align-items: center;
}

#pause-screen .screen-inner {
    transform-origin: center center;
}

#pause-screen h2 {
    color: white;
    font-size: 2.2rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.4);
}

/* Экран после просмотра рекламы */
#ad-continue-screen {
    background: rgba(0,0,0,0.5);
    z-index: 100;
    align-items: center;
}

#ad-continue-screen .screen-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

@keyframes countdownPulse {
    0% { transform: scale(1.5); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

/* Плавающий оверлей обратного отсчёта поверх game-screen */
.ad-countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    pointer-events: none;
    font-size: 6rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 0 40px rgba(0,0,0,0.7), 0 0 80px rgba(0,0,0,0.4);
    animation: countdownPulse 0.5s ease-out;
}

.ad-countdown-overlay.hidden {
    display: none;
}

/* Анимации */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Адаптивность */
@media (max-width: 768px) {
    /* Меню */
    #menu-screen h1 {
        font-size: 1.5rem;
    }

    #menu-screen p {
        font-size: 0.75rem;
    }

    .menu-btn {
        padding: 10px 20px;
        font-size: 0.95rem;
    }

    #menu-screen .mode-select-title {
        font-size: 1.3rem;
    }

    .info-btn {
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }

    .features p {
        font-size: 0.7rem;
        margin: 1px 0;
    }

    .instructions {
        padding: 6px 10px;
    }

    .instructions p {
        font-size: 0.7rem;
        margin: 2px 0;
    }

    .info-modal {
        width: 92%;
        max-height: 65vh;
    }

    .info-modal-content {
        padding: 14px 12px;
    }

    .info-modal-content h3 {
        font-size: 1.1rem;
    }

    .info-modal-content p {
        font-size: 0.75rem;
    }

    .pause-hint small {
        font-size: 0.75rem;
    }

    /* Уровни */
    #levels-screen h2 {
        font-size: 1.3rem;
        margin-bottom: 10px;
    }

    #levels-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px 6px;
    }

    .level-btn {
        width: 50px;
        height: 50px;
        font-size: 1rem;
    }

    /* Игровой HUD — компактный */
    #game-hud {
        height: 32px;
        padding: 2px 6px 0;
        gap: 6px;
    }

    #hud-lives, #hud-score {
        font-size: 0.8rem;
    }

    #hud-level {
        font-size: 0.75rem;
        padding: 1px 4px;
    }

    #hud-progress {
        font-size: 0.65rem;
    }

    #hud-word .letter-cell {
        min-width: var(--cell-w, 10px);
        max-width: var(--cell-w, 24px);
        width: var(--cell-w, 10px);
        height: var(--cell-h, 14px);
        font-size: var(--cell-fs, 0.5rem);
        padding: 0 var(--cell-pad, 1px);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        transition: background 0.15s ease-out, border-color 0.15s ease-out;
    }

    /* Пауза — кнопка компактная */
    #pause-btn {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    /* Завершение */
    #complete-screen h2 {
        font-size: 1.2rem;
        margin-bottom: 4px;
    }

    #complete-stats {
        padding: 5px 8px;
        font-size: 0.7rem;
    }

    #complete-screen .menu-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    /* Проигрыш */
    #gameover-screen h2 {
        font-size: 1.4rem;
    }

    #gameover-screen p {
        font-size: 0.8rem;
        margin-bottom: 8px;
    }

    /* Пауза */
    #pause-screen h2 {
        font-size: 1.4rem;
        margin-bottom: 10px;
    }

    #pause-screen .menu-btn {
        padding: 10px 24px;
        font-size: 0.95rem;
    }

    .lang-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
        top: 6px;
        right: 8px;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .instructions {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    #complete-stats {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* Очень маленькие экраны (320px) */
@media (max-width: 400px) {
    #menu-screen h1 {
        font-size: 1.2rem;
    }

    .menu-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    .mode-btn {
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
    }

    .mode-desc {
        font-size: 0.65rem;
    }

    .mode-buttons {
        gap: 6px;
    }

    .features p {
        font-size: 0.65rem;
    }

    .instructions p {
        font-size: 0.65rem;
    }

    #levels-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px 4px;
    }

    .level-btn {
        width: 42px;
        height: 42px;
        font-size: 0.85rem;
    }
}

/* Альбомная ориентация на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
    #menu-screen {
        justify-content: center;
        padding-top: 5px;
        overflow: hidden;
    }

    #menu-inner {
        gap: 1px;
    }

    #menu-screen h1 {
        font-size: 1.3rem;
        margin-bottom: 2px;
    }

    #menu-screen p {
        font-size: 0.65rem;
        margin-bottom: 2px;
    }

    .features p {
        font-size: 0.55rem;
        margin: 1px 0;
    }

    .menu-btn {
        padding: 6px 16px;
        font-size: 0.85rem;
    }

    .mode-btn {
        padding: 4px 12px !important;
        font-size: 0.75rem !important;
    }

    .mode-desc {
        font-size: 0.6rem;
    }

    .mode-buttons {
        gap: 4px;
    }

    .instructions {
        padding: 4px 8px;
    }

    .instructions p {
        font-size: 0.6rem;
        margin: 1px 0;
    }

    .info-btn {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
    }

    .info-buttons-row {
        margin-bottom: 4px;
    }

    #menu-screen .mode-select-title {
        font-size: 1.3rem;
    }

    .info-modal {
        max-height: 60vh;
    }

    .info-modal-content {
        padding: 10px 10px;
    }

    .info-modal-content h3 {
        font-size: 0.95rem;
        margin-bottom: 6px;
    }

    .info-modal-content p {
        font-size: 0.6rem;
        margin: 2px 0;
    }

    .pause-hint small {
        font-size: 0.55rem;
    }

    #levels-screen {
        justify-content: center;
        padding: 5px;
    }

    #complete-screen {
        padding: 5px;
    }

    #complete-screen .screen-inner {
        padding: 2px 0;
    }

    #complete-screen h2 {
        font-size: 1.2rem;
        margin-bottom: 3px;
    }

    #complete-stats {
        font-size: 0.65rem;
    }

    #complete-screen .menu-btn {
        padding: 6px 14px;
        font-size: 0.75rem;
        margin: 2px;
    }
}

/* Touch-кнопки управления */
.touch-controls {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 15px;
    z-index: 9999;
    pointer-events: none;
}

.touch-controls.hidden {
    display: none;
}

.touch-group {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.touch-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.15);
    color: rgba(255,255,255,0.5);
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.1s, background 0.1s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.touch-btn:active {
    transform: scale(0.9);
    background: rgba(255,255,255,0.2);
}

.touch-group.left .touch-btn {
    border-color: rgba(52,152,219,0.3);
    background: rgba(52,152,219,0.1);
}

.touch-group.left .touch-btn:active {
    background: rgba(52,152,219,0.4);
}

.touch-group.right .touch-btn {
    border-color: rgba(231,76,60,0.3);
    background: rgba(231,76,60,0.1);
}

.touch-group.right .touch-btn:active {
    background: rgba(231,76,60,0.4);
}

/* Победное сообщение — без фона, анимированное */
.victory-msg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    pointer-events: none;
    font-size: 2rem;
    font-weight: 900;
    color: #fff;
    text-shadow:
        0 0 10px rgba(255,215,0,0.9),
        0 0 30px rgba(255,165,0,0.6),
        0 0 60px rgba(255,100,0,0.3),
        2px 2px 0 rgba(0,0,0,0.3);
    animation: victoryBounce 2s cubic-bezier(0.17, 0.89, 0.32, 1.2) forwards;
    white-space: nowrap;
}

@keyframes victoryBounce {
    0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    15% { transform: translate(-50%, -50%) scale(1.4); opacity: 1; }
    25% { transform: translate(-50%, -50%) scale(0.9); }
    35% { transform: translate(-50%, -50%) scale(1.15); }
    45% { transform: translate(-50%, -50%) scale(1.0); }
    100% { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
}

/* Победное сообщение — упрощённое для мобильных */
.victory-msg-mobile {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    pointer-events: none;
    font-size: 1.3rem;
    font-weight: 900;
    color: #fff;
    -webkit-text-stroke: 0.5px rgba(0,0,0,0.5);
    text-shadow:
        0 0 8px rgba(255,215,0,0.7),
        1px 1px 1px rgba(0,0,0,0.7),
        -1px -1px 1px rgba(0,0,0,0.5),
        1px -1px 1px rgba(0,0,0,0.5),
        -1px 1px 1px rgba(0,0,0,0.5);
    animation: victoryBounce 2s cubic-bezier(0.17, 0.89, 0.32, 1.2) forwards;
    white-space: nowrap;
    transition: opacity 0.3s ease-out;
}

.victory-msg-mobile.fading-out {
    opacity: 0;
}

/* Эффект пылинок при исчезновении надписи */
@keyframes dustBurst {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

/* Искры вокруг победного сообщения */
.victory-sparkle {
    position: fixed;
    pointer-events: none;
    z-index: 1001;
    font-size: 18px;
    animation: sparkleFloat 2.5s ease-out forwards;
}

@keyframes sparkleFloat {
    0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
    100% { opacity: 0; transform: translate(var(--sx), var(--sy)) scale(0.4) rotate(var(--sr)); }
}
