/* ПРОРЫВ — HUD chrome.
   Field-manual look: dark olive panels, hairline borders, condensed uppercase
   labels, tabular numerals everywhere a number changes. */

:root {
  --bg: #0d1310;
  --panel: rgba(15, 24, 19, 0.86);
  --panel-solid: #111a15;
  --edge: rgba(150, 190, 160, 0.22);
  --edge-strong: rgba(160, 210, 175, 0.4);
  --ink: #dceadf;
  --dim: #86a08e;
  --dimmer: #5f7466;
  --player: #59b0e8;
  --enemy: #e86a52;
  --gold: #ffd24a;
  --danger: #ff6b4a;
  --ok: #7ed69a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 500 14px/1.35 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; }

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

.hidden { display: none !important; }

/* ============================ HUD ============================ */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#hud > * { pointer-events: auto; }

.hud-top {
  position: absolute;
  top: calc(8px + var(--safe-t));
  left: calc(10px + var(--safe-l));
  right: calc(10px + var(--safe-r));
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}

.res { display: flex; gap: 6px; flex-wrap: wrap; pointer-events: auto; }

.chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(7px);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.chip .ico { font-size: 12px; opacity: 0.85; }
.chip .rate { font-size: 10px; color: var(--dim); font-weight: 600; }
.chip.warn {
  border-color: var(--danger);
  color: #ffd9cf;
  font-size: 10px;
  letter-spacing: 0.1em;
  animation: pulse 1.1s infinite;
}
.chip.low { color: var(--danger); }

@keyframes pulse { 50% { opacity: 0.45; } }

.clock {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

.clock .time {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  line-height: 1;
}
.clock .time.urgent { color: var(--danger); animation: pulse 1s infinite; }

.clock .sector {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--dim);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

.score-line {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.75);
}
.score-line .me { color: var(--player); }
.score-line .them { color: var(--enemy); }
.score-line .sep { color: var(--dimmer); font-weight: 600; }

.capbar {
  position: relative;
  width: min(280px, 42vw);
  height: 5px;
  margin-top: 3px;
  border: 1px solid var(--edge);
  border-radius: 3px;
  background: rgba(8, 14, 11, 0.7);
  overflow: hidden;
}
.capfill {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 0;
  background: var(--player);
  transition: width 0.15s linear, left 0.15s linear, background 0.3s;
}
.capmid {
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 1px;
  background: var(--edge-strong);
}

.icon-btn {
  width: 38px; height: 38px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(7px);
  font-size: 15px;
  pointer-events: auto;
}
.icon-btn:active { background: rgba(40, 60, 48, 0.9); }

/* ---------------------- tactical map ---------------------- */

#tacmap-wrap {
  position: absolute;
  right: calc(8px + var(--safe-r));
  top: calc(96px + var(--safe-t));
  bottom: calc(150px + var(--safe-b));
  width: 74px;
  border: 1px solid var(--edge);
  border-radius: 9px;
  background: var(--panel);
  backdrop-filter: blur(7px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tacmap-head {
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--dim);
  text-align: center;
  padding: 4px 0 2px;
  border-bottom: 1px solid var(--edge);
}

#tacmap { flex: 1; width: 100%; display: block; touch-action: none; }

/* ---------------------- feed & banners ---------------------- */

#feed {
  position: absolute;
  left: calc(10px + var(--safe-l));
  top: calc(120px + var(--safe-t));
  width: min(280px, 46vw);
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
}

.feed-line {
  padding: 3px 8px;
  border-left: 2px solid var(--edge-strong);
  border-radius: 3px;
  background: rgba(10, 18, 14, 0.62);
  font-size: 11px;
  color: var(--ink);
  animation: slidein 0.2s ease-out;
}
.feed-line.good { border-left-color: var(--ok); }
.feed-line.bad { border-left-color: var(--danger); color: #ffd9cf; }
.feed-line.warn { border-left-color: var(--gold); }
.feed-line.fade { opacity: 0; transition: opacity 0.5s; }

@keyframes slidein { from { transform: translateX(-14px); opacity: 0; } }

#banner {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  text-align: center;
}

.banner-item {
  padding: 9px 24px;
  border: 1px solid var(--edge-strong);
  border-radius: 10px;
  background: rgba(10, 18, 14, 0.82);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.1em;
  animation: bannerin 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
}
.banner-item small {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin-top: 2px;
}
.banner-item.good { border-color: var(--ok); color: #d8ffe6; }
.banner-item.bad { border-color: var(--danger); color: #ffd9cf; }
.banner-item.out { opacity: 0; transform: scale(0.96); transition: all 0.4s; }

@keyframes bannerin { from { transform: scale(0.8); opacity: 0; } }

#alert {
  position: absolute;
  left: 50%;
  top: calc(78px + var(--safe-t));
  transform: translateX(-50%);
  padding: 6px 18px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: rgba(50, 14, 8, 0.8);
  color: #ffd9cf;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  animation: pulse 0.7s infinite;
  pointer-events: none;
}

/* ---------------------- selection ---------------------- */

#selection {
  position: absolute;
  left: calc(10px + var(--safe-l));
  bottom: calc(148px + var(--safe-b));
  width: 208px;
  padding: 8px 10px;
  border: 1px solid var(--edge);
  border-radius: 9px;
  background: var(--panel);
  backdrop-filter: blur(7px);
}

.sel-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.sel-head span:last-child { color: var(--dim); font-variant-numeric: tabular-nums; }

.sel-bar {
  height: 3px;
  margin: 5px 0 0;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
#sel-fill { height: 100%; width: 100%; background: var(--ok); transition: width 0.2s; }

/* ---------------------- bottom bar ---------------------- */

#bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 calc(8px + var(--safe-r)) calc(8px + var(--safe-b)) calc(8px + var(--safe-l));
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

#abilities {
  display: flex;
  gap: 6px;
  pointer-events: auto;
  padding-right: 86px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
#abilities::-webkit-scrollbar { display: none; }

.abil {
  position: relative;
  min-width: 74px;
  padding: 6px 10px;
  border: 1px solid var(--edge);
  border-radius: 9px;
  background: var(--panel);
  backdrop-filter: blur(7px);
  overflow: hidden;
  text-align: left;
  line-height: 1.15;
}
.abil .n { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.03em; }
.abil .c { display: block; font-size: 9.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.abil .cd {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 8, 0.72);
  transform-origin: bottom;
  pointer-events: none;
}
.abil .dg {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 11px;
  line-height: 1;
  color: var(--gold);
  opacity: 0.9;
  pointer-events: none;
}
.abil.armed { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.abil.active { border-color: var(--ok); color: #d8ffe6; }
.abil.off { opacity: 0.45; }
.abil:active { transform: translateY(1px); }

#shop {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 86px 2px 0;
  pointer-events: auto;
  scrollbar-width: none;
}
#shop::-webkit-scrollbar { display: none; }

.card {
  position: relative;
  flex: 0 0 auto;
  width: 78px;
  padding: 6px 6px 5px;
  border: 1px solid var(--edge);
  border-radius: 9px;
  background: var(--panel);
  backdrop-filter: blur(7px);
  text-align: center;
  line-height: 1.2;
}
.card .ic { font-size: 19px; display: block; line-height: 1.1; }
.card .nm { display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .pr { display: block; font-size: 11px; color: var(--gold); font-variant-numeric: tabular-nums; font-weight: 700; }
.card.off { opacity: 0.42; }
.card.off .pr { color: var(--danger); }
.card:active { transform: translateY(1px); }
.card .q {
  position: absolute;
  top: 3px; right: 4px;
  min-width: 15px;
  padding: 0 3px;
  border-radius: 7px;
  background: var(--player);
  color: #08130d;
  font-size: 9.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.card .build {
  position: absolute;
  left: 0; bottom: 0;
  height: 2px;
  background: var(--player);
  transition: width 0.2s linear;
}

#hint {
  position: absolute;
  left: 50%;
  bottom: calc(154px + var(--safe-b));
  transform: translateX(-50%);
  padding: 5px 14px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: rgba(10, 18, 14, 0.82);
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
}

/* ============================ SCREENS ============================ */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  /* Light enough that the battle running behind the menu stays visible. */
  background: radial-gradient(circle at 50% 40%, rgba(8, 14, 11, 0.42), rgba(5, 9, 7, 0.86));
  backdrop-filter: blur(2px);
  z-index: 10;
  overflow-y: auto;
}

.panel {
  width: min(420px, 100%);
  padding: 22px 22px 20px;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: var(--panel-solid);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
}
.panel.wide { width: min(560px, 100%); text-align: left; }

.panel h1 {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 0.16em;
  margin-bottom: 6px;
  background: linear-gradient(180deg, #e8f4ea, #86a08e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.panel h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin-bottom: 12px;
}

.tagline { font-size: 12.5px; color: var(--dim); margin-bottom: 14px; }

.brief {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
  padding: 10px;
  border: 1px solid var(--edge);
  border-radius: 9px;
  font-size: 12px;
  color: var(--dim);
  text-align: left;
}
.brief b { color: var(--ink); }

.rules { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.rules li {
  font-size: 12.5px;
  color: var(--dim);
  padding-left: 14px;
  position: relative;
  line-height: 1.45;
}
.rules li::before { content: "▸"; position: absolute; left: 0; color: var(--edge-strong); }
.rules b { color: var(--ink); }

button.primary {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 4px;
  border-radius: 10px;
  background: linear-gradient(180deg, #6fc78f, #47996a);
  color: #06110b;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.1em;
}
button.primary:active { transform: translateY(1px); filter: brightness(0.94); }

button.ghost {
  flex: 1;
  padding: 9px;
  margin-top: 8px;
  border: 1px solid var(--edge);
  border-radius: 9px;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.06em;
}
button.ghost.danger { color: var(--danger); border-color: rgba(255, 107, 74, 0.4); }

.row { display: flex; gap: 8px; }

.record { margin-top: 12px; font-size: 11px; color: var(--dimmer); letter-spacing: 0.06em; }

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  font-size: 12.5px;
  color: var(--dim);
  border-bottom: 1px solid var(--edge);
}
.setting input[type="range"] { width: 150px; accent-color: #6fc78f; }
.setting select {
  padding: 5px 8px;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: var(--panel-solid);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

#res-title.win { color: var(--ok); }
#res-title.lose { color: var(--danger); }
#res-title.draw { color: var(--gold); }
.res-reason { font-size: 12px; color: var(--dim); margin-bottom: 14px; }

.stats {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  margin-bottom: 14px;
  font-size: 12.5px;
  text-align: left;
}
.stats .k { color: var(--dim); }
.stats .v { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.score {
  padding: 10px;
  border: 1px solid var(--edge-strong);
  border-radius: 9px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--dim);
}
.score span {
  display: block;
  font-size: 30px;
  font-weight: 900;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ============================ RESPONSIVE ============================ */

@media (max-width: 720px) {
  .clock .time { font-size: 21px; }
  .chip { font-size: 13px; padding: 5px 9px; }
  /* Chips wrap to two rows on a phone, so the alert and the feed start lower. */
  #tacmap-wrap { width: 54px; top: calc(126px + var(--safe-t)); }
  #feed { width: 46vw; top: calc(178px + var(--safe-t)); }
  .feed-line { font-size: 10px; padding: 2px 6px; }
  #alert { top: calc(134px + var(--safe-t)); font-size: 11px; padding: 5px 12px; }
  .card { width: 66px; }
  .abil { min-width: 62px; padding: 5px 8px; }
  .abil .n { font-size: 10px; }
  #abilities, #shop { padding-right: 62px; }
  #selection { width: 178px; }
  .panel h1 { font-size: 34px; }
}

@media (max-height: 520px) {
  #tacmap-wrap { bottom: calc(120px + var(--safe-b)); }
  #selection { bottom: calc(120px + var(--safe-b)); }
  .card { width: 64px; padding: 4px; }
  .card .ic { font-size: 16px; }
}
