/* RTS Project — тема «Улей».
   Тёмная хитиновая палитра, соты на фоне, янтарь (мёд) и кислотно-зелёный (биолюминесценция).
   Панели с угловыми HUD-скобками, аватары-соты, сегментные полосы, как в интерфейсе RTS. */
:root {
  --bg: #0b1008;
  --panel: #141c0e;
  --panel-hi: #1b2613;
  --inset: #0e150a;
  --line: #36481f;
  --text: #ecefd9;
  --muted: #9fae86;
  --amber: #f5b52e;
  --amber-hi: #ffd467;
  --amber-edge: #9a6a0a;
  --amber-text: #1d1403;
  --acid: #a6e22e;
  --rust: #d2432c;
  --rust-edge: #7a2214;
  --err: #ff9b86;
  --display: Bahnschrift, "DIN Alternate", "Roboto Condensed", "Arial Narrow", "Segoe UI", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --hex: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  --cut: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 16px/1.55 var(--body);
  background:
    radial-gradient(ellipse 900px 420px at 50% -40px, rgba(245,181,46,.16), transparent 70%),
    radial-gradient(ellipse 600px 500px at 100% 100%, rgba(166,226,46,.07), transparent 70%),
    url(/hex.svg),
    linear-gradient(180deg, #111a0b, var(--bg) 60%);
  background-color: var(--bg);
  background-attachment: fixed, fixed, fixed, fixed;
}

/* ---------- Шапка ---------- */
.top {
  position: relative;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 22px;
  background: rgba(8,12,6,.82);
  border-bottom: 2px solid #050803;
  box-shadow: 0 8px 22px rgba(0,0,0,.45);
}
/* «феромонная тропа» под шапкой */
.top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -5px; height: 3px;
  background: repeating-linear-gradient(90deg, var(--amber) 0 14px, transparent 14px 24px);
  opacity: .55;
}
.top nav { display: flex; gap: 20px; align-items: center; }
.top nav a { font: 600 14px/1 var(--display); letter-spacing: .08em; text-transform: uppercase; text-decoration: none; }
.top nav a:hover { color: var(--amber-hi); }
.logo {
  font: 700 20px/1 var(--display); letter-spacing: .1em; text-transform: uppercase;
  color: var(--text); text-decoration: none;
}
.top .logo:hover { color: var(--amber); }
a { color: var(--amber); text-underline-offset: 3px; }
a:hover { color: var(--amber-hi); }

/* ---------- Панель-карточка с HUD-скобками ---------- */
.card {
  position: relative;
  max-width: 460px; margin: 44px auto; padding: 30px;
  background: linear-gradient(180deg, var(--panel-hi), var(--panel) 45%);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.05),
    0 24px 50px rgba(0,0,0,.55),
    0 0 90px rgba(245,181,46,.06);
}
.card::before, .card::after {
  content: ""; position: absolute; width: 22px; height: 22px; pointer-events: none;
  border: 3px solid var(--amber);
}
.card::before { top: -3px; left: -3px; border-right: 0; border-bottom: 0; }
.card::after  { bottom: -3px; right: -3px; border-left: 0; border-top: 0; }
@media (max-width: 520px) {
  .card { margin: 16px 12px; padding: 20px; }
}
.card.wide { max-width: 780px; }

h1 {
  margin: 0 0 20px; font: 700 28px/1.2 var(--display);
  letter-spacing: .06em; text-transform: uppercase;
}
main.card > h1::before {
  content: ""; display: inline-block; width: 15px; height: 17px; margin-right: 12px;
  background: var(--amber); clip-path: var(--hex); vertical-align: -1px;
}
h2 {
  margin: 28px 0 12px; padding-bottom: 7px;
  font: 700 15px/1.3 var(--display); letter-spacing: .12em; text-transform: uppercase;
  color: var(--amber);
  border-bottom: 1px solid var(--line);
}
p { margin: 0 0 14px; }
ul.lost { margin: 0 0 18px; padding-left: 20px; color: var(--muted); }
ul.lost li { margin-bottom: 4px; }

/* ---------- Формы ---------- */
label { display: block; margin-bottom: 14px; color: var(--muted); font-size: 13px; letter-spacing: .04em; }
input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  background: var(--inset); color: var(--text);
  border: 1px solid #2c3d19; border-bottom: 2px solid #4a6428; border-radius: 2px; font-size: 16px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.6);
}
input[type=search] { -webkit-appearance: none; appearance: none; }
input:focus-visible { outline: none; border-color: var(--amber); box-shadow: inset 0 2px 6px rgba(0,0,0,.6), 0 0 0 2px rgba(245,181,46,.35); }
input.code { letter-spacing: 10px; text-align: center; font: 700 26px/1.3 var(--display); }
label.check {
  display: flex; gap: 10px; align-items: flex-start;
  color: var(--text); font-size: 15px; letter-spacing: 0;
}
label.check input { width: 18px; height: 18px; margin: 3px 0 0; flex: none; accent-color: var(--rust); box-shadow: none; }

/* ---------- Кнопки ---------- */
button, a.btn {
  display: block; width: 100%; padding: 11px 16px 9px; border: 0; border-bottom: 3px solid var(--amber-edge);
  cursor: pointer; text-align: center; text-decoration: none;
  background: linear-gradient(180deg, var(--amber-hi), var(--amber));
  color: var(--amber-text);
  font: 700 15px/1.4 var(--display); letter-spacing: .1em; text-transform: uppercase;
  clip-path: var(--cut);
  transition: filter .12s, transform .08s;
}
button:hover, a.btn:hover { filter: brightness(1.1); color: var(--amber-text); }
button:active, a.btn:active { transform: translateY(2px); border-bottom-width: 1px; padding-bottom: 11px; }
button:focus-visible, a.btn:focus-visible { outline: 2px solid #fff; outline-offset: -5px; }
button.danger, a.btn.danger {
  background: linear-gradient(180deg, #e8644b, var(--rust));
  color: #fff4ea; border-bottom-color: var(--rust-edge);
}
button.danger:hover, a.btn.danger:hover { color: #fff4ea; }
button.quiet, a.btn.quiet {
  clip-path: none; background: transparent; color: var(--text);
  border: 1px solid var(--line); padding: 10px 16px;
}
button.quiet:hover, a.btn.quiet:hover { background: rgba(255,255,255,.06); color: var(--text); filter: none; }
button.quiet:active, a.btn.quiet:active { padding: 10px 16px; border-width: 1px; }
button.link {
  clip-path: none; display: inline; width: auto; padding: 0; background: none; border: 0;
  color: var(--amber); font: 500 14px/1.4 var(--body); letter-spacing: 0; text-transform: none; text-decoration: underline;
}
button.link:hover { background: none; color: var(--amber-hi); filter: none; }
button.link:active { transform: none; padding: 0; }
button.link:focus-visible { outline-offset: 2px; }
button:disabled { opacity: .55; cursor: default; }
.actions { display: grid; gap: 12px; margin-top: 8px; }
.actions.two { grid-template-columns: 1fr 1fr; }

form.inline { display: inline; margin: 0; }
form.resend { margin-top: 14px; text-align: center; }

/* ---------- Сообщения ---------- */
.errors {
  background: rgba(210,67,44,.14); border: 1px solid var(--rust); border-left: 4px solid var(--rust);
  color: var(--err); border-radius: 2px; padding: 8px 14px; margin-bottom: 16px;
}
.errors ul { margin: 0; padding-left: 18px; }
.info {
  background: rgba(166,226,46,.10); border: 1px solid #5f8a1f; border-left: 4px solid var(--acid);
  border-radius: 2px; padding: 8px 14px; margin-bottom: 16px;
}
.notice {
  margin: 0 0 16px; padding: 10px 14px; font-size: 14px;
  background: rgba(245,181,46,.10); border: 1px solid var(--amber-edge);
  border-left: 4px solid var(--amber); border-radius: 2px;
}
.muted { color: var(--muted); font-size: 14px; }

dl.profile { display: grid; grid-template-columns: 1fr 1.5fr; gap: 0; margin: 0; }
dl.profile dt, dl.profile dd { padding: 8px 0; border-bottom: 1px dotted var(--line); }
dl.profile dt { color: var(--muted); padding-right: 12px; }
dl.profile dd { margin: 0; word-break: break-word; }

.danger-zone {
  margin-top: 32px; padding: 22px 16px 16px;
  border: 1px solid var(--rust-edge); border-radius: 2px;
  background:
    repeating-linear-gradient(135deg, var(--rust) 0 10px, #1a0e08 10px 20px) top / 100% 6px no-repeat,
    rgba(210,67,44,.07);
}
.danger-zone h2 { margin-top: 0; border-bottom: 0; padding-bottom: 0; color: var(--err); }
.danger-zone p { color: var(--muted); font-size: 14px; }
.danger-zone a.btn { width: auto; display: inline-block; padding: 8px 18px 6px; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  button, a.btn { transition: none; }
}

/* ---------- Звания: цвет по касте улья ---------- */
.rank-0 { --rk:#a7a08a; --rk-hi:#5b5646; --rk-lo:#25231b; --rk-glow:rgba(167,160,138,.22); }  /* личинка */
.rank-1 { --rk:#c98a4b; --rk-hi:#6e4524; --rk-lo:#2c1a0d; --rk-glow:rgba(201,138,75,.28); }   /* рабочий */
.rank-2 { --rk:#8fc7d6; --rk-hi:#3f6a76; --rk-lo:#132329; --rk-glow:rgba(143,199,214,.26); }  /* фуражир */
.rank-3 { --rk:#f5b52e; --rk-hi:#8a5d0c; --rk-lo:#2e2008; --rk-glow:rgba(245,181,46,.34); }  /* страж улья */
.rank-4 { --rk:#a6e22e; --rk-hi:#4a7a12; --rk-lo:#14240a; --rk-glow:rgba(166,226,46,.32); }  /* командир роя */
.rank-5 { --rk:#ff6a4d; --rk-hi:#9a2c1a; --rk-lo:#2e0e08; --rk-glow:rgba(255,106,77,.38); }  /* повелитель роя */

/* ---------- Профиль: командная панель ---------- */
.hero {
  display: flex; align-items: center; gap: 24px;
  padding: 24px 26px;
  border: 1px solid var(--line); border-left: 4px solid var(--rk, var(--amber)); border-radius: 2px;
  background:
    radial-gradient(circle 160px at 70px 50%, var(--rk-glow, rgba(245,181,46,.2)), transparent 100%),
    url(/hex.svg),
    linear-gradient(135deg, #1c2813, #10170b);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), inset 0 0 40px rgba(0,0,0,.45);
}
.hero-text { min-width: 0; }
.hero h1 { margin: 0; font-size: 32px; text-transform: none; letter-spacing: .02em; overflow-wrap: anywhere; }
.hero h1::before { content: none; }
.hero .handle { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.hero .rank-line { margin: 6px 0 0; }
.hero .since { margin: 8px 0 0; }
.rank-name {
  display: inline-block; padding: 3px 14px 2px;
  font: 700 14px/1.5 var(--display); letter-spacing: .12em; text-transform: uppercase;
  color: var(--rk); border: 1px solid var(--rk);
  background: rgba(0,0,0,.35);
  clip-path: polygon(7px 0, 100% 0, calc(100% - 7px) 100%, 0 100%);
}

/* Аватар — соты. Рамку даёт цвет звания (padding вокруг вставки). */
.emblem {
  position: relative; overflow: hidden; margin: 0; flex: none;
  width: 104px; height: 116px; padding: 4px;
  display: grid; place-items: center; font-size: 46px; line-height: 1;
  background: var(--rk, var(--amber));
  clip-path: var(--hex);
}
.emblem img, .emblem-emoji {
  display: grid; place-items: center; width: 100%; height: 100%; object-fit: cover;
  clip-path: var(--hex);
  background: radial-gradient(circle at 35% 28%, var(--rk-hi, #6e4524), var(--rk-lo, #1b120b));
}
.emblem-badge {
  display: none; position: absolute; left: 0; right: 0; bottom: 14px;
  padding: 4px 0 5px; text-align: center;
  font: 700 11px/1.2 var(--display); letter-spacing: .1em; text-transform: uppercase;
  color: var(--text); background: rgba(8,12,6,.85);
  transform: translateY(200%); transition: transform .15s;
}
.js .emblem-edit { cursor: pointer; }
.js .emblem-badge { display: block; }
.js .emblem-edit:hover .emblem-badge { transform: none; }
.hero.drop { outline: 2px dashed var(--amber); outline-offset: -8px; }

.avatar-tools { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-top: 14px; }
.avatar-tools form { margin: 0; }
.avatar-tools .muted { margin: 8px 0 0; font-size: 13px; }

/* ---------- Полосы: сегменты, как шкала в RTS ---------- */
.rankbar { margin: 18px 0 6px; }
.rankbar-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 14px; }
.rankbar-head strong { font: 700 17px/1 var(--display); letter-spacing: .04em; }
.bar {
  appearance: none; -webkit-appearance: none;
  display: block; width: 100%; height: 16px; border: 1px solid #050803; border-radius: 1px;
  background: #0a0f07; box-shadow: inset 0 2px 5px rgba(0,0,0,.7);
  overflow: hidden;
}
.bar::-webkit-progress-bar { background: #0a0f07; }
.rank-progress::-webkit-progress-value {
  background: repeating-linear-gradient(90deg, transparent 0 9px, rgba(0,0,0,.6) 9px 11px),
              linear-gradient(180deg, var(--rk), var(--rk-hi));
}
.rank-progress::-moz-progress-bar {
  background: repeating-linear-gradient(90deg, transparent 0 9px, rgba(0,0,0,.6) 9px 11px),
              linear-gradient(180deg, var(--rk), var(--rk-hi));
}
/* победы зелёные, остаток до 100% = поражения */
.record-bar { background: var(--rust); height: 20px; }
.record-bar::-webkit-progress-bar   { background: var(--rust); }
.record-bar::-webkit-progress-value { background: linear-gradient(180deg, var(--acid), #5f8a1f); }
.record-bar::-moz-progress-bar      { background: linear-gradient(180deg, var(--acid), #5f8a1f); }

/* плитки-ресурсы, как строка ресурсов в RTS */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; margin: 18px 0 4px; }
.tile {
  --tile: var(--line);
  padding: 10px 14px 12px;
  background: var(--inset);
  border: 1px solid #2c3d19; border-top: 3px solid var(--tile); border-radius: 2px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.6);
}
.tile span { display: block; color: var(--muted); font: 600 12px/1.4 var(--display); letter-spacing: .12em; text-transform: uppercase; }
.tile b { display: block; font: 700 30px/1.15 var(--display); letter-spacing: .02em; }
.tile.rate  { --tile: var(--amber); }
.tile.games { --tile: #8fc7d6; }
.tile.win   { --tile: var(--acid); }
.tile.loss  { --tile: var(--rust); }
.record .muted { margin: 8px 0 0; }

@media (max-width: 520px) {
  .hero { flex-direction: column; text-align: center; padding: 20px 16px; border-left-width: 1px; border-top: 4px solid var(--rk, var(--amber)); }
  .hero { background-position: 50% 58px, 0 0, 0 0; }
  .rankbar-head { flex-direction: column; gap: 2px; }
}

/* ---------- Мини-аватар в шапке ---------- */
.mini-avatar { width: 30px; height: 34px; object-fit: cover; clip-path: var(--hex); }
.navuser { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Загрузка файла: без JS обычный выбор, с JS красивая кнопка ---------- */
input.nojs-file { width: auto; margin: 0 0 10px; padding: 7px; font-size: 14px; }
input.nojs-file::file-selector-button {
  margin-right: 10px; padding: 5px 12px; cursor: pointer;
  background: var(--panel-hi); color: var(--text);
  border: 1px solid var(--line); border-radius: 2px; font: inherit;
}
.js input.nojs-file {
  position: absolute; width: 1px; height: 1px; margin: 0; padding: 0;
  border: 0; opacity: 0; overflow: hidden;
}
label.pick {
  display: none; margin: 0; padding: 8px 18px 6px; cursor: pointer; text-align: center;
  border: 1px solid var(--amber-edge); border-radius: 2px; background: rgba(245,181,46,.08); color: var(--amber);
  font: 700 13px/1.4 var(--display); letter-spacing: .1em; text-transform: uppercase;
}
label.pick:hover { background: rgba(245,181,46,.18); color: var(--amber-hi); }
.js label.pick { display: inline-block; }
.js .nojs-only { display: none; }
input.nojs-file:focus-visible + label.pick { outline: 2px solid var(--amber); outline-offset: 2px; }
.nojs-only { width: auto; }

/* ---------- Кадрирование ---------- */
.crop-dialog {
  position: relative;
  width: min(420px, calc(100vw - 24px)); padding: 24px; margin: auto;
  color: var(--text);
  background: linear-gradient(180deg, var(--panel-hi), var(--panel) 45%);
  border: 1px solid var(--line); border-radius: 2px;
  box-shadow: 0 30px 70px rgba(0,0,0,.75), 0 0 90px rgba(245,181,46,.08);
}
.crop-dialog::backdrop { background: rgba(4,7,3,.85); }
.crop-dialog h2 { margin-top: 0; border-bottom: 0; padding-bottom: 0; }
#crop-canvas {
  display: block; width: 100%; aspect-ratio: 1;
  border: 1px solid #050803; border-radius: 2px; background: #0f1609;
  touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: grab;
}
#crop-canvas.grabbing { cursor: grabbing; }
#crop-canvas:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.crop-tools { display: flex; gap: 10px; justify-content: center; margin: 14px 0; }
button.tool {
  width: 44px; height: 44px; padding: 0; display: grid; place-items: center;
  font: 700 22px/1 var(--display); letter-spacing: 0; text-transform: none;
  clip-path: none; background: var(--inset); color: var(--text);
  border: 1px solid #2c3d19; box-shadow: inset 0 2px 5px rgba(0,0,0,.5);
}
button.tool:hover { background: #18240f; color: var(--text); filter: none; }
button.tool:active { transform: none; border-width: 1px; padding: 0; box-shadow: inset 0 2px 5px rgba(0,0,0,.5); }
button.tool.text { width: auto; padding: 0 16px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
button.tool.text:active { padding: 0 16px; }

@media (max-width: 520px) {
  .avatar-tools { justify-content: center; }
}

/* ---------- Игроки ---------- */
form.search { display: flex; gap: 10px; align-items: stretch; margin-bottom: 4px; }
form.search input { margin: 0; flex: 1; }
form.search button { width: auto; padding: 0 22px; }
ul.players { list-style: none; margin: 0; padding: 0; }
ul.players li { border-bottom: 1px dotted var(--line); }
ul.players a {
  display: flex; align-items: center; gap: 14px; padding: 8px 8px;
  color: var(--text); text-decoration: none;
  border-left: 3px solid transparent;
}
ul.players a:hover { background: rgba(245,181,46,.07); border-left-color: var(--rk, var(--amber)); }
.pl-av {
  flex: none; width: 42px; height: 48px; padding: 2px;
  background: var(--rk, var(--line)); clip-path: var(--hex);
}
.pl-in {
  display: grid; place-items: center; width: 100%; height: 100%; font-size: 20px;
  clip-path: var(--hex); background: radial-gradient(circle at 35% 28%, var(--rk-hi, #3a4a24), var(--rk-lo, #10170b));
}
.pl-in img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pl-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.pl-rank { color: var(--rk, var(--muted)); font: 700 12px/1 var(--display); letter-spacing: .12em; text-transform: uppercase; }
.pl-rating { font: 700 18px/1 var(--display); min-width: 48px; text-align: right; }
@media (max-width: 520px) { .pl-rank { display: none; } }

/* никнейм показываем как есть, без капса */
.top nav a.navuser { text-transform: none; letter-spacing: .02em; font-size: 15px; }
.tile span { white-space: nowrap; }
