/* ============================================================================
   WIGANTARA CTF for CTFd
   core.css: tokens, base, paper engine, chrome, controls, tables
   Direction: DESIGN.md · Persona 5 cut-paper ransom note
   ENERGY 3 / RHYTHM 3 / MOTION 3
   ========================================================================= */

/* --- 1. Tokens ----------------------------------------------------------- */

:root {
  color-scheme: dark;

  --ink-void:   #0B0B0D;
  --ink-panel:  #141416;
  --ink-raise:  #1D1D21;
  --ink-line:   #2A2A30;

  /* Form fields. Dark: inset black on a dark card. Light: warm sand inset on a
     cream card, never pure white, so profile / token / search fields read as
     recessed paper rather than a white box colliding with the dark theme. */
  --field-bg:       #141416;
  --field-bg-focus: #1D1D21;
  --field-border:   #2A2A30;

  /* Hard offset shadows. Dark: black ink. Light: warm ink at low alpha so the
     cut-paper shadow stays but does not dirty the beige ground. */
  --shadow:      rgb(11 11 13 / 0.55);
  --shadow-soft: rgb(11 11 13 / 0.35);

  --paper:      #F2EDE3;
  --paper-2:    #E4DCCB;
  --paper-3:    #D2C8B4;
  /* Fixed collage tokens. The ransom-note rhythm depends on dark scraps sitting
     next to light scraps; if those inverted with the theme the whole effect
     would collapse to a single tone. Paper keeps its colour, ink keeps its
     colour, and only the page ground behind them changes. */
  --paper-fixed:   #F2EDE3;
  --paper-fixed-2: #E4DCCB;
  --scrap-dark:    #141416;
  --scrap-dark-2:  #1D1D21;
  --acid-fill:     #F2E205;

  --static-ink:   #16161A; /* always-dark text for always-light surfaces */
  --crimson:      #E4002B; /* fills: white text on this is 4.85:1 */
  --crimson-text: #FF4D62; /* small text on dark ground: 5.2:1, #E4002B is only 3.8 */
  --crimson-deep: #A8001F;
  --acid:         #F2E205;

  --bone:   #F2EDE3;
  --smoke:  #9A958C;
  --ash:    #8B857B;

  /* semantic state: used as a stamp, always with a word */
  --ok:      #4FD98A;
  --ok-wash: #10231A;
  --bad:     #FF5A5A;
  --bad-wash:#26100F;
  --warn:    #F2C14E;
  --warn-wash:#241C0C;

  --col: 1120px;
  --gut: 26px;

  --font-display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --font-body:    "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, monospace;

  --snap: cubic-bezier(.22, 1, .36, 1);
  --snap-fast: 170ms;
  --snap-mid: 280ms;
  --snap-slow: 380ms;

  --nav-h: 66px;

  /* fixed rotation set: cards and scraps pick from these, so nothing looks
     randomly generated while still looking hand-placed */
  --rot-1: -1.4deg;
  --rot-2:  1.1deg;
  --rot-3: -0.7deg;
  --rot-4:  1.8deg;
  --rot-5: -2.1deg;
}

/* Light mode keeps the same structure but inverts paper and ink. The collage
   reads as evidence photographed on a light table. Four distinct warm tones
   (ground < field < card < focus) keep every surface separated without ever
   using pure white, so light never collides with dark: dark is black ink on
   black ground, light is warm ink on warm paper. */
html[data-bs-theme="light"] {
  color-scheme: light;

  --ink-void:   #E8E0CD;
  --ink-panel:  #F5F0E3;
  --ink-raise:  #EDE6D3;
  --ink-line:   #C4B896;

  --field-bg:       #EDE6D3;
  --field-bg-focus: #FAF6EB;
  --field-border:   #9A8B6E;

  --shadow:      rgb(22 22 26 / 0.20);
  --shadow-soft: rgb(22 22 26 / 0.12);

  --paper:      #16161A;
  --paper-2:    #1E1E23;
  --paper-3:    #2A2A31;

  --bone:   #16161A;
  --smoke:  #5C574E;
  --ash:    #635F57;

  --crimson:      #C4001F;
  --crimson-text: #B0001B;
  --static-ink:   #16161A;
  --crimson-deep: #910017;
  --acid:         #5E5400; /* code/accent text: 5.99 on the light ground */

  --ok:      #107040;
  --ok-wash: #E4F3EA;
  --bad:     #B21010;
  --bad-wash:#FBE7E5;
  --warn:    #7A5A00;
  --warn-wash:#F8F0DC;
}

/* --- 2. Base ------------------------------------------------------------- */

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

/* Native scrolling. scroll-padding-top keeps anchor targets clear of the
   sticky nav without any JS offset maths; smooth behaviour is opt-in and is
   removed again for reduced motion further down this file. */
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
  /* the off-canvas drawer sits outside the viewport by design; clip stops it
     widening the scrollable area. `clip` rather than `hidden` so sticky still
     works and no scroll container is created. */
  overflow-x: clip;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ink-void);
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body > main { flex: 1 0 auto; position: relative; z-index: 1; }

h1, h2, h3, h4 {
  margin: 0 0 0.45em;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.01em;
  color: var(--bone);
}

h1 { font-size: clamp(2rem, 1.4rem + 3.4vw, 3.5rem); }
h2 { font-size: clamp(1.375rem, 1.1rem + 1.5vw, 2rem); }
h3 { font-size: 1.0625rem; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--crimson-text); text-decoration: none; text-underline-offset: 0.18em; }
a:hover { text-decoration: underline; }

img, svg, video { max-width: 100%; height: auto; }

hr { height: 0; margin: 1.5rem 0; border: 0; border-top: 1px solid var(--ink-line); opacity: 1; }

::selection { background: var(--crimson); color: #fff; }

:focus-visible {
  outline: 3px solid var(--acid) !important;
  outline-offset: 2px;
}
html[data-bs-theme="light"] :focus-visible { outline-color: var(--crimson) !important; }

a[href], button, summary, select, label[for],
input[type="checkbox"], input[type="radio"], input[type="submit"],
input[type="button"], input[type="reset"],
[role="button"], [role="tab"], [role="switch"] { cursor: pointer; }

button:disabled, input:disabled, select:disabled, textarea:disabled,
.btn.disabled, [aria-disabled="true"] { cursor: not-allowed; }

/* --- 3. Layout ----------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--col);
  margin-inline: auto;
  padding-inline: var(--gut);
}

.wg-section {
  position: relative;
  padding-block: clamp(52px, 6.5vw, 96px);
}

/* Section boundaries are cut at an angle, never square. Alternating direction
   stops the page from reading as a stack of identical slabs. */
.wg-cut-top::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: -1px;
  height: 34px;
  background: var(--ink-void);
  clip-path: polygon(0 0, 100% 0, 100% 42%, 0 100%);
  pointer-events: none;
  z-index: 2;
}
.wg-cut-top--alt::before { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 42%); }

/* --- 4. Paper engine ----------------------------------------------------- */

/* A scrap is a cut piece of paper: solid tone, hard edge, optional 1px ink
   border, optional torn edge. Rotation comes from a fixed set, never random. */
.wg-scrap {
  position: relative;
  background: var(--paper-fixed);
  color: var(--static-ink);
  border: 2px solid #0B0B0D;
  border: 1px solid #16161A;
}
.wg-scrap--dark {
  background: var(--scrap-dark);
  color: var(--paper-fixed);
  border-color: #0B0B0D;
}
.wg-scrap--alt { background: var(--paper-fixed-2); }

.wg-rot-1 { transform: rotate(var(--rot-1)); }
.wg-rot-2 { transform: rotate(var(--rot-2)); }
.wg-rot-3 { transform: rotate(var(--rot-3)); }
.wg-rot-4 { transform: rotate(var(--rot-4)); }
.wg-rot-5 { transform: rotate(var(--rot-5)); }

/* Torn bottom edge, CSS only. Two tones so a light scrap over dark ground
   still shows the tear. */
.wg-torn::after {
  content: "";
  position: absolute;
  inset-inline: -1px;
  bottom: -7px;
  height: 8px;
  background: inherit;
  border-bottom: 1px solid currentColor;
  clip-path: polygon(
    0 0, 4% 62%, 8% 0, 13% 74%, 18% 0, 23% 58%, 28% 0, 34% 82%, 39% 0,
    45% 66%, 50% 0, 56% 78%, 61% 0, 67% 58%, 72% 0, 78% 72%, 83% 0,
    89% 62%, 94% 0, 100% 70%, 100% 0
  );
  opacity: 0.9;
  pointer-events: none;
}

/* Halftone: printing ink on the ground. Density is low on purpose. */
.wg-halftone {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(currentColor 1.1px, transparent 1.2px);
  background-size: 7px 7px;
  opacity: 0.10;
  color: var(--bone);
}
.wg-halftone--fine { background-size: 5px 5px; opacity: 0.07; }
.wg-halftone--acid { color: var(--acid); opacity: 0.10; }

/* Skewed band: the single loudest structural gesture. Text inside is
   counter-skewed so it stays level and readable. */
.wg-band {
  position: relative;
  display: inline-block;
  padding: 9px 22px 9px 18px;
  background: var(--crimson);
  color: #fff;
  transform: skewX(-9deg);
  border: 2px solid #0B0B0D;
}
.wg-band > * { display: inline-block; transform: skewX(9deg); }
.wg-band--dark { background: var(--scrap-dark); color: var(--paper-fixed); border-color: #0B0B0D; }

/* --- 5. Cut-burst icon -------------------------------------------------- */

/* Four thin angular triangles radiating from a point. Replaces a sparkle:
   same burst energy at the same moments, drawn as a cut, not as a star glyph. */
.wg-burst {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: none;
  vertical-align: -0.1em;
  color: var(--crimson);
}
.wg-burst svg { display: block; width: 100%; height: 100%; }
.wg-burst--acid { color: var(--acid); }
.wg-burst--paper { color: var(--bone); }

/* --- 6. Navigation ------------------------------------------------------ */

.wg-nav {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--ink-void);
  border-bottom: 2px solid #0B0B0D;
}

.wg-nav__slab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--nav-h);
  padding-inline: calc(var(--gut) - 6px);
  margin-inline: calc(var(--gut) * -1 + var(--gut) * 0.5);
  isolation: isolate;
}
.wg-nav__slab::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--crimson);
  /* Cut on both vertical edges, mirrored: the slab is full width at the top and
     tapers 26px on each side at the bottom. The two edges lean toward each
     other rather than running parallel, so it reads as a slanted banner rather
     than a sheared rectangle. */
  clip-path: polygon(0 0, 100% 0, calc(100% - 26px) 100%, 26px 100%);
  z-index: -1;
}

.wg-brand {
  display: inline-flex;
  align-items: center;
  height: 38px;
  /* clears the angled left edge of the slab */
  padding: 0 12px 0 20px;
  margin-right: 6px;
  color: #fff;
  text-decoration: none;
  flex: 0 1 auto;      /* may shrink; the tool row has priority */
}
.wg-brand:hover { text-decoration: none; }
.wg-brand img {
  width: 34px; height: 34px;
  display: block;
  background: #0B0B0D;
  border: 1px solid #0B0B0D;
  padding: 1px;
}
.wg-brand__txt { display: flex; flex-direction: column; line-height: 1.02; }
.wg-brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
/* the brand is the flex item that gives way when the bar is tight */
.wg-brand { min-width: 0; }
.wg-brand__sub {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #FFFFFF;
}

.wg-nav__links { display: flex; align-items: center; gap: 2px; }

/* Left-hand links are built to the same spec as the right-hand tool buttons:
   one fixed height, squared corners, an ink hover chip, and the same icon size.
   Previously they were wider, letterspaced caps with an underline active
   marker, which made the two halves of the bar look like two different bars. */
.wg-nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 12px;
  border: 2px solid transparent;
  color: rgb(255 255 255 / 0.94);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  text-decoration: none;
  transition: color var(--snap-fast) linear, background-color var(--snap-fast) linear,
              border-color var(--snap-fast) linear;
}
.wg-nav__link i { font-size: 0.75rem; opacity: 0.95; }
.wg-nav__link:hover {
  color: #fff;
  background: rgb(11 11 13 / 0.22);
  border-color: rgb(11 11 13 / 0.32);
  text-decoration: none;
}
/* active: a solid ink chip, the same weight as a pressed tool button */
.wg-nav__link.is-active {
  background: #0B0B0D;
  border-color: #0B0B0D;
  color: #fff;
}
.wg-nav__link.is-active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -2px;
  height: 3px;
  background: var(--acid-fill);
}
.wg-nav__link.is-active { color: #fff; }
.wg-nav__link.is-active::after {
  content: "";
  position: absolute;
  inset-inline: 8px;
  bottom: 1px;
  height: 3px;
  background: #0B0B0D;
}

.wg-nav__spacer { flex: 1 1 auto; min-width: 0; }
/* The tool row takes the space it needs and no less; the brand is what gives
   way. Without this the two halves fought each other and the page scrolled
   sideways on a phone. The right padding keeps every tool button fully inside
   the crimson slab at all heights, so a hover chip never paints outside the
   navbar over the page ground. */
.wg-nav__tools { display: flex; align-items: center; gap: 3px; flex: none; padding-right: 12px; }

.wg-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  flex: none;
  border: 1px solid transparent;
  background: transparent;
  color: #fff;
  font-size: 0.875rem;
  transition: background-color var(--snap-fast) linear, border-color var(--snap-fast) linear,
              box-shadow var(--snap-fast) linear;
}
.wg-icon:hover {
  background: rgb(11 11 13 / 0.30);
  border-color: rgb(11 11 13 / 0.45);
  box-shadow: inset 0 0 0 1px rgb(11 11 13 / 0.18);
}

.wg-account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid rgb(0 0 0 / 0.55);
  background: rgb(0 0 0 / 0.24);
  color: #fff;
  text-decoration: none;
  transition: background-color var(--snap-fast) linear;
}
.wg-account:hover { background: rgb(0 0 0 / 0.42); text-decoration: none; }
.wg-account__av {
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  background: #0B0B0D;
  color: var(--paper-fixed);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
}
.wg-account__meta { display: flex; flex-direction: column; line-height: 1.15; }
.wg-account__name {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  max-width: 15ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wg-account__score { font-family: var(--font-mono); font-size: 0.5625rem; color: rgb(255 255 255 / 0.7); }

.wg-burger { display: none; }

/* drawer */
.wg-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(330px, 88vw);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 18px;
  background: var(--ink-panel);
  border-left: 3px solid var(--crimson);
  transform: translateX(101%);
  visibility: hidden;
  overflow-y: auto;
  /* visibility flips at the END of a close, and immediately on open, so the
     drawer is focusable the moment it starts sliding in. */
  transition: transform var(--snap-mid) var(--snap), visibility 0s linear var(--snap-mid);
}
.wg-drawer.is-open {
  transform: none;
  visibility: visible;
  transition: transform var(--snap-mid) var(--snap), visibility 0s linear 0s;
}
.wg-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -18px -18px 12px;
  padding: 14px 16px;
  background: var(--crimson);
}
.wg-drawer__label {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
}
.wg-drawer a {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 46px;
  padding: 10px 12px;
  border-left: 3px solid transparent;
  color: var(--bone);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background-color var(--snap-fast) linear, border-color var(--snap-fast) linear;
}
.wg-drawer a:hover { background: var(--ink-raise); border-left-color: var(--crimson); text-decoration: none; }
.wg-drawer a i { width: 18px; color: var(--crimson); font-size: 0.8125rem; text-align: center; }
.wg-drawer a.is-active { background: var(--ink-raise); border-left-color: var(--crimson); }

.wg-scrim {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgb(11 11 13 / 0.72);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--snap-mid) linear, visibility 0s linear var(--snap-mid);
}
.wg-scrim.is-open { opacity: 1; visibility: visible; transition: opacity var(--snap-mid) linear, visibility 0s linear 0s; }

/* --- 7. Buttons --------------------------------------------------------- */

.btn {
  --btn-bg: transparent;
  --btn-fg: var(--bone);
  --btn-bd: var(--bone);
  /* Map Bootstrap's button variables onto our tokens so main.css never paints
     its default #0d6efd / #0b5ed7 blue on hover, focus, or active. */
  --bs-btn-bg: var(--btn-bg);
  --bs-btn-color: var(--btn-fg);
  --bs-btn-border-color: var(--btn-bd);
  --bs-btn-hover-bg: var(--btn-bg);
  --bs-btn-hover-color: var(--btn-fg);
  --bs-btn-hover-border-color: var(--btn-bd);
  --bs-btn-active-bg: var(--btn-bg);
  --bs-btn-active-color: var(--btn-fg);
  --bs-btn-active-border-color: var(--btn-bd);
  --bs-btn-focus-shadow-rgb: 228, 0, 43;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 11px 20px;
  border: 2px solid var(--btn-bd);
  border-radius: 0;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transform: skewX(-6deg);
  transition: transform var(--snap-fast) var(--snap), background-color var(--snap-fast) linear,
              border-color var(--snap-fast) linear, color var(--snap-fast) linear;
}
.btn > * { transform: skewX(6deg); }
.btn:hover { text-decoration: none; transform: skewX(-6deg) translate(2px, -2px); }
.btn:hover,
.btn:focus-visible,
:not(.btn-check) + .btn:active,
.btn:first-child:active,
.btn.active,
.btn.show {
  background-color: var(--btn-bg);
  border-color: var(--btn-bd);
  color: var(--btn-fg);
}

.btn-primary {
  --btn-bg: var(--crimson);
  --btn-fg: #fff;
  --btn-bd: #0B0B0D;
  --bs-btn-bg: var(--crimson);
  --bs-btn-color: #fff;
  --bs-btn-border-color: #0B0B0D;
  --bs-btn-hover-bg: var(--crimson-deep);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-border-color: #0B0B0D;
  --bs-btn-active-bg: var(--crimson-deep);
  --bs-btn-active-color: #fff;
  --bs-btn-active-border-color: #0B0B0D;
  --bs-btn-disabled-bg: #3A2A2C;
  --bs-btn-disabled-color: #8E7F80;
  --bs-btn-disabled-border-color: #4A3538;
}
.btn-primary:hover,
.btn-primary:focus-visible,
:not(.btn-check) + .btn-primary:active,
.btn-primary:first-child:active,
.btn-primary.active {
  --btn-bg: var(--crimson-deep);
  --btn-fg: #fff;
  --btn-bd: #0B0B0D;
}

/* Navbar Register CTA sits on the crimson slab, so hover goes solid ink (#0B0B0D)
   to match the active nav chip instead of fading into darker red or Bootstrap blue. */
.wg-nav .wg-nav__register:hover,
.wg-nav .wg-nav__register:focus-visible,
.wg-nav .wg-nav__register:active,
.wg-nav .wg-nav__register.active {
  --btn-bg: #0B0B0D;
  --btn-fg: #fff;
  --btn-bd: #0B0B0D;
  --bs-btn-hover-bg: #0B0B0D;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-border-color: #0B0B0D;
  --bs-btn-active-bg: #0B0B0D;
  --bs-btn-active-color: #fff;
  --bs-btn-active-border-color: #0B0B0D;
  background-color: #0B0B0D;
  border-color: #0B0B0D;
  color: #fff;
}

.btn-ghost { --btn-fg: var(--bone); --btn-bd: var(--smoke); --btn-bg: transparent; }
.btn-ghost:hover { --btn-bg: var(--ink-raise); --btn-fg: var(--bone); --btn-bd: var(--bone); }

.btn-paper { --btn-bg: var(--paper-fixed); --btn-fg: var(--static-ink); --btn-bd: var(--static-ink); }
.btn-paper:hover { --btn-bg: var(--paper-fixed-2); --btn-fg: var(--static-ink); }

.btn-secondary, .btn-outline-secondary {
  --btn-bg: var(--ink-raise);
  --btn-fg: var(--bone);
  --btn-bd: var(--ink-line);
}
.btn-secondary:hover, .btn-outline-secondary:hover {
  --btn-bg: var(--ink-panel);
  --btn-fg: var(--bone);
  --btn-bd: var(--smoke);
}
.btn-danger {
  --btn-bg: var(--bad);
  --btn-fg: #0B0B0D;
  --btn-bd: #0B0B0D;
}
.btn-danger:hover {
  --btn-bg: var(--crimson);
  --btn-fg: #fff;
  --btn-bd: #0B0B0D;
}
.btn-success {
  --btn-bg: var(--ok);
  --btn-fg: #0B0B0D;
  --btn-bd: #0B0B0D;
}

.btn-sm { min-height: 36px; padding: 8px 14px; font-size: 0.75rem; }
.btn-lg { min-height: 52px; padding: 15px 26px; font-size: 0.875rem; }

.btn:disabled, .btn.disabled {
  --btn-bg: var(--ink-raise);
  --btn-fg: var(--ash);
  --btn-bd: var(--ink-line);
  background-color: var(--btn-bg);
  border-color: var(--btn-bd);
  color: var(--btn-fg);
  opacity: 1;
  transform: skewX(-6deg);
}
.btn-primary:disabled {
  --btn-bg: #3A2A2C;
  --btn-fg: #8E7F80;
  --btn-bd: #4A3538;
}

/* --- 8. Forms ----------------------------------------------------------- */

.form-label, label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--smoke);
}

/* Inputs are never skewed or rotated: this is where people type. Fields use
   --field-bg (inset) and --field-bg-focus (popped) so in light mode they read
   as warm sand on cream, never as a pure-white box. */
.form-control, .form-select, textarea.form-control {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 2px solid var(--field-border);
  border-radius: 0;
  background: var(--field-bg);
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.4;
  transition: border-color var(--snap-fast) linear, background-color var(--snap-fast) linear;
  appearance: none;
}
.form-control::placeholder { color: var(--smoke); opacity: 1; }
.form-control:hover, .form-select:hover { border-color: var(--ash); }
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--crimson);
  background: var(--field-bg-focus);
  box-shadow: 3px 3px 0 0 var(--crimson);
}
.form-control:disabled { background: var(--ink-void); color: var(--ash); }

.form-select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239A958C' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}

.form-check { display: flex; gap: 9px; align-items: flex-start; padding-left: 0; }
.form-check .form-check-input { margin: 3px 0 0; flex: none; }
.form-check-input {
  width: 17px; height: 17px;
  border: 2px solid var(--ash);
  border-radius: 0;
  background: var(--field-bg);
  appearance: none;
}
.form-check-input:checked {
  background: var(--crimson);
  border-color: var(--crimson);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='9'%3E%3Cpath d='M1 4.5L4 7.5L10 1' fill='none' stroke='%23fff' stroke-width='2.2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.form-text, small.form-text {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--smoke);
}

.text-muted { color: var(--smoke) !important; }
.invalid-feedback { color: var(--bad); font-size: 0.8125rem; }
.form-control.is-invalid { border-color: var(--bad); }

/* --- 9. Alerts, stamps, states ------------------------------------------ */

.alert {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 13px 15px;
  margin-bottom: 16px;
  border: 2px solid currentColor;
  border-left-width: 6px;
  background: var(--ink-panel);
  color: var(--bone);
  font-size: 0.875rem;
  text-align: left !important;
}
.alert.text-center {
  justify-content: center;
  text-align: center !important;
  align-items: center;
  position: relative;
}
.alert.text-center .btn-close,
.alert.text-center button.close {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}
.alert.text-center span {
  flex: 1 1 auto;
  text-align: center;
}
.alert-success { color: var(--ok); background: var(--ok-wash); }
.alert-danger, .alert-error { color: var(--bad); background: var(--bad-wash); }
.alert-warning { color: var(--warn); background: var(--warn-wash); }
.alert-info { color: var(--bone); border-color: var(--ink-line); border-left-color: var(--smoke); }
.alert i { margin-top: 2px; }
.alert .btn-close, .alert button.close {
  position: static;
  flex: none;
  margin-left: auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 2px solid currentColor;
  border-radius: 0;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M1 1l10 10M11 1L1 11' stroke='%23F2EDE3' stroke-width='2.2'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 11px;
  color: inherit;
  opacity: 1;
  filter: none !important;
}
html[data-bs-theme="light"] .alert .btn-close,
html[data-bs-theme="light"] .alert button.close {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M1 1l10 10M11 1L1 11' stroke='%2316161A' stroke-width='2.2'/%3E%3C/svg%3E");
}
.alert .btn-close:hover, .alert button.close:hover {
  background-color: var(--crimson);
  border-color: var(--crimson);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M1 1l10 10M11 1L1 11' stroke='%23FFFFFF' stroke-width='2.2'/%3E%3C/svg%3E");
}

/* Stamp: a rubber stamp pressed at a slight angle. Always boxed, never a dot. */
.wg-stamp {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px;
  border: 2px solid currentColor;
  color: var(--bone);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1;
  transform: rotate(-1.5deg);
  white-space: nowrap;
}
.wg-stamp--live { color: #fff; background: var(--crimson); border-color: #0B0B0D; }
.wg-stamp--ok { color: var(--ok); }
.wg-stamp--muted { color: var(--smoke); border-color: var(--smoke); }
.wg-stamp--acid { color: var(--acid); }

/* Three states required of every data view. */
.wg-empty {
  padding: 46px 24px;
  border: 2px dashed var(--ink-line);
  background: var(--ink-panel);
  text-align: center;
  color: var(--smoke);
  font-size: 0.875rem;
}
.wg-empty strong {
  display: block;
  margin-bottom: 5px;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bone);
}
.wg-empty i, .wg-empty .wg-burst { font-size: 1.25rem; color: var(--crimson); margin-bottom: 12px; display: inline-block; }

.wg-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 58px 24px;
  color: var(--smoke);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.wg-loading::before {
  content: "";
  width: 15px; height: 15px;
  border: 2px solid var(--ink-line);
  border-top-color: var(--crimson);
  animation: wg-spin 620ms steps(8) infinite;
}
@keyframes wg-spin { to { transform: rotate(360deg); } }

/* --- 10. Tables --------------------------------------------------------- */

/* Tables stay upright and solid: this is dense reading, not collage. */
.wg-table-wrap {
  border: 2px solid var(--ink-line);
  background: var(--ink-panel);
  overflow: hidden;
}
.wg-table-scroll { overflow-x: auto; }

table, .table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: 0.875rem;
  color: var(--bone);
  --bs-table-bg: transparent;
}
table th, .table th {
  padding: 12px 15px;
  border-bottom: 2px solid var(--ink-line);
  background: var(--ink-raise);
  color: var(--smoke);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}
table td, .table td {
  padding: 12px 15px;
  border-bottom: 1px solid var(--ink-line);
  vertical-align: middle;
}
table tbody tr:last-child td { border-bottom: 0; }
table tbody tr { transition: background-color var(--snap-fast) linear; }
table tbody tr:hover { background: var(--ink-raise); }
.table > :not(caption) > * > * { background: transparent; border-color: var(--ink-line); }
.table-striped > tbody > tr:nth-of-type(odd) > * { background: var(--ink-raise); color: var(--bone); }

/* --- Top 3 podium rows ---------------------------------------------------
   Places 1-3 are cut-paper medals, not just coloured numbers: a tilted chip,
   a thick left bar, a tinted row, a matched avatar and a larger score. The
   chip colours are fixed (crimson / paper / acid) so the podium reads the
   same in dark and light; only the row tint uses theme tokens. */
.wg-rank {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1;
  color: var(--smoke);
  border: 2px solid var(--ink-line);
  background: transparent;
  transition: transform var(--snap-fast) var(--snap), background-color var(--snap-fast) linear,
              border-color var(--snap-fast) linear, color var(--snap-fast) linear;
}
tr.wg-rank-1 .wg-rank,
tr.wg-rank-2 .wg-rank,
tr.wg-rank-3 .wg-rank { border-color: #0B0B0D; box-shadow: 3px 3px 0 0 var(--shadow); }
tr.wg-rank-1 .wg-rank {
  background: var(--crimson);
  color: #fff;
  transform: rotate(-3deg);
}
tr.wg-rank-2 .wg-rank {
  background: var(--paper-fixed);
  color: var(--static-ink);
  transform: rotate(2deg);
}
tr.wg-rank-3 .wg-rank {
  background: var(--acid-fill);
  color: var(--static-ink);
  transform: rotate(-1.5deg);
}
/* Row tints + left bars. Rank 1 is the loudest, 3 the quietest. */
tr.wg-rank-1 td { background: rgb(228 0 43 / 0.09); }
tr.wg-rank-2 td { background: rgb(242 237 227 / 0.05); }
tr.wg-rank-3 td { background: rgb(242 226 5 / 0.05); }
html[data-bs-theme="light"] tr.wg-rank-1 td { background: rgb(196 0 31 / 0.07); }
html[data-bs-theme="light"] tr.wg-rank-2 td { background: rgb(22 22 26 / 0.04); }
html[data-bs-theme="light"] tr.wg-rank-3 td { background: rgb(94 84 0 / 0.06); }
tr.wg-rank-1 td:first-child { box-shadow: inset 6px 0 0 var(--crimson); }
tr.wg-rank-2 td:first-child { box-shadow: inset 5px 0 0 var(--bone); }
tr.wg-rank-3 td:first-child { box-shadow: inset 4px 0 0 var(--acid); }
/* Podium rows breathe: taller cells, larger score. */
tr.wg-rank-1 td, tr.wg-rank-2 td, tr.wg-rank-3 td { padding-block: 14px; }
tr.wg-rank-1 .wg-sb__score { color: var(--crimson-text); font-size: 1.0625rem; }
tr.wg-rank-2 .wg-sb__score, tr.wg-rank-3 .wg-sb__score { font-size: 1rem; }
/* Hover straightens the chip and lifts the row: picking the medal up. */
tr.wg-rank-1:hover .wg-rank,
tr.wg-rank-2:hover .wg-rank,
tr.wg-rank-3:hover .wg-rank { transform: rotate(0deg) scale(1.06); }
tr.wg-rank-1:hover td { background: rgb(228 0 43 / 0.14); }
html[data-bs-theme="light"] tr.wg-rank-1:hover td { background: rgb(196 0 31 / 0.11); }
/* Entrance: a fast snap, staggered 1 -> 2 -> 3. CSS-only, no JS cost. */
@keyframes wg-row-in {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: none; }
}
tr.wg-rank-1, tr.wg-rank-2, tr.wg-rank-3 { animation: wg-row-in 260ms var(--snap) backwards; }
tr.wg-rank-2 { animation-delay: 60ms; }
tr.wg-rank-3 { animation-delay: 120ms; }
@keyframes wg-chip-pop {
  from { transform: scale(0.6) rotate(-10deg); }
  to { transform: scale(1) rotate(var(--chip-rot, 0deg)); }
}
tr.wg-rank-1 .wg-rank { --chip-rot: -3deg; }
tr.wg-rank-2 .wg-rank { --chip-rot: 2deg; }
tr.wg-rank-3 .wg-rank { --chip-rot: -1.5deg; }
tr.wg-rank-1 .wg-rank, tr.wg-rank-2 .wg-rank, tr.wg-rank-3 .wg-rank {
  animation: wg-chip-pop 300ms var(--snap) backwards;
}
tr.wg-rank-2 .wg-rank { animation-delay: 60ms; }
tr.wg-rank-3 .wg-rank { animation-delay: 120ms; }

/* --- 11. Footer --------------------------------------------------------- */

.wg-footer {
  position: relative;
  margin-top: auto;
  padding-block: 46px 30px;
  background: var(--ink-void);
  border-top: 3px solid var(--crimson);
  color: var(--smoke);
  font-size: 0.8125rem;
}
.wg-footer__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) repeat(2, minmax(0, 1fr));
  gap: 34px;
  padding-bottom: 30px;
}
.wg-footer__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.wg-footer__brand img { width: 28px; height: 28px; }
.wg-footer__brand strong {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bone);
}
.wg-footer p { max-width: 46ch; font-size: 0.8125rem; color: var(--smoke); }
.wg-footer h3 {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ash);
}
.wg-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.wg-footer a { color: var(--smoke); }
.wg-footer a:hover { color: var(--crimson); }
.wg-footer__base {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--ink-line);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ash);
  flex-wrap: wrap;
}

/* --- 12. Theme toggle + language ---------------------------------------- */

.wg-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  flex: none;
  border: 1px solid transparent;
  background: transparent;
  color: #fff;
  transition: background-color var(--snap-fast) linear, border-color var(--snap-fast) linear,
              box-shadow var(--snap-fast) linear;
}
.wg-theme-toggle:hover {
  background: rgb(11 11 13 / 0.30);
  border-color: rgb(11 11 13 / 0.45);
  box-shadow: inset 0 0 0 1px rgb(11 11 13 / 0.18);
}
.wg-theme-toggle svg { width: 16px; height: 16px; display: block; }
.wg-theme-toggle .i-sun { display: none; }
html[data-bs-theme="dark"] .wg-theme-toggle .i-sun { display: block; }
html[data-bs-theme="dark"] .wg-theme-toggle .i-moon { display: none; }

.wg-lang .dropdown-menu {
  min-width: 200px;
  max-height: min(62vh, 420px);
  overflow-y: auto;
  padding: 4px;
  border: 2px solid var(--ink-line);
  border-radius: 0;
  background: var(--ink-panel);
  box-shadow: 6px 6px 0 0 var(--shadow);
}
.wg-lang .dropdown-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 0;
  color: var(--bone);
  font-size: 0.8125rem;
  white-space: nowrap;
}
.wg-lang .dropdown-item:hover, .wg-lang .dropdown-item:focus { background: var(--ink-raise); color: var(--bone); }
.wg-lang .dropdown-item.is-active {
  background: var(--crimson-text);
  color: #fff;
  font-weight: 600;
}

/* --- 13. Inherited CTFd core templates ---------------------------------- */

.jumbotron {
  padding: 38px 0 26px;
  margin-bottom: 28px;
  background: transparent;
  border-bottom: 3px solid var(--crimson);
  border-radius: 0;
}
.jumbotron h1 { margin: 0 0 4px; }
.jumbotron p { color: var(--smoke); margin: 0; }

.card {
  border: 2px solid var(--ink-line);
  border-radius: 0;
  background: var(--ink-panel);
  box-shadow: none;
}
.card-header {
  padding: 12px 16px;
  border-bottom: 2px solid var(--ink-line);
  background: var(--ink-raise);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.card-body { padding: 18px 16px; }
.card-footer { border-top: 2px solid var(--ink-line); background: transparent; }

.list-group-item { border-color: var(--ink-line); background: var(--ink-panel); color: var(--bone); padding: 12px 16px; }

.nav-tabs { border-bottom: 2px solid var(--ink-line); gap: 0; }
.nav-tabs .nav-link {
  padding: 10px 15px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--smoke);
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav-tabs .nav-link:hover { color: var(--bone); border-bottom-color: var(--ash); }
.nav-tabs .nav-link.active { color: var(--bone); background: none; border-bottom-color: var(--crimson); }

.dropdown-menu {
  padding: 4px;
  border: 2px solid var(--ink-line);
  border-radius: 0;
  background: var(--ink-panel);
  box-shadow: 6px 6px 0 0 var(--shadow);
  font-size: 0.875rem;
}
.dropdown-item { padding: 8px 10px; border-radius: 0; color: var(--bone); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--ink-raise); color: var(--bone); }
.dropdown-divider { margin: 4px 0; border-color: var(--ink-line); }

.modal-content {
  border: 3px solid #0B0B0D;
  border-radius: 0;
  background: var(--ink-panel);
  box-shadow: 10px 10px 0 0 var(--crimson);
}
.modal-header, .modal-footer { border-color: var(--ink-line); padding: 14px 18px; }
.modal-body { padding: 18px; }
.modal-title { font-family: var(--font-display); font-size: 1.0625rem; text-transform: uppercase; letter-spacing: 0.04em; }
.modal-backdrop { background: #0B0B0D; }
.modal-backdrop.show { opacity: 0.76; }
.btn-close {
  width: 32px; height: 32px;
  padding: 0;
  border: 2px solid #0B0B0D;
  border-radius: 0;
  background: #F2EDE3 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M1 1l10 10M11 1L1 11' stroke='%230B0B0D' stroke-width='2.2' stroke-linecap='square'/%3E%3C/svg%3E") center / 12px no-repeat;
  opacity: 1;
  filter: none !important;
  box-shadow: 3px 3px 0 0 #0B0B0D;
}
html[data-bs-theme="light"] .btn-close {
  border-color: #0B0B0D;
  background: #F2EDE3 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M1 1l10 10M11 1L1 11' stroke='%230B0B0D' stroke-width='2.2' stroke-linecap='square'/%3E%3C/svg%3E") center / 12px no-repeat;
  box-shadow: 3px 3px 0 0 #0B0B0D;
}
.btn-close:hover {
  background-color: var(--crimson);
  border-color: #0B0B0D;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M1 1l10 10M11 1L1 11' stroke='%23FFFFFF' stroke-width='2.2' stroke-linecap='square'/%3E%3C/svg%3E");
  box-shadow: 3px 3px 0 0 #0B0B0D;
}
html[data-bs-theme="light"] .btn-close:hover {
  background-color: var(--crimson);
  border-color: #0B0B0D;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M1 1l10 10M11 1L1 11' stroke='%23FFFFFF' stroke-width='2.2' stroke-linecap='square'/%3E%3C/svg%3E");
}

/* --- Toast: the "Success! Your profile has been updated" notice -----------
   Two real defects here, both reproduced at 1440 and 390:

   1. The close button was styled at (0,1,0) with border --ink-line (#2A2A30)
      while the toast header is rgba(33,37,41,.85). That is 1.09:1, effectively
      invisible, so the control looked like it was not there.
   2. The toast had no width discipline. At 390px the body text ran wider than
      the card and the close button sat half outside the visible box.

   The toast is now a cut-paper card: solid panel, ink border, the X on a paper
   chip with a crimson hover, and a hard 12px right offset so it never sits
   flush against the viewport edge on a phone. */

/* CTFd pins this at z-index 11, which is below the nav (60) and the drawer (90),
   so a toast raised over the page gets covered by the top bar. The wrapper is an
   inherited inline style, hence !important on the one property that has to win. */
div.position-fixed.bottom-0.end-0.p-3:has(> .toast) { z-index: 70 !important; }

.toast {
  width: min(360px, calc(100vw - 32px));
  background: var(--ink-panel);
  border: 2px solid var(--ink-line);
  border-left: 6px solid var(--crimson);
  border-radius: 0;
  box-shadow: 6px 6px 0 0 var(--shadow);
  color: var(--bone);
  overflow: hidden;
}
.toast-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px 9px;
  background: var(--ink-raise);
  border-bottom: 2px solid var(--ink-line);
  color: var(--bone);
}
.toast-header strong {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bone);
}
.toast-header small {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--smoke);
}
.toast-body {
  padding: 12px;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--smoke);
  overflow-wrap: anywhere;
}
/* the close chip: 44px on touch via the block near the end of this file */
.toast .btn-close {
  flex: none;
  width: 30px;
  height: 30px;
  margin: 0;
  border: 2px solid var(--smoke);
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M1 1l10 10M11 1L1 11' stroke='%23C9C3B8' stroke-width='2'/%3E%3C/svg%3E");
  background-position: center;
  background-size: 12px;
  background-repeat: no-repeat;
  opacity: 1;
  filter: none !important;
}
.toast .btn-close:hover,
.toast .btn-close:focus-visible {
  background-color: var(--crimson);
  border-color: var(--crimson);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M1 1l10 10M11 1L1 11' stroke='%23FFFFFF' stroke-width='2'/%3E%3C/svg%3E");
}
/* light theme: the default dark toast did not invert with the page.
   The shadow now follows --shadow, so only the close glyph needs a light swap. */
html[data-bs-theme="light"] .toast .btn-close {
  border-color: var(--ink-line);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M1 1l10 10M11 1L1 11' stroke='%235C574E' stroke-width='2'/%3E%3C/svg%3E");
}

.page-link {
  padding: 8px 13px;
  border: 2px solid var(--ink-line);
  background: var(--ink-panel);
  color: var(--smoke);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.page-link:hover { background: var(--ink-raise); color: var(--bone); }
.page-item.active .page-link { background: var(--crimson); border-color: #0B0B0D; color: #fff; }
.page-item.disabled .page-link { color: var(--ash); }

.progress { height: 8px; border-radius: 0; background: var(--ink-raise); }
.progress-bar { background: var(--crimson); }

.text-primary { color: var(--crimson-text) !important; }
.bg-primary { background-color: var(--crimson) !important; }
.badge, .badge.bg-secondary, .badge.bg-primary, .badge.bg-danger, .badge.bg-success, .badge.bg-warning {
  border-radius: 0 !important;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 8px;
}
.badge.bg-secondary { background: var(--ink-raise) !important; color: var(--smoke) !important; border: 1px solid var(--ink-line); }
.badge.bg-primary { background: var(--crimson) !important; color: #fff !important; }
.badge.bg-danger { background: var(--bad) !important; }
.badge.bg-success { background: var(--ok) !important; color: #0B0B0D !important; }
.badge.bg-warning { background: var(--warn) !important; color: #0B0B0D !important; }

/* --- 14. Utilities ----------------------------------------------------- */

.wg-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.wg-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%);
  white-space: nowrap;
  border: 0;
}
.wg-skip {
  position: absolute;
  top: 8px; left: 8px;
  z-index: 200;
  padding: 11px 16px;
  background: var(--paper-fixed);
  color: var(--static-ink);
  border: 2px solid #0B0B0D;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: translateY(-180%);
}
.wg-skip:focus { transform: none; text-decoration: none; }

/* --- 15. Reduced motion ------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  [data-reveal] { opacity: 1 !important; transform: none !important; }
}

html.wg-no-motion [data-reveal] { opacity: 1 !important; transform: none !important; }

/* --- 16. Touch targets (R-03) ------------------------------------------ */

/* --- 44px touch targets (R-03) ------------------------------------------
   `pointer: coarse` alone is not enough. A number of Android browsers, some
   WebViews, and all of Chrome's device-emulation modes report `pointer: fine`
   or `none` on a touch device, so the rule silently does not apply and every
   control stays at its mouse-sized 32 to 42px. Both conditions are therefore
   checked: a coarse pointer OR a viewport narrow enough that the device is
   almost certainly being held. The duplication is intentional. */
@media (pointer: coarse), (max-width: 767px) {
  .wg-chip, .wg-fchip { min-height: 44px; padding: 10px 14px; }
  .wg-icon, .wg-theme-toggle, .wg-burger { width: 44px; height: 44px; }
  .wg-brand { min-height: 44px; }
  .wg-drawer a { min-height: 50px; }
  .btn { min-height: 46px; }
  /* .btn-sm was deliberately 42px. At 44 the nav stop-gap button and the
     section CTAs all clear the minimum, and visually the extra 2px are
     invisible. */
  .btn-sm { min-height: 44px; }
  .wg-tab { min-height: 46px; }
  .btn-close { width: 44px; height: 44px; }
  .toast .btn-close { width: 44px; height: 44px; }
  .toast { width: min(360px, calc(100vw - 24px)); }
  .dropdown-item { min-height: 44px; display: flex; align-items: center; }
  /* Footer links were 34 to 38px wide: real tap targets, not decoration, so
     they get the full 44px box and fill the column while we are at it. */
  .wg-footer__grid a { min-height: 44px; display: flex; align-items: center; padding-block: 4px; }
  .wg-footer__base a { min-height: 44px; display: inline-flex; align-items: center; }
  /* table rows are read, not tapped, but the team link inside them is */
  .wg-sb__team { min-height: 44px; }
  .wg-board__name { min-height: 44px; display: inline-flex; align-items: center; }
  .wg-brand { gap: 6px; }
  .wg-auth__alt a, .wg-prose a { min-height: 44px; display: inline-flex; align-items: center; }
}

/* --- Modal stacking ------------------------------------------------------
   main carries position:relative + z-index:1 so the hero collage layers above
   the page ground. That also traps any fixed-position descendant in main's
   stacking context, and the challenge modal lives inside main. Its z-index of
   1055 was therefore compared against main's siblings only, never against the
   body-level backdrop at 1050, so the backdrop painted over the dialog and the
   close button became a dead control (R-26).

   Dropping main to z-index:auto while a modal is open removes the stacking
   context without touching anything else: the page body has no z-index, so it
   still paints under the backdrop, and the modal now competes at body level
   where it belongs. */
body.modal-open main { z-index: auto; }
#challenge-window.modal { z-index: 1055; }
#challenge-window .modal-dialog { z-index: 1060; }
.modal-backdrop { z-index: 1050; }
body.modal-open .wg-nav { z-index: 40; }
