/* ===== ОСНОВНЫЕ СТИЛИ С ПИКСЕЛЬНЫМ ШРИФТОМ ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    image-rendering: pixelated;
}

/* ===== ПИКСЕЛЬНЫЕ ШРИФТЫ ===== */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
    --transition-smooth: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    --pixel-font: 'Press Start 2P', 'VT323', monospace;
    --gothic-font: 'Press Start 2P', 'VT323', monospace;
}

body {
    font-family: var(--pixel-font);
    background: #0d1310;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    color: #bfbefa;
    image-rendering: pixelated;
}

#gameContainer {
    position: relative;
    width: 1000px;
    height: 650px;
    background: #0d1310;
    border: 4px solid #482b15;
    box-shadow: 0 0 40px rgba(72, 43, 21, 0.3), inset 0 0 40px rgba(72, 43, 21, 0.1);
    border-radius: 8px;
    overflow: hidden;
    image-rendering: pixelated;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.6s ease, transform 0.6s ease;
    transform: scale(1);
}

.screen.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
    display: none;
}

/* ===== ПИКСЕЛЬНЫЕ КНОПКИ ===== */
.pixel-btn {
    font-family: var(--pixel-font);
    font-size: 14px;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-width: 4px;
    padding: 10px 24px;
    image-rendering: pixelated;
}

.pixel-btn.small {
    font-size: 10px;
    padding: 6px 14px;
}

/* ===== КНОПКИ УПРАВЛЕНИЯ ЗВУКОМ ===== */
.sound-controls {
    position: absolute;
    bottom: 15px;
    right: 15px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.sound-btn {
    background: rgba(13, 19, 16, 0.7);
    border: 3px solid rgba(189, 148, 128, 0.3);
    color: #a5978a;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    font-family: var(--pixel-font);
    image-rendering: pixelated;
}

.sound-btn:hover {
    background: rgba(189, 148, 128, 0.2);
    border-color: #bd9480;
    transform: scale(1.1);
}

.sound-btn.muted {
    opacity: 0.4;
}

/* ===== ГОТИЧЕСКИЙ СТИЛЬ ===== */
.gothic-btn {
    background: transparent;
    border: 4px solid #bd9480;
    color: #bd9480;
    padding: 12px 36px;
    font-family: var(--pixel-font);
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 3px;
    cursor: pointer;
    transition: var(--transition-bounce);
    position: relative;
    text-transform: uppercase;
    background: rgba(13, 19, 16, 0.8);
    image-rendering: pixelated;
}

.gothic-btn:hover:not(:disabled) {
    background: #bd9480;
    color: #0d1310;
    box-shadow: 0 0 30px rgba(189, 148, 128, 0.3);
    transform: scale(1.05);
}

.gothic-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.gothic-btn.small {
    padding: 8px 20px;
    font-size: 10px;
    letter-spacing: 2px;
}

.gothic-btn.danger {
    border-color: #78353b;
    color: #78353b;
}

.gothic-btn.danger:hover:not(:disabled) {
    background: #78353b;
    color: #fff;
}

.gothic-btn::before {
    content: '◆';
    margin-right: 12px;
    font-size: 10px;
}

.gothic-btn::after {
    content: '◆';
    margin-left: 12px;
    font-size: 10px;
}

.gothic-btn.small::before,
.gothic-btn.small::after {
    content: '◇';
    font-size: 8px;
}

/* ===== ПОЛЯ ВВОДА ===== */
.gothic-input {
    background: rgba(13, 19, 16, 0.8);
    border: 4px solid rgba(189, 148, 128, 0.3);
    color: #bd9480;
    padding: 10px 20px;
    font-family: var(--pixel-font);
    font-size: 12px;
    border-radius: 4px;
    transition: var(--transition-smooth);
    width: 220px;
    text-align: center;
    image-rendering: pixelated;
}

.gothic-input:focus {
    outline: none;
    border-color: #bd9480;
    box-shadow: 0 0 20px rgba(189, 148, 128, 0.2);
}

.gothic-input::placeholder {
    color: rgba(165, 151, 138, 0.4);
    font-size: 10px;
}

.auth-container {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.auth-error {
    color: #78353b;
    font-size: 10px;
    width: 100%;
    text-align: center;
    margin-top: 4px;
    transition: var(--transition-smooth);
    font-family: var(--pixel-font);
}

.auth-error.hidden {
    opacity: 0;
    transform: translateY(-10px);
}

/* ===== ГЛАВНОЕ МЕНЮ ===== */
#mainMenu {
    background: radial-gradient(ellipse at center, #1a1f1c 0%, #0d1310 70%);
    position: relative;
}

.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px;
}

.game-title {
    font-size: 48px;
    font-weight: 400;
    color: #bd9480;
    text-shadow: 0 0 60px rgba(189, 148, 128, 0.2);
    letter-spacing: 4px;
    line-height: 1.2;
    text-align: center;
    font-family: var(--pixel-font);
    image-rendering: pixelated;
}

.game-title::after {
    content: '✦';
    display: block;
    font-size: 20px;
    color: #a5978a;
    margin-top: -4px;
}

.menu-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.character-preview {
    width: 120px;
    height: 140px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
}

.character {
    position: relative;
    width: 60px;
    height: 100px;
    transition: transform 0.3s ease;
}

.character-body {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 50px;
    background: #2a1f1a;
    border-radius: 4px 4px 2px 2px;
    border: 3px solid #482b15;
}

.character-head {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 35px;
    height: 40px;
    background: #2a1f1a;
    border-radius: 50% 50% 40% 40%;
    border: 3px solid #482b15;
}

.eye {
    position: absolute;
    width: 6px;
    height: 8px;
    background: #bd9480;
    border-radius: 0;
    top: 12px;
    transition: var(--transition-smooth);
}

.left-eye {
    left: 7px;
}

.right-eye {
    right: 7px;
}

.thought-bubble {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    background: rgba(189, 148, 128, 0.15);
    border: 3px solid #bd9480;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 10px;
    color: #bd9480;
    white-space: nowrap;
    opacity: 0;
    transition: var(--transition-bounce);
    font-family: var(--pixel-font);
}

.thought-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid rgba(189, 148, 128, 0.15);
}

.character-preview:hover .thought-bubble {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.character-preview:hover .character {
    animation: jumpPreview 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes jumpPreview {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-30px); }
}

.menu-subtitle {
    color: #a5978a;
    font-size: 10px;
    letter-spacing: 4px;
    opacity: 0.7;
    margin-top: -4px;
    font-family: var(--pixel-font);
}

/* ===== ЭКРАН ПРАВИЛ ===== */
#rulesScreen {
    background: radial-gradient(ellipse at center, #1a1f1c 0%, #0d1310 70%);
}

.rules-container {
    display: flex;
    width: 85%;
    height: 60%;
    gap: 20px;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(189, 148, 128, 0.15);
    padding: 20px;
    border-radius: 4px;
    transition: var(--transition-smooth);
}

.rules-left, .rules-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.rules-center {
    flex: 2;
    max-width: 40%;
}

.rules-text-wrapper {
    background: rgba(13, 19, 16, 0.8);
    border: 3px solid rgba(189, 148, 128, 0.2);
    border-radius: 4px;
    padding: 8px;
    height: 100%;
    max-height: 250px;
}

.rules-text-scroll {
    max-height: 230px;
    overflow-y: auto;
    padding: 12px 16px;
    color: #a5978a;
}

.rules-text-scroll::-webkit-scrollbar {
    width: 4px;
}

.rules-text-scroll::-webkit-scrollbar-track {
    background: rgba(13, 19, 16, 0.5);
}

.rules-text-scroll::-webkit-scrollbar-thumb {
    background: #bd9480;
    border-radius: 2px;
}

.rules-text-scroll h2 {
    color: #bd9480;
    font-size: 16px;
    letter-spacing: 3px;
    margin-bottom: 12px;
    font-family: var(--pixel-font);
}

.rules-text-scroll ul {
    list-style: none;
    padding: 0;
}

.rules-text-scroll ul li {
    padding: 4px 0;
    padding-left: 20px;
    position: relative;
    font-size: 10px;
    line-height: 1.8;
    color: #a5978a;
    border-bottom: 1px solid rgba(189, 148, 128, 0.05);
    font-family: var(--pixel-font);
}

.rules-text-scroll ul li::before {
    content: '✦';
    position: absolute;
    left: 0;
    color: #bd9480;
    font-size: 8px;
}

.pipe-entrance {
    width: 40px;
    height: 80px;
    background: radial-gradient(ellipse at center, #482b15 0%, #2a1a0e 100%);
    border-radius: 20px 20px 4px 4px;
    border: 3px solid #bd9480;
    position: relative;
    box-shadow: inset -4px 0 12px rgba(0,0,0,0.5);
    transition: var(--transition-smooth);
}

.pipe-entrance::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -6px;
    right: -6px;
    height: 10px;
    background: #bd9480;
    border-radius: 6px 6px 0 0;
    opacity: 0.3;
}

.pipe-label {
    color: #a5978a;
    font-size: 8px;
    margin-top: 6px;
    letter-spacing: 2px;
    opacity: 0.6;
    font-family: var(--pixel-font);
}

#rulesCharacter {
    transform: scale(1.2);
}

#rulesStartBtn {
    margin-top: 16px;
}

/* ===== ЭКРАН ДОСТИЖЕНИЙ ===== */
#achievementsScreen {
    background: radial-gradient(ellipse at center, #1a1f1c 0%, #0d1310 80%);
}

.achievements-container {
    max-width: 80%;
    width: 100%;
    max-height: 80%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.achievements-container h2 {
    color: #bd9480;
    font-size: 20px;
    font-family: var(--pixel-font);
    letter-spacing: 3px;
}

.achievements-list {
    width: 100%;
    max-height: 400px;
    overflow-y: auto;
    padding: 12px 16px;
    border: 3px solid rgba(189, 148, 128, 0.1);
    border-radius: 4px;
    background: rgba(13, 19, 16, 0.5);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.achievements-list::-webkit-scrollbar {
    width: 4px;
}

.achievements-list::-webkit-scrollbar-track {
    background: rgba(13, 19, 16, 0.5);
}

.achievements-list::-webkit-scrollbar-thumb {
    background: #bd9480;
    border-radius: 2px;
}

.achievement-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(13, 19, 16, 0.6);
    border-radius: 4px;
    border: 2px solid rgba(189, 148, 128, 0.05);
    transition: var(--transition-smooth);
}

.achievement-item.unlocked {
    border-color: rgba(247, 212, 74, 0.3);
    background: rgba(247, 212, 74, 0.05);
}

.achievement-item.locked {
    opacity: 0.4;
}

.achievement-item .ach-icon {
    font-size: 16px;
}

.achievement-item .ach-info {
    flex: 1;
}

.achievement-item .ach-name {
    color: #bd9480;
    font-size: 10px;
    font-weight: 700;
    font-family: var(--pixel-font);
}

.achievement-item .ach-desc {
    color: #a5978a;
    font-size: 8px;
    opacity: 0.7;
    font-family: var(--pixel-font);
}

.achievement-item .ach-status {
    font-size: 10px;
    color: #a5978a;
}

.achievement-item.unlocked .ach-status {
    color: #f7d44a;
}

/* ===== ИГРОВОЙ ЭКРАН ===== */
#gameScreen {
    background: #0d1310;
    padding: 0;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
}

/* ===== HUD ===== */
.hud {
    position: absolute;
    top: 12px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    font-size: 10px;
    color: #a5978a;
    letter-spacing: 2px;
    pointer-events: none;
    font-family: var(--pixel-font);
    background: rgba(13, 19, 16, 0.6);
    padding: 6px 16px;
    border-radius: 4px;
    border: 3px solid rgba(189, 148, 128, 0.1);
    transition: var(--transition-smooth);
}

.hud-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hud-right {
    display: flex;
    gap: 16px;
    align-items: center;
}

.hud span {
    text-shadow: 0 0 20px rgba(0,0,0,0.8);
    font-size: 10px;
}

/* ===== ПОЛОСКА ЗДОРОВЬЯ ===== */
.health-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(13, 19, 16, 0.5);
    padding: 2px 12px 2px 8px;
    border-radius: 4px;
    border: 2px solid rgba(189, 148, 128, 0.1);
    transition: var(--transition-smooth);
}

.health-icon {
    font-size: 12px;
    color: #ff4444;
    text-shadow: 0 0 10px rgba(255, 68, 68, 0.3);
}

.health-bar-outer {
    width: 100px;
    height: 6px;
    background: rgba(255, 68, 68, 0.15);
    border-radius: 2px;
    overflow: hidden;
    border: 2px solid rgba(255, 68, 68, 0.1);
}

.health-bar-inner {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff4444, #ff6b6b);
    border-radius: 2px;
    transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.2);
}

.health-bar-inner.low {
    background: linear-gradient(90deg, #ff2200, #ff4444);
    animation: healthPulse 0.8s ease-in-out infinite;
}

@keyframes healthPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.health-text {
    font-size: 8px;
    color: #a5978a;
    min-width: 25px;
    text-align: center;
    font-weight: 700;
    font-family: var(--pixel-font);
}

/* ===== УВЕДОМЛЕНИЯ ===== */
.level-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    font-size: 48px;
    font-weight: 400;
    color: #bd9480;
    text-shadow: 0 0 80px rgba(189, 148, 128, 0.3);
    font-family: var(--pixel-font);
    letter-spacing: 4px;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    image-rendering: pixelated;
}

.level-notification.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.level-notification.fading {
    opacity: 0;
    transform: translate(-50%, -60%) scale(1.1);
}

.star-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    font-size: 18px;
    color: #f7d44a;
    text-shadow: 0 0 40px rgba(247, 212, 74, 0.5);
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: rgba(13, 19, 16, 0.7);
    padding: 16px 32px;
    border-radius: 4px;
    border: 3px solid rgba(247, 212, 74, 0.2);
    text-align: center;
    font-family: var(--pixel-font);
}

.star-notification.visible {
    opacity: 1;
    transform: translate(-50%, -60%) scale(1);
}

.star-notification .star-icon {
    font-size: 28px;
    display: block;
    margin-bottom: 4px;
}

.star-notification .compliment {
    font-size: 14px;
    color: #f7d44a;
    font-family: var(--pixel-font);
}

.achievement-notification {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    font-size: 12px;
    color: #f7d44a;
    background: rgba(13, 19, 16, 0.85);
    border: 3px solid #f7d44a;
    padding: 10px 24px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: var(--pixel-font);
    text-align: center;
    max-width: 80%;
}

.achievement-notification.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== ЭКРАН СМЕРТИ ===== */
#deathScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
    backdrop-filter: blur(8px);
}

#deathScreen.visible {
    opacity: 1;
    pointer-events: all;
}

.death-content {
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#deathScreen.visible .death-content {
    transform: scale(1);
}

.death-icon {
    font-size: 60px;
    animation: deathPulse 1.5s ease-in-out infinite;
}

@keyframes deathPulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
}

.death-content h2 {
    color: #ff4444;
    font-size: 32px;
    font-family: var(--pixel-font);
    letter-spacing: 4px;
    margin: 12px 0;
    text-shadow: 0 0 40px rgba(255, 68, 68, 0.3);
}

.death-content p {
    color: #a5978a;
    font-size: 12px;
    margin-bottom: 20px;
    opacity: 0.8;
    font-family: var(--pixel-font);
}

.death-content .gothic-btn {
    margin: 4px;
}

.death-stats {
    display: flex;
    gap: 30px;
    margin: 12px 0 20px;
    color: #a5978a;
    font-size: 10px;
    font-family: var(--pixel-font);
}

.death-stats span {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== ЭКРАН ЗАВЕРШЕНИЯ ===== */
#completionScreen {
    background: radial-gradient(ellipse at center, #1a1f1c 0%, #0d1310 80%);
}

.completion-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 70%;
    text-align: center;
}

.final-star {
    font-size: 60px;
    animation: starPulse 1.5s ease-in-out infinite;
}

@keyframes starPulse {
    0%, 100% { transform: scale(1); opacity: 1; text-shadow: 0 0 60px rgba(247, 212, 74, 0.6); }
    50% { transform: scale(1.2); opacity: 0.8; text-shadow: 0 0 120px rgba(247, 212, 74, 0.9); }
}

.completion-content h2 {
    color: #bd9480;
    font-size: 24px;
    font-family: var(--pixel-font);
    letter-spacing: 4px;
}

.completion-text-scroll {
    max-height: 200px;
    overflow-y: auto;
    padding: 12px 20px;
    color: #a5978a;
    font-size: 12px;
    line-height: 2;
    border: 3px solid rgba(189, 148, 128, 0.1);
    border-radius: 4px;
    background: rgba(13, 19, 16, 0.5);
    font-family: var(--pixel-font);
}

.completion-text-scroll::-webkit-scrollbar {
    width: 4px;
}

.completion-text-scroll::-webkit-scrollbar-thumb {
    background: #bd9480;
    border-radius: 2px;
}

#restartButton {
    margin-top: 8px;
}

/* ===== АНИМАЦИЯ ВРЕДА ===== */
@keyframes damageFlash {
    0% { filter: brightness(1); }
    25% { filter: brightness(2) hue-rotate(0deg); }
    50% { filter: brightness(0.5) hue-rotate(0deg); }
    75% { filter: brightness(1.5) hue-rotate(0deg); }
    100% { filter: brightness(1); }
}

.damage-flash {
    animation: damageFlash 0.3s ease;
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 1024px) {
    #gameContainer {
        width: 95vw;
        height: 80vh;
        border-radius: 4px;
    }
}

@media (max-width: 768px) {
    .game-title {
        font-size: 28px;
    }
    .rules-container {
        flex-direction: column;
        height: auto;
        padding: 12px;
    }
    .rules-center {
        max-width: 100%;
        width: 100%;
    }
    .rules-left, .rules-right {
        display: none;
    }
    .level-notification {
        font-size: 28px;
    }
    .star-notification {
        font-size: 14px;
        padding: 12px 20px;
    }
    .hud {
        font-size: 8px;
        padding: 4px 8px;
        flex-wrap: wrap;
        gap: 4px;
    }
    .hud-left, .hud-right {
        width: 100%;
        justify-content: space-between;
    }
    .health-bar-outer {
        width: 60px;
    }
    .health-text {
        font-size: 7px;
        min-width: 20px;
    }
    .sound-controls {
        bottom: 10px;
        right: 10px;
    }
    .sound-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    .achievements-list {
        grid-template-columns: 1fr;
        max-height: 300px;
    }
    .menu-buttons {
        flex-direction: column;
        align-items: center;
    }
    .auth-container {
        flex-direction: column;
    }
    .gothic-input {
        width: 100%;
        max-width: 200px;
        font-size: 10px;
    }
    .death-content h2 {
        font-size: 24px;
    }
    .death-icon {
        font-size: 48px;
    }
    .death-stats {
        flex-direction: column;
        gap: 8px;
    }
    .gothic-btn {
        font-size: 10px;
        padding: 8px 20px;
    }
    .pixel-btn {
        font-size: 10px;
    }
}