@font-face { font-family: 'Orbitron'; font-weight: 500; font-display: swap; src: url(fonts/orbitron-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Orbitron'; font-weight: 700; font-display: swap; src: url(fonts/orbitron-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Orbitron'; font-weight: 900; font-display: swap; src: url(fonts/orbitron-latin-900-normal.woff2) format('woff2'); }

:root {
  --bg: #07010f;
  --pink: #ff2bd6;
  --cyan: #00f0ff;
  --yellow: #ffe14d;
  --purple: #b14bff;
  --text: #f4e9ff;
  --muted: #a98fd0;
  --panel: rgba(16, 3, 36, 0.86);
  --font: 'Orbitron', 'Segoe UI', sans-serif;
  --safe-top: var(--tg-content-safe-area-inset-top, env(safe-area-inset-top, 0px));
  --safe-bottom: var(--tg-content-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  user-select: none; -webkit-user-select: none;
  touch-action: none; overscroll-behavior: none;
}

#bg { position: fixed; inset: 0; z-index: 0; }

#app {
  position: fixed; inset: 0; z-index: 1;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 8px) 10px calc(var(--safe-bottom) + 6px);
  max-width: 560px; margin: 0 auto;
}

/* ---------- HUD ---------- */
.hud {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  background: rgba(10, 1, 24, 0.6);
  border: 1px solid rgba(255, 43, 214, 0.45);
  border-radius: 14px;
  box-shadow: 0 0 18px rgba(255, 43, 214, 0.25), inset 0 0 12px rgba(0, 240, 255, 0.08);
  backdrop-filter: blur(6px);
}
.stat { display: flex; flex-direction: column; min-width: 0; }
.stat .label { font-size: 9px; letter-spacing: 2px; color: var(--muted); }
.stat .value {
  font-size: 24px; font-weight: 900; color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan); line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat .value.small { font-size: 15px; color: var(--yellow); text-shadow: 0 0 8px var(--yellow); }
.stat .value.bump { animation: bump 0.25s ease-out; }
@keyframes bump { 40% { transform: scale(1.18); } }
.stat.next { align-items: center; }
.stat.next img { width: 34px; height: 34px; }
.buttons { margin-left: auto; display: flex; gap: 6px; }
.icon {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid rgba(0, 240, 255, 0.5); background: rgba(0, 240, 255, 0.08);
  color: var(--cyan); font-size: 16px; cursor: pointer; padding: 0;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.25);
}
.icon.off { opacity: 0.35; filter: grayscale(1); }

/* ---------- Игровое поле ---------- */
#stage {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding-top: 4px;
}
#game { display: block; touch-action: none; }

#chain {
  display: flex; justify-content: center; align-items: center; gap: 3px;
  padding-top: 4px; height: 30px;
}
#chain img { width: 22px; height: 22px; opacity: 0.25; filter: grayscale(0.8); transition: 0.3s; }
#chain img.got { opacity: 1; filter: none; }
#chain img.got.newest { transform: scale(1.35); }

/* ---------- Оверлеи ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(5, 0, 14, 0.6);
  backdrop-filter: blur(3px);
  animation: fade 0.25s ease-out;
}
.overlay.hidden, .hidden { display: none !important; }
@keyframes fade { from { opacity: 0; } }

.panel {
  width: 100%; max-width: 380px;
  padding: 24px 20px;
  background: var(--panel);
  border: 1px solid rgba(255, 43, 214, 0.6);
  border-radius: 20px;
  box-shadow: 0 0 30px rgba(255, 43, 214, 0.35), inset 0 0 30px rgba(0, 240, 255, 0.07);
  text-align: center;
  display: flex; flex-direction: column; gap: 12px;
}
.panel.tall { max-height: calc(100% - 20px); }

.logo { margin: 0 0 4px; line-height: 1; }
.logo span {
  display: block; font-size: 64px; font-weight: 900; letter-spacing: 4px;
  background: linear-gradient(180deg, #ffe14d 0%, #ff8a00 45%, #ff2bd6 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 12px rgba(255, 43, 214, 0.8));
}
.logo small {
  display: block; margin-top: 6px; font-size: 18px; letter-spacing: 8px;
  color: var(--cyan); text-shadow: 0 0 10px var(--cyan);
}
.hint { margin: 0; font-family: system-ui, sans-serif; font-size: 14px; color: var(--muted); line-height: 1.45; }
.hint b { color: var(--yellow); }
.chain-big { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 4px 0; }
.chain-big img { width: 30px; height: 30px; }

h2 { margin: 0; font-size: 26px; letter-spacing: 4px; color: var(--pink); text-shadow: 0 0 12px var(--pink); }
.glitch { animation: glitch 1.6s infinite; }
@keyframes glitch {
  0%, 92%, 100% { transform: none; text-shadow: 0 0 12px var(--pink); }
  94% { transform: translateX(-3px); text-shadow: 3px 0 var(--cyan), -3px 0 var(--pink); }
  97% { transform: translateX(2px); text-shadow: -2px 0 var(--cyan), 2px 0 var(--yellow); }
}
.final {
  font-size: 56px; font-weight: 900; color: var(--cyan);
  text-shadow: 0 0 18px var(--cyan); font-variant-numeric: tabular-nums;
}
.record { color: var(--yellow); text-shadow: 0 0 10px var(--yellow); font-weight: 900; letter-spacing: 2px; animation: bump 0.6s infinite; }
.meta { font-family: system-ui, sans-serif; color: var(--muted); font-size: 14px; min-height: 18px; }

.btn {
  font-family: var(--font); font-weight: 700; font-size: 15px; letter-spacing: 2px;
  padding: 13px 16px; border-radius: 12px; cursor: pointer;
  color: var(--cyan); background: rgba(0, 240, 255, 0.07);
  border: 1px solid rgba(0, 240, 255, 0.6);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
  flex: 1;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  font-size: 20px; padding: 16px; color: #12032a; border: none;
  background: linear-gradient(90deg, var(--pink), var(--yellow));
  box-shadow: 0 0 22px rgba(255, 43, 214, 0.6);
}
.row { display: flex; gap: 10px; }

/* ---------- Лидерборд ---------- */
.tabs { display: flex; gap: 6px; }
.tab {
  flex: 1; font-family: var(--font); font-size: 12px; letter-spacing: 1px; font-weight: 700;
  padding: 8px; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid rgba(169, 143, 208, 0.35);
}
.tab.active { color: var(--pink); border-color: var(--pink); box-shadow: 0 0 10px rgba(255, 43, 214, 0.35); }

.board {
  list-style: none; margin: 0; padding: 0;
  overflow-y: auto; min-height: 120px; max-height: 52vh;
  touch-action: pan-y;
  text-align: left;
}
.board li, .me {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-family: system-ui, sans-serif; font-size: 15px;
}
.board li.mine { background: rgba(255, 43, 214, 0.12); border-radius: 8px; }
.rank { width: 28px; text-align: center; font-family: var(--font); font-weight: 900; color: var(--muted); }
.board li:nth-child(1) .rank { color: #ffd23d; text-shadow: 0 0 8px #ffd23d; }
.board li:nth-child(2) .rank { color: #d8e2ff; }
.board li:nth-child(3) .rank { color: #ff9b5c; }
.ava {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #12032a; background: linear-gradient(135deg, var(--cyan), var(--pink));
  object-fit: cover;
}
.name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pts { font-family: var(--font); font-weight: 700; color: var(--cyan); }
.me { border: 1px solid rgba(255, 43, 214, 0.5); border-radius: 10px; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; font-family: system-ui, sans-serif; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 60px); transform: translateX(-50%);
  z-index: 20; padding: 10px 16px; border-radius: 10px;
  background: rgba(16, 3, 36, 0.95); border: 1px solid var(--pink);
  font-family: system-ui, sans-serif; font-size: 14px; max-width: 90%;
}
