/* BowClash leaderboard. Dark only: the game's own night navy, steel blue and gold
   (scripts/look.gd), its fonts (Barlow Condensed, Russo One for the mark) and its slanted
   "blade" shapes. No rounded corners anywhere; slants instead. */

@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap;
  src: url("/fonts/BarlowCondensed-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap;
  src: url("/fonts/BarlowCondensed-Bold.woff2") format("woff2"); }
@font-face { font-family: "Russo One"; font-weight: 400; font-display: swap;
  src: url("/fonts/RussoOne-Regular.woff2") format("woff2"); }

:root {
  color-scheme: dark;
  --bg: #0b1522;
  --bg-deep: #08101a;
  --panel: #111f31;
  --panel-hi: #16283e;
  --line: rgba(246, 244, 239, 0.08);
  --line-hi: rgba(246, 244, 239, 0.16);
  --text: #f6f4ef;
  --muted: rgba(246, 244, 239, 0.64);
  --faint: rgba(246, 244, 239, 0.56);
  --gold: #ffd84a;
  --steel: #1d5a8c;
  --steel-hi: #2a73ad;
  --slant: 14px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(16px, 4vw, 48px);
  --max: 1240px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 600 18px/1.4 "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* --- Top bar ------------------------------------------------------------------------- */

.bar {
  position: absolute; inset: 0 0 auto 0; z-index: 2;
  padding: max(18px, env(safe-area-inset-top)) var(--gutter) 0;
  max-width: var(--max); margin: 0 auto;
}
.brand img { width: clamp(150px, 16vw, 210px); height: auto; }

/* --- Hero ---------------------------------------------------------------------------- */

.hero {
  position: relative;
  isolation: isolate;
  min-height: min(720px, 86dvh);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
/* A rooftop duel from the game: the archer on the left aims across at the title. */
.hero-art {
  position: absolute; inset: 0; z-index: -1;
  background: url("/hero.webp") 30% 62% / cover no-repeat;
}
/* The render fades into the page: under the title on the right, and at the bottom. */
.hero-art::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(270deg, rgba(11, 21, 34, 0.92) 0%, rgba(11, 21, 34, 0.7) 34%, rgba(11, 21, 34, 0) 62%),
    linear-gradient(0deg, var(--bg) 0%, rgba(11, 21, 34, 0) 34%),
    linear-gradient(180deg, rgba(11, 21, 34, 0.6) 0%, rgba(11, 21, 34, 0) 20%);
}
.hero-copy {
  width: 100%; max-width: var(--max); margin: 0 auto;
  padding: 120px var(--gutter) 64px;
}
.hero-inner { margin-left: auto; width: min(600px, 48%); }
.hero h1 {
  margin: 0;
  font: 400 clamp(46px, 6.1vw, 92px)/0.92 "Russo One", "Barlow Condensed", sans-serif;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 24px rgba(8, 16, 26, 0.6);
}
.lede {
  margin: 18px 0 0; max-width: 30ch;
  font-size: clamp(20px, 2vw, 24px); color: var(--muted);
}
.totals {
  display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 36px 0 0;
}
.totals div { min-width: 64px; }
/* Live now: a green dot that fades out and back in, like an "on air" light. */
.totals .live-dot {
  display: inline-block; width: 10px; height: 10px; margin: 0 7px 1px 0; border-radius: 50%;
  background: #3ddc6b; box-shadow: 0 0 8px rgba(61, 220, 107, 0.8); vertical-align: middle;
  animation: live 1.8s ease-in-out infinite;
}
@keyframes live {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(61, 220, 107, 0.8); }
  50% { opacity: 0.15; box-shadow: 0 0 0 rgba(61, 220, 107, 0); }
}
@media (prefers-reduced-motion: reduce) { .totals .live-dot { animation: none; } }
.totals dt {
  font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint);
}
.totals dd {
  margin: 2px 0 0; font: 700 clamp(30px, 3.4vw, 40px)/1 "Barlow Condensed", sans-serif; color: var(--text);
  min-height: 1em;
}

/* --- Podium -------------------------------------------------------------------------- */

.podium {
  max-width: var(--max); margin: 0 auto; padding: 8px var(--gutter) 0;
  display: grid; grid-template-columns: 1fr 1.14fr 1fr; gap: 18px; align-items: end;
}
.podium:empty { display: none; }
.place {
  position: relative; display: block; isolation: isolate;
  padding: 26px 30px 24px calc(30px + var(--slant));
  background:
    radial-gradient(60% 90% at 88% 70%, color-mix(in srgb, var(--cc, #1d5a8c) 45%, transparent), transparent 70%),
    linear-gradient(160deg, var(--panel-hi), var(--panel) 60%);
  clip-path: polygon(var(--slant) 0, 100% 0, calc(100% - var(--slant)) 100%, 0 100%);
  min-width: 0; color: inherit; text-decoration: none;
  transition: filter 0.2s var(--ease);
}
.place:hover { filter: brightness(1.12); }
/* The player's character, standing at the right of their card. */
.place .figure {
  position: absolute; z-index: -1; right: -12%; bottom: -30%; height: 118%; width: auto;
  opacity: 0.42; pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, #000 50%, transparent 90%);
  mask-image: linear-gradient(180deg, #000 50%, transparent 90%);
  transition: opacity 0.25s var(--ease);
}
.place:hover .figure { opacity: 0.6; }
.place::before {
  /* The steel edge of a blade button. */
  content: ""; position: absolute; inset: 0 auto 0 0; width: calc(var(--slant) + 4px);
  background: var(--steel);
  clip-path: polygon(var(--slant) 0, calc(var(--slant) + 4px) 0, 4px 100%, 0 100%);
}
.place.p1 { padding-top: 38px; padding-bottom: 34px; }
.place.p1::before { background: var(--gold); }
.place .pos {
  font: 400 34px/1 "Russo One", sans-serif; color: var(--faint);
}
.place.p1 .pos { color: var(--gold); font-size: 44px; }
.place .who { display: flex; align-items: center; gap: 12px; margin-top: 16px; min-width: 0; }
.place .name {
  font: 700 clamp(26px, 2.6vw, 34px)/1 "Barlow Condensed", sans-serif;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.place .rank-name { color: var(--muted); font-size: 16px; margin-top: 4px; }
.place .elo {
  margin-top: 20px; font: 700 clamp(44px, 4.6vw, 60px)/0.9 "Barlow Condensed", sans-serif;
}
.place.p1 .elo { color: var(--gold); }
.place .elo small { font-size: 16px; color: var(--faint); letter-spacing: 0.08em; margin-left: 6px; }
.place .record { margin-top: 12px; color: var(--muted); font-size: 17px; }
.place .record b { color: var(--text); font-weight: 700; }

/* --- Rank badge (the game's level ring: Look.draw_rank) ----------------------------- */

.badge {
  --ring: #3fe05a;
  flex: none; display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: #121417; border: 4px solid var(--ring);
  box-shadow: inset 0 0 0 1px rgba(246, 244, 239, 0.12);
  font: 700 16px/1 "Barlow Condensed", sans-serif; color: var(--text);
}
.badge.top { color: var(--gold); box-shadow: inset 0 0 0 1px rgba(255, 216, 74, 0.4); }
.place .badge { width: 42px; height: 42px; font-size: 20px; border-width: 5px; }

/* --- Board --------------------------------------------------------------------------- */

.board { max-width: var(--max); margin: 0 auto; padding: 72px var(--gutter) 40px; }
.board-head {
  display: flex; align-items: end; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.board h2 { margin: 0; font: 700 36px/1 "Barlow Condensed", sans-serif; }
.search input {
  width: min(320px, 78vw); height: 46px;
  padding: 0 22px 0 calc(16px + var(--slant));
  background: var(--panel); border: 0; color: var(--text);
  clip-path: polygon(var(--slant) 0, 100% 0, calc(100% - var(--slant)) 100%, 0 100%);
  font-size: 19px;
  transition: background 0.2s var(--ease);
}
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; background: var(--panel-hi); box-shadow: inset 0 -2px 0 var(--gold); }
.search input::-webkit-search-cancel-button { filter: invert(1) opacity(0.5); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg); text-align: right; white-space: nowrap;
  border-bottom: 1px solid var(--line-hi);
  padding: 0;
}
thead th.c-name, thead th.c-pos { text-align: left; }
thead button {
  all: unset; cursor: pointer; display: block; width: 100%; box-sizing: border-box;
  padding: 12px 14px; color: var(--faint);
  font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase;
  transition: color 0.15s;
}
thead button:hover { color: var(--text); }
thead button:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
th[aria-sort] button { color: var(--gold); }
th[aria-sort] button::after {
  content: ""; display: inline-block; margin-left: 6px; vertical-align: 2px;
  border: 5px solid transparent; border-top-color: currentColor; border-bottom-width: 0;
}
th[aria-sort="ascending"] button::after { transform: rotate(180deg); }

tbody td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
/* Each row carries its rank's colour (the badge ring's, Look.LEVEL_COLORS): an edge on the left
   and a wash that fades out across the row, stronger on hover. */
tbody tr {
  --rc: transparent;
  background: linear-gradient(90deg, color-mix(in srgb, var(--rc) 22%, transparent), color-mix(in srgb, var(--rc) 6%, transparent) 55%, transparent);
  transition: background-color 0.15s;
}
tbody tr:hover { background-color: rgba(246, 244, 239, 0.04); }
tbody tr td:first-child { box-shadow: inset 4px 0 0 var(--rc); padding-left: 18px; }
tbody tr td .rank-name { color: color-mix(in srgb, var(--rc) 60%, var(--text)); }
tr.skel td:first-child { box-shadow: none; }
td.c-pos { text-align: left; width: 56px; color: var(--faint); font-weight: 700; }
td.c-name { text-align: left; }
td.c-name .cell { display: flex; align-items: center; gap: 12px; }
td.c-name .name { font-weight: 700; font-size: 21px; color: inherit; text-decoration: none; }
td.c-name .name:hover { color: var(--gold); }
tbody tr[data-href] { cursor: pointer; }
td.c-name .rank-name { display: block; color: var(--faint); font-size: 15px; line-height: 1.1; }
td.c-elo { font-weight: 700; font-size: 22px; }
td.c-date { color: var(--muted); }
td .none { color: var(--faint); }
tbody tr.t1 td.c-pos, tbody tr.t1 td.c-elo { color: var(--gold); }

/* Loading rows: the table's own shape, gently pulsing. */
tr.skel td { height: 63px; }
tr.skel td span {
  display: inline-block; height: 14px; width: 100%; max-width: 64px; background: var(--panel);
}
tr.skel td.c-name span { max-width: 180px; }
@media (prefers-reduced-motion: no-preference) {
  tr.skel td span { animation: pulse 1.4s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: 0.45; } }

.status { margin: 28px 0 0; color: var(--muted); font-size: 20px; }
.status:empty { display: none; }
.status button {
  margin-left: 12px; padding: 8px 24px; border: 0; cursor: pointer;
  background: var(--steel); color: var(--text); font-weight: 700; letter-spacing: 0.04em;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}
.status button:hover { background: var(--steel-hi); }
.status button:active { transform: translateY(1px); }
.note { margin: 22px 0 0; color: var(--faint); font-size: 16px; max-width: 70ch; }

/* --- Shared pieces: character heads, rating deltas, the back link -------------------- */

.head {
  --cc: #1d5a8c;
  flex: none; display: inline-block; width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 50% 70%, color-mix(in srgb, var(--cc) 75%, #f6f4ef 10%), #0f1b2b 72%);
  box-shadow: inset 0 0 0 1px rgba(246, 244, 239, 0.1);
}
.head img { width: 100%; height: 100%; object-fit: cover; }
.head.sm { width: 38px; height: 38px; }
.delta { font-weight: 700; color: var(--muted); }
.delta.up { color: var(--gold); }
.delta.down { color: #e98a80; }
.back {
  display: inline-flex; align-items: center; gap: 8px; color: var(--muted); text-decoration: none;
  font-size: 17px; letter-spacing: 0.04em;
}
.back:hover { color: var(--text); }
.ico { width: 1em; height: 1em; flex: none; }
.none { color: var(--faint); }
.status a { color: var(--gold); }

/* Inner pages: the bar sits on the page rather than over a hero. */
body.sub .bar { position: static; width: 100%; padding-bottom: 8px; }

/* --- Player page --------------------------------------------------------------------- */

.profile {
  --cc: #1d5a8c; --rc: transparent;
  max-width: var(--max); margin: 0 auto; padding: 8px var(--gutter) 0;
  display: grid; grid-template-columns: minmax(220px, 380px) 1fr; gap: 24px 56px; align-items: end;
}
.portrait {
  position: relative; aspect-ratio: 3 / 4.4; display: flex; align-items: flex-end; justify-content: center;
  background:
    radial-gradient(50% 42% at 50% 62%, color-mix(in srgb, var(--cc) 70%, transparent), transparent 75%),
    radial-gradient(46% 7% at 50% 96%, rgba(0, 0, 0, 0.55), transparent 80%);
}
.portrait img { height: 96%; width: 100%; object-fit: contain; object-position: 50% 100%; position: relative; }
.profile-copy { padding-bottom: 28px; min-width: 0; }
.profile h1 {
  margin: 18px 0 0; font: 400 clamp(44px, 6vw, 80px)/0.95 "Russo One", sans-serif;
  overflow-wrap: anywhere;
}
.rank-line { display: flex; align-items: center; gap: 12px; margin: 16px 0 0; font-size: 22px; font-weight: 700; }
.rank-line .badge { width: 40px; height: 40px; font-size: 19px; border-width: 5px; }
.rank-line .char { color: var(--muted); font-weight: 600; font-size: 19px; }
.rating { margin-top: 18px; font: 700 clamp(56px, 6vw, 76px)/0.9 "Barlow Condensed", sans-serif; color: var(--gold); }
.rating small { font-size: 16px; color: var(--faint); letter-spacing: 0.08em; margin-left: 8px; }
.tiles {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; margin: 28px 0 0;
}
.tiles div { background: var(--panel); padding: 14px 16px; }
.tiles div:first-child { clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%); padding-left: 22px; }
.tiles div:last-child { clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 0 100%); }
.tiles dt { font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.tiles dd { margin: 4px 0 0; font-size: 30px; font-weight: 700; line-height: 1; }
.meta { margin: 18px 0 0; color: var(--muted); font-size: 18px; }
.meta .sep {
  display: inline-block; width: 4px; height: 4px; margin: 0 12px; vertical-align: middle;
  background: var(--faint); transform: rotate(45deg);
}

.history { max-width: var(--max); margin: 0 auto; padding: 56px var(--gutter) 40px; }
.history h2, .rounds-wrap h2, .log-wrap h2 { margin: 0 0 18px; font: 700 36px/1 "Barlow Condensed", sans-serif; }
.duels { list-style: none; margin: 0; padding: 0; }
.duel {
  display: grid; align-items: center; gap: 0 20px;
  grid-template-columns: 76px 74px minmax(0, 1.6fr) minmax(0, 1.2fr) 56px 112px 20px;
  padding: 12px 8px 12px 0; border-bottom: 1px solid var(--line);
}
.duel.open { cursor: pointer; transition: background 0.15s; }
.duel.open:hover { background: rgba(29, 90, 140, 0.14); }
.duel.skel { height: 63px; background: linear-gradient(90deg, var(--panel), transparent); opacity: 0.6; }
.result {
  display: inline-grid; place-items: center; height: 32px; font-weight: 700; letter-spacing: 0.06em; font-size: 17px;
  clip-path: polygon(9px 0, 100% 0, calc(100% - 9px) 100%, 0 100%);
}
.result.win { background: var(--gold); color: #1a1405; }
.result.loss { background: var(--steel); color: var(--text); }
.score { font-size: 26px; font-weight: 700; text-align: center; }
.score i, .big-score i, .hp-n i { font-style: normal; color: var(--faint); margin: 0 4px; }
.opp { display: flex; align-items: center; gap: 12px; min-width: 0; }
.opp > span:last-child { min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.vs { color: var(--faint); font-size: 16px; }
.opp-name {
  font-weight: 700; font-size: 21px; color: var(--text); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.opp-name:hover { color: var(--gold); }
.opp-elo { color: var(--faint); font-size: 16px; }
.ended { color: var(--muted); }
.duel .delta { text-align: right; font-size: 20px; }
.duel time { color: var(--muted); text-align: right; white-space: nowrap; }
.go { color: var(--faint); display: grid; place-items: center; }

/* --- Match page ---------------------------------------------------------------------- */

.duel-head {
  max-width: var(--max); margin: 0 auto; padding: 8px var(--gutter) 0;
  display: grid; grid-template-columns: 1fr minmax(240px, auto) 1fr; align-items: end; gap: 16px;
}
.side { display: flex; align-items: flex-end; gap: 4px; min-width: 0; }
.side.s1 { flex-direction: row-reverse; text-align: right; }
.fig {
  flex: none; width: clamp(150px, 19vw, 280px); aspect-ratio: 3 / 4;
  display: flex; align-items: flex-end; justify-content: center;
  background: radial-gradient(50% 40% at 50% 60%, color-mix(in srgb, var(--cc) 65%, transparent), transparent 75%);
}
/* The renders are about 3:4; never squeezed to the box. */
.fig img { width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%; }
/* The right-hand archer turned round, so the two face each other as in the game. */
.side.s1 .fig img { transform: scaleX(-1); }
.side-copy { padding-bottom: 28px; min-width: 0; }
.won-tag {
  display: inline-block; padding: 3px 14px; margin-bottom: 8px; background: var(--gold); color: #1a1405;
  font-weight: 700; letter-spacing: 0.08em; font-size: 14px;
  clip-path: polygon(7px 0, 100% 0, calc(100% - 7px) 100%, 0 100%);
}
.side-copy .won-tag { display: table; }
.side.s1 .side-copy .won-tag { margin-left: auto; }
.side-name {
  font: 700 clamp(28px, 3vw, 40px)/1 "Barlow Condensed", sans-serif; overflow-wrap: anywhere;
  box-shadow: inset 0 -3px 0 var(--sc); display: inline-block; padding-bottom: 4px;
}
.side-name a { color: inherit; text-decoration: none; }
.side-name a:hover { color: var(--gold); }
.side-elo { margin-top: 10px; font-size: 22px; font-weight: 700; display: flex; gap: 10px; align-items: baseline; }
.side.s1 .side-elo { justify-content: flex-end; }
.side-elo .delta { font-size: 18px; }
.middle { text-align: center; padding-bottom: 28px; }
.big-score { margin-top: 18px; font: 400 clamp(64px, 8vw, 112px)/1 "Russo One", sans-serif; color: var(--muted); }
.big-score .lead { color: var(--gold); }
.how { margin: 10px 0 0; font-size: 22px; font-weight: 700; }
.when { margin: 6px 0 0; color: var(--muted); }

.rounds-wrap, .log-wrap { max-width: var(--max); margin: 0 auto; padding: 48px var(--gutter) 0; }
.log-wrap { padding-bottom: 40px; }
.rounds {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px;
}
.round {
  position: relative; display: grid; gap: 6px; padding: 16px 20px 16px 24px;
  background: linear-gradient(160deg, var(--panel-hi), var(--panel) 70%);
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}
.round::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 14px; background: var(--sc);
  clip-path: polygon(10px 0, 14px 0, 4px 100%, 0 100%);
}
.r-n { font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.r-who { font-size: 24px; font-weight: 700; }
.r-kill { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 18px; }
.r-kill .ico { width: 22px; height: 22px; }
.round.gold .r-kill { color: var(--gold); }
.r-arrows { color: var(--muted); font-size: 16px; }

.log-round { margin-top: 28px; }
.log-round h3 { margin: 0 0 8px; font-size: 22px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.log-round h3 .lr-head { color: var(--muted); font-size: 18px; font-weight: 600; }
table.log { min-width: 0; width: 100%; table-layout: fixed; }
table.log th:nth-child(1) { width: 20%; } table.log th:nth-child(2) { width: 27%; }
table.log th:nth-child(3) { width: 10%; }
table.log th {
  text-align: left; font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint);
  padding: 8px 12px; border-bottom: 1px solid var(--line-hi); font-weight: 600; position: static; background: none;
}
table.log td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.log tbody tr { background: none; }
.l-who { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; max-width: 100%; }
.l-who .arrow-tag, .l-who .side-dot { flex: none; }
.side-dot { width: 10px; height: 10px; background: var(--sc); transform: rotate(45deg); flex: none; }
.l-what { display: inline-flex; align-items: center; gap: 8px; }
tr.z-miss .l-what, tr.z-ground .l-what, tr.z-timeout .l-what { color: var(--muted); }
tr.z-head .l-what { font-weight: 700; }
.kill-tag {
  margin-left: 6px; padding: 1px 10px; background: var(--gold); color: #1a1405;
  font-size: 13px; font-weight: 700; letter-spacing: 0.08em;
  clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
}
.l-dmg { font-weight: 700; font-size: 20px; width: 90px; }
.hp {
  display: inline-block; width: calc(50% - 46px); max-width: 220px; height: 8px; margin-right: 8px;
  background: rgba(246, 244, 239, 0.08); vertical-align: middle;
}
.hp span { display: block; height: 100%; background: var(--sc); }
.hp-n { color: var(--muted); font-size: 16px; }

/* --- Gold on the match page ------------------------------------------------------- */

.coin-amt { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: var(--gold); white-space: nowrap; }
.coin-amt.neg { color: #e98a80; }
.coin {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none;
  background: var(--gold); box-shadow: inset 0 0 0 2px #b88a10;
}
.item-ico { width: 20px; height: 20px; display: block; }
.r-gold { display: grid; gap: 4px; margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.r-side { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.r-side .side-dot { background: var(--sc); }
.r-item { color: var(--text); display: inline-flex; }
.r-item.shield, .r-item.armor { color: #73d9ff; }
.r-pay { display: inline-flex; gap: 14px; margin-left: auto; font-size: 17px; }
.r-pay > span { display: inline-flex; align-items: center; gap: 6px; }
.r-pay .side-dot { background: var(--sc); }

.gold-wrap { max-width: var(--max); margin: 0 auto; padding: 48px var(--gutter) 0; }
.gold-legend { display: flex; flex-wrap: wrap; gap: 10px 36px; margin-bottom: 10px; }
.gl-side { display: flex; align-items: center; gap: 10px; font-size: 18px; color: var(--muted); }
.gl-side b { color: var(--text); font-size: 20px; }
.gl-side .side-dot { background: var(--sc); }
.gold-chart { width: 100%; max-width: 760px; height: auto; display: block; }
.gold-chart .grid { stroke: var(--line); stroke-width: 1; }
.gold-chart .axis { fill: var(--faint); font: 600 13px "Barlow Condensed", sans-serif; }

.l-hits { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.l-what.muted { color: var(--muted); }
.l-what .dmg { margin-left: 6px; font-size: 18px; }
.arrow-tag { display: inline-flex; margin-left: 6px; color: var(--gold); }
.block-tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 10px 1px 6px; color: #06222e;
  background: #73d9ff; font-size: 13px; font-weight: 700; letter-spacing: 0.08em;
  clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
}
.block-tag .item-ico { width: 16px; height: 16px; }
/* A heavy arrow broke through the shield: gold, like the arrow. */
.block-tag.pierced { background: #ffc94a; color: #2a1d00; }
.l-paid { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.l-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.paid-shield { display: inline-flex; align-items: center; gap: 4px; color: #73d9ff; }
table.log.econ th:nth-child(1) { width: 18%; } table.log.econ th:nth-child(2) { width: 38%; }
table.log.econ th:nth-child(3) { width: 14%; }

/* --- Footer -------------------------------------------------------------------------- */

.foot {
  display: flex; align-items: center; gap: 12px;
  max-width: var(--max); width: 100%; margin: 0 auto;
  padding: 28px var(--gutter) max(28px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); color: var(--faint); font-size: 16px;
}

/* --- Entrances ----------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .hero-inner > * { animation: rise 0.8s var(--ease) both; }
  .hero-inner > :nth-child(2) { animation-delay: 0.08s; }
  .hero-inner > :nth-child(3) { animation-delay: 0.16s; }
  .hero-art { animation: settle 1.6s var(--ease) both; }
  .place { animation: rise 0.7s var(--ease) both; }
  .place.p1 { animation-delay: 0.05s; }
  .place.p2 { animation-delay: 0.14s; }
  .place.p3 { animation-delay: 0.22s; }
  tbody tr.in { animation: fade 0.5s var(--ease) both; animation-delay: calc(min(var(--i), 20) * 22ms); }
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes settle { from { opacity: 0; transform: scale(1.04); } }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

/* --- Narrow screens ------------------------------------------------------------------ */

@media (max-width: 960px) {
  .duel {
    grid-template-columns: 70px 64px minmax(0, 1fr) 50px 20px;
    grid-template-areas: "r s o d g" "r s e t g"; gap: 2px 14px;
  }
  .duel .result { grid-area: r; } .duel .score { grid-area: s; } .duel .opp { grid-area: o; }
  .duel .ended { grid-area: e; font-size: 16px; padding-left: 50px; } .duel .delta { grid-area: d; }
  .duel time { grid-area: t; font-size: 15px; } .duel .go { grid-area: g; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tiles div:first-child, .tiles div:last-child { clip-path: none; padding-left: 16px; }
}

@media (max-width: 860px) {
  .podium { grid-template-columns: 1fr; gap: 12px; }
  .place .figure { height: 150%; bottom: -60%; right: 18%; opacity: 0.32; }
  .place.p1 { order: -1; }
  .place, .place.p1 { padding: 18px 22px 18px calc(22px + var(--slant)); }
  .place { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0 14px; }
  .place .pos, .place.p1 .pos { font-size: 28px; }
  .place .who { margin-top: 0; }
  .place .elo { margin-top: 0; font-size: 36px; text-align: right; }
  .place .elo small { display: block; margin: 2px 0 0; font-size: 13px; }
  .place .record { grid-column: 2 / 4; margin-top: 8px; font-size: 16px; }
  .place .name { font-size: 26px; }
}

@media (max-width: 760px) {
  .profile { grid-template-columns: 1fr; gap: 0; }
  .portrait { aspect-ratio: auto; height: 300px; order: -1; }
  .profile-copy { padding-bottom: 0; }
  .profile h1 { margin-top: 12px; }
  .duel { grid-template-columns: 62px 56px minmax(0, 1fr) 20px; grid-template-areas: "r s o g" "r s e g" "r s t g"; }
  .duel .delta { display: none; } .duel .ended { padding-left: 0; } .duel time { text-align: left; }
  .duel .opp .head { display: none; }
  .hero { min-height: 0; display: block; }
  .hero-art { position: relative; inset: auto; width: 100%; aspect-ratio: 4 / 3; background-position: 34% 60%; }
  .hero-inner { width: auto; margin: 0; }
  .hero-art::after {
    background:
      linear-gradient(0deg, var(--bg) 0%, rgba(11, 21, 34, 0) 45%),
      linear-gradient(180deg, rgba(11, 21, 34, 0.7) 0%, rgba(11, 21, 34, 0) 30%);
  }
  .hero-copy { padding: 0 var(--gutter) 32px; margin-top: -56px; position: relative; }
  .totals { gap: 10px 24px; margin-top: 26px; }
  .board { padding-top: 48px; }
  .search, .search input { width: 100%; }
  .board-head { display: block; }
  .board h2 { margin-bottom: 16px; }

  /* Each archer becomes a compact block: place, badge, name and rating on top, the stats
     in a row of labelled figures below. */
  .table-wrap { overflow: visible; }
  #table, #table tbody { display: block; min-width: 0; }
  #table thead { display: none; }
  #table tbody tr {
    display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; grid-template-areas:
      "pos name elo" "stats stats stats";
    align-items: center; padding: 14px 12px 14px 0; border-bottom: 1px solid var(--line);
    box-shadow: inset 4px 0 0 var(--rc);
  }
  #table tbody tr td:first-child { box-shadow: none; padding-left: 16px; }
  #table tbody td { border: 0; padding: 0; }
  #table td.c-pos { grid-area: pos; width: auto; }
  #table td.c-name { grid-area: name; min-width: 0; }
  #table td.c-name .cell > div { min-width: 0; }
  #table td.c-name .name { display: block; overflow: hidden; text-overflow: ellipsis; }
  #table td.c-elo { grid-area: elo; font-size: 24px; }
  #table tbody tr .stat { display: none; }
  #table tbody tr .stats {
    grid-area: stats; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 8px;
    margin: 12px 0 0 56px; text-align: left;
  }
  #table .stats span { display: block; font-size: 13px; color: var(--faint); letter-spacing: 0.06em; text-transform: uppercase; }
  #table .stats b { font-size: 19px; font-weight: 700; }
  #table tr.skel { grid-template-areas: "pos name elo"; }
  #table tr.skel td { height: 36px; }
  #table tr.skel td:not(.c-pos):not(.c-name):not(.c-elo) { display: none; }
}
@media (min-width: 761px) {
  tbody tr .stats { display: none; }
}

/* --- Match page on a phone ----------------------------------------------------------
   The score on top, the two archers side by side under it, rounds as full-width cards,
   and each shot as a small card (who, gold; the arrows; both health bars) instead of a
   four-column table. */

@media (max-width: 760px) {
  .duel-head { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
  .middle { grid-column: 1 / 3; grid-row: 1; padding-bottom: 4px; }
  .big-score { margin-top: 10px; font-size: 72px; }
  .how { font-size: 20px; }
  .when { font-size: 16px; }
  .side, .side.s1 { flex-direction: column; align-items: stretch; gap: 0; }
  .fig { width: min(100%, 150px); }
  .side.s1 .fig { margin-left: auto; }
  .side-copy { padding-bottom: 4px; width: 100%; }
  .side-name {
    display: block; font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    overflow-wrap: normal;
  }
  .side-elo { margin-top: 6px; font-size: 19px; }
  .side-elo .delta { font-size: 16px; }
  .won-tag { font-size: 12px; padding: 2px 10px; margin-bottom: 6px; }

  .rounds-wrap, .gold-wrap, .log-wrap { padding-top: 36px; }
  .history h2, .rounds-wrap h2, .log-wrap h2, .gold-wrap h2 { font-size: 30px; margin-bottom: 14px; }
  .rounds { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .round {
    grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "n arrows" "who who" "kill kill" "gold gold";
    gap: 4px 12px; padding: 12px 18px 12px 22px;
  }
  .r-n { grid-area: n; } .r-arrows { grid-area: arrows; text-align: right; }
  .r-who { grid-area: who; font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .r-kill { grid-area: kill; }
  .r-gold { grid-area: gold; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 12px; }
  .r-side { flex-wrap: wrap; gap: 4px 6px; }
  .r-side .item-ico { width: 18px; height: 18px; }

  .gold-legend { display: grid; gap: 8px; }
  .gl-side { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; font-size: 16px; }
  .gl-side b { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .gl-side > span:not(.side-dot) { grid-column: 2; }
  .gl-side > span:nth-of-type(2) { grid-row: 2; }
  .gl-side > span:nth-of-type(3) { grid-row: 3; }

  .log-round { margin-top: 24px; }
  .log-round h3 { font-size: 20px; padding-bottom: 8px; border-bottom: 1px solid var(--line-hi); margin-bottom: 0; }
  .log-round h3 .lr-head { font-size: 17px; }
  .r-pay { flex-basis: 100%; margin-left: 0; font-size: 16px; }
  table.log, table.log tbody { display: block; width: 100%; }
  table.log thead { display: none; }
  table.log tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who gold" "hits hits" "hp hp";
    gap: 6px 12px; padding: 10px 0; border-bottom: 1px solid var(--line);
  }
  table.log td { display: block; padding: 0; border: 0; white-space: normal; min-width: 0; }
  table.log td:nth-child(1) { grid-area: who; }
  table.log td:nth-child(2) { grid-area: hits; padding-left: 20px; }
  table.log td.l-gold { grid-area: gold; }
  table.log td.l-gold .none { display: none; }
  table.log td.l-hp { grid-area: hp; padding-left: 20px; }
  .l-who { display: flex; max-width: 100%; }
  .l-hits { gap: 4px 12px; }
  .l-paid { justify-content: flex-end; gap: 4px 10px; font-size: 16px; }
  .l-bars { display: flex; align-items: center; gap: 6px; }
  .hp { flex: 1 1 0; width: auto; max-width: none; margin: 0; height: 6px; }
  .hp-n { flex: none; font-size: 14px; min-width: 52px; text-align: right; }
}
