/* ============================================================
   НЕ НАЖИМАЙ — стили
   ============================================================ */

:root {
  --bg: #07070c;
  --bg-2: #0d0d18;
  --card: rgba(22, 22, 34, 0.72);
  --card-brd: rgba(255, 255, 255, 0.08);
  --text: #f3f3fa;
  --muted: #9a9ab0;
  --dim: #6b6b80;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --red: #ff2d3f;
  --red-dark: #b3121f;
  --red-glow: rgba(255, 45, 63, 0.55);
  --gold: #ffd35c;
  --silver: #cfd6e4;
  --bronze: #e69a5a;
  --radius: 22px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 80% -10%, #17172b 0%, transparent 60%),
    radial-gradient(1000px 800px at 0% 110%, #16101f 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ── фоновые светящиеся пятна ────────────────────────────── */
.bg-orbs { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.orb {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.5;
  animation: float 18s ease-in-out infinite;
}
.orb-a { width: 420px; height: 420px; left: -120px; top: -80px;
  background: radial-gradient(circle, #7c5cff, transparent 70%); }
.orb-b { width: 360px; height: 360px; right: -100px; top: 20%;
  background: radial-gradient(circle, #22d3ee, transparent 70%); animation-delay: -6s; }
.orb-c { width: 480px; height: 480px; left: 30%; bottom: -180px;
  background: radial-gradient(circle, #ff2d3f, transparent 70%); opacity: 0.28; animation-delay: -11s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, -30px) scale(1.08); }
}

/* ── переключение разделов ───────────────────────────────── */
.view {
  position: relative; z-index: 1;
  min-height: 100dvh;
  display: none;
  padding: clamp(20px, 4vw, 48px);
}
.view.is-active { display: flex; }

/* ============================================================
   ГЛАВНАЯ
   ============================================================ */
.view-home { align-items: flex-start; justify-content: center; }
.home-inner {
  width: 100%; max-width: 560px; margin: auto;
  display: flex; flex-direction: column; gap: clamp(22px, 4vh, 40px);
  animation: rise 0.6s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }

/* ── минималистичные иконки (тонкая линия, наследуют цвет) ── */
.ico { width: 1.15em; height: 1.15em; display: inline-block; flex: none; vertical-align: -0.18em; }
.ico-cup { color: var(--gold); }

/* ── карточка топа ──────────────────────────────────────── */
.board-card {
  background: var(--card);
  border: 1px solid var(--card-brd);
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 26px);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255,255,255,0.05);
}
.board-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.board-head h2 { margin: 0; font-size: clamp(17px, 4vw, 20px); font-weight: 800; letter-spacing: -0.01em;
  display: inline-flex; align-items: center; gap: 9px; }
.board-hint { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.12em; }

.board-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.board-row {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  transition: background 0.2s, transform 0.2s, border-color 0.2s;
  animation: rowin 0.45s ease both;
}
.board-row:hover { background: rgba(255,255,255,0.05); }
.board-row .rank {
  font-family: var(--mono); font-weight: 700; font-size: 15px; text-align: center;
  color: var(--dim);
}
.board-row .who { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .ms { font-family: var(--mono); font-weight: 700; font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }

.board-row.top1 { background: linear-gradient(90deg, rgba(255,211,92,0.16), rgba(255,211,92,0.03)); border-color: rgba(255,211,92,0.3); }
.board-row.top1 .rank, .board-row.top1 .ms { color: var(--gold); }
.board-row.top2 { background: linear-gradient(90deg, rgba(207,214,228,0.13), transparent); border-color: rgba(207,214,228,0.22); }
.board-row.top2 .rank { color: var(--silver); }
.board-row.top3 { background: linear-gradient(90deg, rgba(230,154,90,0.13), transparent); border-color: rgba(230,154,90,0.22); }
.board-row.top3 .rank { color: var(--bronze); }

.board-row.just-landed {
  animation: landed 1.1s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes landed {
  0% { background: rgba(124,92,255,0.5); transform: scale(1.06); box-shadow: 0 0 40px rgba(124,92,255,0.6); }
  100% { transform: scale(1); }
}
@keyframes rowin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.board-empty { text-align: center; color: var(--dim); font-size: 14px; padding: 22px 0 6px; margin: 0; }
.board-empty.hidden { display: none; }

/* ── кнопка "начать" ────────────────────────────────────── */
.btn-start {
  position: relative; border: none; cursor: pointer;
  font-family: var(--font); font-weight: 800; font-size: clamp(17px, 4.4vw, 20px);
  color: #fff; padding: 18px 26px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: linear-gradient(135deg, var(--accent), #a17bff 40%, var(--accent-2));
  box-shadow: 0 18px 45px -14px rgba(124, 92, 255, 0.7), inset 0 1px 0 rgba(255,255,255,0.3);
  transition: transform 0.16s cubic-bezier(.2,.8,.2,1), box-shadow 0.2s, filter 0.2s;
  overflow: hidden;
}
.btn-start::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 20%, rgba(255,255,255,0.35) 50%, transparent 80%);
  transform: translateX(-120%); transition: transform 0.6s;
}
.btn-start:hover { transform: translateY(-2px); box-shadow: 0 24px 55px -14px rgba(124,92,255,0.85); filter: brightness(1.06); }
.btn-start:hover::after { transform: translateX(120%); }
.btn-start:active { transform: translateY(1px) scale(0.99); }
.btn-start-arrow { display: inline-flex; transition: transform 0.2s; }
.btn-start-arrow svg { width: 1.25em; height: 1.25em; }
.btn-start:hover .btn-start-arrow { transform: translateX(4px); }

/* ============================================================
   ИГРА
   ============================================================ */
.view-game { flex-direction: column; align-items: center; justify-content: center; gap: clamp(28px, 6vh, 60px); }

.timer-wrap { text-align: center; animation: rise 0.5s ease both; }
.timer {
  font-family: var(--mono); font-weight: 700;
  font-size: clamp(46px, 13vw, 96px); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; line-height: 1;
  color: #fff; text-shadow: 0 0 40px rgba(124,92,255,0.35);
  display: inline-flex; align-items: baseline;
}
.timer .t-ms { color: var(--accent-2); font-size: 0.62em; margin-left: 0.04em; }
.timer .t-sep, .timer .t-dot { color: var(--dim); }

/* ── красная кнопка ─────────────────────────────────────── */
.redzone { display: grid; place-items: center; }
.red-button {
  position: relative; cursor: pointer; border: none; background: none; padding: 0;
  width: clamp(210px, 62vw, 320px); height: clamp(210px, 62vw, 320px);
  border-radius: 50%;
  animation: breathe 2.4s ease-in-out infinite;
  touch-action: manipulation;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}
.rb-glow {
  position: absolute; inset: -14%; border-radius: 50%;
  background: radial-gradient(circle, var(--red-glow), transparent 62%);
  filter: blur(14px); animation: pulseGlow 2.4s ease-in-out infinite;
}
@keyframes pulseGlow { 0%,100% { opacity: 0.55; transform: scale(1); } 50% { opacity: 0.95; transform: scale(1.1); } }
.rb-face {
  position: absolute; inset: 0; border-radius: 50%;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 38% 30%, #ff7480 0%, var(--red) 34%, var(--red-dark) 82%, #7a0c15 100%);
  box-shadow:
    inset 0 -14px 34px rgba(0,0,0,0.55),
    inset 0 12px 26px rgba(255,255,255,0.35),
    0 24px 60px -12px rgba(255,45,63,0.6);
  border: 2px solid rgba(255,255,255,0.14);
  transition: transform 0.08s;
}
.rb-face::before {
  content: ""; position: absolute; top: 12%; left: 18%; width: 46%; height: 32%;
  border-radius: 50%; background: linear-gradient(180deg, rgba(255,255,255,0.55), transparent);
  filter: blur(4px);
}
.rb-text {
  position: relative; font-weight: 900; color: #fff; text-align: center;
  font-size: clamp(26px, 8vw, 40px); line-height: 1.02; letter-spacing: 0.02em;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5); text-transform: uppercase;
}
.red-button:active .rb-face { transform: scale(0.94); box-shadow: inset 0 -6px 20px rgba(0,0,0,0.6), inset 0 6px 18px rgba(255,255,255,0.25); }
.red-button.smashed { animation: smash 0.4s ease both; }
@keyframes smash {
  0% { transform: scale(0.9); }
  40% { transform: scale(1.12) rotate(-2deg); }
  100% { transform: scale(0); opacity: 0; }
}

/* ============================================================
   МОДАЛКА ПРОИГРЫША
   ============================================================ */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: safe center; justify-content: safe center;
  padding: 24px; gap: 26px; flex-wrap: wrap;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: rgba(4, 4, 10, 0.72);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.overlay.is-open { display: flex; animation: fadein 0.3s ease both; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.result-card {
  width: min(420px, 92vw);
  background: linear-gradient(180deg, rgba(30,30,46,0.95), rgba(18,18,28,0.95));
  border: 1px solid var(--card-brd); border-radius: 26px;
  padding: 34px 28px 28px; text-align: center;
  box-shadow: 0 40px 100px -30px rgba(0,0,0,0.9), inset 0 1px 0 rgba(255,255,255,0.06);
  animation: pop 0.42s cubic-bezier(.2,.9,.25,1.15) both;
}
@keyframes pop { 0% { opacity: 0; transform: scale(0.86) translateY(14px); } 100% { opacity: 1; transform: none; } }

.result-icon { display: grid; place-items: center; margin-bottom: 4px;
  animation: bounceIn 0.6s cubic-bezier(.2,.8,.2,1.4) both; }
.result-icon svg { width: 56px; height: 56px; color: var(--red);
  filter: drop-shadow(0 4px 18px rgba(255,45,63,0.5)); }
@keyframes bounceIn { 0% { transform: scale(0) rotate(-20deg); } 60% { transform: scale(1.25) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
.result-title { margin: 12px 0 4px; font-size: 26px; font-weight: 900; letter-spacing: -0.01em; }
.result-caption { margin: 0; color: var(--muted); font-size: 14px; text-transform: lowercase; letter-spacing: 0.05em; }
.result-time {
  font-family: var(--mono); font-weight: 800; font-variant-numeric: tabular-nums;
  font-size: clamp(38px, 11vw, 52px); margin: 8px 0 20px;
  background: linear-gradient(180deg, #fff, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

.name-input {
  width: 100%; font-family: var(--font); font-size: 16px; font-weight: 600; color: var(--text);
  text-align: center; padding: 14px 16px; border-radius: 14px;
  background: rgba(255,255,255,0.05); border: 1.5px solid var(--card-brd);
  outline: none; transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  user-select: text;
}
.name-input::placeholder { color: var(--dim); font-weight: 500; }
.name-input:focus { border-color: var(--accent); background: rgba(124,92,255,0.08); box-shadow: 0 0 0 4px rgba(124,92,255,0.15); }
.name-input.saved { border-color: rgba(34,211,238,0.5); background: rgba(34,211,238,0.06); }
.name-input.hidden { display: none; }

.rank-note { min-height: 0; margin: 0; font-size: 14px; font-weight: 700; color: var(--accent-2);
  overflow: hidden; max-height: 0; opacity: 0; transition: max-height 0.4s, opacity 0.4s, margin 0.4s; }
.rank-note.show { max-height: 60px; opacity: 1; margin: 14px 0 2px; }

.result-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn-again, .btn-home {
  cursor: pointer; font-family: var(--font); font-weight: 700; font-size: 15px;
  border-radius: 14px; border: 1px solid transparent; transition: transform 0.14s, filter 0.2s, background 0.2s;
}
.btn-again { flex: 1; padding: 14px 12px; color: #fff; background: linear-gradient(135deg, var(--red), #ff5a68); box-shadow: 0 14px 30px -12px rgba(255,45,63,0.7); }
.btn-again:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn-again:active { transform: translateY(1px); }
.btn-home { flex: 0 0 auto; padding: 0 18px; display: grid; place-items: center;
  color: var(--muted); background: rgba(255,255,255,0.06); border-color: var(--card-brd); }
.btn-home svg { width: 22px; height: 22px; }
.btn-home:hover { transform: translateY(-2px); background: rgba(255,255,255,0.11); color: var(--text); }
.btn-home:active { transform: translateY(1px); }

/* ── мини-топ рядом с карточкой (для анимации залёта) ─────── */
.fly-board {
  width: min(320px, 92vw);
  background: var(--card); border: 1px solid var(--card-brd); border-radius: 22px;
  padding: 18px 18px 20px; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,0.8);
  display: none;
}
.fly-board.show { display: block; animation: rise 0.5s ease both; }
.fly-board-title { font-weight: 800; font-size: 16px; margin-bottom: 12px;
  display: inline-flex; align-items: center; gap: 8px; }
.fly-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.fly-list .board-row { padding: 8px 10px; grid-template-columns: 28px 1fr auto; gap: 10px; }
.fly-list .board-row .rank, .fly-list .board-row .who, .fly-list .board-row .ms { font-size: 13.5px; }

/* ── летящий результат ──────────────────────────────────── */
.flyer {
  position: fixed; z-index: 100; pointer-events: none; display: none;
  font-family: var(--mono); font-weight: 800; font-variant-numeric: tabular-nums;
  padding: 10px 16px; border-radius: 12px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 14px 40px -8px rgba(124,92,255,0.7);
  white-space: nowrap;
}
.flyer.go { display: block; }

/* ── адаптив ────────────────────────────────────────────── */
@media (max-width: 760px) {
  /* Стопкой, без переноса во второй столбец; при нехватке высоты — прокрутка. */
  .overlay { flex-direction: column; flex-wrap: nowrap; gap: 16px; justify-content: safe center; }
  .fly-board { order: -1; width: min(420px, 92vw); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
