/* ==============================================
   Лол, куда? — Стили интерактивной новеллы
   Тёмная тема, минималистичный техно-абсурд
   ============================================== */

/* --- Кастомные свойства (Design Tokens) --- */
:root {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.85);
  --bg-card-hover: rgba(15, 23, 42, 0.95);
  --border-subtle: rgba(56, 189, 248, 0.12);
  --border-accent: rgba(56, 189, 248, 0.35);
  --border-glow: rgba(56, 189, 248, 0.6);

  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #38bdf8;
  --text-accent-soft: #7dd3fc;
  --text-green: #34d399;
  --text-red: #fb7185;
  --text-yellow: #fbbf24;

  --accent-cyan: #38bdf8;
  --accent-violet: #a78bfa;
  --accent-green: #34d399;
  --accent-red: #f87171;

  --glow-cyan: 0 0 30px rgba(56, 189, 248, 0.08);
  --glow-cyan-strong: 0 0 40px rgba(56, 189, 248, 0.15);

  --font-sans: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', 'Courier New', monospace;

  --transition-fast: 0.2s ease;
  --transition: 0.3s ease;
  --transition-slow: 0.5s ease;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --max-width: 700px;
  --padding-page: 20px;
}

/* --- Сброс и базовые стили --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Фон с градиентом и анимацией --- */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(56, 189, 248, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(167, 139, 250, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(52, 211, 153, 0.02) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-primary) 100%);
  z-index: -1;
  animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

/* --- Основной контейнер --- */
#app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--padding-page);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* --- Экраны --- */
.screen {
  display: none;
  animation: screenFadeIn 0.5s ease forwards;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

@keyframes screenFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Главный экран (меню) --- */
.main-menu {
  text-align: center;
  gap: 12px;
  padding: 40px 0;
}

.logo-title {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-violet) 50%, var(--accent-green) 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientShift 6s ease infinite;
  margin-bottom: 4px;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.logo-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 32px;
  font-weight: 400;
}

.logo-decoration {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 40px;
  opacity: 0.7;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

/* --- Кнопки --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-accent);
  background: rgba(56, 189, 248, 0.06);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.4;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.06), transparent);
  transition: left 0.5s ease;
}

.btn:hover::before {
  left: 100%;
}

.btn:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--border-glow);
  box-shadow: var(--glow-cyan);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(167, 139, 250, 0.1));
  border-color: var(--accent-cyan);
  font-weight: 600;
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(167, 139, 250, 0.15));
  box-shadow: var(--glow-cyan-strong);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border-accent);
  color: var(--text-primary);
}

.btn-danger {
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--text-red);
  background: rgba(248, 113, 113, 0.05);
  font-size: 0.85rem;
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.5);
  box-shadow: 0 0 20px rgba(248, 113, 113, 0.08);
}

.btn-small {
  padding: 10px 18px;
  font-size: 0.9rem;
}

/* --- Карточка сцены --- */
.scene-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: 100%;
  backdrop-filter: blur(12px);
  box-shadow: var(--glow-cyan);
  position: relative;
}

.scene-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
  opacity: 0.4;
}

/* --- Заголовок истории --- */
.story-header {
  text-align: center;
  margin-bottom: 20px;
  width: 100%;
}

.story-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 500;
}

.story-title {
  font-size: 1.2rem;
  color: var(--text-accent);
  font-weight: 600;
  margin-top: 2px;
}

/* --- Текст сцены --- */
.scene-text {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-line;
  margin-bottom: 28px;
  animation: textFadeIn 0.6s ease forwards;
}

@keyframes textFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Кнопки выбора --- */
.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.choice-btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(56, 189, 248, 0.04);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 400;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  line-height: 1.5;
  position: relative;
  overflow: hidden;
  animation: choiceSlideIn 0.4s ease forwards;
  opacity: 0;
  transform: translateY(12px);
}

.choice-btn:nth-child(1) { animation-delay: 0.15s; }
.choice-btn:nth-child(2) { animation-delay: 0.25s; }
.choice-btn:nth-child(3) { animation-delay: 0.35s; }
.choice-btn:nth-child(4) { animation-delay: 0.45s; }

@keyframes choiceSlideIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.choice-btn::after {
  content: '→';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  opacity: 0;
  color: var(--text-accent);
  transition: all var(--transition);
  font-size: 1.1rem;
}

.choice-btn:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--border-accent);
  padding-left: 24px;
  box-shadow: var(--glow-cyan);
}

.choice-btn:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.choice-btn:active {
  background: rgba(56, 189, 248, 0.15);
  transform: translateY(1px);
}

/* --- Футер игрового экрана --- */
.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 20px;
  padding-top: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.endings-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.endings-status span {
  color: var(--text-accent);
}

/* --- Экран концовки --- */
.ending-screen {
  text-align: center;
  gap: 20px;
  padding: 40px 0;
}

.ending-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 20px;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: var(--text-green);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.2); }
  50% { box-shadow: 0 0 20px 4px rgba(52, 211, 153, 0.1); }
}

.ending-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 8px 0;
  line-height: 1.3;
}

.ending-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  width: 100%;
  text-align: left;
  backdrop-filter: blur(12px);
}

.ending-text {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-line;
}

.ending-epilogue {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-line;
  font-style: italic;
}

.ending-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin-top: 8px;
}

/* --- Список концовок --- */
.endings-list-screen {
  gap: 20px;
  padding: 40px 0;
  width: 100%;
}

.endings-list-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
}

.endings-counter {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  font-family: var(--font-mono);
  margin-bottom: 8px;
}

.endings-counter span {
  color: var(--text-accent);
}

.endings-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.ending-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  transition: all var(--transition);
}

.ending-item.found {
  border-color: rgba(52, 211, 153, 0.2);
}

.ending-item.found:hover {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(52, 211, 153, 0.05);
}

.ending-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}

.ending-item.found .ending-icon {
  color: var(--text-green);
}

.ending-item.locked .ending-icon {
  color: var(--text-muted);
  opacity: 0.5;
}

.ending-name {
  font-size: 0.95rem;
  font-weight: 500;
}

.ending-item.found .ending-name {
  color: var(--text-primary);
}

.ending-item.locked .ending-name {
  color: var(--text-muted);
  font-style: italic;
}

.endings-list-footer {
  text-align: center;
  margin-top: 8px;
}

/* --- Экран ошибки --- */
.error-screen {
  text-align: center;
  gap: 16px;
  padding: 40px 0;
}

.error-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

.error-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-red);
}

.error-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 480px;
  line-height: 1.7;
}

.error-code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

/* --- Скрытые элементы --- */
.hidden {
  display: none !important;
}

/* --- Скроллбар --- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-accent);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

/* --- Загрузка --- */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 200px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Адаптивная вёрстка --- */
@media (max-width: 600px) {
  :root {
    --padding-page: 16px;
  }

  html {
    font-size: 15px;
  }

  .logo-title {
    font-size: 2.2rem;
  }

  .scene-card {
    padding: 24px 20px;
    border-radius: var(--radius-md);
  }

  .choice-btn {
    padding: 12px 16px;
    font-size: 0.95rem;
  }

  .ending-title {
    font-size: 1.4rem;
  }

  .game-footer {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
}

@media (max-width: 380px) {
  .logo-title {
    font-size: 1.9rem;
  }

  .scene-card {
    padding: 20px 16px;
  }
}

/* --- Анимация мерцания курсора (терминал) --- */
.cursor-blink {
  display: inline-block;
  width: 8px;
  height: 1.1em;
  background: var(--accent-cyan);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cursorBlink 1s step-end infinite;
}

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

/* --- Transition для смены экранов --- */
.screen-transition-enter {
  opacity: 0;
  transform: translateY(12px);
}

.screen-transition-active {
  opacity: 1;
  transform: translateY(0);
  transition: all var(--transition-slow);
}

/* --- Подсветка кода / терминальных блоков в тексте --- */
.scene-text code,
.ending-text code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: rgba(56, 189, 248, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-accent-soft);
}

/* --- Выделение --- */
::selection {
  background: rgba(56, 189, 248, 0.3);
  color: var(--text-primary);
}

/* --- Фокус (доступность) --- */
.btn:focus-visible,
.choice-btn:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

/* --- Подвал страницы --- */
.page-footer {
  text-align: center;
  padding: 24px 0;
  margin-top: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  opacity: 0.5;
}

.page-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.page-footer a:hover {
  color: var(--text-accent);
}
