/* ============================================================
   Сферическая змейка 3D — стили
   ============================================================ */

:root {
  --accent: #59f2c8;
  --accent-soft: rgba(89, 242, 200, 0.55);
  --danger: #ff6b81;
  --text: #eaf6ff;
  --muted: #9db4d6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #03060f;
  color: var(--text);
  font-family: 'Russo One', 'Segoe UI', system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
}

/* Вигнетка + лёгкое затемнение краёв */
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
              rgba(0,0,0,0) 42%,
              rgba(0,0,0,0.55) 100%);
  z-index: 2;
}

/* Красная вспышка при столкновении */
#flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
              rgba(255,60,80,0.0) 30%,
              rgba(255,40,70,0.55) 100%);
  opacity: 0;
  transition: opacity 0.12s ease-out;
  z-index: 3;
}
#flash.on { opacity: 1; }

/* ===================== HUD ===================== */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px 30px;
  pointer-events: none;
  z-index: 5;
}

.hud-left, .hud-right { display: flex; gap: 26px; }
.hud-right { flex-direction: row; align-items: center; }

.stat { display: flex; flex-direction: column; }
.stat .label {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--muted);
  margin-bottom: 4px;
}
.stat .value {
  display: block;
  font-size: 30px;
  line-height: 1;
  text-shadow: 0 0 18px var(--accent-soft);
}

/* импульс цифры счёта при поедании еды */
.stat .value.bump { animation: bumpAnim 0.45s ease; }
@keyframes bumpAnim {
  30% { transform: scale(1.4); color: #ffffff; }
}
.stat .value.best { color: var(--accent); }
.stat.small .value { font-size: 15px; letter-spacing: 2px; }

/* индикатор скорости */
#speedbar-wrap {
  display: inline-block;
  width: 90px; height: 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.10);
  overflow: hidden;
  margin-bottom: 6px;
}
#speedbar {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), #7ad0ff);
  box-shadow: 0 0 12px var(--accent-soft);
  transition: width 0.15s ease-out;
}

/* ===================== Подсказка клавиш ===================== */
#hint {
  position: fixed;
  bottom: 20px; left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 26px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 1px;
  pointer-events: none;
  z-index: 5;
}
#hint span { display: inline-flex; align-items: center; gap: 6px; }

kbd {
  display: inline-block;
  min-width: 24px;
  padding: 3px 7px;
  text-align: center;
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  border-bottom-width: 3px;
  border-radius: 6px;
}

/* ===================== Оверлеи ===================== */
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(2, 5, 14, 0.35);
  backdrop-filter: blur(3px);
  transition: opacity 0.35s ease;
}
#overlay.hidden { opacity: 0; pointer-events: none; }

.panel {
  text-align: center;
  padding: 46px 62px;
  max-width: 720px;
  background: rgba(8, 16, 34, 0.55);
  border: 1px solid rgba(120, 200, 255, 0.18);
  border-radius: 22px;
  box-shadow: 0 0 70px rgba(60, 160, 255, 0.18),
              inset 0 0 60px rgba(60, 160, 255, 0.05);
}
.panel.hidden { display: none; }

h1 {
  font-size: 58px;
  line-height: 1.05;
  letter-spacing: 4px;
  background: linear-gradient(180deg, #d7ffef, var(--accent) 60%, #37b9e8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 40px rgba(89,242,200,0.25);
  margin-bottom: 22px;
}
h2 {
  font-size: 44px;
  letter-spacing: 5px;
  color: var(--danger);
  text-shadow: 0 0 34px rgba(255,107,129,0.35);
  margin-bottom: 18px;
}

.sub {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.75;
  margin-bottom: 26px;
}

.keys {
  display: flex;
  justify-content: center;
  gap: 34px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 30px;
}
.keys span { display: inline-flex; align-items: center; gap: 6px; }

.press {
  font-size: 15px;
  color: var(--accent);
  letter-spacing: 2px;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.65; }
  50%       { opacity: 1; }
}

.final-score {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
}
.final-score .label {
  font-size: 12px; letter-spacing: 4px; color: var(--muted); margin-bottom: 6px;
}
.final-score span:last-child {
  font-size: 56px;
  text-shadow: 0 0 30px var(--accent-soft);
}

.record {
  color: #ffd76b;
  letter-spacing: 3px;
  font-size: 18px;
  margin-bottom: 22px;
  text-shadow: 0 0 24px rgba(255,215,107,0.5);
}
.record.hidden { display: none; }

/* Кнопки «Продолжить / Заново» на панели старта */
.btn-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 30px;
}
.btn-row.hidden { display: none; }
#start-hint.hidden { display: none; }

.game-btn {
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--text);
  background: rgba(89, 242, 200, 0.10);
  border: 1px solid var(--accent-soft);
  border-radius: 12px;
  padding: 12px 34px;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.game-btn:hover {
  background: rgba(89, 242, 200, 0.22);
  box-shadow: 0 0 24px rgba(89, 242, 200, 0.35);
}
.game-btn:active { transform: scale(0.97); }

.game-btn.primary {
  font-size: 18px;
  padding: 15px 46px;
  color: #dffff2;
  background: rgba(89, 242, 200, 0.18);
  border-color: var(--accent);
}
.game-btn.primary:hover { box-shadow: 0 0 34px rgba(89, 242, 200, 0.55); }

/* Ошибка загрузки */
#err {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 18px;
  line-height: 1.7;
  color: var(--danger);
  background: #03060f;
  z-index: 50;
}
#err.hidden { display: none; }

/* Кнопка вызова панели тем */
.hud-right .theme-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(120, 200, 255, 0.25);
  background: rgba(8, 16, 34, 0.55);
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 12px;
}
.hud-right .theme-toggle-btn:hover {
  background: rgba(89, 242, 200, 0.15);
  border-color: var(--accent-soft);
}
.hud-right .theme-toggle-btn:active { transform: scale(0.95); }

/* Панель смены фона */
#bg-theme-panel {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(8, 16, 34, 0.75);
  border: 1px solid rgba(120, 200, 255, 0.25);
  border-radius: 16px;
  backdrop-filter: blur(6px);
  z-index: 11;
  pointer-events: auto;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#bg-theme-panel.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}
.theme-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  font-size: 26px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-btn:hover {
  background: rgba(89, 242, 200, 0.15);
  border-color: var(--accent-soft);
  transform: scale(1.08);
}
.theme-btn.active {
  background: rgba(89, 242, 200, 0.25);
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(89, 242, 200, 0.35);
}

/* Адаптив */
@media (max-width: 720px) {
  h1 { font-size: 40px; }
  h2 { font-size: 32px; }
  .panel { padding: 34px 28px; margin: 0 16px; }
  #hint { gap: 14px; font-size: 11px; }
  .stat .value { font-size: 22px; }
  .hud-right .theme-toggle-btn { width: 32px; height: 32px; font-size: 16px; }
  #bg-theme-panel { bottom: 70px; padding: 10px 16px; }
  .theme-btn { width: 42px; height: 42px; font-size: 22px; }
}
