/* ============ LODE RUNNER — Золото глубин ============ */

:root {
  --bg-deep: #07091200;
  --bg0: #070912;
  --bg1: #0d1122;
  --amber: #ffc65a;
  --amber-hot: #ffe9b0;
  --teal: #3ee0c8;
  --red: #ff5f6d;
  --ink: #cfd6ea;
  --ink-dim: #6b7492;
  --frame-glow: rgba(255, 190, 90, 0.10);
}

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

html, body { height: 100%; }

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #141a33 0%, transparent 60%),
    radial-gradient(900px 500px at 85% 110%, #1a1206 0%, transparent 55%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 70%);
  color: var(--ink);
  font-family: "Tektur", "Segoe UI", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 14px;
  overflow-x: hidden;
}

#stage {
  width: min(1120px, 96vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- HUD ---------- */

#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
}

.hud-title {
  font-family: "Bungee", cursive;
  font-size: 22px;
  letter-spacing: 1px;
  color: var(--amber);
  text-shadow: 0 0 18px rgba(255, 198, 90, 0.45);
  line-height: 1;
}
.hud-title span { color: var(--teal); text-shadow: 0 0 18px rgba(62, 224, 200, 0.4); }

.hud-level {
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-top: 3px;
}

.hud-center { text-align: center; }

.hud-score {
  font-family: "Tektur", monospace;
  font-weight: 800;
  font-size: 30px;
  letter-spacing: 6px;
  color: var(--amber-hot);
  text-shadow: 0 0 22px rgba(255, 198, 90, 0.35);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hud-score-label {
  font-size: 10px;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.hud-gold {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 18px;
  color: var(--amber-hot);
  background: rgba(255, 198, 90, 0.08);
  border: 1px solid rgba(255, 198, 90, 0.22);
  border-radius: 20px;
  padding: 3px 14px 3px 8px;
}
.coin {
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3cd, #ffc65a 45%, #b06a14 100%);
  box-shadow: 0 0 10px rgba(255, 198, 90, 0.8);
  animation: coinPulse 1.6s ease-in-out infinite;
}
@keyframes coinPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.hud-lives { display: flex; gap: 5px; }
.hud-lives .life {
  width: 12px; height: 14px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, #9ff5e6, #3ee0c8 60%, #1e8f80);
  box-shadow: 0 0 8px rgba(62, 224, 200, 0.55);
}
.hud-lives .life.lost {
  background: #232a3d;
  box-shadow: none;
  opacity: 0.5;
}

/* ---------- Игровое поле ---------- */

#frame {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 198, 90, 0.16);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 10px 60px rgba(0, 0, 0, 0.6),
    0 0 90px var(--frame-glow),
    inset 0 0 60px rgba(0, 0, 0, 0.35);
}

#game {
  display: block;
  width: 100%;
  height: auto;
  background: #070912;
}

/* виньетка + лёгкие сканлайны поверх канваса */
#frame::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.38) 100%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.016) 0 1px, transparent 1px 3px);
}

/* ---------- Оверлеи ---------- */

#overlay {
  position: absolute; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 13, 0.72);
  backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 5;
}
#overlay.visible { opacity: 1; pointer-events: auto; }

/* заставка уровня без подложки: темноту даёт ирис-переход на канвасе */
#overlay.clear {
  background: transparent;
  backdrop-filter: none;
}
#overlay.clear .ov-title,
#overlay.clear .ov-sub {
  /* у заголовков градиентная заливка текста: text-shadow пачкал буквы,
     drop-shadow рисует тень позади готовых глифов */
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 3px rgba(0, 0, 0, 0.8));
}

.ov-box { text-align: center; padding: 20px; animation: ovIn 0.5s ease both; }
@keyframes ovIn {
  from { transform: translateY(14px) scale(0.97); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.ov-title {
  font-family: "Bungee", cursive;
  font-size: clamp(34px, 6vw, 64px);
  line-height: 1.05;
  background: linear-gradient(180deg, #ffe9b0 10%, #ffc65a 45%, #e08a1e 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 24px rgba(255, 198, 90, 0.35));
  margin-bottom: 6px;
}
.ov-title.teal {
  background: linear-gradient(180deg, #d6fff7 10%, #3ee0c8 55%, #148a78 90%);
  -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 0 24px rgba(62, 224, 200, 0.35));
}
.ov-title.red {
  background: linear-gradient(180deg, #ffd3d7 10%, #ff5f6d 55%, #9c1f2c 90%);
  -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 0 24px rgba(255, 95, 109, 0.35));
}

.ov-sub {
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--ink);
  margin-bottom: 22px;
}
.ov-sub b { color: var(--amber); }

.ov-keys {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 8px 16px;
  text-align: left;
  font-size: 13px;
  color: var(--ink-dim);
  margin-bottom: 26px;
}
.ov-keys div:nth-child(odd) { text-align: right; color: var(--ink); }

.ov-press {
  font-size: 15px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--amber-hot);
  animation: blink 1.3s ease-in-out infinite;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

.ov-score-final {
  font-family: "Tektur", monospace;
  font-weight: 800;
  font-size: 34px;
  letter-spacing: 6px;
  color: var(--amber-hot);
  margin-bottom: 20px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Меню ---------- */

.ov-box.menu.wide { max-width: 94%; }

.ov-title.small {
  font-size: clamp(24px, 4vw, 38px);
  margin-bottom: 16px;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
}

.m-btn {
  font-family: "Tektur", sans-serif;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink);
  background: rgba(26, 32, 54, 0.75);
  border: 1px solid #303a5c;
  border-radius: 10px;
  padding: 11px 26px;
  min-width: 280px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.m-btn:hover, .m-btn:focus-visible {
  border-color: var(--amber);
  color: var(--amber-hot);
  box-shadow: 0 0 18px rgba(255, 198, 90, 0.18);
  outline: none;
}
.m-btn.primary {
  background: linear-gradient(180deg, rgba(255, 198, 90, 0.22), rgba(255, 198, 90, 0.08));
  border-color: rgba(255, 198, 90, 0.55);
  color: var(--amber-hot);
}
.m-btn b { color: var(--amber); font-weight: 800; }
.m-btn.back {
  min-width: 0;
  margin-top: 16px;
  font-size: 11px;
  padding: 7px 18px;
  color: var(--ink-dim);
}

.diff-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 190px));
  gap: 10px;
  justify-content: center;
  margin-bottom: 14px;
}
.m-card {
  font-family: "Tektur", sans-serif;
  text-align: center;
  padding: 13px 10px 11px;
  border-radius: 12px;
  background: rgba(26, 32, 54, 0.75);
  border: 1px solid #303a5c;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.m-card:hover { border-color: var(--ink-dim); transform: translateY(-2px); }
.m-card b {
  display: block;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.m-card span {
  display: block;
  font-size: 11px;
  line-height: 1.35;
  color: var(--ink-dim);
}
.m-card.sel {
  border-color: var(--teal);
  box-shadow: 0 0 16px rgba(62, 224, 200, 0.22);
}
.m-card.sel b { color: var(--teal); }

.m-sliders {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 10px auto 4px;
  max-width: 470px;
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(13, 17, 34, 0.6);
  border: 1px solid #232a3d;
}
.m-row {
  display: grid;
  grid-template-columns: 175px 1fr 52px;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--ink);
  text-align: left;
}
.m-row .m-val {
  text-align: right;
  color: var(--amber-hot);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #303a5c;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px rgba(255, 198, 90, 0.6);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px rgba(255, 198, 90, 0.6);
}

.ov-press.small {
  margin-top: 18px;
  font-size: 12px;
  letter-spacing: 3px;
}

kbd {
  font-family: "Tektur", monospace;
  font-size: 11px;
  background: #1a2036;
  border: 1px solid #303a5c;
  border-bottom-width: 3px;
  border-radius: 6px;
  padding: 2px 7px;
  color: var(--ink);
  white-space: nowrap;
}

/* ---------- Подсказки внизу ---------- */

#help {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
  font-size: 12px;
  color: var(--ink-dim);
  padding: 2px 0 6px;
}

@media (max-width: 720px) {
  .hud-score { font-size: 22px; letter-spacing: 3px; }
  .hud-title { font-size: 17px; }
  #help { font-size: 10px; gap: 6px 12px; }
  .diff-cards { grid-template-columns: 1fr 1fr; }
  .m-row { grid-template-columns: 120px 1fr 46px; font-size: 11px; }
  .m-btn { min-width: 220px; font-size: 12px; }
}
