/* ==========================================
   БАЗОВЫЕ СТИЛИ
   ========================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #000;
  overflow: hidden;
  font-family: 'Courier New', Courier, monospace;
  color: #ccc;
  user-select: none;
}

canvas#game-canvas {
  display: block;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

.hidden { display: none !important; }

/* ==========================================
   HUD
   ========================================== */
#hud {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Прицел */
#crosshair {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 0 6px #000;
  line-height: 1;
}

/* Ключи */
#keys-display {
  position: absolute;
  top: 20px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
}

.key-slot {
  padding: 6px 14px;
  border: 2px solid #444;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  font-size: 13px;
  color: #555;
  transition: all 0.4s ease;
}

.key-slot.collected {
  color: #ffd080;
  border-color: #ffd080;
  text-shadow: 0 0 8px #ffd080;
  box-shadow: 0 0 10px rgba(255, 208, 128, 0.3);
}

/* Эффекты */
#effects-display {
  position: absolute;
  top: 62px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}

.effect {
  padding: 4px 10px;
  background: rgba(180, 20, 20, 0.8);
  border-radius: 4px;
  font-size: 12px;
  color: #fff;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Фонарик */
#flashlight-indicator {
  position: absolute;
  bottom: 22px; right: 24px;
  font-size: 13px;
  color: #ffd080;
  opacity: 0.75;
}

#flashlight-indicator.off {
  color: #555;
  text-decoration: line-through;
}

/* Подсказка взаимодействия */
#interact-hint {
  position: absolute;
  bottom: 72px; left: 50%;
  transform: translateX(-50%);
  padding: 6px 18px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid #888;
  border-radius: 4px;
  font-size: 13px;
  color: #ddd;
  white-space: nowrap;
}

#interact-label {
  position: absolute;
  bottom: 100px; left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  font-size: 12px;
  color: #aaa;
  white-space: nowrap;
}

/* ==========================================
   ВИЗУАЛЬНЫЕ ЭФФЕКТЫ
   ========================================== */

/* Постоянная виньетка */
#vignette {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(0, 0, 0, 0.72) 100%
  );
  pointer-events: none;
  z-index: 5;
}

/* Размытие при потере зрения */
#blur-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  backdrop-filter: blur(4px) saturate(0.3);
  background: radial-gradient(
    ellipse at center,
    transparent 25%,
    rgba(0, 40, 10, 0.45) 100%
  );
  pointer-events: none;
  z-index: 6;
}

/* ==========================================
   ОВЕРЛЕЙ ЭКРАНОВ
   ========================================== */
#overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
}

#overlay.active {
  pointer-events: all;
}

.screen {
  text-align: center;
  padding: 44px 50px;
  background: rgba(0, 0, 0, 0.93);
  border: 2px solid #2a2a2a;
  border-radius: 6px;
  max-width: 420px;
  width: 90%;
  pointer-events: all;
}

.screen h1 {
  font-size: 40px;
  letter-spacing: 8px;
  margin-bottom: 14px;
  color: #cc3333;
  text-shadow: 0 0 24px #cc3333, 0 0 60px rgba(200, 50, 50, 0.4);
}

.screen h1.red  { color: #cc3333; text-shadow: 0 0 24px #cc3333; }
.screen h1.green { color: #33cc55; text-shadow: 0 0 24px #33cc55; }

.subtitle {
  color: #666;
  font-size: 14px;
  margin-bottom: 32px;
  line-height: 1.6;
}

.controls-help {
  margin-top: 28px;
  font-size: 12px;
  color: #444;
  line-height: 2.1;
}

.controls-help kbd {
  background: #222;
  border: 1px solid #444;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 11px;
  color: #888;
}

/* Кнопки */
button {
  padding: 12px 32px;
  background: #1a1a1a;
  border: 2px solid #555;
  border-radius: 4px;
  color: #ccc;
  font-family: 'Courier New', Courier, monospace;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  margin-top: 18px;
  letter-spacing: 2px;
}

button:hover {
  background: #2a2a2a;
  border-color: #aaa;
  color: #fff;
}

button:active {
  background: #333;
}

/* Win stats */
#win-stats {
  color: #666;
  font-size: 13px;
  line-height: 2.2;
  margin: 12px 0;
}

#win-stats span {
  color: #aaa;
}

/* ==========================================
   ДИАЛОГ
   ========================================== */
#dialog-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.72);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

#dialog-box {
  background: #0e0e0e;
  border: 2px solid #444;
  border-radius: 6px;
  padding: 32px 36px;
  max-width: 520px;
  width: 92%;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
}

#dialog-title {
  color: #ffd080;
  font-size: 18px;
  margin-bottom: 18px;
  letter-spacing: 2px;
  border-bottom: 1px solid #333;
  padding-bottom: 12px;
}

#dialog-body {
  color: #bbb;
  line-height: 1.8;
  font-size: 14px;
  margin-bottom: 20px;
}

#dialog-body p {
  margin-bottom: 10px;
}

#dialog-body em {
  color: #ffd080;
  font-style: italic;
}

/* Поле ввода внутри диалога */
#dialog-body input[type="text"],
#dialog-body input[type="number"] {
  width: 100%;
  padding: 9px 12px;
  margin-top: 12px;
  background: #181818;
  border: 1px solid #555;
  border-radius: 4px;
  color: #fff;
  font-family: 'Courier New', Courier, monospace;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

#dialog-body input:focus {
  border-color: #ffd080;
}

/* Кнопки книг для загадки библиотеки */
.book-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.book-btn {
  width: 52px;
  height: 68px;
  font-size: 13px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 3px;
  letter-spacing: 0;
  margin-top: 0;
}

.book-btn.pressed {
  border-color: #33cc55 !important;
  color: #33cc55 !important;
  background: rgba(50, 200, 80, 0.1) !important;
}

.book-btn.error {
  border-color: #cc3333 !important;
  color: #cc3333 !important;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Действия диалога */
#dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid #222;
  padding-top: 18px;
}

#dialog-actions button {
  margin-top: 0;
  padding: 9px 22px;
  font-size: 13px;
}

#dialog-confirm-btn {
  border-color: #ffd080;
  color: #ffd080;
}

#dialog-confirm-btn:hover {
  background: rgba(255, 208, 128, 0.1);
  border-color: #ffea80;
}

/* Сообщение об ошибке/успехе */
.puzzle-message {
  margin-top: 10px;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
}

.puzzle-message.error {
  background: rgba(200, 50, 50, 0.2);
  color: #cc5555;
  border: 1px solid #cc3333;
}

.puzzle-message.success {
  background: rgba(50, 200, 80, 0.2);
  color: #55cc77;
  border: 1px solid #33cc55;
}
