/* ===== БАЗОВЫЕ НАСТРОЙКИ ===== */
:root {
    --void-purple: #2d1b4e;
    --void-dark: #0f0a1a;
    --echo-blue: #4a90d9;
    --memory-gold: #ffd700;
    --harmony-green: #7cb342;
    --danger-red: #e53935;
    --pixel-scale: 4px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

body {
    margin: 0;
    overflow: hidden;
    background: var(--void-dark);
    font-family: 'Courier New', monospace;
    color: #fff;
    user-select: none;
    -webkit-user-select: none;
}

#gameCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

/* ===== UI СЛОЙ ===== */
#ui-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    padding: 20px;
    z-index: 10;
}

/* Гармония */
#harmony-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 200px;
    height: 24px;
    background: rgba(0,0,0,0.7);
    border: 2px solid var(--echo-blue);
    border-radius: 12px;
    overflow: hidden;
}

#harmony-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--harmony-green), #a5d6a7);
    transition: width 0.5s ease, background 0.3s ease;
}

#harmony-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    text-shadow: 1px 1px 2px #000;
    pointer-events: none;
}

/* Счётчик фрагментов */
#fragment-counter {
    position: absolute;
    top: 54px;
    left: 20px;
    font-size: 14px;
    text-shadow: 2px 2px 0 #000;
    color: var(--memory-gold);
}

/* ===== ПОПАП ЗОНЫ ===== */
#zone-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

#zone-popup-line {
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--echo-blue), transparent);
    margin: 0 auto 20px auto;
    animation: lineExpand 1s ease-out forwards;
}

#zone-popup-name {
    font-size: 48px;
    font-weight: bold;
    text-shadow: 0 0 20px var(--echo-blue), 2px 2px 4px #000;
    opacity: 0;
    transform: translateY(20px);
    animation: nameAppear 0.8s ease-out 0.5s forwards;
    letter-spacing: 4px;
}

#zone-popup-hint {
    margin-top: 30px;
    font-size: 14px;
    color: rgba(255,255,255,0.6);
    opacity: 0;
    animation: hintAppear 0.5s ease-out 1.5s forwards;
}

@keyframes lineExpand {
    0% { width: 0; opacity: 0; }
    100% { width: 400px; opacity: 1; }
}

@keyframes nameAppear {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes hintAppear {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes popupFadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.zone-popup-hiding {
    animation: popupFadeOut 0.5s ease-in forwards !important;
}

.zone-popup-hiding #zone-popup-line,
.zone-popup-hiding #zone-popup-name,
.zone-popup-hiding #zone-popup-hint {
    animation: none !important;
    opacity: 1;
}

/* ===== ДИАЛОГ ===== */
#dialogue-box {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 800px;
    background: rgba(15, 10, 26, 0.95);
    border: 2px solid var(--echo-blue);
    border-radius: 8px;
    padding: 24px;
    z-index: 20;
}

#dialogue-speaker {
    font-size: 18px;
    color: var(--echo-blue);
    margin-bottom: 12px;
    text-shadow: 0 0 10px var(--echo-blue);
}

#dialogue-text {
    font-size: 16px;
    line-height: 1.6;
    min-height: 60px;
}

#dialogue-hint {
    margin-top: 16px;
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    text-align: right;
}

/* ===== ФЛЕШБЕК ===== */
#flashback-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#flashback-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#flashback-text {
    position: relative;
    z-index: 2;
    font-size: 24px;
    max-width: 80%;
    text-align: center;
    line-height: 1.8;
    text-shadow: 0 0 20px rgba(255,255,255,0.5);
    padding: 40px;
}

/* ===== ГЛАВНОЕ МЕНЮ ===== */
#main-menu {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, var(--void-dark) 0%, var(--void-purple) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    gap: 20px;
}

#main-menu h1 {
    font-size: 64px;
    text-shadow: 0 0 30px var(--echo-blue), 4px 4px 0 #000;
    margin-bottom: 10px;
    letter-spacing: 8px;
}

#main-menu .subtitle {
    font-size: 18px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 40px;
    letter-spacing: 2px;
}

#main-menu button {
    background: transparent;
    border: 2px solid var(--echo-blue);
    color: #fff;
    padding: 16px 48px;
    font-size: 20px;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 2px;
}

#main-menu button:hover {
    background: var(--echo-blue);
    box-shadow: 0 0 20px var(--echo-blue);
    transform: scale(1.05);
}

/* ===== СООБЩЕНИЯ ===== */
#message-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.85);
    border: 1px solid var(--echo-blue);
    padding: 16px 32px;
    border-radius: 4px;
    font-size: 16px;
    text-align: center;
    animation: messageAppear 0.3s ease-out;
}

@keyframes messageAppear {
    from { opacity: 0; transform: translate(-50%, -40%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

/* ===== УТИЛИТЫ ===== */
.hidden { display: none !important; }

.pixel-text {
    text-shadow: 2px 2px 0 #000;
    font-size: 16px;
    letter-spacing: 1px;
}


/* ===== МЕНЮ ПАУЗЫ ===== */
.pause-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.pause-overlay h2 {
    font-size: 48px;
    text-shadow: 0 0 20px var(--echo-blue);
    margin-bottom: 20px;
    letter-spacing: 4px;
}

.pause-overlay button {
    background: transparent;
    border: 2px solid var(--echo-blue);
    color: #fff;
    padding: 14px 40px;
    font-size: 18px;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 2px;
    min-width: 250px;
}

.pause-overlay button:hover {
    background: var(--echo-blue);
    box-shadow: 0 0 20px var(--echo-blue);
    transform: scale(1.05);
}


/* ===== АНИМАЦИЯ УРОНА ===== */
@keyframes damageFlash {
    0% { opacity: 0.6; }
    50% { opacity: 0.3; }
    100% { opacity: 0; }
}

/* ===== ДИАЛОГОВЫЕ ОТВЕТЫ ===== */
#dialogue-responses button {
    position: relative;
    overflow: hidden;
}

#dialogue-responses button::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--echo-blue);
    transition: width 0.2s;
}

#dialogue-responses button:hover::before {
    width: 6px;
}

/* ===== ИНДИКАТОРЫ НАСТРОЕНИЯ ===== */
.affinity-indicator {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.affinity-friendly {
    background: rgba(129, 199, 132, 0.3);
    color: #81c784;
    border: 1px solid #81c784;
}

.affinity-neutral {
    background: rgba(144, 164, 174, 0.3);
    color: #90a4ae;
    border: 1px solid #90a4ae;
}

.affinity-hostile {
    background: rgba(229, 57, 53, 0.3);
    color: #e53935;
    border: 1px solid #e53935;
}

/* ===== ПОДСКАЗКИ ДЕЙСТВИЙ ===== */
.action-hint {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    background: rgba(0,0,0,0.7);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* ===== ЭФФЕКТ ДЭША ===== */
@keyframes dashTrail {
    0% { opacity: 0.6; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.5); }
}

.dash-trail {
    animation: dashTrail 0.3s ease-out forwards;
}

/* ===== ЛЕЧЕБНЫЕ КОЛОДЦЫ ===== */
.healing-pulse {
    animation: healingPulse 2s ease-in-out infinite;
}

@keyframes healingPulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 0.4; }
}

/* ===== ГОЛОВОЛОМКИ ===== */
.puzzle-active {
    animation: puzzleGlow 1s ease-in-out infinite alternate;
}

@keyframes puzzleGlow {
    from { box-shadow: 0 0 10px var(--echo-blue); }
    to { box-shadow: 0 0 30px var(--echo-blue), 0 0 50px var(--echo-blue); }
}

.puzzle-solved {
    animation: puzzleSolved 0.5s ease-out forwards;
}

@keyframes puzzleSolved {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 0.5; }
}

/* ===== ЛОВУШКИ ===== */
.hazard-warning {
    animation: hazardPulse 0.5s ease-in-out infinite alternate;
}

@keyframes hazardPulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

/* ===== ФИНАЛЬНЫЙ ЭКРАН ===== */
.ending-screen {
    position: fixed;
    inset: 0;
    background: #0f0a1a;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: endingAppear 2s ease-out forwards;
}

@keyframes endingAppear {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ending-title {
    font-size: 72px;
    font-weight: bold;
    text-shadow: 0 0 40px currentColor;
    margin-bottom: 30px;
    letter-spacing: 8px;
}

.ending-text {
    font-size: 20px;
    max-width: 700px;
    text-align: center;
    line-height: 1.8;
    margin-bottom: 50px;
    padding: 0 40px;
}

.ending-stats {
    display: flex;
    gap: 40px;
    margin-bottom: 50px;
    font-size: 16px;
}

.ending-stat {
    text-align: center;
}

.ending-stat-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--echo-blue);
}

.ending-restart {
    background: transparent;
    border: 2px solid currentColor;
    color: inherit;
    padding: 16px 48px;
    font-size: 20px;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 2px;
}

.ending-restart:hover {
    background: currentColor;
    color: #0f0a1a;
    transform: scale(1.05);
}
