/* Kokona Panel — Strinova-style HUD (cut corners, condensed italic headings) in
   Kokona's own colours, taken from her official art: the navy P.U.S. cape with its
   indigo-to-periwinkle lining, amber eyes and yellow tech accents, the emerald
   gem on her belt, and the pale straps that trail behind her. */

:root {
  color-scheme: dark;
  --bg: #070a17;
  --bg-raised: #0d1226;
  --panel-top: rgba(23, 30, 60, 0.93);
  --panel-bottom: rgba(12, 16, 35, 0.94);
  --field: rgba(6, 9, 22, 0.8);
  --line: rgba(154, 160, 242, 0.18);
  --line-strong: rgba(154, 160, 242, 0.36);
  --text: #eef0fb;
  --muted: #9ea5c8;
  --cape: #9aa0f2;
  --cape-deep: #3f5fe0;
  --cape-soft: rgba(154, 160, 242, 0.14);
  --amber: #f4b942;
  --sky: #5b9cff;
  --sky-soft: rgba(91, 156, 255, 0.12);
  --hair: #c8b9a6;
  --on-amber: #1a1305;
  --ok: #2fd39a;
  --warn: #f5a340;
  --danger: #ff5a6e;
  --cut: 14px;
  --font-body: "Segoe UI", system-ui, -apple-system, "Noto Sans", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: Bahnschrift, "DIN Alternate", "Barlow Condensed", "Roboto Condensed", "Arial Narrow", var(--font-body);
  --font-mono: "Cascadia Code", "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Night sky in her cape colours: the indigo lining glowing behind her, a warm amber trace low left. */
  background:
    radial-gradient(1000px 680px at 96% 4%, rgba(63, 95, 224, 0.26), transparent 64%),
    radial-gradient(820px 560px at 74% 104%, rgba(154, 160, 242, 0.14), transparent 64%),
    radial-gradient(760px 480px at -12% 112%, rgba(244, 185, 66, 0.07), transparent 60%),
    linear-gradient(180deg, #0a0e20 0%, #060915 100%);
  background-color: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font-body);
  /* Nothing is clipped: when a window is too small, the page (or the strip that holds
     the wide part) scrolls instead. Long unbroken names wrap rather than push the layout. */
  overflow-wrap: break-word;
}

/* Thin scrollbars in her colours wherever something scrolls. */
* {
  scrollbar-color: rgba(154, 160, 242, 0.38) transparent;
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 10px;
  background: rgba(154, 160, 242, 0.34) padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(154, 160, 242, 0.55) padding-box;
}

html.has-dialog {
  overflow: hidden;
}

a {
  color: var(--sky);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

h1 {
  font-size: clamp(1.75rem, 3.4vw, 2.6rem);
  font-style: italic;
  text-transform: uppercase;
}

h2 {
  font-size: 1.25rem;
  text-transform: uppercase;
}

h3 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

p {
  margin: 0;
}

code {
  font-family: var(--font-mono);
}

:focus-visible {
  outline: 2px solid var(--sky);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 20;
  padding: 10px 14px;
  background: var(--amber);
  color: var(--on-amber);
  font-weight: 700;
}

.skip-link:focus {
  top: 12px;
}

/* Backdrop: a faint HUD grid with three drifting ribbons, like the straps that trail behind Kokona. */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(154, 160, 242, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(154, 160, 242, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 78%);
  /* A fixed full-window layer: nothing inside it affects the page's layout or paint. */
  contain: strict;
}

.ribbon {
  position: absolute;
  left: -20%;
  width: 140%;
  height: 14px;
  transform-origin: center;
  animation: drift 18s ease-in-out infinite alternate;
}

.ribbon-a {
  top: 20%;
  background: linear-gradient(90deg, transparent 8%, rgba(236, 240, 250, 0.07) 30%, rgba(236, 240, 250, 0.16) 50%, rgba(236, 240, 250, 0.05) 72%, transparent 92%);
  border-top: 1px solid rgba(236, 240, 250, 0.08);
  transform: rotate(-8deg);
}

.ribbon-b {
  top: 60%;
  height: 22px;
  background: linear-gradient(90deg, transparent 10%, rgba(63, 95, 224, 0.12) 35%, rgba(154, 160, 242, 0.16) 55%, transparent 88%);
  transform: rotate(5deg);
  animation-duration: 24s;
}

.ribbon-c {
  top: 86%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
  transform: rotate(-3deg);
  opacity: 0.22;
  animation-duration: 30s;
}

/* Inside the panel the wide ribbons stay out from behind text; the start page keeps all three. */
body:not(.is-home) .ribbon-a,
body:not(.is-home) .ribbon-b {
  display: none;
}

/* Kokona's official art, fixed so she stands just right of the 1240px content, her
   cape tucked a little behind the cards. When the margin is too narrow for her, she
   moves only as far as the window's right edge: clear on the start page and, on
   wide screens, beside the settings; quiet where she has to overlap them.
   (Percentages of a fixed element are of the viewport, without the scrollbar.) */
/* Very tall windows let her grow toward the art's native 1500px, so she still
   reaches up beside the cards instead of standing far below them. */
.splash {
  --splash-height: min(calc(100vh - 70px), max(1100px, calc(100vh - 660px)), 1500px);
  --splash-width: calc(var(--splash-height) * 1044 / 1500);
  position: fixed;
  z-index: -1;
  left: min(calc(50% + 540px), calc(100% - var(--splash-width)));
  bottom: 0;
  height: var(--splash-height);
  aspect-ratio: 1044 / 1500;
  opacity: 0.4;
  pointer-events: none;
  /* One mask layer per layout (no mask-composite, no image filters): the fixed art
     is the largest layer on the page, so it stays cheap to paint. The mask clips at
     the art's own box. */
  -webkit-mask-image: linear-gradient(to top, transparent 0, #000 16%);
  mask-image: linear-gradient(to top, transparent 0, #000 16%);
  /* Nothing paints outside the art's box anyway (the mask clips there). */
  contain: paint;
}

.splash picture,
.splash img {
  display: block;
  width: 100%;
  height: 100%;
}

/* The art is colour-graded toward her cape (deep shadows in indigo); the indigo
   glow behind her and a pool of light at her feet set her into the night sky. */
.splash img {
  object-fit: contain;
  object-position: center bottom;
}

/* The glow stays inside the art's box on the right (the mask cuts it there);
   on the left the fade hides it anyway. */
.splash::before {
  content: "";
  position: absolute;
  inset: 6% 0 8% -12%;
  z-index: -1;
  background:
    radial-gradient(closest-side at 56% 34%, rgba(63, 95, 224, 0.46), rgba(154, 160, 242, 0.12) 58%, transparent),
    radial-gradient(closest-side at 50% 100%, rgba(244, 185, 66, 0.08), transparent 70%);
}

.splash::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 4%;
  bottom: 1.5%;
  height: 7%;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(91, 156, 255, 0.34), rgba(63, 95, 224, 0.12) 60%, transparent);
}

.is-home .splash {
  opacity: 1;
  /* Her feet stand on the window's bottom edge, so only the cape side fades. */
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 26%);
  mask-image: linear-gradient(to right, transparent 0, #000 26%);
}

/* Wide screens leave a margin right of the 1240px content, so she can show there;
   the left fade hides the part that still reaches behind the cards. Instead of
   drifting to the window edge, she stays beside the cards with her cape tucked a
   little under them on the start page (the cards are glass there). */
@media (min-width: 1600px) {
  .is-home .splash {
    left: min(calc(50% + 580px - var(--splash-width) * 0.4), calc(100% - var(--splash-width)));
  }

  body:not(.is-home):not(.with-rail) .splash {
    left: min(calc(50% + 620px - var(--splash-width) * 0.24), calc(100% - var(--splash-width)));
    opacity: 0.6;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 30%);
    mask-image: linear-gradient(to right, transparent 0, #000 30%);
  }
}

/* Server settings below 1500px: no ghost behind the forms. A head-and-shoulders
   portrait (a 26 KB file instead of the full art) watches from the top corner and
   fades out before the first cards. */
.with-rail .splash {
  --bust-width: min(440px, 44vw);
  position: absolute;
  top: 64px;
  right: 0;
  left: auto;
  bottom: auto;
  width: var(--bust-width);
  height: auto;
  aspect-ratio: 420 / 429;
  opacity: 0.5;
  /* The portrait's bottom would end in a hard line above the cards, so it fades
     downward (one layer, so the mask stays cheap). */
  -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent 92%);
  mask-image: linear-gradient(to bottom, #000 30%, transparent 92%);
}

.with-rail .splash::before {
  inset: 4% 0 10%;
}

.with-rail .splash::after {
  display: none;
}

/* Wide screens: she stands beside the settings. The content column moves left just
   enough to leave her about 60% of the art's width; her cape tucks under the cards. */
@media (min-width: 1500px) {
  .with-rail {
    --art-height: min(calc(100vh - 64px), 1500px);
    --art-width: calc(var(--art-height) * 1044 / 1500);
    --art-room: calc(var(--art-width) * 0.6);
    --shell-width: min(1240px, calc(100% - var(--art-room)));
    --shell-left: max(0px, calc((100% - var(--shell-width) - var(--art-room)) / 2));
  }

  .with-rail .shell {
    max-width: var(--shell-width);
    margin-left: var(--shell-left);
    margin-right: 0;
  }

  .with-rail .splash {
    position: fixed;
    top: auto;
    bottom: 0;
    right: auto;
    left: calc(var(--shell-left) + var(--shell-width) + var(--art-room) - var(--art-width));
    width: auto;
    height: var(--art-height);
    aspect-ratio: 1044 / 1500;
    opacity: 0.9;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 34%);
    mask-image: linear-gradient(to right, transparent 0, #000 34%);
  }

  .with-rail .splash::before {
    inset: 6% 0 8% -12%;
  }

  .with-rail .splash::after {
    display: block;
  }
}

@keyframes drift {
  from { translate: -4% 0; }
  to { translate: 4% -12px; }
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 40px);
  /* Opaque instead of a blurred glass bar: a backdrop-filter over scrolling content
     re-blurs on every frame. */
  background: #080b1a;
  border-bottom: 1px solid var(--line);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, var(--cape-deep), var(--cape) 22%, transparent 45%, transparent 70%, var(--amber));
  opacity: 0.75;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
}

.brand-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(63, 95, 224, 0.55), 0 0 18px rgba(63, 95, 224, 0.45);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-text strong {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-style: italic;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.brand-text small {
  margin-top: 4px;
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.32em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line-strong);
}

.lang-switch button {
  min-width: 40px;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 700 0.75rem/1 var(--font-mono);
  letter-spacing: 0.1em;
  cursor: pointer;
}

.lang-switch button[aria-pressed="true"] {
  background: var(--amber);
  color: var(--on-amber);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
}

.user-chip img,
.avatar-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--cape);
}

.avatar-fallback {
  display: inline-grid;
  place-items: center;
  background: var(--cape-soft);
  font-weight: 700;
  font-size: 0.8rem;
}

.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Layout */
.shell {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 40px) 48px;
}

.with-rail .shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.page:focus {
  outline: none;
}

.footer {
  padding: 20px 16px 28px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.footer .art-credit {
  margin-top: 4px;
  opacity: 0.75;
  font-size: 0.72rem;
}

/* Panels: the signature cut-corner frame */
.panel {
  position: relative;
  padding: 22px;
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}

.panel::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 64px;
  height: 2px;
  background: linear-gradient(90deg, var(--cape-deep), var(--cape));
}

.panel::after {
  content: "";
  position: absolute;
  right: 20px;
  bottom: 9px;
  width: 30px;
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--amber) 0 4px, transparent 4px 7px);
  opacity: 0.55;
}

.hud-tag {
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.hud-index {
  margin-bottom: 8px;
  color: var(--cape);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
}

.lead {
  max-width: 68ch;
  margin-top: 8px;
  color: var(--muted);
  font-size: 1.02rem;
}

.muted {
  color: var(--muted);
}

.hint {
  color: var(--muted);
  font-size: 0.82rem;
}

.fine-print {
  color: var(--muted);
  font-size: 0.8rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.page-head h1 {
  margin-top: 6px;
}

/* Buttons: slanted parallelograms */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  min-height: 40px;
  padding: 0.7em 1.5em;
  border: 0;
  font: 700 0.85rem/1 var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  transition: transform 0.15s ease, filter 0.15s ease, background-color 0.15s ease;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.btn:focus-visible {
  outline: none;
  background: var(--sky);
  color: #06112a;
}

.btn-primary {
  background: var(--amber);
  color: var(--on-amber);
}

.btn-ghost {
  background: rgba(154, 160, 242, 0.12);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.btn-danger {
  background: rgba(255, 90, 110, 0.16);
  color: #ffd3dc;
  box-shadow: inset 0 0 0 1px rgba(255, 90, 110, 0.5);
}

.btn-small {
  min-height: 36px;
  padding: 0.5em 1.1em;
  font-size: 0.76rem;
}

.btn-large {
  min-height: 52px;
  padding: 1em 2em;
  font-size: 1rem;
}

.discord-glyph {
  width: 22px;
  height: 22px;
}

.button-row,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Flash messages and callouts */
.flashes {
  display: grid;
  gap: 10px;
}

.flash {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(15, 18, 36, 0.92);
  border: 1px solid var(--line);
  border-left: 3px solid var(--sky);
}

.flash-ok { border-left-color: var(--ok); }
.flash-error { border-left-color: var(--danger); }
.flash-warning { border-left-color: var(--warn); }

.flash-mark {
  flex: none;
  width: 8px;
  height: 8px;
  background: currentColor;
  transform: rotate(45deg);
  color: var(--sky);
}

.flash-ok .flash-mark { color: var(--ok); }
.flash-error .flash-mark { color: var(--danger); }
.flash-warning .flash-mark { color: var(--warn); }

.callout {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--sky);
  background: linear-gradient(var(--sky-soft), var(--sky-soft)), var(--bg-raised);
}

.callout p + p {
  margin-top: 6px;
}

.callout-error {
  border-left-color: var(--danger);
  background: linear-gradient(rgba(255, 90, 110, 0.1), rgba(255, 90, 110, 0.1)), var(--bg-raised);
}

.callout-warning {
  border-left-color: var(--warn);
  background: linear-gradient(rgba(245, 163, 64, 0.1), rgba(245, 163, 64, 0.1)), var(--bg-raised);
}

/* Home */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 40px;
  align-items: center;
  padding: clamp(12px, 4vw, 40px) 0;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.display {
  font-size: clamp(2.2rem, 5.6vw, 4.2rem);
  line-height: 0.98;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 22px;
  margin-top: 6px;
}

/* The art itself is the fixed .splash layer; this column keeps it clear and
   carries a character-select nameplate at her feet. */
.hero-visual {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  align-self: stretch;
  min-height: 420px;
}

.nameplate {
  position: relative;
  padding: 14px 18px 12px 26px;
  text-align: right;
  background: linear-gradient(90deg, transparent, rgba(7, 10, 23, 0.72) 30%);
}

.nameplate::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cape-deep) 30%, var(--cape));
}

.nameplate::after {
  content: "";
  position: absolute;
  right: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: var(--amber);
}

.nameplate-role {
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
}

.nameplate-name {
  margin-top: 2px;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 4.4vw, 3.6rem);
  font-style: italic;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-shadow: 0 0 28px rgba(63, 95, 224, 0.75);
}

.nameplate-alt {
  margin-top: 6px;
  color: var(--hair);
  font-size: 0.95rem;
  letter-spacing: 0.3em;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

/* On the start page the cards are glass, so Kokona stays visible behind them. */
.is-home .feature {
  background: linear-gradient(180deg, rgba(23, 30, 60, 0.62), rgba(12, 16, 35, 0.74));
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.feature h2 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.feature p:last-child {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Server list */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.server-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 18px 18px 18px 22px;
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  border: 1px solid var(--line);
  color: var(--text);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.server-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--line-strong);
  transition: background 0.18s ease;
}

.server-card:hover,
.server-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(154, 160, 242, 0.55);
  background: linear-gradient(180deg, rgba(30, 38, 80, 0.95), var(--panel-bottom));
  text-decoration: none;
}

.server-card:hover::before,
.server-card:focus-visible::before {
  background: var(--cape);
}

.server-index {
  position: absolute;
  top: 8px;
  right: 22px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
}

.server-icon {
  width: 56px;
  height: 56px;
  object-fit: cover;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}

.server-initials {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--cape-deep), var(--cape));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}

.server-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.server-meta strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.02rem;
}

.server-go {
  color: var(--amber);
  font-size: 1.3rem;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
}

.badge-cape {
  background: var(--cape-soft);
  color: var(--cape);
}

.badge-sky {
  background: var(--sky-soft);
  color: var(--sky);
}

.empty-state {
  display: grid;
  gap: 12px;
}

.checklist {
  margin: 0;
  padding-left: 1.2em;
  color: var(--muted);
}

.checklist li + li {
  margin-top: 4px;
}

/* Server rail: sticky, and when the window is too short for all sections the section
   list scrolls on its own (the current section is scrolled into view). */
.rail {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: calc(100vh - 104px);
  min-height: 0;
}

.rail-back {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.rail-guild {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rail-guild img,
.rail-guild .server-initials {
  flex: none;
  width: 52px;
  height: 52px;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}

.rail-guild div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}

.rail-guild strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-left: 1px solid var(--line);
}

.rail-nav.can-scroll-down {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
}

.rail-group {
  margin: 12px 0 2px;
  padding: 0 14px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  opacity: 0.75;
}

.rail-group:first-child {
  margin-top: 0;
}

.rail-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rail-nav a:hover {
  color: var(--text);
  text-decoration: none;
  background: rgba(154, 160, 242, 0.06);
}

.rail-nav a[aria-current="page"] {
  color: var(--text);
  background: linear-gradient(90deg, var(--cape-soft), transparent);
}

.rail-nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--cape);
}

.rail-index {
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

/* Overview */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
}

.stat-label {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.stat-value {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
}

.stat-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

/* The online ring is a pseudo-element animated with transform and opacity only, so
   the browser composites it instead of repainting a box-shadow every frame. */
.stat-online .pulse {
  position: relative;
  background: var(--ok);
}

.stat-online .pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(47, 211, 154, 0.6);
  opacity: 0;
  pointer-events: none;
  animation: pulse 2s ease-out infinite;
}

.stat-offline .pulse {
  background: var(--danger);
}

@keyframes pulse {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(3); opacity: 0; }
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.card-grid-wide {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  align-items: start;
}

.nav-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.nav-card:hover,
.nav-card:focus-visible {
  border-color: rgba(154, 160, 242, 0.55);
  transform: translateY(-2px);
  text-decoration: none;
}

.nav-card-wide {
  grid-column: 1 / -1;
}

.nav-card p:not(.hud-index) {
  color: var(--muted);
  font-size: 0.92rem;
}

.facts {
  display: grid;
  gap: 6px;
  margin: 4px 0 0;
}

.facts div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
}

.facts dt {
  color: var(--muted);
  font-size: 0.88rem;
}

.facts dd {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

/* Forms */
.form-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-card form,
.dialog-body form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 420px;
}

.field > span:not(.visually-hidden) {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

select,
input[type="text"],
input[type="number"],
input[type="search"] {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--field);
  color: var(--text);
  font: inherit;
}

select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23f4b942' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
}

select option {
  background: var(--bg-raised);
  color: var(--text);
}

select option:disabled {
  color: #6b7397;
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(91, 156, 255, 0.18);
}

.segmented {
  display: inline-flex;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line-strong);
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.segmented span {
  display: block;
  padding: 10px 18px;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.segmented input:checked + span {
  background: var(--amber);
  color: var(--on-amber);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--sky);
  outline-offset: -2px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.check input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--cape);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.form-card .inline-form,
.dialog-body .inline-form {
  flex-direction: row;
  align-items: flex-end;
}

.inline-form .field {
  flex: 1 1 220px;
  width: auto;
}

.gain-form .field {
  max-width: 260px;
}

form.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

/* Switches */
.switch-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 6px 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.switch-track {
  position: relative;
  flex: none;
  width: 40px;
  height: 20px;
  background: rgba(154, 160, 242, 0.18);
  border: 1px solid var(--line-strong);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  transition: background 0.15s ease;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 6px;
  width: 12px;
  height: 12px;
  background: var(--muted);
  transition: left 0.15s ease, background 0.15s ease;
}

.switch[aria-checked="true"] .switch-track {
  background: var(--cape-soft);
  border-color: var(--cape);
}

.switch[aria-checked="true"] .switch-thumb {
  left: 22px;
  background: var(--cape);
}

.switch[aria-checked="false"] .switch-label {
  color: var(--muted);
}

.family-groups {
  display: grid;
  gap: 22px;
}

.family-group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

/* Destinations */
.destination-list {
  display: grid;
  gap: 4px;
}

.destination {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px dashed var(--line);
}

.destination-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.destination-label small {
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  background: currentColor;
  transform: rotate(45deg);
}

.status-ok {
  color: var(--ok);
}

.status-warning {
  color: var(--warn);
}

/* Chips */
.chip-list,
.grant-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.grant {
  display: inline-flex;
  align-items: stretch;
}

.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 4px 10px;
  background: rgba(154, 160, 242, 0.1);
  border: 1px solid var(--line);
  font-size: 0.88rem;
}

.role-chip small {
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.role-missing {
  color: var(--muted);
  border-style: dashed;
}

.role-dot {
  flex: none;
  width: 10px;
  height: 10px;
}

.chip-remove {
  min-width: 32px;
  border: 1px solid var(--line);
  border-left: 0;
  background: rgba(255, 90, 110, 0.12);
  color: #ffd3dc;
  font-size: 1rem;
  cursor: pointer;
}

.chip-remove:hover {
  background: rgba(255, 90, 110, 0.3);
}

/* Permissions */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-inline {
  max-width: 360px;
}

.command-list {
  display: grid;
  gap: 12px;
}

.command-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 18px 20px;
}

.command-row[hidden] {
  display: none;
}

.command-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
}

.command-head h2 {
  font-size: 1rem;
  text-transform: none;
}

.command-head code {
  color: var(--cape);
  font-size: 1rem;
}

.command-head p {
  color: var(--muted);
  font-size: 0.9rem;
}

.grant-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.grant-form .field {
  flex: 1 1 200px;
  max-width: 300px;
}

/* Repeating rows: "+" adds a row, × removes one (both need JavaScript). */
.multi-form,
.form-card form.multi-form,
.dialog-body form.multi-form {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 10px;
}

.multi {
  display: grid;
  gap: 8px;
}

.multi-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.multi-row .field {
  flex: 1 1 240px;
  width: auto;
  max-width: 420px;
}

.multi-row .field-number {
  flex: 0 1 200px;
}

.multi-row + .multi-row {
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.multi-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

.multi-actions .field {
  flex: 0 1 260px;
  width: auto;
}

.row-remove {
  flex: none;
  width: 40px;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 90, 110, 0.12);
  color: #ffd3dc;
  font-size: 1.1rem;
  cursor: pointer;
}

.row-remove:hover {
  background: rgba(255, 90, 110, 0.3);
}

.btn[hidden],
.row-remove[hidden] {
  display: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Edit views: a head row with the card's state, a field grid, and one action row */
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 16px;
}

.state {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 10px;
  background: rgba(154, 160, 242, 0.1);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}

.state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.state-on {
  background: rgba(47, 211, 154, 0.12);
  color: var(--ok);
}

.state-warn {
  background: rgba(245, 163, 64, 0.12);
  color: var(--warn);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 16px 18px;
  width: 100%;
}

.form-grid .field {
  max-width: none;
}

.field-wide {
  grid-column: 1 / -1;
}

fieldset.field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset.field > legend {
  margin-bottom: 6px;
  padding: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.field-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.counter {
  margin-left: auto;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.counter.is-over {
  color: var(--danger);
}

textarea,
input[type="url"] {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--field);
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 84px;
  line-height: 1.5;
  resize: vertical;
}

textarea:focus,
input[type="url"]:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(91, 156, 255, 0.18);
}

::placeholder {
  color: #6b7397;
  opacity: 1;
}

.color-field {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
}

input[type="color"] {
  width: 64px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--field);
  cursor: pointer;
}

.color-field code {
  color: var(--muted);
  font-size: 0.85rem;
}

.form-card form > .toggle + .toggle,
.dialog-body form > .toggle + .toggle {
  margin-top: -4px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  width: 100%;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.form-actions .hint {
  flex: 1 1 260px;
  margin: 0;
}

.danger-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 90, 110, 0.22);
  background: rgba(255, 90, 110, 0.05);
}

.form-card form.danger-row,
.dialog-body form.danger-row {
  flex-direction: row;
  align-items: center;
}

.danger-row .hint {
  flex: 1 1 240px;
}

.empty-note {
  padding: 14px 16px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
}

/* Switch-style checkboxes (the checkbox itself stays the form control) */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.toggle input {
  position: relative;
  flex: none;
  width: 42px;
  height: 22px;
  margin: 0;
  border: 1px solid var(--line-strong);
  background: rgba(154, 160, 242, 0.16);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.toggle input::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 7px;
  width: 12px;
  height: 12px;
  background: var(--muted);
  transition: left 0.15s ease, background 0.15s ease;
}

.toggle input:checked {
  border-color: var(--cape);
  background: rgba(154, 160, 242, 0.32);
}

.toggle input:checked::before {
  left: 23px;
  background: var(--amber);
}

.toggle input:focus-visible + .toggle-text > span {
  color: var(--sky);
  text-decoration: underline;
}

.toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-text small {
  color: var(--muted);
  font-size: 0.78rem;
}

/* Quick links to a long page's cards */
.jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -8px;
}

.jump a {
  padding: 6px 14px;
  background: rgba(154, 160, 242, 0.08);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}

.jump a:hover,
.jump a:focus-visible {
  background: var(--cape-soft);
  color: var(--text);
  text-decoration: none;
}

[id] {
  scroll-margin-top: 84px;
}

/* Collapsible editors for lists (subscriptions, ticket systems, shop items) */
.editor-list {
  display: grid;
  gap: 10px;
}

/* Each row carries a state stripe on its left edge: green on sale or active, amber
   when something needs a look, grey when hidden. */
.editor {
  position: relative;
  border: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(154, 160, 242, 0.06), rgba(6, 9, 22, 0.5) 42%);
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.editor::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  bottom: -1px;
  width: 3px;
  background: var(--line-strong);
}

.editor:has(> summary .state-on)::before {
  background: var(--ok);
}

.editor:has(> summary .state-warn)::before {
  background: var(--warn);
}

.editor[open] {
  border-color: var(--line-strong);
  background: rgba(6, 9, 22, 0.6);
}

.editor:hover {
  border-color: rgba(154, 160, 242, 0.42);
}

.editor-off .editor-title strong {
  color: var(--muted);
}

.editor > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 14px 18px;
  cursor: pointer;
  list-style: none;
}

.editor > summary::-webkit-details-marker {
  display: none;
}

.editor > summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--amber);
  border-bottom: 2px solid var(--amber);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.editor[open] > summary::after {
  transform: rotate(45deg);
}

.editor > summary:hover {
  background: rgba(154, 160, 242, 0.06);
}

.editor > summary:focus-visible {
  outline-offset: -2px;
}

/* With JavaScript a row opens its editor in a dialog: the arrow becomes an Edit tag. */
.editor.is-sheet > summary::after,
.menu-card.is-sheet > summary::after {
  display: none;
}

.editor-open {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 10px;
  background: rgba(154, 160, 242, 0.1);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--text);
  font: 700 0.72rem/1 var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.editor-open::before {
  content: "";
  width: 12px;
  height: 12px;
  background: var(--amber);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M11.3 1.3a1 1 0 0 1 1.4 0l2 2a1 1 0 0 1 0 1.4L6 13.4 2 14l.6-4z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M11.3 1.3a1 1 0 0 1 1.4 0l2 2a1 1 0 0 1 0 1.4L6 13.4 2 14l.6-4z'/%3E%3C/svg%3E") center / contain no-repeat;
}

summary:hover .editor-open,
summary:focus-visible .editor-open {
  background: var(--amber);
  color: var(--on-amber);
}

summary:hover .editor-open::before,
summary:focus-visible .editor-open::before {
  background: var(--on-amber);
}

.is-editing {
  border-color: var(--cape) !important;
}

/* After a save the edited row glows once. */
.is-flash {
  animation: row-flash 1.8s ease-out;
}

@keyframes row-flash {
  0%,
  35% {
    border-color: var(--amber);
    box-shadow: 0 0 0 3px rgba(244, 185, 66, 0.22), 0 0 26px rgba(244, 185, 66, 0.18);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(244, 185, 66, 0);
  }
}

.editor-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.editor-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
}

.editor-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.editor-meta > span {
  padding: 1px 8px;
  background: rgba(154, 160, 242, 0.07);
  border: 1px solid rgba(154, 160, 242, 0.1);
}

/* Role menus: one collapsible card per menu. */
.menu-card > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin: -4px 0;
  cursor: pointer;
  list-style: none;
}

.menu-card > summary::-webkit-details-marker {
  display: none;
}

.menu-card > summary strong {
  flex: 1 1 220px;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

.menu-card > summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--amber);
  border-bottom: 2px solid var(--amber);
  transform: rotate(45deg);
}

.menu-card[open] > summary {
  margin-bottom: 4px;
}

.menu-card:not([open]) {
  gap: 0;
}

.menu-card.is-sheet:hover {
  border-color: rgba(154, 160, 242, 0.42);
}

.editor-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px 16px;
  border-top: 1px dashed var(--line);
}

/* Role checklists */
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr));
  gap: 2px 14px;
  max-height: 228px;
  padding: 8px 12px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  background: var(--field);
}

.check-grid label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 32px;
  cursor: pointer;
}

.check-grid input {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--cape);
}

.check-grid span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Simple row lists (banners) */
.row-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.row-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 12px 0;
  border-top: 1px dashed var(--line);
}

.row-main {
  display: flex;
  flex: 1 1 220px;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.row-main small {
  color: var(--muted);
}

.token-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.token-list .hint {
  margin-right: 4px;
}

.token {
  padding: 3px 8px;
  border: 1px solid transparent;
  background: rgba(154, 160, 242, 0.1);
  color: var(--cape);
  font-size: 0.78rem;
  cursor: pointer;
}

.token:hover,
.token:focus-visible {
  border-color: var(--cape);
  background: var(--cape-soft);
}

/* Welcome editor with a live preview beside it */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.preview-card {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.embed-preview {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr);
  overflow: hidden;
  border-radius: 4px;
  background: #2b2d31;
  color: #dbdee1;
}

.embed-bar {
  display: block;
  width: 4px;
  height: 100%;
}

.embed-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px 14px;
}

.embed-text {
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.embed-image {
  display: grid;
  place-items: center;
  min-height: 110px;
  border: 1px dashed rgba(219, 222, 225, 0.25);
  color: #949ba4;
  font-size: 0.8rem;
}

/* Tables. The wrapper is positioned so hidden labels inside a scrolled table stay
   inside it instead of widening the page. */
.table-wrap {
  position: relative;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-align: left;
  text-transform: uppercase;
}

.data-table td {
  padding: 10px;
  border-bottom: 1px dashed var(--line);
  vertical-align: middle;
}

.numeric {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-actions {
  text-align: right;
}

/* Error pages */
.error-panel {
  display: grid;
  gap: 12px;
  max-width: 640px;
}

body.fatal {
  display: grid;
  place-items: center;
  padding: 16px;
}

.fatal-card {
  max-width: 560px;
  padding: 28px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--danger);
}

.fatal-card h1 {
  margin: 8px 0 12px;
}

/* Responsive */
@media (max-width: 1000px) {
  .stat-grid,
  .feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .with-rail .shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .rail {
    position: static;
  }

  .rail-group {
    display: none;
  }

  .split {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview-card {
    position: static;
  }

  .rail-nav {
    flex-direction: row;
    overflow-x: auto;
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }

  .rail-nav a {
    flex: none;
  }

  .rail-nav a[aria-current="page"]::before {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: -1px;
    width: auto;
    height: 3px;
  }
}

@media (max-width: 760px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-visual {
    display: none;
  }

  /* On phones she stands behind the text, so the art steps back further. */
  .splash {
    --splash-height: min(calc(100vh - 70px), 760px);
    left: auto;
    right: -18vw;
  }

  .is-home .splash {
    opacity: 0.3;
  }

  .card-grid,
  .destination {
    grid-template-columns: minmax(0, 1fr);
  }

  .user-name,
  .brand-text small {
    display: none;
  }
}

@media (max-width: 520px) {
  .stat-grid,
  .feature-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar {
    gap: 8px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .user-chip {
    display: none;
  }

  .brand-text strong {
    font-size: 1.1rem;
  }
}

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

/* Statistics page: server-drawn SVG charts. Colours come from the theme variables. */
.period-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.period-link {
  padding: 6px 16px;
  background: rgba(154, 160, 242, 0.08);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}

.period-link:hover,
.period-link:focus-visible,
.period-link.is-current {
  background: var(--cape-soft);
  color: var(--text);
  text-decoration: none;
}

.period-link.is-current {
  box-shadow: inset 0 0 0 1px var(--cape);
}

.stats-tiles {
  margin-top: 4px;
}

.delta-up {
  color: var(--ok);
}

.delta-down {
  color: var(--warn);
}

.chart-stack,
.chart-pair {
  display: grid;
  gap: 14px;
}

.chart-pair {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-card {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.chart-card h2 {
  font-size: 1.05rem;
}

.chart-figure {
  display: grid;
  gap: 6px;
  margin: 0;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-bar {
  fill: var(--cape);
}

.chart-bar:hover {
  fill: var(--sky);
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-baseline {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.chart-tick,
.chart-axis-title {
  fill: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.chart-axis-title {
  letter-spacing: 0.06em;
}

.chart-table > summary {
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* Only the long day-by-day tables scroll; the seven weekdays always fit whole. */
.chart-table .table-capped {
  max-height: 340px;
  overflow: auto;
}

.data-table th[scope="row"] {
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
  letter-spacing: normal;
  text-transform: none;
}

.stats-subtitle {
  margin-top: 8px;
}

.quest-card {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.quest-tasks {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.quest-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.quest-bar {
  width: 100%;
  height: 10px;
  accent-color: var(--cape);
}

@media (max-width: 1000px) {
  .chart-pair {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Role menu options inside a menu card */
.panel-sub {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: rgba(6, 9, 22, 0.42);
}

.panel-sub > p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.btn-danger-solid {
  background: var(--danger);
  color: #1d0207;
}

/* Dialogs: the confirmation and the list editors. Both live in the top layer, dim the
   page, close with Escape or a click outside, and scroll inside when the window is short. */
.dialog {
  width: min(760px, calc(100vw - 32px));
  max-width: none;
  max-height: min(calc(100vh - 48px), 960px);
  max-height: min(calc(100dvh - 48px), 960px);
  margin: auto;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  color: var(--text);
}

.dialog[open] {
  display: flex;
  animation: dialog-in 0.18s ease-out;
}

.dialog::backdrop {
  background: rgba(3, 5, 14, 0.72);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.dialog[open]::backdrop {
  animation: backdrop-in 0.18s ease-out;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
}

.dialog-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  max-height: 100%;
  margin: 0;
  background: linear-gradient(180deg, rgba(25, 32, 66, 0.98), rgba(11, 15, 33, 0.99));
  border: 1px solid var(--line-strong);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(63, 95, 224, 0.15);
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}

.dialog-frame::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 96px;
  height: 2px;
  background: linear-gradient(90deg, var(--cape-deep), var(--cape));
}

.dialog-head {
  display: flex;
  flex: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 14px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(63, 95, 224, 0.14), transparent 60%);
}

.dialog-head h2 {
  margin-top: 6px;
  font-size: 1.35rem;
  font-style: italic;
}

.dialog-title {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  min-width: 0;
}

.dialog-title .editor-title {
  flex: 1 1 260px;
}

.dialog-title .editor-title strong,
.dialog-title > strong {
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 0.03em;
  white-space: normal;
}

.dialog-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: -4px -6px 0 0;
  border: 1px solid var(--line-strong);
  background: rgba(154, 160, 242, 0.08);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.dialog-close::before,
.dialog-close::after {
  content: "";
  grid-area: 1 / 1;
  width: 16px;
  height: 2px;
  background: currentColor;
  transform: rotate(45deg);
}

.dialog-close::after {
  transform: rotate(-45deg);
}

.dialog-close:hover {
  background: rgba(255, 90, 110, 0.2);
  color: #ffd3dc;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 20px 22px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dialog-body > .editor-body {
  padding: 0;
  border: 0;
  gap: 18px;
}

.dialog-body h3 {
  margin-top: 4px;
}

.dialog-text {
  padding: 18px 22px 4px;
  color: var(--text);
  font-size: 1rem;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 22px 22px;
}

.dialog-confirm {
  width: min(480px, calc(100vw - 32px));
}

.dialog-confirm .dialog-frame {
  border-color: rgba(255, 90, 110, 0.4);
}

.dialog-confirm .dialog-frame::before {
  background: linear-gradient(90deg, var(--danger), rgba(255, 90, 110, 0.3));
}

.dialog-confirm .hud-tag {
  color: #ff9aa8;
}

/* Ranges: a slider with a small number box. The box stays the real field. */
.range {
  --fill: 0%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "slider number"
    "scale .";
  align-items: center;
  gap: 0 14px;
  width: 100%;
}

.range .range-number {
  grid-area: number;
  width: calc(var(--digits, 4) * 1ch + 28px);
  min-width: 68px;
  padding: 8px 10px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  -moz-appearance: textfield;
  appearance: textfield;
}

.range .range-number::-webkit-outer-spin-button,
.range .range-number::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.range-slider {
  grid-area: slider;
  width: 100%;
  height: 30px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.range-slider:focus {
  outline: none;
}

.range-slider::-webkit-slider-runnable-track {
  height: 6px;
  background: linear-gradient(90deg, var(--cape-deep), var(--cape) var(--fill), rgba(154, 160, 242, 0.16) var(--fill));
  box-shadow: inset 0 0 0 1px rgba(154, 160, 242, 0.12);
}

.range-slider::-moz-range-track {
  height: 6px;
  background: rgba(154, 160, 242, 0.16);
}

.range-slider::-moz-range-progress {
  height: 6px;
  background: linear-gradient(90deg, var(--cape-deep), var(--cape));
}

.range-slider::-webkit-slider-thumb {
  width: 18px;
  height: 22px;
  margin-top: -8px;
  border: 0;
  background: var(--amber);
  clip-path: polygon(35% 0, 100% 0, 65% 100%, 0 100%);
  transition: transform 0.12s ease;
  -webkit-appearance: none;
  appearance: none;
}

.range-slider::-moz-range-thumb {
  width: 18px;
  height: 22px;
  border: 0;
  border-radius: 0;
  background: var(--amber);
  clip-path: polygon(35% 0, 100% 0, 65% 100%, 0 100%);
}

.range-slider:hover::-webkit-slider-thumb,
.range:focus-within .range-slider::-webkit-slider-thumb {
  transform: scale(1.12);
}

.range:focus-within .range-slider::-webkit-slider-runnable-track {
  box-shadow: inset 0 0 0 1px rgba(91, 156, 255, 0.5);
}

.range.is-empty .range-slider::-webkit-slider-thumb {
  background: var(--muted);
}

.range.is-empty .range-slider::-moz-range-thumb {
  background: var(--muted);
}

.range-scale {
  grid-area: scale;
  display: flex;
  justify-content: space-between;
  margin-top: -2px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  opacity: 0.8;
}

/* Strips that scroll sideways fade at the edge that has more to show. */
.can-scroll-right {
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent);
}

.can-scroll-left {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 44px);
  mask-image: linear-gradient(90deg, transparent, #000 44px);
}

.can-scroll-left.can-scroll-right {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 44px, #000 calc(100% - 44px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 44px, #000 calc(100% - 44px), transparent);
}

/* NovaQ: the section's own tab bar, filters, pager, match and player views. */
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: -6px;
  border-bottom: 1px solid var(--line-strong);
}

.subtabs + .jump {
  margin-top: 0;
}

.subtabs a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 18px;
  background: linear-gradient(180deg, rgba(154, 160, 242, 0.07), rgba(154, 160, 242, 0.02));
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px);
}

.subtabs a:hover,
.subtabs a:focus-visible {
  background: var(--cape-soft);
  color: var(--text);
  text-decoration: none;
}

.subtabs a[aria-current="page"] {
  background: linear-gradient(180deg, rgba(154, 160, 242, 0.2), rgba(154, 160, 242, 0.06));
  color: var(--text);
}

.subtabs a[aria-current="page"]::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--amber);
  box-shadow: 0 0 12px rgba(244, 185, 66, 0.55);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 14px;
}

.filter-bar .field {
  flex: 1 1 160px;
  min-width: 0;
}

.filter-bar .field-wide {
  flex-basis: 260px;
}

.filter-bar .btn,
.filter-bar .form-actions {
  flex: none;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.pager a,
.pager .is-disabled {
  padding: 6px 16px;
  background: rgba(154, 160, 242, 0.08);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--muted);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}

.pager a:hover,
.pager a:focus-visible {
  background: var(--cape-soft);
  color: var(--text);
  text-decoration: none;
}

.pager .is-disabled {
  opacity: 0.4;
}

.team-a {
  --team: var(--sky);
  --team-soft: var(--sky-soft);
}

.team-b {
  --team: var(--amber);
  --team-soft: rgba(244, 185, 66, 0.1);
}

.teams {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.team {
  min-width: 0;
  padding: 14px 16px;
  background: linear-gradient(180deg, var(--team-soft, var(--cape-soft)), transparent 70%);
  border-top: 2px solid var(--team, var(--cape));
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
}

.team > :first-child {
  margin-top: 0;
}

.team h3,
.team h4 {
  color: var(--team, var(--text));
}

/* Inline team marks (a team's names in a table row) take the team colour. */
:not(.team).team-a,
:not(.team).team-b {
  color: var(--team);
}

td .team,
.data-table .team {
  padding: 0;
  background: none;
  border: 0;
  clip-path: none;
}

.kda,
.mmr-delta {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mmr-delta.is-up {
  color: var(--ok);
}

.mmr-delta.is-down {
  color: var(--danger);
}

.player-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.player-head h2,
.player-head h3 {
  margin: 0;
  font-size: 1.6rem;
}

.player-head code,
.player-head .muted {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* Match detail: the facts as a compact grid instead of a long two-column table. */
.fact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1px;
  margin: 4px 0 0;
  background: var(--line);
  box-shadow: inset 0 0 0 1px var(--line);
}

.fact-grid > div {
  min-width: 0;
  padding: 10px 14px;
  background: rgba(8, 11, 26, 0.72);
}

.fact-grid dt {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.fact-grid dd {
  margin: 4px 0 0;
  font-weight: 600;
}

/* A second line under a table cell's main value (a date, a map, an ID). */
.cell-sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.match-id {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}

.score {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.team-names > span {
  display: block;
}

.team-names > span + span {
  margin-top: 2px;
}

.match-table th[scope="row"] {
  white-space: nowrap;
}

.teams-stacked {
  grid-template-columns: minmax(0, 1fr);
}

.roster-table abbr {
  text-decoration: none;
  cursor: help;
}

.roster-table th[scope="row"] {
  min-width: 180px;
}

.roster-table .mmr-delta {
  display: block;
  margin-top: 2px;
}

.chip-mode {
  display: inline-block;
  padding: 2px 8px;
  background: var(--cape-soft);
  color: var(--cape);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
}

/* Phones and small windows */
@media (max-width: 1000px) {
  .rail {
    max-height: none;
  }

  .rail-nav {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .rail-nav::-webkit-scrollbar {
    display: none;
  }

  .rail-nav a {
    min-height: 44px;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 10px 14px;
    background: rgba(8, 11, 26, 0.95);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .is-home .feature {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: linear-gradient(180deg, rgba(23, 30, 60, 0.8), rgba(12, 16, 35, 0.88));
  }

  .with-rail .splash {
    --bust-width: min(300px, 64vw);
    top: 60px;
    opacity: 0.38;
  }

  /* Quick links become one sideways strip instead of several wrapped rows. */
  .jump {
    flex-wrap: nowrap;
    margin-right: calc(-1 * clamp(16px, 4vw, 40px));
    padding-right: 24px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .jump::-webkit-scrollbar {
    display: none;
  }

  .jump a {
    flex: none;
  }

  /* The NovaQ tabs become one sideways strip, and the two teams stack. */
  .subtabs {
    flex-wrap: nowrap;
    margin-right: calc(-1 * clamp(16px, 4vw, 40px));
    padding-right: 24px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .subtabs::-webkit-scrollbar {
    display: none;
  }

  .subtabs a {
    flex: none;
    min-height: 44px;
    padding: 0 14px;
  }

  .teams {
    grid-template-columns: minmax(0, 1fr);
  }

  .page {
    gap: 18px;
  }

  .data-table {
    font-size: 0.9rem;
  }

  .data-table th,
  .data-table td {
    padding: 8px;
  }

  /* The dialog becomes a sheet that slides up from the bottom edge. */
  .dialog-sheet {
    width: 100vw;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    margin: auto 0 0;
  }

  .dialog-sheet[open] {
    animation: sheet-in 0.22s ease-out;
  }

  .dialog-sheet .dialog-frame {
    border-right: 0;
    border-left: 0;
    border-bottom: 0;
    clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 0 100%);
  }

  .dialog-head {
    padding: 14px 16px 12px 18px;
  }

  .dialog-body {
    padding: 16px 16px 28px;
  }

  .dialog-text,
  .dialog-actions {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

@media (max-width: 560px) {
  :root {
    --cut: 10px;
  }

  .panel {
    padding: 18px 16px;
  }

  .editor > summary {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 12px 12px 12px 15px;
  }

  .editor-title {
    grid-column: 1 / -1;
  }

  .editor > summary > .state {
    justify-self: start;
  }

  .editor-body {
    padding: 12px;
  }

  .form-actions .btn-primary {
    flex: 1 1 100%;
  }

  .dialog-actions .btn {
    flex: 1 1 140px;
  }

  .range {
    gap: 0 10px;
  }

  .filter-bar .field,
  .filter-bar .field-wide {
    flex-basis: 100%;
  }

  .filter-bar .btn {
    flex: 1 1 100%;
  }

  .player-head h2,
  .player-head h3 {
    font-size: 1.3rem;
  }

  .fact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Long values (a ban with its end, a default MMR note) wrap instead of widening the page. */
  .facts dd {
    min-width: 0;
    white-space: normal;
    text-align: right;
  }

  .fact-grid > div {
    padding: 8px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dialog[open],
  .dialog[open]::backdrop,
  .is-flash {
    animation: none !important;
  }
}

/* Christmas: the advent day preview (question, four choices, the correct one marked). */
.advent-preview {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--cape-soft);
}

.advent-question {
  margin: 4px 0 10px;
  font-weight: 600;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.advent-choices {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.advent-choices li {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.advent-choices li.is-correct {
  border-color: var(--sky);
  background: var(--sky-soft);
}

.advent-preview + .facts dd a {
  overflow-wrap: anywhere;
}

/* Announcements: the list excerpt and the post preview (embed card or plain text, with the ping line). */
.announcement-excerpt {
  max-width: 36ch;
  overflow-wrap: anywhere;
}

.announcement-preview {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.announcement-ping {
  margin: 0 0 8px;
  color: var(--sky);
  font-weight: 600;
}

.announcement-embed {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid #f2c94c;
  border-radius: 6px;
  background: var(--cape-soft);
}

.announcement-embed-title {
  margin: 0 0 6px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.announcement-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Strinova builds: the stage pickers and the stored stage list. */
.build-stage-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 10px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.build-stage-summary {
  margin: 0 0 12px;
  padding-left: 1.4em;
  overflow-wrap: anywhere;
}

.banner-skin-filter {
  margin-bottom: 6px;
}
