/* Layout: a black field, panels cut at the top-right corner like a HUD plate,
   one loud red rank hero per player, everything else quiet. Single dark theme by choice. */
:root {
  --void: #050505;        /* page */
  --plate: #0f0d0e;       /* panels */
  --plate-2: #171314;     /* raised rows, inputs */
  --line: #2b2226;        /* borders, grid */
  --bone: #efe7e4;        /* primary text */
  --muted: #9a8e8f;       /* secondary text */
  --dim: #6c6264;         /* tertiary text */
  --red: #ff2e43;         /* the accent */
  --red-deep: #7a0d18;
  --red-glow: rgba(255, 46, 67, .16);
  --win: #5fe0ad;         /* semantic, not accent */
  --loss: #ff5b69;
  --draw: #b8acad;

  --f-display: "Chakra Petch", "Bahnschrift", "Segoe UI", system-ui, sans-serif;
  --f-body: "Barlow", "Segoe UI", system-ui, sans-serif;

  --cut: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--void);
  color: var(--bone);
  font: 500 15px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.num { font-family: var(--f-display); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------ top bar */
.bar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(5, 5, 5, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar-in, .wrap {
  max-width: 1180px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.bar-in { display: flex; align-items: center; gap: 20px; padding-block: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--red); }
.brand img { width: 34px; height: 34px; }
.brand span { font: 700 18px/1 var(--f-display); letter-spacing: .02em; color: var(--bone); }
.search { margin-left: auto; display: flex; flex: 0 1 380px; min-width: 0; }
.search input {
  flex: 1; min-width: 0; height: 40px; padding: 0 14px;
  background: var(--plate-2); border: 1px solid var(--line); border-right: 0;
}
.search input::placeholder { color: var(--dim); }
.search input:focus { outline: none; border-color: var(--red); }
.search button {
  height: 40px; padding: 0 16px; border: 0; cursor: pointer;
  background: var(--red); color: var(--void); font: 700 14px/1 var(--f-display);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
}
.search button:hover { background: #ff5263; }

.mock-note {
  max-width: 1180px; margin: 14px auto 0; color: var(--muted); font-size: 13px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.mock-note code { color: var(--bone); }

.wrap { padding-block: 24px 64px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

/* ------------------------------------------------ panels */
.panel {
  background: var(--plate);
  border: 1px solid var(--line);
  padding: 18px 20px;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
  min-width: 0;
}
.panel h2 {
  margin: 0 0 14px; font: 600 15px/1.2 var(--f-display); color: var(--bone);
  display: flex; align-items: baseline; gap: 10px;
}
.panel h2 small { font: 500 13px var(--f-body); color: var(--dim); }
.empty { color: var(--muted); margin: 0; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.c4 { grid-column: span 4; } .c5 { grid-column: span 5; } .c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c12 { grid-column: span 12; }
@media (max-width: 900px) { .c4, .c5, .c7, .c8 { grid-column: span 12; } }

/* ------------------------------------------------ player banner */
.banner {
  position: relative; overflow: hidden; min-height: 132px;
  display: flex; align-items: flex-end; gap: 18px; padding: 20px;
  border: 1px solid var(--line); background: var(--plate);
}
.banner .art { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: .28; filter: grayscale(.4); }
.banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, var(--void) 10%, rgba(5,5,5,.55) 60%, rgba(5,5,5,.2)); }
.banner > *:not(.art) { position: relative; z-index: 1; }
.banner .avatar { width: 72px; height: 72px; border: 1px solid var(--line); background: var(--plate-2); flex: none; }
.banner h1 { margin: 0; font: 700 clamp(26px, 4vw, 38px)/1.05 var(--f-display); overflow-wrap: anywhere; }
.banner h1 .tag { color: var(--dim); font-weight: 500; font-size: .62em; margin-left: 4px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; color: var(--muted); font-size: 14px; }
.banner .who { min-width: 0; }
.banner .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 1px solid var(--line); background: var(--plate-2); cursor: pointer;
  font: 600 13px/1 var(--f-display); text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--red); }
.btn.on { border-color: var(--red); color: var(--red); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--red); border-color: var(--red); color: var(--void); }

/* ------------------------------------------------ rank hero (the loud part) */
.rank {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: auto 1fr; gap: 6px 22px; align-items: center;
}
.rank::before {
  content: ""; position: absolute; z-index: -1; inset: -40% -10% 38% 58%;
  background: linear-gradient(100deg, var(--red-deep), var(--red));
  transform: skewX(-18deg);
  opacity: .9;
}
.rank::after {
  content: ""; position: absolute; z-index: -1; inset: -40% -10% 38% 53%;
  border-left: 2px solid var(--red); transform: skewX(-18deg);
}
.rank .icon { width: 112px; height: 112px; grid-row: span 2; filter: drop-shadow(0 6px 24px var(--red-glow)); }
.rank .tier { font: 700 clamp(28px, 3.6vw, 40px)/1 var(--f-display); letter-spacing: -.01em; }
.rank .rr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.delta { white-space: nowrap; }
.rank .rr b { font: 700 46px/1 var(--f-display); font-variant-numeric: tabular-nums; }
.rank .rr span { color: var(--muted); font: 600 14px var(--f-display); }
.delta { font: 600 13px/1 var(--f-display); padding: 4px 7px; background: var(--plate-2); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.delta.up { color: var(--win); } .delta.down { color: var(--loss); }
.rank .progress { grid-column: 1 / -1; margin-top: 12px; }
.bar-track { height: 6px; background: var(--plate-2); border: 1px solid var(--line); position: relative; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--bone); }
.progress .lbl { display: flex; justify-content: space-between; margin-top: 6px; font-size: 13px; color: var(--muted); }
.rank .facts { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-top: 14px; background: var(--line); border: 1px solid var(--line); }
.fact { background: var(--plate); padding: 10px 12px; min-width: 0; }
.fact dt { font-size: 12px; color: var(--muted); }
.fact dd { margin: 2px 0 0; font: 600 16px/1.2 var(--f-display); display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.fact dd img { width: 22px; height: 22px; }

/* ------------------------------------------------ session */
.session-top { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--plate-2); border: 1px solid var(--line); padding: 12px 14px; min-width: 0; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font: 700 28px/1.15 var(--f-display); font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--dim); }
.status { display: inline-flex; align-items: center; gap: 6px; font: 600 12px/1 var(--f-display); padding: 5px 8px; border: 1px solid var(--line); color: var(--muted); }
.status::before { content: ""; width: 7px; height: 7px; background: var(--dim); }
.status.live { color: var(--bone); border-color: var(--red); }
.status.live::before { background: var(--red); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip {
  width: 58px; padding: 6px 0 5px; text-align: center; background: var(--plate-2);
  border: 1px solid var(--line); border-top: 2px solid var(--draw);
}
.chip.win { border-top-color: var(--win); } .chip.loss { border-top-color: var(--loss); }
.chip b { display: block; font: 700 13px/1 var(--f-display); }
.chip.win b { color: var(--win); } .chip.loss b { color: var(--loss); }
.chip span { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 3px; }

/* ------------------------------------------------ stat strip */
.strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.strip > div { background: var(--plate); padding: 14px 16px; }
.strip .k { font-size: 12px; color: var(--muted); }
.strip .v { font: 700 24px/1.2 var(--f-display); font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .strip { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ------------------------------------------------ chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-label { fill: var(--dim); font: 500 11px var(--f-display); }
.chart .xhair { stroke: var(--muted); stroke-dasharray: 3 3; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px;
  background: var(--void); border: 1px solid var(--line); padding: 8px 10px; font-size: 13px;
  transform: translate(-50%, calc(-100% - 12px));
}
.tip b { font-family: var(--f-display); }
.tip .row { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.range { display: flex; gap: 4px; margin-left: auto; }
.range button { background: none; border: 1px solid var(--line); padding: 3px 9px; cursor: pointer; color: var(--muted); font: 600 12px var(--f-display); }
.range button[aria-pressed="true"] { color: var(--bone); border-color: var(--red); }

/* ------------------------------------------------ lists: maps / agents */
.list { display: grid; gap: 8px; }
.li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.li img { width: 40px; height: 40px; object-fit: cover; background: var(--plate-2); }
.li .name { font: 600 14px/1.2 var(--f-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .sub { font-size: 12px; color: var(--muted); }
.li .wr { text-align: right; font: 700 15px/1.1 var(--f-display); font-variant-numeric: tabular-nums; }
.li .wr small { display: block; font: 500 11px var(--f-body); color: var(--dim); }
.mini { height: 3px; background: var(--plate-2); margin-top: 5px; position: relative; }
.mini i { position: absolute; inset: 0 auto 0 0; background: var(--red); }
.tabs { display: flex; gap: 4px; margin-left: auto; }

/* ------------------------------------------------ home */
.hello h1 { margin: 0; font: 700 clamp(28px, 4.6vw, 46px)/1.05 var(--f-display); text-wrap: balance; max-width: 18ch; }
.hello p { margin: 10px 0 0; color: var(--muted); max-width: 56ch; }
.friends { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.friend { display: flex; background: var(--plate-2); border: 1px solid var(--line); min-width: 0; }
.friend:hover, .friend:focus-within { border-color: var(--red); }
.friend > a {
  flex: 1; min-width: 0; display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 14px; text-decoration: none;
}
.friend .rm {
  flex: none; width: 40px; display: grid; place-items: center; cursor: pointer;
  background: none; border: 0; border-left: 1px solid var(--line); color: var(--dim);
}
.friend .rm svg { width: 16px; height: 16px; }
.friend .rm:hover { color: var(--red); background: var(--red-glow); }
.friend img { width: 48px; height: 48px; }
.friend .fn { font: 600 15px/1.2 var(--f-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend .fn small { color: var(--dim); font-weight: 500; }
.friend .ft { font-size: 13px; color: var(--muted); }
.friend .fl { font-size: 12px; color: var(--dim); margin-top: 2px; }
.friend .fl.hot { color: var(--red); }
.dots { display: flex; gap: 3px; justify-content: flex-end; }
.dots i { width: 6px; height: 14px; background: var(--draw); }
.dots i.w { background: var(--win); } .dots i.l { background: var(--loss); }
.add { display: flex; gap: 8px; margin-top: 14px; }
.add input { flex: 1; min-width: 0; height: 36px; padding: 0 12px; background: var(--plate-2); border: 1px solid var(--line); }
.add input:focus { outline: none; border-color: var(--red); }

.error { border-color: var(--red); }
.error p { margin: 0; }
.loading { color: var(--muted); padding: 40px 0; font-family: var(--f-display); }
.skel { background: linear-gradient(90deg, var(--plate) 0%, var(--plate-2) 50%, var(--plate) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 560px) {
  .bar-in { flex-wrap: wrap; gap: 10px; }
  .search { flex-basis: 100%; }
  .banner { flex-wrap: wrap; }
  .banner .actions { margin-left: 0; justify-content: flex-start; }
  .rank .icon { width: 84px; height: 84px; }
  .rank::before, .rank::after { inset-inline-start: 62%; }
  .session-top { grid-template-columns: 1fr 1fr; }
  .session-top .stat:last-child { grid-column: span 2; }
}

/* ------------------------------------------------ sign-in gate: banner fills the screen, a slim sign-in bar sits under the wordmark */
.gate {
  min-height: 100vh; display: grid; place-items: end center;
  background: linear-gradient(180deg, rgba(5,5,5,0) 62%, rgba(5,5,5,.85)), #0b0b0d url("/banner.png") center / cover no-repeat;
  padding-block: 24px max(5vh, 24px);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.gate-art { display: none; }
.gate-side { width: 100%; display: grid; justify-items: center; min-width: 0; }
.gate-box {
  width: 100%; max-width: 620px; padding: 18px 20px; display: grid; gap: 10px; min-width: 0;
  background: rgba(15, 13, 14, .78); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.gate-box .brand { display: none; }
.gate-box h1 { margin: 0; font: 700 22px/1.1 var(--f-display); }
.gate-hint { margin: 0; color: var(--muted); font-size: 14px; }
.gate-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; min-width: 0; }
.gate-form label { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.gate-form input { width: 100%; min-width: 0; height: 44px; padding: 0 14px; background: var(--plate-2); border: 1px solid var(--line); }
.gate-form .btn { height: 44px; justify-content: center; padding: 0 22px; }
.gate-form .link { grid-column: 1 / -1; justify-self: start; }
.code-input { font: 700 22px var(--f-display) !important; letter-spacing: .4em; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; padding: 4px 0; }
.gate-msg { margin: 0; min-height: 1.2em; font-size: 14px; color: var(--muted); }
.gate-msg:empty { display: none; }
.gate-msg.bad { color: var(--loss); }
@media (max-width: 820px) {
  .gate { place-items: end center; background: linear-gradient(180deg, rgba(5,5,5,0) 30%, var(--void) 62%), #0b0b0d url("/banner.png") center 6% / 150% auto no-repeat; }
  .gate-form { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------ app background: the banner, pushed far back */
body:not(.gate)::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(5,5,5,.82), rgba(5,5,5,.94) 40%, var(--void)), url("/banner.png") center top / cover no-repeat;
}
.gate-form input:focus { outline: none; border-color: var(--red); }
.btn:disabled { opacity: .55; cursor: wait; }
.who-am-i { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); white-space: nowrap; }
@media (max-width: 560px) { .who-am-i { order: 2; } }

/* ------------------------------------------------ all lowercase, except names people chose and what they type */
body { text-transform: lowercase; }
button { text-transform: inherit; }
input::placeholder { text-transform: lowercase; }
input, textarea, .banner h1, .friend .fn, .board .pl > span, #me, code { text-transform: none; }
.brand span { letter-spacing: -.01em; }
