/* ============================================================
   ASTRAVOID — визуальная система
   Палитра «двух температур»: всё враждебное — горячее (маджента),
   всё своё — холодное (циан), награда — золото.
   ============================================================ */

@font-face {
  font-family: 'Unbounded';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('../fonts/unbounded-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: 'Unbounded';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('../fonts/unbounded-cyr.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  --void:   #070312;
  --nebula: #150a38;
  --panel:  rgba(16, 9, 46, .86);
  --line:   rgba(139, 70, 255, .28);
  --ink:    #ece9fb;
  --dim:    #8d86b8;
  --cyan:   #00e5ff;
  --pink:   #ff2d78;
  --gold:   #ffc23d;
  --violet: #8b46ff;
  --font-d: 'Unbounded', system-ui, sans-serif;
  --font-m: ui-monospace, 'Cascadia Mono', 'JetBrains Mono', Consolas, monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--void);
  color: var(--ink);
  font-family: var(--font-m);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#cv {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

/* ---------- кнопки и общие элементы ---------- */

.btn {
  font-family: var(--font-d);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: .12em;
  color: var(--ink);
  background: rgba(139, 70, 255, .08);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 13px 22px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .08s, background .15s;
  touch-action: manipulation;
}
.btn:hover {
  border-color: var(--violet);
  box-shadow: 0 0 18px rgba(139, 70, 255, .35), inset 0 0 12px rgba(139, 70, 255, .12);
}
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.btn-primary {
  border-color: var(--cyan);
  background: rgba(0, 229, 255, .1);
  color: #d9fbff;
  text-shadow: 0 0 12px rgba(0, 229, 255, .8);
  font-weight: 800;
  font-size: 16px;
}
.btn-primary:hover { box-shadow: 0 0 24px rgba(0, 229, 255, .45), inset 0 0 16px rgba(0, 229, 255, .12); border-color: var(--cyan); }

.btn-accent {
  border-color: rgba(255, 194, 61, .5);
  background: rgba(255, 194, 61, .08);
  color: #ffe9b8;
  text-shadow: 0 0 10px rgba(255, 194, 61, .7);
}
.btn-accent:hover { border-color: var(--gold); box-shadow: 0 0 20px rgba(255, 194, 61, .35); }

.chip {
  font-family: var(--font-m);
  font-size: 13px;
  color: var(--ink);
  background: rgba(139, 70, 255, .1);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.chip.dim { color: var(--dim); cursor: default; }
.chip.off { opacity: .4; }

.note { color: var(--dim); font-size: 12px; line-height: 1.5; }

/* ---------- экраны ---------- */

#screens { position: fixed; inset: 0; pointer-events: none; }

.screen {
  position: absolute; inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  pointer-events: auto;
  overflow-y: auto;
  animation: scr-in .28s ease-out;
}
@keyframes scr-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.scr-title {
  font-family: var(--font-d);
  font-weight: 800;
  font-size: clamp(18px, 4.5vw, 26px);
  letter-spacing: .14em;
  text-align: center;
  color: var(--ink);
  text-shadow: 0 0 24px rgba(139, 70, 255, .8);
}

.h-sub {
  font-family: var(--font-d);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: .2em;
  color: var(--dim);
}

/* ---------- меню ---------- */

#scr-menu { justify-content: center; gap: 16px; }

#logo {
  font-family: var(--font-d);
  font-weight: 800;
  font-size: clamp(34px, 9vw, 64px);
  letter-spacing: .06em;
  line-height: 1;
  text-align: center;
  color: #fff;
  text-shadow:
    0 0 8px  rgba(0, 229, 255, .9),
    0 0 28px rgba(0, 229, 255, .55),
    0 0 80px rgba(0, 229, 255, .3);
  animation: logo-breathe 4s ease-in-out infinite;
}
#logo span {
  color: transparent;
  -webkit-text-stroke: 1.5px var(--pink);
  text-shadow: 0 0 14px rgba(255, 45, 120, .8), 0 0 46px rgba(255, 45, 120, .4);
}
@keyframes logo-breathe {
  0%, 100% { text-shadow: 0 0 8px rgba(0,229,255,.9), 0 0 28px rgba(0,229,255,.55), 0 0 80px rgba(0,229,255,.3); }
  50%      { text-shadow: 0 0 10px rgba(0,229,255,1), 0 0 40px rgba(0,229,255,.7), 0 0 110px rgba(0,229,255,.42); }
}

#tagline {
  margin-top: 8px;
  text-align: center;
  color: var(--dim);
  font-size: 13px;
  letter-spacing: .55em;
  text-transform: lowercase;
}

#menu-player { display: flex; align-items: center; gap: 10px; }
#player-name {
  font-family: var(--font-d);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: .1em;
  color: var(--cyan);
  background: none;
  border: none;
  border-bottom: 1px dashed rgba(0, 229, 255, .4);
  padding: 4px 2px;
  cursor: pointer;
}
#player-name:hover { text-shadow: 0 0 12px rgba(0, 229, 255, .8); }
#streak-chip {
  font-size: 13px;
  color: var(--gold);
  border: 1px solid rgba(255, 194, 61, .35);
  border-radius: 999px;
  padding: 4px 12px;
  text-shadow: 0 0 10px rgba(255, 194, 61, .6);
}

#daily-card {
  width: min(360px, 92vw);
  background: var(--panel);
  border: 1px solid rgba(255, 194, 61, .3);
  border-radius: 6px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 0 30px rgba(255, 194, 61, .08), inset 0 0 40px rgba(255, 194, 61, .03);
}
.dc-top { display: flex; justify-content: space-between; align-items: baseline; }
.dc-label {
  font-family: var(--font-d); font-weight: 800; font-size: 11px;
  letter-spacing: .25em; color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 194, 61, .7);
}
#daily-timer { font-size: 12px; color: var(--dim); }
#daily-mutator {
  font-family: var(--font-d); font-weight: 500; font-size: 17px;
  letter-spacing: .08em; color: var(--ink);
}
.dc-desc { color: var(--dim); font-size: 12px; }
.dc-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); }
.dc-row b { color: var(--ink); }
#daily-rank { color: var(--gold); }
#btn-daily { margin-top: 4px; }

#menu-nav { display: flex; flex-direction: column; gap: 10px; width: min(360px, 92vw); }
#menu-nav .btn { width: 100%; }

#menu-foot { display: flex; gap: 10px; align-items: center; }

/* ---------- таблицы ---------- */

#scr-boards { justify-content: flex-start; padding-top: max(36px, env(safe-area-inset-top)); }

#board-tabs { display: flex; gap: 8px; }
.tab {
  font-family: var(--font-d); font-weight: 500; font-size: 12px;
  letter-spacing: .12em; color: var(--dim);
  background: none; border: 1px solid transparent; border-radius: 4px;
  padding: 8px 14px; cursor: pointer;
}
.tab.active {
  color: var(--gold);
  border-color: rgba(255, 194, 61, .4);
  text-shadow: 0 0 10px rgba(255, 194, 61, .6);
}

#board-list {
  width: min(420px, 94vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 0;
  max-height: 52vh;
  overflow-y: auto;
}
.brow {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 7px 16px;
  font-size: 14px;
}
.brow .pos { color: var(--dim); text-align: right; }
.brow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: .04em; }
.brow .pts { color: var(--cyan); font-weight: 700; }
.brow.top1 .pos, .brow.top1 .pts { color: var(--gold); text-shadow: 0 0 12px rgba(255,194,61,.7); }
.brow.top2 .pos, .brow.top3 .pos { color: var(--ink); }
.brow.me { background: rgba(0, 229, 255, .07); border-left: 2px solid var(--cyan); }
.brow.me .name { color: var(--cyan); }

#board-me {
  width: min(420px, 94vw);
  border: 1px dashed rgba(0, 229, 255, .35);
  border-radius: 6px;
  background: rgba(0, 229, 255, .05);
}
#board-me .brow { padding: 9px 16px; }

/* ---------- ангар ---------- */

#scr-hangar { justify-content: flex-start; padding-top: max(36px, env(safe-area-inset-top)); }

#ship-list, #trail-list {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  width: min(460px, 94vw);
}
.ship-card {
  width: 132px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.ship-card canvas { width: 72px; height: 72px; }
.ship-card .sname {
  font-family: var(--font-d); font-weight: 500; font-size: 11px; letter-spacing: .14em;
}
.ship-card .scond { font-size: 10px; color: var(--dim); text-align: center; line-height: 1.4; }
.ship-card.sel { border-color: var(--cyan); box-shadow: 0 0 18px rgba(0, 229, 255, .3); }
.ship-card.locked { opacity: .45; cursor: default; }
.ship-card.locked .sname { color: var(--dim); }

.trail-card {
  width: 64px; height: 44px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.trail-card i {
  position: absolute; left: 10%; top: 50%; width: 80%; height: 3px;
  border-radius: 3px;
  transform: translateY(-50%);
}
.trail-card.sel { border-color: var(--cyan); box-shadow: 0 0 14px rgba(0,229,255,.35); }
.trail-card.locked { opacity: .35; cursor: default; }
.trail-card .tcond {
  position: absolute; inset: auto 0 2px; text-align: center;
  font-size: 8px; color: var(--dim);
}

/* ---------- как играть ---------- */

#help-body {
  width: min(460px, 94vw);
  max-height: 60vh;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.help-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 16px;
}
.help-block h3 {
  font-family: var(--font-d); font-weight: 500; font-size: 12px;
  letter-spacing: .2em; color: var(--violet);
  margin-bottom: 6px;
  text-shadow: 0 0 12px rgba(139, 70, 255, .6);
}
.help-block p { font-size: 13px; line-height: 1.6; color: var(--ink); }
.help-block b { color: var(--cyan); }
.help-block i { color: var(--gold); font-style: normal; }

/* ---------- смерть ---------- */

#scr-death { gap: 14px; }
#death-title { color: var(--pink); text-shadow: 0 0 24px rgba(255, 45, 120, .8); }
#death-score-wrap { text-align: center; }
#death-score {
  font-family: var(--font-d); font-weight: 800;
  font-size: clamp(38px, 10vw, 64px);
  color: var(--ink);
  text-shadow: 0 0 18px rgba(0, 229, 255, .7), 0 0 60px rgba(0, 229, 255, .35);
  letter-spacing: .04em;
}
#death-stats {
  display: flex; gap: 22px; flex-wrap: wrap; justify-content: center;
  font-size: 13px; color: var(--dim);
}
#death-stats b { color: var(--ink); display: block; text-align: center; font-size: 17px; }
#death-callout {
  color: var(--gold);
  font-size: 14px;
  text-shadow: 0 0 12px rgba(255, 194, 61, .6);
  animation: pulse-soft 1.6s ease-in-out infinite;
}
@keyframes pulse-soft { 50% { opacity: .65; } }
#death-ranks { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.rank-chip {
  font-size: 12px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px;
  background: var(--panel);
}
.rank-chip b { color: var(--gold); }
.death-nav { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- имя ---------- */

#name-input {
  font-family: var(--font-d); font-weight: 500;
  font-size: 20px; letter-spacing: .1em;
  text-align: center;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px 18px;
  width: min(320px, 88vw);
  outline: none;
}
#name-input:focus { border-color: var(--cyan); box-shadow: 0 0 18px rgba(0, 229, 255, .25); }

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

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

#hud-top {
  position: absolute;
  left: var(--fx, 12px); right: var(--fx, 12px); top: max(10px, env(safe-area-inset-top));
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 0 6px;
}
#hud-score {
  font-family: var(--font-d); font-weight: 800;
  font-size: clamp(20px, 5vw, 30px);
  color: var(--ink);
  text-shadow: 0 0 14px rgba(0, 229, 255, .55);
  letter-spacing: .05em;
  font-variant-numeric: tabular-nums;
}
#hud-chain { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
#chain-x {
  font-family: var(--font-d); font-weight: 500; font-size: 15px;
  color: var(--gold); text-shadow: 0 0 10px rgba(255, 194, 61, .7);
}
#chain-bar { width: 70px; height: 3px; background: rgba(255,255,255,.12); border-radius: 2px; overflow: hidden; }
#chain-bar i { display: block; height: 100%; width: 100%; background: var(--gold); transform-origin: left; }

#hud-right { text-align: right; display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
#hud-wave {
  font-family: var(--font-d); font-weight: 500; font-size: 12px;
  letter-spacing: .18em; color: var(--dim);
}
#hud-lives, #hud-bombs { display: flex; gap: 5px; }
.life-dot {
  width: 11px; height: 11px; transform: rotate(45deg);
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(0, 229, 255, .8);
}
.life-dot.off { background: rgba(255,255,255,.12); box-shadow: none; }
.bomb-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(255, 194, 61, .8);
}
.bomb-dot.off { background: rgba(255,255,255,.12); box-shadow: none; }

#boss-bar {
  position: absolute;
  left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 46px);
  transform: translateX(-50%);
  width: min(420px, 80vw);
  text-align: center;
}
#boss-name {
  font-family: var(--font-d); font-weight: 800; font-size: 12px;
  letter-spacing: .3em; color: var(--pink);
  text-shadow: 0 0 14px rgba(255, 45, 120, .8);
}
#boss-hp {
  margin-top: 4px; height: 4px;
  background: rgba(255,255,255,.1);
  border-radius: 2px; overflow: hidden;
}
#boss-hp i {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--pink), var(--violet));
  box-shadow: 0 0 12px rgba(255, 45, 120, .8);
  transform-origin: left;
  transition: transform .12s linear;
}

#hud-bottom {
  position: absolute;
  left: 50%; bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  pointer-events: auto;
}
#od-meter {
  position: relative;
  width: min(260px, 56vw); height: 22px;
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(7, 3, 18, .6);
}
#od-fill {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, #0090a8, var(--cyan));
  transform: scaleX(0); transform-origin: left;
}
#od-meter.ready #od-fill {
  background: linear-gradient(90deg, var(--cyan), #b6f6ff);
  animation: od-ready .7s ease-in-out infinite;
}
@keyframes od-ready { 50% { filter: brightness(1.5); } }
#od-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-d); font-weight: 500; font-size: 10px;
  letter-spacing: .3em; color: #fff;
  mix-blend-mode: screen;
}

#banner {
  position: absolute;
  left: 50%; top: 38%;
  transform: translate(-50%, -50%);
  font-family: var(--font-d); font-weight: 800;
  font-size: clamp(22px, 6vw, 40px);
  letter-spacing: .25em;
  color: var(--ink);
  text-shadow: 0 0 24px rgba(0, 229, 255, .8);
  text-align: center;
  animation: banner-in 2.2s ease-out forwards;
  white-space: nowrap;
}
#banner.warn { color: var(--pink); text-shadow: 0 0 30px rgba(255, 45, 120, .9); }
#banner.gold { color: var(--gold); text-shadow: 0 0 30px rgba(255, 194, 61, .9); }
@keyframes banner-in {
  0%   { opacity: 0; letter-spacing: .6em; }
  12%  { opacity: 1; letter-spacing: .25em; }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- мобильные кнопки ---------- */

#touch-ui { position: fixed; inset: 0; pointer-events: none; z-index: 6; }
.tbtn {
  position: absolute;
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 40px);
  width: 64px; height: 64px;
  border-radius: 50%;
  font-family: var(--font-d); font-weight: 800; font-size: 11px;
  letter-spacing: .06em;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity .15s;
}
#btn-pulse {
  left: 14px;
  color: var(--gold);
  background: rgba(255, 194, 61, .1);
  border: 1.5px solid rgba(255, 194, 61, .55);
  box-shadow: 0 0 16px rgba(255, 194, 61, .25);
}
#btn-od {
  right: 14px;
  color: var(--cyan);
  background: rgba(0, 229, 255, .1);
  border: 1.5px solid rgba(0, 229, 255, .55);
  box-shadow: 0 0 16px rgba(0, 229, 255, .25);
}
.tbtn:disabled { opacity: .25; }
.tbtn:active { transform: scale(.92); }

/* ---------- прочее ---------- */

#toast {
  position: fixed;
  left: 50%; top: 14%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 6px;
  color: var(--gold);
  font-size: 13px;
  padding: 10px 20px;
  z-index: 20;
  text-shadow: 0 0 10px rgba(255, 194, 61, .6);
  box-shadow: 0 0 24px rgba(255, 194, 61, .2);
  animation: toast-in 3s ease forwards;
  text-align: center;
  max-width: 88vw;
}
@keyframes toast-in {
  0%   { opacity: 0; transform: translate(-50%, -8px); }
  8%   { opacity: 1; transform: translate(-50%, 0); }
  85%  { opacity: 1; }
  100% { opacity: 0; }
}

.touch-only { display: none; }
body.is-touch .touch-only { display: block; }
body.is-touch .pc-only { display: none; }

@media (prefers-reduced-motion: reduce) {
  #logo, #banner, #od-meter.ready #od-fill, #death-callout { animation: none; }
  .screen { animation: none; }
}

/* компактная высота (телефон-альбом) */
@media (max-height: 560px) {
  #logo { font-size: 30px; }
  #tagline { display: none; }
  .screen { gap: 10px; }
  #daily-card { padding: 10px 14px; gap: 5px; }
  #menu-nav { gap: 7px; }
  .btn { padding: 10px 18px; }
}
