/* Глобални стилове */
:root {
  --primary-color: #ffb86c;
  --success-color: #50fa7b;
  --danger-color: #ff5555;
  --font-pixel: 'Press Start 2P', monospace;
}

body {
  margin: 0; padding: 0; background: #000; color: #fff;
  font-family: var(--font-pixel), sans-serif;
  overflow: hidden; touch-action: none; user-select: none;
}

#app {
  position: absolute; top: 0; left: 0; width: 100vw; height: 100vh;
}

/* Общи UI Компоненти */
.overlay-screen {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center;
  z-index: 100; flex-direction: column; backdrop-filter: blur(5px);
}
.panel {
  background: rgba(20, 20, 25, 0.95); border: 4px solid var(--primary-color); padding: 20px; 
  max-width: 90%; width: 500px; text-align: center; border-radius: 8px; box-shadow: 0 0 20px #000;
}
input, select {
  width: 100%; padding: 15px; margin: 10px 0; background: #000; color: #fff;
  border: 2px solid #555; font-family: var(--font-pixel); box-sizing: border-box; text-align: center;
}
.btn {
  background: #28a745; border: 2px solid #fff; color: #fff; padding: 15px 20px; width: 100%;
  font-family: var(--font-pixel); cursor: pointer; text-transform: uppercase; margin: 10px 0;
  box-shadow: 0 4px 0 #145a24; transition: transform 0.1s, box-shadow 0.1s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 #145a24; }

/* Бутони за управление (Музика и Помощ) */
#help-btn {
  position: absolute; top: 10px; left: 10px;
  background: rgba(0,0,0,0.7); border: 2px solid var(--primary-color);
  color: #fff; font-size: 20px; padding: 10px 15px; border-radius: 50%;
  cursor: pointer; z-index: 120;
}
#music-btn {
  position: absolute; top: 10px; right: 10px;
  background: rgba(0,0,0,0.7); border: 2px solid var(--primary-color);
  color: #fff; font-size: 20px; padding: 10px 15px; border-radius: 50%;
  cursor: pointer; z-index: 120;
}
#help-modal {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.9); display: none; align-items: center; justify-content: center;
  z-index: 130; flex-direction: column; text-align: center; padding: 20px; box-sizing: border-box;
}
.help-content {
  background: #111; border: 4px solid var(--primary-color); padding: 20px;
  max-width: 600px; width: 100%; border-radius: 10px; line-height: 1.6; font-size: 14px;
}

/* Анимации за плавен преход */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* Изгледи (Екрани) */
.view-screen {
  position: absolute; width: 100%; height: 100%; display: none;
}

/* 1. Лоби (Поправено мащабиране!) */
#lobby-view {
  background: #000;
  display: flex; /* Започва като flex за центриране */
  align-items: center; justify-content: center;
}
.lobby-wrapper {
  position: relative;
  width: 100%; max-width: 100vw; max-height: 100vh;
  aspect-ratio: 1698 / 926; /* Точното съотношение на снимката ти */
  display: flex;
}
.lobby-wrapper img {
  width: 100%; height: 100%; object-fit: contain;
}

/* Вратата за мазето - нагласена на % спрямо самата снимка! */
#basement-door {
  position: absolute;
  /* Изчислени спрямо твоите координати (X:258, Y:275) */
  top: 60%; left: 32%; width: 7%; height: 20%; 
  background: transparent; border: none;
  cursor: pointer; z-index: 10;
}

/* Героят вътре в лобито */
#lobby-player {
  position: absolute;
  top: 85%; left: 15%; transform: translate(-50%, -100%);
  z-index: 5;
  transition: top 1s linear, left 1s linear;
}

/* Анимация пропадане на героя */
.falling-anim { animation: fallDown 1.2s forwards cubic-bezier(0.5, 0, 1, 1); }
@keyframes fallDown {
  0% { transform: translate(-50%, -100%) scale(1) rotate(0); opacity: 1; }
  100% { transform: translate(-50%, 300px) scale(0.1) rotate(360deg); opacity: 0; }
}

/* 2. Килия */
#cell-view {
  background-image: url('assets/cell_bg.png'); background-size: cover; background-position: center;
  display: none; justify-content: flex-end; align-items: center; padding: 20px; box-sizing: border-box;
}
.questions-panel {
  width: 45%; max-width: 450px; background: rgba(0,0,0,0.85); border: 4px solid #555;
  padding: 20px; border-radius: 10px; box-shadow: 0 0 30px #000;
  display: flex; flex-direction: column; gap: 15px; margin-right: 5%; box-sizing: border-box;
}
@media (max-width: 800px) {
  #cell-view { align-items: flex-end; justify-content: center; padding-bottom: 5%; }
  .questions-panel { width: 95%; margin-right: 0; }
}
.q-bg-text { font-size: 16px; color: var(--primary-color); line-height: 1.5; text-align: center; background: #111; padding: 15px; border-radius: 8px; }
.opt-btn {
  background: #222; color: #fff; padding: 20px; border: 2px solid #777; text-align: left;
  font-family: var(--font-pixel); font-size: 12px; cursor: pointer; transition: 0.2s;
  display: flex; gap: 10px; align-items: center;
}
.opt-btn:hover { background: #333; border-color: #fff; }
.opt-btn.correct { background: #28a745; border-color: #fff; }
.opt-btn.wrong { background: #dc3545; opacity: 0.5; }
.lang-badge { background: #000; color: #fff; padding: 5px 10px; border-radius: 4px; font-size: 10px; }

/* Анимация ключ */
#key-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.9);
  z-index: 50; display: none; flex-direction: column; align-items: center; justify-content: center;
  animation: whiteFlash 0.5s;
}
@keyframes whiteFlash { from { opacity: 0; } to { opacity: 1; } }
#the-key { width: 150px; height: auto; image-rendering: pixelated; animation: keyPop 2s forwards; filter: drop-shadow(0 10px 10px rgba(0,0,0,0.5)); }
@keyframes keyPop {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  50% { transform: scale(1.5) rotate(10deg); opacity: 1; }
  80% { transform: scale(1.2) rotate(0deg); opacity: 1; }
  100% { transform: scale(1.2) rotate(0deg); opacity: 1; }
}

/* 3. Покрив */
#roof-view {
  background-image: url('assets/roof.png'); background-size: cover; background-position: bottom center;
}
.roof-area { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.bouncing-hero { position: absolute; width: 60px; height: 80px; transform: translate(-50%, 0); animation: bounce 0.5s infinite alternate; }
@keyframes bounce { from { margin-bottom: 0; } to { margin-bottom: 40px; } }

/* Админ Панел (Обновен с карта!) */
.admin-card { background: #111; padding: 15px; border: 2px solid #444; margin-bottom: 10px; font-size: 10px; line-height: 1.5; text-align: left; }
.progress-bar { width: 100%; height: 10px; background: #333; margin-top: 5px; }
.progress-fill { height: 100%; background: var(--success-color); }

.admin-map-container {
  width: 100%; height: 300px; background: url('assets/lobby_bg.png') center/contain no-repeat #222;
  border: 4px solid #555; margin-top: 20px; position: relative; overflow: hidden; border-radius: 8px;
}
.admin-player-dot {
  position: absolute; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid #fff; transform: translate(-50%, -50%); transition: 0.5s;
  box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

/* Герой рисуван с CSS */
.pixel-char { display: inline-flex; flex-direction: column; align-items: center; justify-content: flex-end; position: absolute; width: 40px; height: 60px; bottom: 0; }
.char-name { position: absolute; top: -20px; font-size: 8px; color: #fff; text-shadow: 1px 1px 0 #000; white-space: nowrap; }
.char-head { width: 28px; height: 24px; background: #f1c27d; border: 2px solid #000; position: absolute; top: 0; z-index: 2; }
.char-hair { position: absolute; top: -4px; left: -2px; width: 28px; height: 8px; background: #3e2723; border: 2px solid #000; }
.char-hair.female { height: 16px; border-radius: 4px 4px 0 0; }
.char-eyes { position: absolute; top: 8px; left: 4px; display: flex; gap: 8px; }
.eye { width: 4px; height: 4px; background: #000; }
.char-body { width: 32px; height: 20px; border: 2px solid #000; position: absolute; top: 24px; z-index: 1; }
.char-legs { display: flex; gap: 4px; position: absolute; top: 44px; }
.leg { width: 10px; height: 14px; background: #3e2723; border: 2px solid #000; }
