/* Badminton club Mini App - dark brand theme from the design prototype.

   Layout follows Telegram's "sticky app" recipe: html/body are exactly the
   stable viewport height and never scroll, #app is the single scroll container,
   so a vertical swipe scrolls the page instead of collapsing the Mini App. The
   palette is dark-only on purpose: Telegram theme colours are not used for
   surfaces (the native chrome is matched from app.js with setHeaderColor &
   co.), so the app looks the same on every client. Every colour, radius and
   size lives in a token below; components only reference tokens. */

:root {
  --bg: #0E1015;
  --bg-nav: #12141A;
  --bg-sheet: #15181E;
  --surface: #171A21;
  --surface-2: #1C2028;
  --surface-3: #1F232C;
  --surface-4: #232832;
  --surface-5: #2A2F3A;
  --avatar: #20242D;
  --border: #262A34;
  --border-2: #2B303B;
  --divider: #232731;
  --track: #262B35;
  --track-2: #2E333E;
  --handle: #353B47;
  --off: #3A404C;
  --text: #F3F2EE;
  --text-2: #E3E5EA;
  --text-3: #CDD1D9;
  --muted: #A0A6B2;
  --muted-2: #8C929E;
  --disabled: #6E7480;
  --accent: #D7F75B;
  --accent-dim: rgba(215, 247, 91, 0.14);
  --ink: #11130C;
  --blue: #74B9FF;
  --neg: #FF9046;
  --warn-bg: #33241A;
  --warn-fg: #FFB27F;
  --danger: #FF8A7A;
  --gold: #F2C14E;
  --gold-bg: #2A2416;
  --gold-border: #4A3E1E;
  --scrim: rgba(5, 6, 9, 0.66);
  --shadow-toast: 0 10px 30px rgba(0, 0, 0, 0.45);
  --r-sheet: 26px;
  --r-card: 20px;
  --r-pick: 18px;
  --r-btn: 14px;
  --r-sm: 12px;
  --r-ico: 11px;
  --r-seg: 10px;
  --r-mark: 8px;
  --header-h: 56px;
  --gutter: 16px;
  --gap: 12px;
  --gap-lg: 14px;
  --font-text: Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: Unbounded, Manrope, system-ui, sans-serif;
  --safe-top: calc(var(--tg-content-safe-area-inset-top, 0px) + var(--tg-safe-area-inset-top, 0px));
  --safe-bottom: var(--tg-safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --t-fast: 160ms;
  --t-sheet: 200ms;
  color-scheme: dark;
}

/* ---- base ------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: var(--app-height, var(--tg-viewport-stable-height, 100vh));
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

body {
  font: 400 15px/1.4 var(--font-text);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

#app {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

#app::-webkit-scrollbar { display: none; }

/* The extra pixel keeps the WebView scrollable on iOS/Android even when the
   content is shorter than the viewport, so the swipe stays inside the app. */
html.is-mobile .screen { min-height: calc(100% + 1px); }

button, input {
  font: inherit;
  color: inherit;
  margin: 0;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  text-align: inherit;
}

button:disabled { cursor: default; }

button:focus-visible, input:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a { color: var(--accent); }

svg { display: block; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- screen shell ----------------------------------------------------- */

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  animation: screen-in var(--t-fast) var(--ease);
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 12px 0;
  background: var(--bg);
}

.topbar__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 14px 0 10px;
  border-radius: 22px;
  background: var(--surface-2);
  font-weight: 700;
  font-size: 15px;
  transition: background var(--t-fast);
}

.topbar__back:active { background: var(--surface-4); }

.topbar__title {
  flex: 1;
  min-width: 0;
  font-weight: 800;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar--root .topbar__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
  padding-left: 4px;
}

.topbar__spacer { width: 40px; }

.content {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 6px var(--gutter) calc(28px + var(--safe-bottom));
}

.content--lg { gap: var(--gap-lg); }

.footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin-top: auto;
  padding: 12px var(--gutter) calc(22px + var(--safe-bottom));
  background: linear-gradient(to bottom, rgba(14, 16, 21, 0), var(--bg) 35%);
}

/* ---- typography ------------------------------------------------------- */

.h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.25;
}

.num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.lbl {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
}

.eyebrow { padding: 6px 4px 0; }

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.sub { font-size: 13px; color: var(--muted); }
.note-text { font-size: 12px; color: var(--muted); padding: 0 4px; }
.pos { color: var(--accent); }
.neg { color: var(--neg); }
.tabular { font-variant-numeric: tabular-nums; }
.intro { padding: 4px 2px 0; display: flex; flex-direction: column; gap: 6px; }

/* ---- cards, rows, tags ------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}

.card--pad { padding: 18px; }
.card--list { overflow: hidden; }

.card--tap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast);
}

.card--tap:active { transform: scale(0.985); background: var(--surface-2); }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 10px 16px;
  border-top: 1px solid var(--divider);
  transition: background var(--t-fast);
}

.row:first-child { border-top: 0; }
button.row:active { background: var(--surface-2); }
.row--static { cursor: default; }

/* The nudge row's target lights up twice when the row scrolls to it. */
@keyframes row-flash {
  0%, 100% { background: transparent; }
  20%, 45% { background: var(--accent-dim); }
  60% { background: transparent; }
  75% { background: var(--accent-dim); }
}

.row--flash { animation: row-flash 1.8s var(--ease) 1; }
.row__check { flex: none; color: var(--accent); }

.row__ico {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--r-ico);
  background: var(--surface-4);
  color: var(--text-3);
  font-size: 18px;
  overflow: hidden;
  white-space: nowrap;
}

.row__ico svg { width: 20px; height: 20px; }
.row__ico--accent { background: var(--accent-dim); color: var(--accent); }
.row__ico--warn { background: var(--warn-bg); color: var(--warn-fg); }

.row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row__title { font-weight: 800; }
.row__sub { font-size: 13px; color: var(--muted); }
.row__sub--ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__chev { flex: none; color: var(--muted); }
.row__chev svg { width: 18px; height: 18px; }
.row__trail { flex: none; font-weight: 800; font-variant-numeric: tabular-nums; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 12px;
  background: var(--surface-4);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag--accent { background: var(--accent); color: var(--ink); }
.tag--warn { background: var(--warn-bg); color: var(--warn-fg); }
.tag--gold { background: var(--gold-bg); color: var(--gold); }
.tag--blue { background: rgba(116, 185, 255, 0.16); color: var(--blue); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---- buttons, chips, segments, switches -------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 16px;
  border-radius: var(--r-btn);
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), opacity var(--t-fast);
}

.btn:active { transform: scale(0.97); }
a.btn { text-decoration: none; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.btn--primary { background: var(--accent); color: var(--ink); }
.btn--primary:disabled { background: var(--surface-4); color: var(--disabled); transform: none; }
.btn--ghost { background: var(--surface-4); color: var(--text); }
.btn--sm { height: auto; min-height: 44px; padding: 0 14px; border-radius: var(--r-sm); font-size: 14px; }
.btn--full { width: 100%; height: 52px; }
.btn svg { width: 16px; height: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* A filter row with more chips than fit scrolls sideways instead of wrapping;
   the gutter bleed lets the last chip peek in from the edge as the affordance. */
.chips--scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  margin: 0 calc(-1 * var(--gutter));
  padding: 2px var(--gutter);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips--scroll::-webkit-scrollbar { display: none; }
.chips--scroll .chip { flex: none; }

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text-2);
  font-weight: 700;
  font-size: 14px;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.chip[aria-pressed="true"] { background: var(--accent); color: var(--ink); border-color: var(--accent); }

.seg {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
}

.seg__btn {
  height: 44px;
  border-radius: var(--r-seg);
  font-weight: 800;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  transition: background var(--t-fast), color var(--t-fast);
}

.seg__btn[aria-pressed="true"] { background: var(--surface-5); color: var(--text); }

.switch {
  position: relative;
  flex: none;
  width: 50px;
  height: 30px;
  border-radius: 15px;
  background: var(--off);
  transition: background var(--t-fast) var(--ease);
}

.switch__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 12px;
  background: #FFFFFF;
  transition: transform 180ms var(--ease);
}

[aria-pressed="true"] > .switch { background: var(--accent); }
[aria-pressed="true"] > .switch > .switch__knob { transform: translateX(20px); }
.switch--unset { background: var(--track); box-shadow: inset 0 0 0 2px var(--off); }
.switch--unset > .switch__knob { background: var(--muted); transform: translateX(10px) scale(0.7); }
button:disabled > .switch { opacity: 0.45; }
.row--busy .switch { opacity: 0.6; }

/* ---- forms ------------------------------------------------------------ */

.field { display: flex; flex-direction: column; gap: 8px; }
.field__label { padding: 0 2px; }
.field__help { font-size: 13px; color: var(--muted); padding: 0 2px; }
.field__error { font-size: 13px; color: var(--danger); padding: 0 2px; }

.input-wrap { position: relative; display: flex; align-items: center; }

.input {
  width: 100%;
  height: 54px;
  padding: 0 16px;
  border-radius: var(--r-btn);
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--t-fast);
}

.input::placeholder { color: var(--muted-2); font-weight: 500; }
.input:focus { border-color: var(--accent); outline: none; }
.input--error { border-color: var(--danger); }
.input-wrap .input { padding-right: 104px; }

.input-clear {
  position: absolute;
  right: 6px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  background: var(--surface-4);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.pick {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  border-radius: var(--r-btn);
  border: 2px solid var(--border-2);
  background: var(--surface);
  color: var(--text-3);
  font-size: 24px;
  line-height: 1;
  overflow: hidden;
  white-space: nowrap;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}

.pick:active { transform: scale(0.95); }
.pick[aria-pressed="true"] { background: var(--surface-4); border-color: var(--accent); color: var(--text); }
.pick--text { font-size: 13px; font-weight: 800; }

.level {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  border-radius: var(--r-pick);
  border: 2px solid var(--border-2);
  background: var(--surface);
  color: var(--text-3);
  transition: border-color var(--t-fast), background var(--t-fast);
}

.level[aria-pressed="true"] { background: var(--surface-4); border-color: var(--accent); color: var(--text); }
.level__bars { display: flex; align-items: flex-end; gap: 3px; height: 22px; flex: none; }
.level__bar { width: 6px; border-radius: 2px; background: var(--handle); }
.level[aria-pressed="true"] .level__bar--on { background: var(--accent); }
.level__bar--on { background: var(--muted); }
.level__name { flex: 1; font-weight: 800; }
.level__rating { font-family: var(--font-display); font-weight: 700; font-size: 16px; }

.preview-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.preview-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.preview-line .btn {
  pointer-events: none;
  max-width: 100%;
  height: auto;
  min-height: 40px;
  padding: 8px 14px;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
}

/* ---- profile ---------------------------------------------------------- */

.hero { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.hero__top { display: flex; align-items: center; gap: 16px; }

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--avatar);
  border: 2px solid var(--accent);
  font-size: 34px;
  line-height: 1;
  white-space: nowrap;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--initial { font-family: var(--font-display); font-weight: 700; font-size: 26px; color: var(--text); }

.hero__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }

.hero__name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.pencil {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: var(--r-btn);
  background: var(--surface-4);
  color: var(--text);
  transition: transform var(--t-fast) var(--ease);
}

.pencil:active { transform: scale(0.94); }
.pencil svg { width: 18px; height: 18px; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border-radius: var(--r-btn);
  background: var(--surface-3);
}

.tile__val { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.tile__sub { font-size: 11.5px; line-height: 1.25; color: var(--muted); overflow-wrap: anywhere; }

.hero__debts { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.35; color: var(--muted); }
.hero__debts svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.hero__debts__text { min-width: 0; }
.hero__debts--open svg, .hero__debts--open .hero__debts__main { color: var(--warn-fg); }

.info {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-radius: var(--r-btn);
  background: var(--surface);
  font-size: 13px;
  color: var(--muted);
}

.info svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.info--accent { border: 1px solid var(--border); }
.info--accent svg { color: var(--accent); }

.nudge { border-color: rgba(215, 247, 91, 0.35); }
.nudge__head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 8px; font-weight: 800; }
.nudge__head svg { width: 18px; height: 18px; color: var(--accent); }
.nudge .row { min-height: 52px; padding: 8px 16px; }
.nudge .row__ico { width: 32px; height: 32px; }
.nudge .row__ico svg { width: 18px; height: 18px; }
.nudge .row__title { font-weight: 600; font-size: 14px; line-height: 1.3; }

/* ---- achievements ----------------------------------------------------- */

.ach-summary { display: flex; align-items: center; gap: 18px; padding: 18px; }
.ring { flex: none; }
.ring__text { font-family: var(--font-display); font-weight: 700; font-size: 16px; fill: var(--text); }
.ring__track { stroke: var(--track); }
.ring__fill { stroke: var(--accent); transition: stroke-dasharray 400ms var(--ease); }

.ach-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

/* A section head counts families: «ПРИСУТНІСТЬ · 4 з 10» - the label is the
   uppercase eyebrow, the count keeps its case. A section with nothing held
   is one tappable line until opened. */
.eyebrow--count { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.eyebrow__count { font-size: 11px; font-weight: 800; letter-spacing: 0.02em; color: var(--muted); white-space: nowrap; }

.section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 4px 4px 0;
}

.section-toggle .eyebrow { padding: 0; }

.section-toggle__more {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.section-toggle__more svg { width: 16px; height: 16px; transform: rotate(90deg); }

.ach {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 20px 8px 12px;
  text-align: center;
  transition: transform var(--t-fast) var(--ease);
}

.ach:active { transform: scale(0.97); }
.ach--locked { opacity: 0.62; }
.ach--legend.ach--held { border-color: var(--gold-border); }

.ach__badge {
  position: absolute;
  top: 6px;
  right: 6px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
  line-height: 20px;
  background: var(--surface-5);
  color: var(--text);
}

.ach__badge--new { background: var(--accent); color: var(--ink); }
.ach__name { font-weight: 800; font-size: 12.5px; line-height: 1.25; overflow-wrap: anywhere; }
.ach__cap {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.3;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.coin {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--avatar);
  border: 2px solid var(--off);
  border-style: dashed;
  color: var(--muted);
}

.coin svg { width: 26px; height: 26px; }
.coin--held { border-style: solid; border-color: var(--accent); color: var(--text); }
.coin--legend { background: var(--gold-bg); border-color: var(--gold); color: var(--gold); }
.coin--legend.coin--locked { border-style: dashed; opacity: 0.9; }
.coin--sm { width: 44px; height: 44px; }
.coin--sm svg { width: 20px; height: 20px; }

.coin__tier {
  position: absolute;
  right: -6px;
  bottom: -4px;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--surface-5);
  color: var(--text);
  font-size: 10px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.coin--held .coin__tier { background: var(--accent); color: var(--ink); }
.coin--legend .coin__tier { background: var(--gold); color: var(--ink); }

/* The progress meter under a cumulative rung: a hairline track, the accent
   fill, the «37 із 50» caption. Drawn only where the API measured one. */
.meter { display: flex; flex-direction: column; gap: 5px; width: 100%; margin-top: auto; }
.meter__track { display: block; width: 100%; height: 4px; border-radius: 2px; background: var(--track-2); overflow: hidden; }
.meter__fill { display: block; height: 100%; border-radius: 2px; background: var(--accent); transition: width 400ms var(--ease); }
.meter__text { font-size: 10.5px; font-weight: 800; color: var(--text-3); font-variant-numeric: tabular-nums; line-height: 1.3; }
.ach .meter { padding-top: 2px; }
.meter__track--sheet { height: 6px; margin: -2px 0 10px; }

/* ---- results ---------------------------------------------------------- */

.ev { overflow: hidden; }

.ev__head {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  transition: background var(--t-fast);
}

.ev__head:active { background: var(--surface-2); }

.ev__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ev__title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 800; }
.ev__id { color: var(--muted-2); font-variant-numeric: tabular-nums; }
.ev__deltas { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.ev__delta { display: flex; align-items: baseline; gap: 5px; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ev__delta .lbl { font-size: 10px; }
.ev__detail { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.ev__detail--loading { padding-top: 4px; }

/* The expanded evening's header: one line per ladder - record, Δ рейтингу,
   Δ перемог - as the admin's evening row. */
.ev__summary { display: flex; flex-direction: column; gap: 6px; }
.ev__mode { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.ev__stat b { font-weight: 800; }

/* The evening's stored recap, the bot's message read back line by line. */
.recap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
}

.recap__text { display: flex; flex-direction: column; gap: 2px; }
.recap__line { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--text-2); overflow-wrap: anywhere; white-space: pre-wrap; }
.recap__gap { margin: 0; height: 6px; }

.grp { display: flex; flex-direction: column; gap: 6px; }
.grp__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 2px; }
.grp__record { font-size: 12px; font-weight: 800; color: var(--text-3); font-variant-numeric: tabular-nums; }

.match {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  font-size: 13.5px;
}

.mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: var(--r-mark);
  font-size: 12px;
  font-weight: 800;
  background: var(--surface-5);
  color: var(--text-3);
}

.mark--w { background: var(--accent); color: var(--ink); }
.mark--p { background: var(--surface-4); color: var(--muted); }
.match__score { flex: none; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 28px; }
.match__body { flex: 1; min-width: 0; line-height: 1.35; }
.match__with { font-weight: 700; }
.match__vs { color: var(--muted); }
.match__delta { flex: none; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.match__tags { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 6px; vertical-align: 1px; }

/* «корт 3» when a block spans courts, «достроково» for a match closed early. */
.minitag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--surface-5);
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.minitag--warn { background: var(--warn-bg); color: var(--warn-fg); }

/* ---- statistics ------------------------------------------------------- */

.stat-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat-tiles .tile--wide { grid-column: 1 / -1; }
.stat-tiles .tile__val { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: -0.01em; }

.chart-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chart-card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.chart-card__range { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart { width: 100%; height: auto; touch-action: pan-y; }
.chart__grid { stroke: var(--border); stroke-width: 1; }
.chart__area { fill: var(--accent); fill-opacity: 0.1; }
.chart__line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__dot { fill: var(--muted); stroke: var(--surface); stroke-width: 2; }
.chart__dot--in { fill: var(--accent); }
.chart__dot--end { r: 5; }
.chart__hit { fill: transparent; pointer-events: all; }
.chart__cursor { stroke: var(--text-3); stroke-width: 1; opacity: 0; transition: opacity var(--t-fast); }
.chart__cursor--on { opacity: 1; }
.chart__tick { font-size: 10px; fill: var(--muted); font-weight: 700; }
.chart__readout { display: flex; justify-content: space-between; gap: 10px; min-height: 20px; font-size: 13px; color: var(--muted); }
.chart__readout strong { color: var(--text); font-weight: 800; font-variant-numeric: tabular-nums; }

.hl-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.hl-row { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.hl-row__label { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-row__games { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hl-row__val { min-width: 48px; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }

.table { padding: 6px 0 4px; display: flex; flex-direction: column; }
.table__head, .table__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px 48px 42px 50px;
  gap: 6px;
  align-items: center;
  padding: 8px 14px;
}
.table__head { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.table__row { border-top: 1px solid var(--divider); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.table__row > span:not(:first-child), .table__head > span:not(:first-child) { text-align: right; }
.table__name { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.table__label { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table__sub { font-size: 10.5px; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table__title { padding: 14px 16px 4px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.table__more { margin: 6px 16px 10px; }
.table__empty { padding: 10px 16px 16px; font-size: 13px; color: var(--muted); }

.streaks { padding: 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; }
.streaks__item { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.streaks__item--wide { grid-column: 1 / -1; }
.streaks__val { font-family: var(--font-display); font-weight: 700; font-size: 20px; }
.streaks__sub { font-size: 12px; color: var(--muted); }

/* ---- states ----------------------------------------------------------- */

.empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.empty--card { border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border); }
.empty__icon { font-size: 32px; margin-bottom: 8px; }
.empty__reason { margin-top: 6px; font-size: 13px; color: var(--muted-2); }

.terminal {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex: 1;
  padding: 40px 28px calc(40px + var(--safe-bottom));
  text-align: center;
}

.terminal__icon { font-size: 44px; }
.terminal__title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 20px; }
.terminal__text { margin: 0; color: var(--muted); font-size: 14px; max-width: 320px; }
.terminal__code { font-size: 12px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.terminal .btn { min-width: 180px; margin-top: 6px; }

.skel {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.skel--text { height: 14px; }
.skel--title { height: 22px; width: 60%; }
.skel--avatar { width: 72px; height: 72px; border-radius: 50%; }
.skel--tile { height: 62px; border-radius: var(--r-btn); }
.skel--row { height: 58px; border-radius: 0; }
.skel--chart { height: 140px; }

/* ---- toast & bottom sheet --------------------------------------------- */

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  /* --toast-lift is the sticky footer's height when the screen has one. */
  bottom: calc(16px + var(--safe-bottom) + var(--toast-lift, 0px));
  z-index: 8;
  padding: 14px 16px;
  border-radius: var(--r-btn);
  background: var(--text);
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-toast);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

.toast--on { opacity: 1; transform: none; }
.toast--error { background: var(--danger); color: var(--ink); }

.sheet-root { position: fixed; inset: 0; z-index: 6; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet-root[hidden] { display: none; }

.scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  opacity: 0;
  transition: opacity var(--t-sheet) var(--ease);
}

.sheet {
  position: relative;
  max-height: calc(100% - 40px);
  overflow-y: auto;
  padding: 10px 18px calc(26px + var(--safe-bottom));
  background: var(--bg-sheet);
  border-top: 1px solid var(--border-2);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  transform: translateY(100%);
  transition: transform var(--t-sheet) var(--ease);
}

.sheet-root--on .scrim { opacity: 1; }
.sheet-root--on .sheet { transform: none; }
.sheet__handle { width: 40px; height: 5px; margin: 0 auto 14px; border-radius: 3px; background: var(--handle); }
.sheet__head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.sheet__title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 18px; line-height: 1.25; }
.sheet__close {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 22px;
  background: var(--surface-4);
  color: var(--text);
}
.sheet__close svg { width: 18px; height: 18px; }
.sheet__row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--divider); font-size: 14px; }
.sheet__row:first-of-type { border-top: 0; }
.sheet__row span:last-child { text-align: right; font-weight: 700; }
.sheet__text { margin: 0 0 12px; color: var(--text-2); line-height: 1.45; }
.sheet__note { margin: -4px 0 10px; font-size: 12.5px; color: var(--muted); }

/* The evening picker: one row per evening, the chosen one ticked. */
.sheet__list { display: flex; flex-direction: column; margin: 0 -4px; }
.sheet__list .row { min-height: 56px; padding: 10px 4px; }
.sheet__list .row[aria-pressed="true"] .row__title { color: var(--accent); }

/* ---- mock-only dataset switcher ---------------------------------------- */

.mockbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 4px 0;
  font-size: 12px;
  color: var(--muted);
}

.mockbar .chip { min-height: 36px; padding: 0 12px; font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

@media (min-width: 560px) {
  .content { max-width: 560px; width: 100%; margin: 0 auto; }
  .topbar { padding-left: calc(50% - 268px); padding-right: calc(50% - 268px); }
}
