/* Reusable components, styled only through tokens. Where they sit on screen is css/layout.css.
   card (.sheet) · brand · buttons · kbd · fields · tabs · chip · menu · avatar · banner · score pill · round markers ·
   score list · game details · versus · person list (rank, score, tag, streak chip) · count badge · code display · statistics ·
   badge card · streak panel · map of knowledge · danger zone · tool group · loader · toast · dialog */

/* --- card: every panel over the map --- */
.sheet {
  --pad-y: var(--space-7); --pad-x: var(--space-7);
  width: min(var(--card-w), 100% - 2 * var(--gutter));
  padding: var(--pad-y) var(--pad-x);
  border-radius: var(--radius-card);
  background: var(--surface); border: 1px solid var(--line);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-card); color: var(--ink);
  display: flex; flex-direction: column; gap: var(--space-4);
}
.sheet h1 { font-size: var(--text-title); font-weight: var(--weight-display); line-height: var(--leading-tight); letter-spacing: var(--tracking-tight); }
.sheet p { line-height: var(--leading-body); }
.lead { font-size: var(--text-lg); color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }   /* a group inside a card (a tab panel) */
/* the card's last row ("Zpět", "Sdílet | Hotovo"): always at the bottom of a card that scrolls, the content passes
   under it; in a card taller than its content (min-height) it sits at the bottom too */
.sheet-foot {
  position: sticky; bottom: calc(-1 * var(--pad-y)); z-index: 1;
  display: flex; gap: var(--space-3); margin: auto calc(-1 * var(--pad-x)) calc(-1 * var(--pad-y));
  padding: var(--space-3) var(--pad-x) var(--pad-y); background: var(--surface-solid);
}
.sheet-foot > .btn { flex: 1; }

/* --- brand: logo mark + name --- */
.brand { display: flex; align-items: center; gap: var(--space-3); }
.brand::before {
  content: ''; flex: none; width: .9em; height: .9em; border-radius: 28%;
  background: linear-gradient(135deg, var(--accent) 0 55%, var(--highlight) 55%);
}

/* --- buttons: one .btn-primary per screen; .btn-lg + .btn-block for the main action at the bottom of a card --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h); padding: 0 var(--space-6);
  border: 0; border-radius: var(--radius-control);
  font-size: var(--text-lg); font-weight: var(--weight-strong); line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: transform var(--dur-fast), background-color var(--dur-fast), opacity var(--dur-fast);
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: progress; transform: none; }
.btn-lg { min-height: var(--control-h-lg); }
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-button); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { box-shadow: none; }
.btn-secondary { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-danger { background: var(--danger-solid); color: #fff; }
.btn-google { background: #fff; color: #1f1f1f; box-shadow: inset 0 0 0 1px #dadce0; }   /* Google's brand rules */
.btn-google svg { width: 18px; height: 18px; flex: none; }
.btn-link {
  min-height: 0; padding: var(--space-1) 2px; border-radius: 4px; background: none; color: inherit;
  font-size: inherit; font-weight: 650;
  text-decoration: underline; text-decoration-color: var(--line-strong); text-decoration-thickness: 1.5px; text-underline-offset: 3px;
}
.btn-link:hover { transform: none; text-decoration-color: currentColor; }
.btn-link.danger { color: var(--danger); }
.kbd {
  font-size: 12px; font-weight: 600; line-height: 1; padding: 4px 6px; border-radius: 6px;
  border: 1.5px solid currentColor; opacity: .6;
}
.is-mobile .kbd { display: none; }
@media (hover: none) { .kbd { display: none; } }   /* touch screens have no Enter key at hand */

/* --- form fields: label above, error under the field (.form-msg) --- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field-head { font-size: var(--text-sm); font-weight: 650; color: var(--muted); }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.field-head .btn-link { font-size: var(--text-sm); color: var(--ink); }
.field input {
  width: 100%; min-height: var(--control-h); padding: 0 14px; border-radius: var(--radius-control);
  font-size: 16px; color: var(--ink); background: var(--field-bg); border: 1px solid var(--field-line);
}
.field textarea {   /* a longer text: the look of .field input */
  width: 100%; min-height: 7.5em; padding: var(--space-3) 14px; border-radius: var(--radius-control); resize: vertical;
  font: inherit; font-size: 16px; line-height: var(--leading-body); color: var(--ink); background: var(--field-bg); border: 1px solid var(--field-line);
}
.field input:focus, .field textarea:focus { border-color: var(--accent); outline: none; }
.field input:focus-visible, .field textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.check { display: flex; gap: var(--space-3); align-items: flex-start; font-size: 14px; line-height: 1.4; color: var(--muted); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--accent); }
.check a { color: var(--ink); }
.check:has(input:disabled) { cursor: default; opacity: .6; }
.form-msg { font-size: 14px; line-height: 1.4; font-weight: 600; }
.form-msg.error { color: var(--danger); }
.form-msg.info { color: var(--tier-good); }
.form-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); }
.divider { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); color: var(--muted); }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.divider:empty { gap: 0; }

/* --- tabs: segmented switch --- */
.tabs { display: flex; padding: 4px; border-radius: var(--radius-control); background: var(--surface-2); }
.tabs [role="tab"] {
  flex: 1; min-height: 40px; border: 0; border-radius: calc(var(--radius-control) - 3px); padding: 0 var(--space-3);
  background: none; color: var(--muted); font-size: var(--text-md); font-weight: var(--weight-strong); cursor: pointer;
}
.tabs [role="tab"]:hover { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"] { background: var(--ink); color: var(--ink-inverse); }

/* --- chip: small floating pill (account, guest) --- */
.chip {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: 6px var(--space-4) 6px 6px;
  border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); font-size: var(--text-md); font-weight: 600; white-space: nowrap;
}
.chip.plain { padding-left: var(--space-4); }

/* --- menu: <details class="menu"><summary class="chip">…</summary><div class="menu-list">buttons</div></details> --- */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; transition: background-color var(--dur-fast); }
.menu > summary:hover, .menu[open] > summary { background-image: linear-gradient(var(--surface-hover), var(--surface-hover)); }
.menu > summary.chip { padding-block: 5px; }   /* 44 px with the avatar, as tall as the guest's chip */
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after {
  content: ''; width: 8px; height: 8px; margin: -3px 2px 0 2px; border: solid var(--muted); border-width: 0 2px 2px 0;
  transform: rotate(45deg); transition: transform var(--dur-fast);
}
.menu[open] > summary::after { transform: rotate(-135deg); margin-top: 3px; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + var(--space-2)); z-index: var(--z-menu); min-width: 100%;
  display: flex; flex-direction: column; padding: 6px; border-radius: var(--radius-control);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card);
}
.menu-list button {
  display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: none; text-align: left;
  font-size: var(--text-md); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.menu-list button:hover { background: var(--surface-hover); }

/* --- avatar: initial on the account's colour (--avatar-bg), or the account photo --- */
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
  background: var(--avatar-bg, var(--tier-bad)); color: #fff; font-weight: 800; font-size: 15px; line-height: 1; text-transform: uppercase;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.lg { width: 60px; height: 60px; font-size: 26px; }

/* --- banner: one-line status inside a card (save note, e-mail not verified); .notice is the same --- */
.banner, .notice {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 14px; border-radius: var(--radius-inner);
  background: var(--surface-2); font-size: 14.5px; line-height: 1.4;
}
.banner::before, .notice::before {
  content: ''; flex: none; width: 18px; height: 18px; background: var(--info);
  -webkit-mask: var(--icon, var(--icon-info)) center / contain no-repeat; mask: var(--icon, var(--icon-info)) center / contain no-repeat;
}
.banner .btn-link, .notice .btn-link { color: var(--ink); }

/* --- score pill: points with the tier colour and icon (scoreTier(): .good ≥ 160, .mid ≥ 50, .bad below) --- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-pill);
  font-weight: 800; font-size: var(--text-md); line-height: 1; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.pill::before {
  content: ''; width: 14px; height: 14px; flex: none; background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.pill.good { color: var(--tier-good); background: var(--tier-good-bg); --icon: var(--icon-star); }
.pill.mid { color: var(--tier-mid); background: var(--tier-mid-bg); --icon: var(--icon-pin); }
.pill.bad { color: var(--tier-bad); background: var(--tier-bad-bg); --icon: var(--icon-dot); }

/* --- round markers: one per round, coloured by its tier; .cur is the round being played --- */
.rounds { display: flex; gap: 5px; margin: 0; padding: 0; list-style: none; }
.rounds li { width: 26px; height: 8px; border-radius: 4px; background: var(--tier-empty); }
.rounds li.cur { background: var(--ink); }
.rounds li.good { background: var(--tier-good); }
.rounds li.mid { background: var(--tier-mid); }
.rounds li.bad { background: var(--tier-bad); }

/* --- score list: place, distance, points per row (summary, history); optional photo thumbnail --- */
.score-list { list-style: none; margin: 0; padding: 0; }
.score-list li {
  display: grid; grid-template-columns: 1fr auto auto; gap: var(--space-3); align-items: center;
  padding: 9px 0; border-top: 1px solid var(--line); font-size: var(--text-md);
}
.score-list li:last-child { border-bottom: 1px solid var(--line); }
.score-list li.with-thumb { grid-template-columns: 44px 1fr auto; }
.score-list .place[title] { cursor: help; }   /* the summary: the question of the round as a tooltip */
.score-list .thumb { width: 44px; height: 44px; border-radius: var(--radius-inner); object-fit: cover; background: var(--surface-2); }
.score-list .what { display: flex; flex-direction: column; min-width: 0; }
.score-list .place { font-weight: var(--weight-strong); min-width: 0; }
.score-list .dist { color: var(--muted); white-space: nowrap; font-size: var(--text-sm); }
.score-list li:not(.with-thumb) .dist { font-size: inherit; }
.score-list .pts { text-align: right; }

/* --- game details: a saved game to expand (history, a friend's game)
   <details class="game-details"><summary><span class="when">…</span><span class="total-pts">…</span></summary>
   <ol class="score-list">…</ol></details> --- */
.game-details > summary {
  display: flex; justify-content: space-between; gap: var(--space-3); padding: 10px 2px; cursor: pointer; list-style: none;
}
.game-details > summary::-webkit-details-marker { display: none; }
.game-details > summary:hover .when { color: var(--ink); }
.game-details > summary::before { content: '▸'; color: var(--muted); margin-right: -4px; transition: transform var(--dur-fast); }
.game-details[open] > summary::before { transform: rotate(90deg); }
.game-details .when { flex: 1; color: var(--muted); }
.game-details .total-pts { font-weight: 800; font-variant-numeric: tabular-nums; }
.game-details .score-list { margin: 0 0 10px 18px; }
.game-details .score-list li { font-size: 14px; padding: 6px 0; }
.game-details .score-list li:last-child { border-bottom: 0; }
.game-details .score-list .pill { padding: 4px 9px; font-size: 13px; }

/* --- versus: two results of the same rounds side by side (comparing today's game); the lower points dimmed --- */
.versus { list-style: none; margin: 0; padding: 0; }
.versus li {
  display: grid; grid-template-columns: minmax(0, 1fr) 84px 84px; gap: var(--space-2); align-items: center;
  padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px;
}
.versus .place { font-weight: var(--weight-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.versus .pill, .versus .who, .versus .total-pts { justify-self: end; }
.versus .pill { padding: 4px 9px; font-size: 13px; }
.versus .who { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); font-weight: var(--weight-strong); color: var(--muted); }
.versus .versus-head { border-top: 0; padding-top: 0; }
.versus .versus-total { font-weight: 800; }
.versus .total-pts { font-variant-numeric: tabular-nums; padding-right: 9px; }
.versus .lower { opacity: .5; }

/* --- person list: a player in a row (avatar, name, a line of detail, actions on the right) --- */
.person-list { list-style: none; margin: 0; padding: 0; }
.person-list > li { border-top: 1px solid var(--line); }
.person-list > li:last-child { border-bottom: 1px solid var(--line); }
.person { display: flex; align-items: center; gap: var(--space-3); padding: 10px 2px; }
.person-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* the name shortens, its tags ("ty", the streak chip, "nová hra") stay visible */
.person-name { display: flex; align-items: center; min-width: 0; }
.person-name > .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-name > .tag, .person-name > .streak-chip { flex: none; }
.person-text .muted { font-size: var(--text-sm); }
.person-actions { display: flex; align-items: center; gap: var(--space-3); flex: none; }
.person-actions.spacer { visibility: hidden; }   /* the player's own row: keeps the points in the column of the friends' */
.person-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding: 0 2px 12px; font-size: var(--text-md); }
.person-confirm p { flex: 1 1 100%; }
.person .rank { flex: none; min-width: 1.6em; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); }
.person .rank.first { color: var(--accent); }
.person .person-score { flex: none; font-size: var(--text-lg); font-weight: 800; font-variant-numeric: tabular-nums; }
.person-list > li.is-me {   /* the player's own row: a band reaching a bit past the list */
  margin-inline: calc(-1 * var(--space-2)); padding-inline: var(--space-2); border-radius: var(--radius-inner);
  background: var(--surface-2);
}
.tag {
  display: inline-block; margin-left: var(--space-2); padding: 1px 7px; border-radius: var(--radius-pill); vertical-align: 1px;
  background: var(--ink); color: var(--ink-inverse); font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.tag.new { background: var(--accent); color: var(--accent-ink); }

/* --- streak chip: days in a row next to a nickname (personRow; a friend's from 7 days, the player's own from 1) --- */
.streak-chip {
  display: inline-flex; align-items: center; gap: 2px; margin-left: var(--space-2); padding: 1px 7px 1px 4px;
  border-radius: var(--radius-pill); background: var(--highlight-bg); color: var(--highlight); vertical-align: 1px;
  font-size: 12px; font-weight: 800; line-height: 1.35; font-variant-numeric: tabular-nums;
}
.streak-chip::before {
  content: ''; width: 13px; height: 13px; flex: none; background: currentColor;
  -webkit-mask: var(--icon-flame) center / contain no-repeat; mask: var(--icon-flame) center / contain no-repeat;
}

/* --- count badge: how many things wait, next to a chip, a menu item or a tab (not used yet) --- */
.count-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: var(--space-1);
  border-radius: var(--radius-pill); background: var(--accent); color: var(--accent-ink);
  font-size: 12px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; vertical-align: 1px;
}

/* --- code display: a short code to read out or type (invite) --- */
.code-display {
  align-self: flex-start; padding: var(--space-2) var(--space-4); border-radius: var(--radius-inner); background: var(--surface-2);
  font-size: var(--text-xl); font-weight: 800; letter-spacing: .12em; font-variant-numeric: tabular-nums; user-select: all;
}

/* --- statistics row, section title, danger zone, legal line --- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); margin: 0; }
.stat-row div { padding: var(--space-3) 14px; border-radius: var(--radius-inner); background: var(--surface-2); }
.stat-row dt { font-size: var(--text-sm); color: var(--muted); }
.stat-row dd { margin: 2px 0 0; font-size: var(--text-xl); font-weight: 800; font-variant-numeric: tabular-nums; }
.section-title { font-size: var(--text-lg); font-weight: var(--weight-strong); margin-bottom: calc(-1 * var(--space-2)); }
.danger-zone {
  display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-inner);
  border: 1.5px solid var(--danger);
}
.legal { font-size: var(--text-sm); text-align: center; color: var(--muted); }

/* --- badge list and badge card (badgeCard() in js/ui/badge.js): medal | name, description, meta (tier, date, progress,
   rarity); a grid of two columns on a wide card, one on a phone (.one-col always one).
   States: .earned, .secret (hidden, not earned yet), .negative, .unavailable, .just-earned (the summary); data-tier="1|2|3"
   on a held tier, data-next on the tier being worked towards (the colour of the progress bar).
   --m / --m-bg: the medal colour and its tint; --next: the progress bar --- */
.badge-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 272px), 1fr)); gap: var(--space-2);
}
.badge-list.one-col { grid-template-columns: minmax(0, 1fr); }
.badge-card {
  --m: var(--muted); --m-bg: transparent; --next: var(--highlight);
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-3); align-items: start;
  padding: var(--space-3); border-radius: var(--radius-inner); background: var(--surface-2); border: 1px solid transparent;
}
.badge-card.earned { --m: var(--highlight); --m-bg: var(--highlight-bg); }
.badge-card.earned[data-tier="1"] { --m: var(--medal-bronze); --m-bg: var(--medal-bronze-bg); }
.badge-card.earned[data-tier="2"] { --m: var(--medal-silver); --m-bg: var(--medal-silver-bg); }
.badge-card.earned[data-tier="3"] { --m: var(--medal-gold); --m-bg: var(--medal-gold-bg); }
.badge-card.earned.negative { --m: var(--medal-odd); --m-bg: var(--medal-odd-bg); }
.badge-card[data-next="1"] { --next: var(--medal-bronze); }
.badge-card[data-next="2"] { --next: var(--medal-silver); }
.badge-card[data-next="3"] { --next: var(--medal-gold); }
.badge-card.unavailable { background: transparent; border: 1px dashed var(--line-strong); }
.badge-medal {
  position: relative; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%;
  color: var(--m); background: var(--m-bg); border: 2px dashed var(--line-strong);
}
.badge-card.earned .badge-medal { border: 2px solid var(--m); box-shadow: 0 0 18px var(--m-bg); }
.badge-card:not(.earned) .badge-medal > * { opacity: .6; }
.badge-medal svg { width: 26px; height: 26px; overflow: visible; }
.badge-medal svg.shape { width: 32px; height: 32px; }                 /* a region's outline instead of an icon */
.badge-medal .secret-mark { font-family: var(--font-display); font-size: 24px; font-weight: var(--weight-display); line-height: 1; }
.badge-card.negative .badge-medal { border-radius: 30%; transform: rotate(-8deg); }   /* another shape, not only colour */
.badge-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.badge-name { font-weight: var(--weight-strong); line-height: 1.3; overflow-wrap: anywhere; }
.badge-name .tag { vertical-align: 2px; }
.badge-card.secret .badge-name { color: var(--muted); }
.badge-desc { font-size: var(--text-sm); line-height: 1.4; color: var(--muted); }
.badge-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); margin-top: var(--space-1);
  font-size: 12px; line-height: 1.35; color: var(--muted);
}
.badge-tier {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--radius-pill);
  background: var(--m-bg); color: var(--m); font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
}
.badge-flag {
  display: inline-block; margin-left: var(--space-2); padding: 0 7px; border-radius: var(--radius-pill); vertical-align: 1px;
  border: 1px solid var(--line-strong); color: var(--muted); font-size: 11px; font-weight: 700; line-height: 1.5; white-space: nowrap;
}
/* the way to the badge or its next tier: a thin bar and "12/30 dní"; a goal of two requirements as a line */
.badge-progress { flex: 1 1 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-2); }
.badge-progress-bar { display: block; height: 4px; border-radius: 2px; background: var(--tier-empty); overflow: hidden; }
.badge-progress-bar i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); border-radius: inherit; background: var(--next, var(--highlight)); }
.badge-progress b, .badge-goal b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.badge-goal { flex-basis: 100%; }
.badge-rarity { flex-basis: 100%; }   /* always the last line of the card */
/* earned in the game just finished (the summary): the medal pops in */
.badge-card.just-earned .badge-medal { animation: medal-pop .6s var(--ease-pop) both; }
.badge-card.just-earned:nth-child(2) .badge-medal { animation-delay: .15s; }
.badge-card.just-earned:nth-child(3) .badge-medal { animation-delay: .3s; }
.badge-card.just-earned.negative .badge-medal { animation-name: medal-pop-tilted; }
@keyframes medal-pop { from { transform: scale(.4); opacity: 0; } }
@keyframes medal-pop-tilted { from { transform: rotate(-8deg) scale(.4); opacity: 0; } }

/* --- streak panel (Moje hry): the current streak, the longest one, the freeze (.used: spent, pips = days to refill) --- */
.streak-panel {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-3) var(--space-4); align-items: center;
  padding: var(--space-4); border-radius: var(--radius-inner); background: var(--surface-2);
}
.streak-count {
  display: flex; align-items: center; gap: var(--space-1); color: var(--highlight);
  font-family: var(--font-display); font-size: var(--text-result); font-weight: var(--weight-display); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.streak-count::before {
  content: ''; width: .85em; height: .85em; background: currentColor;
  -webkit-mask: var(--icon-flame) center / contain no-repeat; mask: var(--icon-flame) center / contain no-repeat;
}
.streak-panel.off .streak-count { color: var(--muted); }
.streak-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.streak-info strong { font-size: var(--text-lg); }
.streak-info span { font-size: var(--text-sm); color: var(--muted); }
.freeze-state {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2);
  padding-top: var(--space-3); border-top: 1px solid var(--line); font-size: 14px; line-height: 1.4;
}
.freeze-state::before {
  content: ''; width: 18px; height: 18px; flex: none; background: var(--info);
  -webkit-mask: var(--icon-snow) center / contain no-repeat; mask: var(--icon-snow) center / contain no-repeat;
}
.freeze-state.used::before { background: var(--muted); }
.freeze-state strong { font-weight: var(--weight-strong); }
.freeze-state .muted { flex-basis: 100%; padding-left: calc(18px + var(--space-2)); font-size: var(--text-sm); }
.freeze-pips { display: inline-flex; gap: 3px; margin-left: auto; }
.freeze-pips i { width: 10px; height: 4px; border-radius: 2px; background: var(--tier-empty); }
.freeze-pips i.on { background: var(--info); }

/* --- map of knowledge (renderRegionMap() in js/ui/region-map.js): the regions by the tier of their badge, the legend
   and the picked region under it --- */
.region-map { display: block; width: 100%; height: auto; }
.region-map path {
  fill: var(--tier-empty); stroke: var(--surface); stroke-width: 1.4; stroke-linejoin: round;
  vector-effect: non-scaling-stroke; cursor: pointer;
}
.region-map path:focus { outline: none; }
.region-map path:focus-visible { stroke: var(--focus); stroke-width: 2.4; }
.region-map .sel-outline { fill: none; stroke: var(--ink); stroke-width: 2.4; pointer-events: none; }
.region-map .t3 { fill: var(--medal-gold); }
.region-map .t2 { fill: var(--medal-silver); }
.region-map .t1 { fill: var(--medal-bronze); }
.region-map .t0 { fill: var(--tier-bad); }
.region-map .empty { fill: var(--tier-empty); }
.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); font-size: var(--text-sm); color: var(--muted); }
.map-legend .swatch { display: inline-flex; align-items: center; gap: 6px; }
.map-legend .swatch::before { content: ''; width: 14px; height: 14px; border-radius: 4px; background: var(--sw); }
.map-caption {
  min-height: 44px; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-inner); background: var(--surface-2); font-size: 14px;
}
.map-caption .pill { padding: 4px 9px; font-size: 13px; }
.map-caption-detail { flex-basis: 100%; font-size: var(--text-sm); color: var(--muted); }

/* --- tool group: stacked icon buttons over the map (zoom) --- */
.tool-group {
  display: flex; flex-direction: column; overflow: hidden; border-radius: var(--radius-control);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.tool-group button {
  width: var(--tool-size); height: var(--tool-size); border: 0; padding: 0; background: none; cursor: pointer;
  display: grid; place-items: center; font-size: 24px; font-weight: 600; line-height: 1;
}
.tool-group button:hover { background: var(--surface-hover); }
.tool-group button + button { border-top: 1px solid var(--line); }

/* --- corner-bar › corner-btn: floating buttons over the map ("Napiš nám", "Podpoř nás"; placed in layout.css);
   a pill with the icon (.icon-chat / .icon-heart) and the label, on phones the icon alone --- */
.corner-bar { display: flex; gap: var(--space-2); }
.corner-bar[hidden] { display: none; }
.corner-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 var(--space-3) 0 10px;
  border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-card); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  font: inherit; font-size: var(--text-sm); font-weight: 600; line-height: 1; cursor: pointer;
}
.corner-btn::before {
  content: ''; flex: none; width: 16px; height: 16px; background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.corner-btn.icon-chat { --icon: var(--icon-chat); }
.corner-btn.icon-heart { --icon: var(--icon-heart); }
.corner-btn:hover { background: var(--surface-hover); }
.corner-btn[hidden] { display: none; }
@media (max-width: 640px) {
  .corner-btn { justify-content: center; width: 40px; height: 40px; padding: 0; }
  .corner-btn::before { width: 18px; height: 18px; }
  .corner-btn-label { display: none; }   /* the button's aria-label still names it */
}

/* --- loader: indeterminate bar above a status text --- */
.loader { display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--text-sm); color: var(--muted); }
.loader::before {
  content: ''; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent) 0 0 / 40% 100% no-repeat, var(--surface-2);
  animation: loader 1.4s ease-in-out infinite;
}
.loader.error { color: var(--danger); }
.loader.error::before { display: none; }
@keyframes loader { from { background-position: -40% 0, 0 0; } to { background-position: 140% 0, 0 0; } }

/* --- toast --- */
#toast {   /* centred by the margins, so a long message may take the whole width between the gutters */
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: calc(var(--dock-gap) + env(safe-area-inset-bottom)); z-index: var(--z-toast);
  width: fit-content; margin-inline: auto; transform: translateY(10px);
  padding: 11px 18px; border-radius: var(--radius-pill); background: var(--toast-bg); color: var(--toast-ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  font-size: 14px; font-weight: 600; text-align: center; opacity: 0; pointer-events: none;
  transition: opacity var(--dur), transform var(--dur);
}
#toast.show { opacity: 1; transform: none; }

/* --- dialog: a card in a modal <dialog class="sheet dialog"> (showModal), closed by Escape, the backdrop or a
   <form method="dialog"> button; on phones at the bottom edge like the screen cards --- */
.dialog {
  max-height: calc(100% - 2 * var(--gutter)); margin: auto; overflow-y: auto; overscroll-behavior: contain;
  animation: rise var(--dur-enter) var(--ease-out) both;
}
.dialog h2 { font-size: var(--text-heading); font-weight: var(--weight-display); line-height: var(--leading-tight); letter-spacing: var(--tracking-tight); }
.dialog h2[tabindex="-1"]:focus { outline: none; }   /* the title takes the opening focus, so a long dialog opens at its top */
.dialog:not([open]) { display: none; }   /* .sheet's display would win over the browser's hiding */
.dialog::backdrop { background: var(--backdrop); }
.dialog form { display: contents; }

/* icons for masks (currentColor shapes) */
:root {
  --icon-star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.5l2.9 6 6.6.9-4.8 4.6 1.2 6.5L12 17.3l-5.9 3.2 1.2-6.5L2.5 9.4l6.6-.9z'/%3E%3C/svg%3E");
  --icon-pin: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 22s-7-6.6-7-12a7 7 0 0 1 14 0c0 5.4-7 12-7 12zm0-9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z'/%3E%3C/svg%3E");
  --icon-dot: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='6'/%3E%3C/svg%3E");
  --icon-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 15h-2v-6h2zm0-8h-2V7h2z'/%3E%3C/svg%3E");
  --icon-cloud: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 19h10a5 5 0 0 0 .7-9.95A7 7 0 0 0 4.3 10.6 4.5 4.5 0 0 0 7 19z'/%3E%3C/svg%3E");
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm-1.5 14.5L6 12l1.4-1.4 3.1 3.1 6.1-6.1L18 9z'/%3E%3C/svg%3E");
  --icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 1 21h22zm1 15h-2v-2h2zm0-4h-2V9h2z'/%3E%3C/svg%3E");
  --icon-chat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 3h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-9l-5 4v-4H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zm3 5v2h10V8zm0 4v2h7v-2z' fill-rule='evenodd'/%3E%3C/svg%3E");
  --icon-heart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54z'/%3E%3C/svg%3E");
  --icon-help: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 17h-2v-2h2zm2.1-7.7-.9.9c-.7.7-1.2 1.3-1.2 2.8h-2v-.5c0-1.1.5-2.1 1.2-2.8l1.2-1.3A2 2 0 1 0 10 9H8a4 4 0 1 1 7.1 2.3z'/%3E%3C/svg%3E");
  --icon-flame: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 22a7 7 0 0 1-7-7c0-3.3 2-5.6 3.7-7.4.3 1.7 1.1 3 2.3 3.6C10.6 7.4 11.5 4.4 13.5 2c.6 3.3 3 5.4 4.3 7.6.8 1.4 1.2 3 1.2 5.4a7 7 0 0 1-7 7z'/%3E%3C/svg%3E");
  --icon-snow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 12L12 2M14.3 7.8L12 5.5L9.7 7.8M12 12L20.7 7M16.8 11.8L17.6 8.8L14.5 7.9M12 12L20.7 17M14.5 16.1L17.6 15.3L16.8 12.2M12 12L12 22M9.7 16.2L12 18.5L14.3 16.2M12 12L3.3 17M7.2 12.2L6.4 15.3L9.5 16.1M12 12L3.3 7M9.5 7.9L6.4 8.8L7.2 11.8'/%3E%3C/svg%3E");
}

@media (max-width: 640px), (orientation: landscape) and (max-height: 500px) {
  .sheet { --pad-y: var(--space-5); --pad-x: 18px; gap: 14px; }
  #toast { border-radius: var(--radius-control); }   /* a message of two or three lines is no pill */
  .stat-row dd { font-size: 19px; }
  .versus li { grid-template-columns: minmax(0, 1fr) 72px 72px; }
  .badge-medal { width: 46px; height: 46px; }
  .badge-medal svg { width: 23px; height: 23px; }
  .badge-medal svg.shape { width: 28px; height: 28px; }
  .dialog { width: auto; max-width: none; margin: auto var(--gutter) calc(var(--gutter) + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .btn:hover { transition: none; transform: none; }
  .loader::before { animation: none; background: var(--surface-2); }
  .badge-card.just-earned .badge-medal { animation: none; }
  .dialog { animation: none; }
}
