/* CS2 LAN portal — single stylesheet. No framework, no shadows. */

@font-face { font-family: "Unbounded"; src: url("/static/fonts/unbounded-latin-wght-normal.woff2") format("woff2"); font-weight: 200 900; font-display: swap; }
@font-face { font-family: "Sora"; src: url("/static/fonts/sora-latin-wght-normal.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/static/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

@layer reset, tokens, base, lobby, board, matches, gate;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
  button:disabled { cursor: not-allowed; }
  ul, ol { padding: 0; list-style: none; }
  a { color: inherit; text-decoration: none; }
  img { display: block; max-width: 100%; }
  table { border-collapse: separate; }
}

@layer tokens {
  :root {
    --void: #06040f;
    --ink: #0d0822;
    --panel: #130b2e;
    --slate: #241f3f;
    --line: rgb(255 255 255 / .09);
    --text: #efecff;
    --mist: #a29dc2;
    --dim: #6b6690;

    --t1-a: #4f8cff;   /* team 1: electric blue -> violet */
    --t1-b: #9d56ff;
    --t2-a: #34f5a4;   /* team 2: neon green -> lime */
    --t2-b: #c4ff3d;
    --lime: #bdff3a;
    --ok: #3dffa2;
    --warn: #ffb347;
    --r-lg: 1.9rem;
    --r-md: 1.2rem;
    --r-av: .45rem;     /* avatar corner radius: Steam pictures stay square */

    --display: "Unbounded", "Sora", system-ui, sans-serif;
    --ui: "Sora", system-ui, "Segoe UI", sans-serif;
    --num: "JetBrains Mono", ui-monospace, monospace;
    --pad: clamp(14px, 1.5vw, 40px);
  }
}

@layer base {
  html {
    font-size: clamp(15px, calc(.52vw + 5px), 25px);
    color-scheme: dark;
    scroll-behavior: smooth;
    background: var(--void);
  }
  body {
    min-height: 100dvh;
    font-family: var(--ui);
    color: var(--text);
    background:
      radial-gradient(75rem 48rem at 6% -8%, #3d1b94 0, transparent 62%),
      radial-gradient(70rem 52rem at 104% 6%, #0f2f94 0, transparent 60%),
      radial-gradient(64rem 46rem at 48% 118%, #3b0e70 0, transparent 62%),
      linear-gradient(180deg, #08051a, #090722 55%, #06040f);
    background-attachment: fixed;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
  }
  :focus-visible { outline: 3px solid var(--lime); outline-offset: 3px; }
  .ic { width: 1em; height: 1em; fill: currentColor; flex: none; vertical-align: -.125em; }
  ::-webkit-scrollbar { height: 12px; width: 12px; }
  ::-webkit-scrollbar-thumb { background: #3b3466; border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
  ::-webkit-scrollbar-track { background: transparent; }

  .empty {
    display: flex; align-items: center; justify-content: center; gap: .8rem;
    padding: 3rem 1rem; color: var(--mist); font-size: 1.05rem;
    border: 2px dashed var(--line); border-radius: var(--r-lg);
  }
  .live-dot {
    display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--ok);
    animation: pulse 1.6s ease-in-out infinite;
  }
  @keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
}

/* ───────────────────────── lobby ───────────────────────── */
@layer lobby {
  main > section { scroll-margin-top: 0; }

  .lobby {
    min-height: 100dvh;
    padding: var(--pad);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(min-content, 1fr);
    grid-template-areas: "bar" "maps" "areas";
    gap: calc(var(--pad) * .7);
  }

  .bar {
    grid-area: bar;
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem;
  }
  .brand { display: flex; align-items: center; gap: .8rem; font-family: var(--display); font-weight: 700; font-size: 1.25rem; letter-spacing: -.01em; width: max-content; }
  .brand img { border-radius: .6rem; }

  .status {
    display: flex; align-items: center; gap: .8rem;
    padding: .55rem 1.3rem; border-radius: 99px;
    background: rgb(255 255 255 / .06); border: 1px solid var(--line);
    font-weight: 500; font-size: .95rem; color: var(--mist);
    .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--dim); }
    b { color: var(--text); font-weight: 700; }
    .notice { display: inline-flex; gap: .6rem; align-items: center; color: var(--warn); font-weight: 600; }
    &.st-match { color: var(--text); border-color: rgb(61 255 162 / .45); background: rgb(61 255 162 / .1); }
    &.st-launching > .ic { animation: spin 1s linear infinite; }
    &:has(.go) { padding: .35rem .35rem .35rem 1.3rem; }   /* the action sits inside the badge, flush with its rounded end */
    .abort {   /* admins only: ends the running match; takes the badge's look */
      display: grid; place-items: center; width: 1.7rem; height: 1.7rem; margin: -.2rem 0 -.2rem .15rem;
      border-radius: 50%; background: rgb(255 255 255 / .12); color: inherit; font-size: .8rem;
      transition: background .2s, color .2s;
      &:hover { background: #ff4d73; color: #fff; }
    }
  }
  @keyframes spin { to { rotate: 360deg; } }

  .account { display: flex; align-items: center; gap: .7rem; justify-self: end; }
  .account .av { width: 2.3rem; height: 2.3rem; border-radius: var(--r-av); }
  .account-name { font-weight: 600; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .navlink {
    display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 50%;
    background: rgb(255 255 255 / .06); color: var(--mist); font-size: 1.05rem;
    transition: background .2s, color .2s;
    &:hover { background: rgb(255 255 255 / .14); color: var(--text); }
    &.bot:hover { background: var(--lime); color: #11180a; }   /* the only navlink that DOES something: admins start a bot match */
  }

  /* areas */
  .areas {
    grid-area: areas;
    display: grid; grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: minmax(min-content, 1fr) auto;
    gap: calc(var(--pad) * .7);
  }
  .area-t1 { grid-column: 1 / 7; }
  .area-t2 { grid-column: 7 / 13; }
  .area-obs { grid-column: 1 / 7; grid-row: 2; }
  .area-break { grid-column: 7 / 13; grid-row: 2; }
  .area-obs, .area-break { min-height: 14rem; }   /* Observer/Break take what their rows need, never less than this */

  .area {
    --a: var(--slate); --b: var(--panel); --edge: rgb(255 255 255 / .10);
    position: relative; overflow: hidden; isolation: isolate;
    display: flex; flex-direction: column; gap: 1rem;
    padding: 1.4rem 1.5rem 1.5rem;
    border-radius: var(--r-lg);
    border: 2px solid var(--edge);
    background: linear-gradient(150deg, color-mix(in oklab, var(--a) 34%, var(--void)), color-mix(in oklab, var(--b) 24%, var(--void)) 70%);
    transition: border-color .25s, background .35s, filter .35s;
    &[role="button"] { cursor: pointer; }
    &[role="button"]:hover { --edge: color-mix(in oklab, var(--a) 70%, white 10%); }
    &.is-mine {
      --edge: var(--a);
      background: linear-gradient(150deg, color-mix(in oklab, var(--a) 52%, var(--void)), color-mix(in oklab, var(--b) 40%, var(--void)) 75%);
    }
    h2 {
      display: flex; align-items: center; gap: .8rem;
      font-family: var(--display); font-weight: 700; font-size: 1.35rem; letter-spacing: -.02em;
      .ic { font-size: 1.3rem; color: var(--a); }
      .count {
        margin-left: auto; min-width: 2.2rem; text-align: center; padding: .15rem .6rem; border-radius: 99px;
        font-family: var(--num); font-weight: 700; font-size: .95rem; background: rgb(255 255 255 / .1);
      }
    }
    ul { display: flex; flex-direction: column; gap: .6rem; min-height: 0; }
  }
  .area-t1 { --a: var(--t1-a); --b: var(--t1-b); }
  .area-t2 { --a: var(--t2-a); --b: var(--t2-b); }
  .area-obs { --a: #8a7fd6; --b: #3b3470; }
  .area-break { --a: #8c8aa3; --b: #3a384d; }

  /* ghost numerals behind the teams */
  .area-t1::before, .area-t2::before {
    content: "1"; position: absolute; z-index: -1; right: 1.5rem; bottom: -3.2rem;
    font-family: var(--display); font-weight: 900; font-size: 19rem; line-height: 1;
    color: var(--a); opacity: .13; pointer-events: none;
  }
  .area-t2::before { content: "2"; }
  .area-t1 .player, .area-t2 .player { font-size: 1.3rem; padding: .5rem 1.2rem .5rem .5rem; .av { width: 3rem; height: 3rem; } .flags { font-size: 1.4rem; gap: 1rem; } }

  .area-obs ul, .area-break ul { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: .6rem; }
  .area-t1 ul, .area-t2 ul { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: .75rem; }

  .player {
    display: flex; align-items: center; gap: .8rem;
    padding: .4rem .9rem .4rem .4rem; border-radius: calc(var(--r-av) + .4rem);
    background: rgb(7 4 18 / .48);
    border: 2px solid transparent;
    transition: opacity .7s ease, background .3s, border-color .3s, transform .35s;
    @starting-style { opacity: 0; transform: translateY(.5rem) scale(.97); }
    .av { width: 2.4rem; height: 2.4rem; border-radius: var(--r-av); background: var(--slate); object-fit: cover; }
    .nm { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    &.me { border-color: var(--lime); }
    .flags { display: flex; gap: .75rem; font-size: 1.15rem; }
    .flag { display: inline-flex; color: rgb(255 255 255 / .2); transition: color .25s, scale .25s; }
    .flag.on { color: var(--ok); scale: 1.1; }
    .flag.vote.on { color: var(--lime); }
  }
  .area-obs .flags, .area-break .flags { display: none; }
  .lockmark { display: inline-flex; margin-left: .2rem; font-size: .95rem; color: var(--mist); }
  .lobby[data-phase="match"] .areas .area, .lobby[data-phase="launching"] .areas .area { cursor: default; }
  .area-break .player { opacity: .38; }
  .area-break .player.me { opacity: .6; }

  /* map vote */
  .maps {   /* one full-width ribbon: any number of tiles share the row equally */
    grid-area: maps; min-width: 0;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: calc(var(--pad) * .55);
    grid-auto-rows: clamp(5.6rem, 10.5dvh, 8.6rem);
  }
  @media (max-width: 1240px) {   /* narrower than a laptop: two rows of five instead of ten slivers */
    .maps { grid-auto-flow: row; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  }
  .map {
    position: relative; overflow: hidden; isolation: isolate; container-type: inline-size;
    border-radius: var(--r-md); border: 2px solid var(--edge, transparent);
    background: var(--void); text-align: left;
    transition: border-color .2s, opacity .2s;
    img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; filter: brightness(.62) saturate(.85); transition: filter .35s, scale .5s; }
    &::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgb(8 5 22 / .85), transparent 62%); }
    &:not(:disabled):hover { --edge: rgb(255 255 255 / .5); }
    &:not(:disabled):hover img { filter: brightness(.9) saturate(1); scale: 1.05; }
    &.is-mine { --edge: var(--lime); }
    &.is-mine img { filter: brightness(1) saturate(1.1); }
    &:disabled { opacity: .5; }
    &.is-picked { --edge: var(--lime); opacity: 1; }
    &.is-picked img { filter: brightness(1) saturate(1.1); }
    /* the name scales with the tile (container query) so "Overpass" and "Dust II" are never cut off */
    .map-name { position: absolute; left: .75rem; right: .5rem; bottom: .6rem; font-family: var(--display); font-weight: 600; font-size: clamp(.68rem, 11.5cqi, 1.1rem); letter-spacing: -.01em; line-height: 1.15; }
    .votes {
      position: absolute; top: .5rem; right: .5rem; min-width: 1.7rem; height: 1.7rem; padding: 0 .45rem;
      display: grid; place-items: center; border-radius: 99px;
      font-family: var(--num); font-weight: 700; font-size: .85rem; background: rgb(8 5 22 / .65); color: var(--mist);
      &.some { background: var(--lime); color: #11180a; }
    }
  }

  /* the lobby's one action (Ready up / Copy connect) lives inside the status badge in the header */
  .go {
    display: inline-flex; align-items: center; justify-content: center; gap: .7rem;
    height: 2.5rem; padding: 0 1.4rem; margin-left: .3rem;
    font-family: var(--display); font-weight: 700; font-size: .98rem; letter-spacing: -.01em; white-space: nowrap;
    color: #fff; border-radius: 99px;
    background: linear-gradient(135deg, #6c3dff, #3f7bff);
    transition: background .3s, color .3s, opacity .2s, scale .15s;
    &:not(:disabled):hover { scale: 1.03; }
    &:not(:disabled):active { scale: .97; }
    &:disabled { opacity: .45; background: var(--slate); color: var(--mist); }
    &.on { background: linear-gradient(135deg, var(--t2-a), var(--t2-b)); color: #0b1a0d; }
    &.connect {
      background: linear-gradient(135deg, var(--t2-a), var(--t1-a)); color: #04140e;
      .when-copied { display: none; }
      &.copied { background: linear-gradient(135deg, var(--lime), var(--t2-a)); }
      &.copied .when-idle { display: none; }
      &.copied .when-copied { display: inline; }
    }
  }

  .lobby[data-phase="match"] .areas { filter: saturate(.7); }
}

/* ───────────────────────── leaderboard ───────────────────────── */
@layer board {
  #leaderboard, #matches { padding: 0 var(--pad); }
  #matches { padding-top: calc(var(--pad) * 1.4); padding-bottom: calc(var(--pad) * 2); }

  .board-wrap { overflow-x: auto; border-radius: var(--r-lg); }
  .board {
    width: 100%; border-spacing: 0 .5rem;
    font-size: 1rem;
    th, td { white-space: nowrap; }
    th { font-weight: 600; font-size: .82rem; text-align: right; padding: 0 .3rem; color: var(--mist); }
    th:first-child { text-align: left; }
    th button {
      display: inline-flex; align-items: center; gap: .3rem; padding: .7rem .6rem; border-radius: .7rem; width: 100%; justify-content: flex-end;
      transition: color .2s, background .2s;
      &:hover { background: rgb(255 255 255 / .08); color: var(--text); }
    }
    th:first-child button { justify-content: flex-start; padding-left: 1.2rem; }
    th.sorted button { color: var(--lime); }
    th .ic { font-size: .8em; }

    td { padding: 0 .9rem; height: 3.5rem; text-align: right; }
    td.n { font-family: var(--num); font-size: .98rem; font-variant-numeric: tabular-nums; min-width: 4.2rem; }
    td.sticky, th.sticky { position: sticky; left: 0; z-index: 3; }
    th.sticky { background: #0b0723; }

    tbody tr { --row: linear-gradient(90deg, #1d1347, #14123c); }
    tbody td { background: var(--row); }
    tbody td:first-child { border-radius: 1.1rem 0 0 1.1rem; }
    tbody td:last-child { border-radius: 0 1.1rem 1.1rem 0; }
    tbody tr:not([class*="rk"]) td.sorted { background: linear-gradient(0deg, rgb(189 255 58 / .1), rgb(189 255 58 / .1)), var(--row); }

    td.sticky { text-align: left; padding: 0 1.4rem 0 .8rem; min-width: 17rem; }
    td.sticky .who {
      display: flex; align-items: center; gap: .85rem; height: 3.5rem;
      .pos { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; font-family: var(--display); font-weight: 700; font-size: .78rem; background: rgb(255 255 255 / .1); }
      .av { width: 2rem; height: 2rem; border-radius: calc(var(--r-av) * .8); object-fit: cover; }
      .nm { font-weight: 700; font-size: 1.05rem; }
    }

    /* viewer's row: different border colour */
    tr.me td { border-block: 2px solid var(--lime); }
    tr.me td:first-child { border-left: 2px solid var(--lime); }
    tr.me td:last-child { border-right: 2px solid var(--lime); }

    /* podium rows — brushed metal */
    tr.rk1 { --metal: linear-gradient(180deg, #fbe795 0%, #e3b53a 42%, #b78420 100%); --ink: #261a02; --edge: #fff4bf; }
    tr.rk2 { --metal: linear-gradient(180deg, #f6f8fc 0%, #c3c9d8 45%, #8f96aa 100%); --ink: #14172a; --edge: #ffffff; }
    tr.rk3 { --metal: linear-gradient(180deg, #f0b283 0%, #c1713a 44%, #84421a 100%); --ink: #2a1205; --edge: #ffd9b8; }
    tr[class*="rk"]:not(.rk0) {
      color: var(--ink);
      td { background: var(--brush), var(--metal); background-blend-mode: overlay, normal; border-block: 1px solid var(--edge); }
      td:first-child { border-left: 1px solid var(--edge); }
      td:last-child { border-right: 1px solid var(--edge); }
      td.sticky .pos { background: rgb(0 0 0 / .78); color: #fff; }
      td.sticky .nm { font-weight: 800; }
      td.sorted { filter: brightness(1.08); }
    }
    tr.me[class*="rk"]:not(.rk0) td { border-block: 2px solid var(--lime); }
    tr.me[class*="rk"]:not(.rk0) td:first-child { border-left: 2px solid var(--lime); }
    tr.me[class*="rk"]:not(.rk0) td:last-child { border-right: 2px solid var(--lime); }
  }
  :root {
    --brush: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='420' height='96'><filter id='n' x='0' y='0' width='100%25' height='100%25'><feTurbulence type='fractalNoise' baseFrequency='0.0035 0.75' numOctaves='3' seed='11' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 .5  0 0 0 0 .5  0 0 0 0 .5  1.6 0 0 0 -.55'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  }
}

/* ───────────────────────── matches ───────────────────────── */
@layer matches {
  .matches { display: flex; flex-direction: column; gap: .7rem; }
  .match {
    position: relative; overflow: hidden; isolation: isolate;
    display: grid; grid-template-columns: minmax(11rem, 18rem) minmax(0, 1fr) auto minmax(0, 1fr) auto; align-items: center; gap: 1.4rem;
    height: 5.2rem; padding: 0 1.1rem 0 1.6rem;
    border-radius: 1.3rem; background: var(--panel); border: 1px solid var(--line);
    .mimg { position: absolute; left: 0; top: 0; width: 46%; height: 100%; object-fit: cover; z-index: -2; mask-image: linear-gradient(90deg, #000 25%, transparent); }
    &::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgb(10 6 26 / .4) 0, rgb(19 11 46 / .92) 34%); }
    .mname { font-family: var(--display); font-weight: 700; font-size: 1.25rem; letter-spacing: -.02em; display: flex; align-items: center; gap: .7rem; }
    .roster { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--mist); font-size: 1rem; font-weight: 500; }
    .r1 { text-align: right; }
    .roster.win { color: var(--text); font-weight: 700; }
    .score {
      display: flex; align-items: center; gap: .55rem; font-family: var(--num);
      b { min-width: 3.1rem; text-align: center; padding: .25rem .7rem; border-radius: .8rem; font-size: 1.35rem; font-weight: 700; border: 2px solid rgb(255 255 255 / .18); }
      i { font-style: normal; color: var(--dim); }
    }
    .score b:first-child { border-color: color-mix(in oklab, var(--t1-a) 55%, transparent); }
    .score b:last-child { border-color: color-mix(in oklab, var(--t2-a) 55%, transparent); }
    .dl { display: flex; align-items: center; gap: .6rem; }
    .dl-btn {
      display: grid; place-items: center; width: 2.7rem; height: 2.7rem; border-radius: 50%; font-size: 1.05rem;
      background: rgb(255 255 255 / .05); color: rgb(255 255 255 / .22);
      &.on { background: rgb(157 86 255 / .28); color: #d9c4ff; transition: scale .15s; &:hover { scale: 1.1; } }
      &.demo { width: 3.2rem; height: 3.2rem; font-size: 1.2rem; }
      &.demo.on { background: linear-gradient(135deg, var(--t2-a), var(--t2-b)); color: #07210f; }
    }
    .botmark { display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: .5rem; background: rgb(255 255 255 / .14); font-size: .8rem; color: var(--text); }
    &.st-live { border-color: rgb(61 255 162 / .4); }
    &.st-aborted { opacity: .55; }
  }
}

/* ───────────────────────── sign-in gate ───────────────────────── */
@layer gate {
  .backdrop { position: fixed; inset: 0; overflow: hidden; filter: blur(22px) saturate(1.1); scale: 1.06; pointer-events: none; }
  .gate {
    position: fixed; inset: 0; display: grid; place-items: center; z-index: 10;
    background: rgb(6 4 15 / .5);
  }
  .gate-card {
    display: flex; flex-direction: column; align-items: center; gap: 1.6rem;
    padding: 3.2rem 4rem 3.4rem; border-radius: 2.2rem;
    background: linear-gradient(160deg, #1d1048, #0c0a2c);
    border: 2px solid rgb(157 86 255 / .45);
    h1 { font-family: var(--display); font-weight: 800; font-size: 2.6rem; letter-spacing: -.03em; }
    .gate-logo { border-radius: 1.2rem; width: 5.4rem; height: 5.4rem; }
  }
  .steam-btn {
    display: inline-flex; align-items: center; gap: 1rem; padding: 1.1rem 2.4rem; border-radius: 1.2rem;
    font-weight: 700; font-size: 1.2rem; color: #fff;
    background: linear-gradient(135deg, #2c4cff, #7b3dff);
    transition: scale .15s, filter .2s;
    .ic { font-size: 1.6rem; }
    &:hover { scale: 1.03; filter: brightness(1.12); }
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
