/* ============================================================
   TOWER FACES — минималистичный ч/б стиль (как «динозаврик»).
   Только мобильный портретный режим.
   ============================================================ */

:root {
  --ink: #1a1a1a;       /* «чёрный» — мягкий, как у дино-игры */
  --paper: #f7f7f7;     /* «белый» фон */
  --line: #1a1a1a;
  --muted: #9a9a9a;
  --font: 'Courier New', 'Consolas', monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
}

#app {
  position: fixed;
  inset: 0;
  /* учёт «чёлки»/жестовой зоны на мобильных */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- Экраны ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 28px 22px;
  text-align: center;
}
.screen.is-active { display: flex; }

.screen-title {
  font-size: clamp(22px, 7vw, 34px);
  letter-spacing: 2px;
  font-weight: 700;
  margin-top: 10px;
}

/* ---------- Кнопки ---------- */
.btn {
  display: block;
  width: 100%;
  max-width: 320px;
  padding: 16px 20px;
  margin: 8px auto;
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 2px;
  cursor: pointer;
  transition: transform .05s ease;
}
.btn:active { transform: translateY(2px); }

.btn--primary {
  color: var(--paper);
  background: var(--ink);
}

.btn--ghost {
  border: none;
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: lowercase;
  color: var(--muted);
  padding: 10px;
}

/* ---------- Главное меню ---------- */
.menu-top { margin-top: 18px; }
.logo {
  font-size: clamp(40px, 14vw, 64px);
  line-height: .95;
  font-weight: 700;
  letter-spacing: 3px;
}
.tagline {
  margin-top: 10px;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
}

/* Фон главного меню — сгенерированная сцена со светлой вуалью для читаемости */
.screen--menu {
  background-image:
    linear-gradient(rgba(247, 247, 247, 0.74), rgba(247, 247, 247, 0.90)),
    url('../assets/bg/scene.png');
  background-size: cover;
  background-position: center bottom;
}
.menu-tower {
  flex: 1;
  width: 100%;
  pointer-events: none;
}

.menu-actions { width: 100%; }
.hello {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
  min-height: 18px;
  letter-spacing: 1px;
  /* светлое свечение — гарантирует читаемость над любым участком сцены */
  text-shadow: 0 0 6px var(--paper), 0 0 10px var(--paper), 0 1px 0 var(--paper);
}
.hint {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-top: 8px;
}

/* ---------- Ввод имени ---------- */
.name-form {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: auto 0;
}
.name-input {
  width: 100%;
  padding: 18px 16px;
  font-family: var(--font);
  font-size: 22px;
  text-align: center;
  letter-spacing: 2px;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 2px;
  outline: none;
}
.name-input::placeholder { color: var(--muted); text-transform: lowercase; }
.name-input:focus { border-color: var(--ink); }
.name-error {
  min-height: 18px;
  font-size: 13px;
  color: var(--ink);
  font-weight: 700;
}

/* ---------- Игра ---------- */
.screen--game {
  padding: 0;
  justify-content: flex-start;
}
.hud {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 14px);
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
/* Крупное окно очков по центру сверху */
.score-panel {
  text-align: center;
  min-width: 150px;
  padding: 8px 30px 10px;
  background: rgba(247, 247, 247, 0.82);
  border: 3px solid var(--ink);
  border-radius: 6px;
  box-shadow: 4px 4px 0 rgba(26, 26, 26, 0.12);
}
.score-panel .hud-label {
  display: block;
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--muted);
  margin-bottom: 2px;
}
.score-panel .hud-value {
  display: block;
  font-size: 54px;
  font-weight: 700;
  line-height: 1;
}
/* Этажи — компактная «пилюля» в правом верхнем углу */
.floors-chip {
  position: absolute;
  top: 4px;
  right: 16px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 6px 13px;
  border-radius: 20px;
}

/* Тёмная тема (в «космосе») — инвертируем HUD */
.screen--game.theme-dark .score-panel {
  background: rgba(20, 20, 26, 0.7);
  border-color: var(--paper);
  color: var(--paper);
  box-shadow: 4px 4px 0 rgba(247, 247, 247, 0.12);
}
.screen--game.theme-dark .score-panel .hud-value { color: var(--paper); }
.screen--game.theme-dark .floors-chip {
  background: var(--paper);
  color: var(--ink);
}
.screen--game.theme-dark .combo-pop { color: var(--paper); }
/* Кнопка звука в игре — компактная иконка слева сверху */
.sound-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 16px;
  z-index: 6;
  width: 42px;
  height: 42px;
  font-size: 18px;
  line-height: 1;
  background: rgba(247, 247, 247, 0.82);
  border: 3px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
}
.sound-btn:active { transform: translateY(1px); }
.screen--game.theme-dark .sound-btn {
  background: rgba(20, 20, 26, 0.7);
  border-color: var(--paper);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.combo-pop {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%) scale(.6);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}
.combo-pop.show {
  animation: pop .7s ease forwards;
}
@keyframes pop {
  0%   { opacity: 0; transform: translate(-50%, -40%) scale(.6); }
  25%  { opacity: 1; transform: translate(-50%, -55%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -85%) scale(1); }
}

/* ---------- Game Over ---------- */
.result { margin: auto 0; }
.result-score {
  font-size: clamp(56px, 22vw, 96px);
  font-weight: 700;
  line-height: 1;
}
.result-sub {
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--muted);
  margin-top: 6px;
}
.result-rank {
  margin-top: 18px;
  font-size: 16px;
  letter-spacing: 1px;
  min-height: 22px;
  font-weight: 700;
}
.over-actions { width: 100%; }

/* ---------- Рейтинг ---------- */
.screen--leaders { justify-content: flex-start; gap: 16px; }
.leaders-list {
  width: 100%;
  max-width: 420px;
  flex: 1;
  margin: 16px 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.leaders-loading, .leaders-empty {
  color: var(--muted);
  margin-top: 30px;
  letter-spacing: 1px;
}
.leader-row {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 8px;
  border-bottom: 2px solid #e2e2e2;
  text-align: left;
}
.leader-row.is-me {
  background: var(--ink);
  color: var(--paper);
  border-radius: 2px;
  border-bottom-color: transparent;
}
.leader-rank { font-weight: 700; font-size: 18px; }
.leader-name {
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leader-score { font-weight: 700; font-size: 18px; }
.leader-row:nth-child(1) .leader-rank,
.leader-row:nth-child(2) .leader-rank,
.leader-row:nth-child(3) .leader-rank { font-size: 20px; }

/* ---------- Заглушка ориентации ---------- */
#rotate-hint {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  text-align: center;
  padding: 30px;
}
.rotate-inner p { font-size: 22px; font-weight: 700; letter-spacing: 2px; margin: 16px 0 10px; }
.rotate-inner small { color: var(--muted); font-size: 12px; letter-spacing: 1px; }
.phone-icon {
  font-size: 60px;
  display: inline-block;
  animation: rotate-wiggle 1.6s ease-in-out infinite;
}
@keyframes rotate-wiggle {
  0%, 100% { transform: rotate(90deg); }
  50% { transform: rotate(0deg); }
}

/* Показываем заглушку в альбомной ориентации (низкая высота). */
@media (orientation: landscape) and (max-height: 560px) {
  #rotate-hint { display: flex; }
  #app { display: none; }
}
