/* Xynitra panel. Palette sampled from the pack's own logo and artwork. */
:root {
  /* Brand greens and purples are fixed: they come from the logo and don't
     belong to a theme. Only the surfaces around them follow the device. */
  --acid:      #B1EF00;   /* logo green, the loudest thing on screen */
  --acid-dim:  #67B700;
  --acid-deep: #02A95C;
  --glow:      #FFFF32;   /* highlight in the logo */
  --purple:    #3B276D;   /* sky in the artwork */
  --night:     #101351;   /* deepest blue of the sky */
  --magenta:   #87376C;   /* sunset band */

  /* light-dark() picks by device setting. No toggle, no duplicated rules. */
  color-scheme: light dark;

  --ink:      light-dark(#EDECF3, #0A0A12);
  --veil:     light-dark(rgba(237,236,243,.80), rgba(10,10,18,.66));
  --panel:    light-dark(rgba(255,255,255,.74), rgba(18,16,38,.76));
  --sunk:     light-dark(rgba(255,255,255,.60), rgba(0,0,0,.26));
  --hairline: light-dark(rgba(24,20,50,.11), rgba(255,255,255,.06));
  --edge:     light-dark(rgba(2,169,92,.32), rgba(177,239,0,.18));

  --text:     light-dark(#191634, #E8E6F0);
  --muted:    light-dark(#57507B, #9A93B8);
  --muted-2:  light-dark(#6C6593, #7E76A0);

  /* Acid green is unreadable as text on a light surface, so accents get their
     own token that darkens to the deep green. Fills keep --acid. */
  --brand-ink: light-dark(#04794A, #B1EF00);
  --warn-ink:  light-dark(#8A6300, #FFFF32);
  --danger:    light-dark(#C42B2B, #FF5C5C);

  --radius: 14px;
}

* { box-sizing: border-box; }

/* The base colour goes on <html> ONLY. Giving <body> a background too hid the
   artwork completely: body is an unpositioned child of the root stacking
   context, so it paints *after* (on top of) the z-index:-2/-1 pseudo
   elements underneath it. */
html {
  min-height: 100%;
  background: var(--ink);
  -webkit-text-size-adjust: 100%;   /* iOS otherwise reflows the type in landscape */
}
body {
  margin: 0; min-height: 100%;
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

/* The artwork, blurred enough to read as atmosphere rather than a picture:
   felt behind the cards, never competing with them. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2;
  background: url("/static/bg.webp") center/cover no-repeat;
  filter: blur(9px) saturate(1.06);
  transform: scale(1.09);          /* covers the soft edge the blur leaves */
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1;
  /* A flat veil, not a gradient to solid: the old one hit 90% opacity halfway
     down and buried the artwork completely. */
  background:
    radial-gradient(1200px 700px at 50% -15%, rgba(177,239,0,.10), transparent 60%),
    var(--veil);
}

/* ---- scrollbar: no track, thumb in the pack's green ---- */
* { scrollbar-width: thin; scrollbar-color: var(--acid-dim) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--acid-dim), var(--acid-deep));
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--acid), var(--acid-dim));
  background-clip: padding-box;
}
::-webkit-scrollbar-corner { background: transparent; }

/* ---- shell ---- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 20px 64px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.brand img { width: 260px; max-width: 52vw; display: block;
             filter: drop-shadow(0 4px 18px rgba(0,0,0,.35)); }
.who { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; min-width: 0; }
/* A long account name gives way rather than pushing the button off-screen. */
.who .user { font-weight: 600; color: var(--text);
             min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The role is a fact about the account, so it gets a badge rather than being
   run together with the name behind a separator. */
.who .role {
  flex: none;
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 7px;
  color: var(--brand-ink); border: 1px solid var(--edge);
  background: light-dark(rgba(2,169,92,.10), rgba(177,239,0,.08));
}

.card {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 20px 22px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px light-dark(rgba(30,24,70,.14), rgba(0,0,0,.42));
  margin-bottom: 18px;
}
.card h2 {
  margin: 0 0 16px; font-size: 12px; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted-2);
}

/* While the live feed is down the readings are stale, so say so instead of
   showing numbers that quietly stopped moving. */
body.offline-link .stats,
body.offline-link .status-row { opacity: .45; }
body.offline-link .wrap::before {
  content: "Reconnecting";
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  z-index: 5; font-size: 12px; font-weight: 600; letter-spacing: .08em;
  padding: 6px 16px; border-radius: 0 0 10px 10px;
  color: var(--warn-ink); background: var(--panel); border: 1px solid var(--hairline);
  border-top: none; backdrop-filter: blur(14px);
}

/* ---- status ---- */
.status-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.dot.online   { background: var(--acid-deep); box-shadow: 0 0 0 4px rgba(2,169,92,.18); animation: pulse 2.4s infinite; }
.dot.starting { background: var(--warn-ink);  box-shadow: 0 0 0 4px rgba(255,200,50,.18); animation: pulse 1s infinite; }
.dot.offline  { background: var(--muted-2); }
@keyframes pulse { 50% { opacity: .45; } }

.state { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.state.online { color: var(--brand-ink); }
.state.starting { color: var(--warn-ink); }
.state.offline { color: var(--muted); }

.addr {
  margin-left: auto; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px; color: var(--muted); background: var(--sunk);
  padding: 7px 12px; border-radius: 9px; border: 1px solid var(--hairline);
  cursor: pointer; transition: .15s;
}
.addr:hover { color: var(--brand-ink); border-color: var(--edge); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 18px; }
.stat { background: var(--sunk); border: 1px solid var(--hairline);
        border-radius: 11px; padding: 13px 15px; }
.stat .k { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); }
.stat .v { font-size: 21px; font-weight: 700; margin-top: 5px; font-variant-numeric: tabular-nums; }
.stat .v.good { color: var(--brand-ink); }
.stat .v.warn { color: var(--warn-ink); }
.stat .v.bad  { color: var(--danger); }

.players { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.tag { font-size: 13px; padding: 5px 12px; border-radius: 99px;
       background: light-dark(rgba(2,169,92,.12), rgba(177,239,0,.10));
       border: 1px solid var(--edge); color: var(--brand-ink); }

/* ---- buttons ---- */
.btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 600;
  border-radius: 11px; padding: 11px 18px; transition: .16s;
  border: 1px solid var(--hairline);
  background: var(--sunk); color: var(--text);
  text-decoration: none;          /* Download is an <a>, not a <button> */
  display: inline-block; text-align: center;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--edge); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--acid), var(--acid-dim));
  color: #10210A; border: none; box-shadow: 0 8px 26px rgba(103,183,0,.30);
}
.btn.primary:hover:not(:disabled) { box-shadow: 0 12px 34px rgba(103,183,0,.45); }
.btn.danger { color: var(--danger); border-color: light-dark(rgba(196,43,43,.32), rgba(255,92,92,.28)); }
.btn.danger:hover:not(:disabled) { background: light-dark(rgba(196,43,43,.08), rgba(255,92,92,.10)); }
.controls { display: flex; gap: 10px; flex-wrap: wrap; }

/* keyboard users get the same affordance as the mouse */
:where(a, button, input):focus-visible {
  outline: 2px solid var(--brand-ink); outline-offset: 2px;
}

/* ---- download ---- */
.dl { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.dl .meta { flex: 1; min-width: 190px; }
.dl .meta .t { font-size: 15px; font-weight: 700; word-break: break-all;
               font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.dl .meta .s { font-size: 13px; color: var(--muted-2); margin-top: 4px; }
.dl .btn.primary { font-size: 15px; padding: 13px 26px; }

/* ---- console ---- */
.console {
  background: light-dark(rgba(255,255,255,.68), rgba(0,0,0,.52));
  border: 1px solid var(--hairline);
  border-radius: 11px; padding: 14px 16px; height: 340px; overflow-y: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; line-height: 1.65;
}
.console div { white-space: pre-wrap; word-break: break-word;
               color: light-dark(#403A63, #B9B3D0); }
.console div.warn  { color: var(--warn-ink); }
.console div.error { color: var(--danger); }
.console div.ok    { color: var(--acid-deep); }
/* Typed commands read as the admin's own voice among the server's output. */
.console div.cmd { color: var(--acid-deep); font-weight: 700; margin-top: 4px; }

/* Same input and same button as everywhere else on the page; the row only has
   to hand the leftover width to the field. */
.cmdline { display: flex; gap: 8px; margin-top: 12px; }
.cmdline .search { flex: 1; min-width: 0;
                   font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

/* ---- mods ---- */
.search {
  width: 100%; padding: 11px 15px; border-radius: 11px; font: inherit;
  background: var(--sunk); border: 1px solid var(--hairline); color: var(--text);
}
.search:focus { outline: none; border-color: var(--edge); }
.search::placeholder { color: var(--muted-2); }
.modlist { margin-top: 14px; max-height: 320px; overflow-y: auto;
           display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.mod { background: var(--sunk); border: 1px solid var(--hairline);
       border-radius: 9px; padding: 9px 12px; font-size: 13px; }
.mod .n { color: var(--text); }
.mod .v { color: var(--muted-2); font-size: 11px; margin-top: 2px;
          font-family: ui-monospace, Menlo, monospace; }

/* ---- login ---- */
/* dvh, not vh: the mobile URL bar makes 100vh taller than the visible page. */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 22px; }
.login { width: 100%; max-width: 380px; text-align: center; }
.login img { width: 300px; max-width: 78vw; margin-bottom: 30px;
             filter: drop-shadow(0 6px 26px rgba(0,0,0,.38)); }
.login .card { text-align: left; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
               color: var(--muted-2); margin-bottom: 7px; }
.field input {
  width: 100%; padding: 12px 15px; border-radius: 11px; font: inherit;
  background: var(--sunk); border: 1px solid var(--hairline); color: var(--text);
}
.field input:focus { outline: none; border-color: var(--acid-dim);
                     box-shadow: 0 0 0 3px rgba(103,183,0,.16); }
.login .btn { width: 100%; margin-top: 6px; }
.msg { margin-top: 14px; font-size: 13px; color: var(--danger); min-height: 18px; text-align: center; }

/* Two facts, told apart by a rule rather than by a punctuation mark. */
.foot { margin-top: 30px; font-size: 12px; color: var(--muted-2);
        display: flex; justify-content: center; }
.foot span + span { margin-left: 14px; padding-left: 14px; border-left: 1px solid var(--hairline); }

/* ---- phones ----
   The title bar is what breaks first. Logo, name, role badge and Sign out
   cannot share one line under ~560px: the button ended up 40px past the right
   edge and took the whole page into horizontal scroll with it. Below this
   width the header becomes two rows — logo, then the account as its own bar,
   which also gives the badge and the button room to be tapped. */
@media (max-width: 560px) {
  .wrap {
    padding: 18px max(14px, env(safe-area-inset-right))
             calc(40px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .top { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 20px; }
  .brand { display: flex; justify-content: center; }
  .brand img { width: 100%; max-width: 240px; }

  /* Scoped to .top: #pmsg in the power card carries .who too and must stay
     plain text, not a second bar. */
  .top .who {
    /* Without an explicit width this stretches to its own min-content and
       overflows the column instead of making the name give way. */
    width: 100%;
    justify-content: space-between; gap: 8px;
    padding: 8px 8px 8px 14px;
    background: var(--panel); border: 1px solid var(--edge);
    border-radius: var(--radius); backdrop-filter: blur(14px);
  }
  .top .who .role { margin-right: auto; }   /* name + badge left, button right */
  .top .who .btn { flex: none; padding: 10px 14px; }

  /* 44px is the smallest thing a thumb hits reliably. */
  .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }

  .card { padding: 16px 15px; margin-bottom: 14px; }
  .card h2 { margin-bottom: 13px; }

  .status-row { gap: 10px; }
  .state { font-size: 20px; }
  .addr { margin-left: 0; width: 100%; text-align: center; }

  /* Two columns hold down to a 320px screen. */
  .stats { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; margin-top: 14px; }
  .stat { padding: 11px 12px; }
  .stat .v { font-size: 19px; }

  .controls .btn { flex: 1; min-width: 0; }   /* start/restart/stop share one row */
  .controls #pmsg { flex-basis: 100%; }

  /* The download is the whole point of the page on a phone. */
  .dl { gap: 14px; }
  .dl .btn.primary { width: 100%; }

  .console { height: 240px; font-size: 11px; padding: 12px 13px; line-height: 1.55; }

  .modlist { grid-template-columns: 1fr; max-height: 260px; }

  .foot { margin-top: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .btn:hover:not(:disabled) { transform: none; }
}
