/* Рейд Резервуара — мини-приложение.
   Поверхности и текст — из темы Telegram (--tg-theme-*), чтобы приложение было «родным» в светлой и тёмной теме.
   Своё — вода резервуара, игровые цвета зон и песок каньона. Заголовки и большие цифры — Unbounded. */

:root {
  --bg: var(--tg-theme-secondary-bg-color, #EFEFF4);
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #FFFFFF));
  --text: var(--tg-theme-text-color, #141821);
  --hint: var(--tg-theme-hint-color, #8A8F98);
  --sub: var(--tg-theme-subtitle-text-color, var(--hint));
  --link: var(--tg-theme-link-color, #1C7FCB);
  --accent: var(--tg-theme-accent-text-color, var(--link));
  --btn: var(--tg-theme-button-color, #1C8FD1);
  --btn-text: var(--tg-theme-button-text-color, #FFFFFF);
  --danger: var(--tg-theme-destructive-text-color, #D8434B);
  --head: var(--tg-theme-section-header-text-color, var(--hint));
  --sep: color-mix(in srgb, var(--hint) 22%, transparent);

  --water: #1C8FD1;
  --water-deep: #0F6FA8;
  --water-foam: #8FD3F5;
  --sand: #D9B27C;
  --z-green: #2E9E5B;
  --z-blue: #2F6FDB;
  --z-red: #D8434B;
  --z-orange: #E8892B;
  --z-center: #8A7CF0;
  --z-water: #1C8FD1;

  --display: "Unbounded", system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 9px;
  --tabs-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tg]) {
    --bg: #101418;
    --surface: #1A2027;
    --text: #E9EDF2;
    --hint: #8B95A1;
    --link: #5DB3F0;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.42 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
[hidden] { display: none !important; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 14px calc(var(--tabs-h) + 28px + var(--safe-b));
}
body.no-tabs main { padding-bottom: calc(96px + var(--safe-b)); }

/* ------------------------------------------------------------- заголовки */
.screen-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 6px 4px 14px; }
.screen-title {
  font: 700 22px/1.15 var(--display);
  letter-spacing: -0.01em;
  margin: 0;
}
.screen-sub { color: var(--hint); font-size: 13px; margin: 2px 4px 14px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--water) 14%, var(--surface));
  color: var(--water-deep); font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pill--test { background: color-mix(in srgb, var(--sand) 35%, var(--surface)); color: #7A5418; }
.pill--muted { background: color-mix(in srgb, var(--hint) 16%, var(--surface)); color: var(--sub); }
@media (prefers-color-scheme: dark) { .pill { color: var(--water-foam); } .pill--test { color: var(--sand); } }
:root[data-scheme="dark"] .pill { color: var(--water-foam); }
:root[data-scheme="dark"] .pill--test { color: var(--sand); }

/* ------------------------------------------------------- резервуар (герой) */
.hero { display: grid; grid-template-columns: 112px 1fr; gap: 16px; align-items: end; margin: 0 2px 18px; }
.tank {
  position: relative;
  height: 156px;
  border-radius: 26px 26px 20px 20px;
  background: var(--surface);
  border: 2px solid color-mix(in srgb, var(--water) 40%, var(--sep));
  overflow: hidden;
  isolation: isolate;
}
.tank::before {           /* шкала делений — как на настоящем резервуаре */
  content: "";
  position: absolute; inset: 14px auto 14px 10px; width: 7px; z-index: 2;
  background: repeating-linear-gradient(to top, color-mix(in srgb, var(--hint) 55%, transparent) 0 1.5px, transparent 1.5px 13px);
  opacity: .55;
}
.water {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: var(--fill, 0%);
  background: linear-gradient(180deg, #43ADE6 0%, var(--water) 45%, var(--water-deep) 100%);
  transition: height .9s cubic-bezier(.2, .8, .2, 1);
}
.water::before {
  content: "";
  position: absolute; left: 0; top: -9px; width: 200%; height: 12px;
  background: radial-gradient(14px 9px at 14px 9px, #43ADE6 98%, transparent 100%) 0 0 / 28px 12px repeat-x;
  animation: wave 4.5s linear infinite;
}
.tank--boot .water::before { animation-duration: 2.4s; }
@keyframes wave { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .water { transition: none; }
  .water::before { animation: none; }
}
.tank-reading { display: flex; flex-direction: column; gap: 4px; padding-bottom: 6px; }
.reading-big { font: 700 44px/1 var(--display); letter-spacing: -0.03em; }
.reading-big small { font-size: 22px; color: var(--hint); letter-spacing: 0; }
.reading-label { color: var(--sub); font-size: 13.5px; }
.reading-extra { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12.5px;
  background: var(--surface); color: var(--sub);
  border: 1px solid var(--sep);
}
.chip b { color: var(--text); font-weight: 650; }
.chip--warn b { color: var(--danger); }

/* --------------------------------------------------------- группы-списки */
.group-title { margin: 18px 6px 7px; color: var(--head); font-size: 13px; font-weight: 600; }
.group {
  background: var(--surface);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.group + .group { margin-top: 10px; }
.note { color: var(--hint); font-size: 12.5px; margin: 7px 8px 0; }
.row {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 48px;
  padding: 10px 14px;
  background: transparent; border: 0; text-align: left;
}
.row + .row::before {
  content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--sep);
}
button.row:active { background: color-mix(in srgb, var(--hint) 12%, transparent); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 560; overflow-wrap: anywhere; }
.row-sub { color: var(--hint); font-size: 13px; margin-top: 1px; overflow-wrap: anywhere; }
.row-value { color: var(--hint); font-size: 14px; white-space: nowrap; }
.row--action .row-title { color: var(--link); font-weight: 560; }
.row--danger .row-title { color: var(--danger); }
.row-icon {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px;
  display: grid; place-items: center; font-size: 16px;
  background: color-mix(in srgb, var(--water) 14%, transparent);
}
.chev::after { content: "›"; color: var(--hint); font-size: 22px; line-height: 1; margin-left: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }

/* ------------------------------------------------------------ контролы */
.switch { position: relative; width: 50px; height: 30px; flex: 0 0 50px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px;
  background: color-mix(in srgb, var(--hint) 38%, transparent); transition: background .2s;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
.switch input:checked + span { background: var(--btn); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }

.seg {
  display: flex; padding: 3px; gap: 3px; border-radius: 11px;
  background: color-mix(in srgb, var(--hint) 15%, transparent);
}
.seg button {
  flex: 1; min-height: 32px; border: 0; border-radius: 9px; padding: 5px 8px;
  background: transparent; color: var(--text); font-size: 13.5px; white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 600; }
.seg--scroll { overflow-x: auto; scrollbar-width: none; }
.seg--scroll::-webkit-scrollbar { display: none; }
.seg--scroll button { flex: 0 0 auto; }
.row .seg { flex: 0 1 auto; }
.row-stack { flex-direction: column; align-items: stretch; gap: 8px; }

.stepper { display: inline-flex; align-items: center; gap: 2px; }
.stepper button {
  width: 34px; height: 32px; border-radius: 9px; border: 0;
  background: color-mix(in srgb, var(--hint) 15%, transparent); font-size: 18px; line-height: 1;
}
.stepper output { min-width: 42px; text-align: center; font: 600 16px/1 var(--display); }

.field {
  width: 100%; border: 0; outline: 0; background: transparent;
  text-align: right; padding: 6px 0; font-size: 15px; min-width: 0;
}
.field::placeholder { color: color-mix(in srgb, var(--hint) 75%, transparent); }
.input {
  width: 100%; padding: 11px 13px; border-radius: var(--r-md);
  border: 1px solid var(--sep); background: var(--surface); outline: 0;
}
.input:focus { border-color: var(--link); }
textarea.input { min-height: 110px; resize: vertical; line-height: 1.4; }
select.field { text-align: right; text-align-last: right; appearance: none; -webkit-appearance: none; }
.row > .field, .row > select.field { flex: 0 1 58%; width: auto; min-width: 0; color: var(--hint); }
.profile-row > .field { flex: 1 1 55%; color: var(--text); }
.row > input[type="time"].field { flex: 0 0 auto; color: var(--text); }
input[type="time"].field { max-width: 110px; }

.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days button {
  min-width: 40px; height: 34px; border-radius: 10px; border: 1px solid var(--sep);
  background: transparent; font-size: 13.5px;
}
.days button[aria-pressed="true"] { background: var(--btn); color: var(--btn-text); border-color: transparent; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: var(--r-md); border: 0;
  background: var(--btn); color: var(--btn-text); font-weight: 600; font-size: 15px;
}
.btn--ghost { background: color-mix(in srgb, var(--btn) 12%, transparent); color: var(--link); }
.btn--danger { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.btn--wide { width: 100%; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 1; }
.btn:disabled { opacity: .5; }

/* --------------------------------------------------------- заявки и зоны */
.app-row .row-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 6px;
  background: color-mix(in srgb, var(--hint) 16%, transparent); color: var(--sub);
}
.tag--proxy { background: color-mix(in srgb, var(--sand) 30%, transparent); color: #7A5418; }
:root[data-scheme="dark"] .tag--proxy { color: var(--sand); }
.empty { padding: 22px 16px; text-align: center; color: var(--hint); }

.zone { background: var(--surface); border-radius: var(--r-lg); overflow: hidden; margin-top: 10px; }
.zone-head {
  display: grid; grid-template-columns: 6px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 14px 10px 0;
}
.zone-bar { align-self: stretch; border-radius: 0 6px 6px 0; background: var(--zc); }
.zone-name { font: 600 15.5px/1.2 var(--display); }
.zone-meta { color: var(--hint); font-size: 12.5px; margin-top: 3px; }
.zone-count { font: 700 20px/1 var(--display); color: var(--zc); }
.zone-players { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 14px 14px; }
.player-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--zc) 40%, var(--sep));
  background: color-mix(in srgb, var(--zc) 9%, transparent); font-size: 14px;
}
.player-chip small { color: var(--hint); font-size: 12px; }
.player-chip--fixed { border-style: dashed; }
.zone-empty { color: var(--hint); font-size: 13px; padding: 0 14px 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--hint); font-size: 12.5px; margin: 8px 6px 0; }

/* ------------------------------------------------------------- анкета */
.banner {
  display: flex; gap: 12px; align-items: center;
  padding: 13px 14px; border-radius: var(--r-lg); margin-bottom: 12px;
  background: color-mix(in srgb, var(--water) 12%, var(--surface));
}
.banner--warn { background: color-mix(in srgb, var(--sand) 26%, var(--surface)); }
.banner-icon { font-size: 22px; }
.banner b { display: block; }
.banner span { color: var(--sub); font-size: 13px; }
.profile-row .row-title { flex: 0 0 auto; }
.profile-row .opt { color: var(--hint); font-weight: 400; font-size: 12.5px; }
.req-mark { color: var(--danger); margin-left: 2px; }

/* ------------------------------------------------------------ навигация */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  padding: 6px 8px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--sep);
}
.tabs-inner { display: flex; width: 100%; max-width: 640px; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 2px; border: 0; background: transparent; color: var(--hint); font-size: 11.5px;
}
.tab svg { width: 26px; height: 26px; }
.tab[aria-current="page"] { color: var(--btn); font-weight: 600; }

.mainbtn {
  position: fixed; left: 14px; right: 14px; z-index: 25;
  bottom: calc(var(--tabs-h) + 10px + var(--safe-b));
  max-width: 612px; margin: 0 auto;
  min-height: 50px; border-radius: 14px; border: 0;
  background: var(--btn); color: var(--btn-text); font-weight: 650; font-size: 16px;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--btn) 35%, transparent);
}
body.no-tabs .mainbtn { bottom: calc(14px + var(--safe-b)); }

/* --------------------------------------------------------------- шторка */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(8, 12, 18, .42);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease-out;
}
.sheet {
  width: 100%; max-width: 640px; max-height: 86vh; overflow: auto;
  background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 10px 14px calc(18px + var(--safe-b));
  animation: rise .22s cubic-bezier(.2, .8, .2, 1);
}
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--sep); margin: 2px auto 12px; }
.sheet-title { font: 600 17px/1.25 var(--display); margin: 2px 4px 12px; }
.zone-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.zone-pick button {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 12px;
  border-radius: var(--r-md); border: 1px solid var(--sep); background: var(--surface); text-align: left;
}
.zone-pick button[aria-pressed="true"] { border: 2px solid var(--zc); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-backdrop { animation: none; } }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--tabs-h) + 74px + var(--safe-b));
  max-width: min(92vw, 560px); padding: 11px 15px; border-radius: 14px;
  background: color-mix(in srgb, var(--text) 88%, transparent); color: var(--bg);
  font-size: 14px; white-space: pre-line; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast--error { background: var(--danger); color: #fff; }

.boot { min-height: 70vh; display: grid; place-content: center; justify-items: center; gap: 14px; }
.boot .tank { width: 92px; height: 120px; }
.hint { color: var(--hint); }
.fatal { padding: 40px 20px; text-align: center; }
.fatal h1 { font: 700 20px/1.2 var(--display); }
.map-img { display: block; width: 100%; border-radius: var(--r-md); margin: 10px 0 2px; }
.mono-num { font-variant-numeric: tabular-nums; }
