/* ══════════════════════════════════════════════════════════════
   The signed-in app shell
   Top bar, rail, phone tab bar and account menu — the chrome every
   page on the application layout shares. Authority for the look:
   docs/design/app-redesign/app-shell-editor.dc.html.

   The bars are charcoal in BOTH themes (a shade deeper in dark so they
   still separate from the plum page); only the page between them
   changes with the theme. Their colours are therefore fixed brand
   values declared here, not the theme tokens.

   Every selector is two classes deep or carries .fr-shell-*, so the
   rules win over Tailwind utilities without !important (Tailwind
   sorts last in the stylesheet glob).
   ══════════════════════════════════════════════════════════════ */

:root {
  --shell-bar: #30202d;
  --shell-edge: #1c121b;
  --shell-cream: #fadcc2;
  --shell-cream-70: rgba(250, 220, 194, 0.7);
  --shell-cream-30: rgba(250, 220, 194, 0.3);
  --shell-pink: #f046a0;
  --shell-on-pink: #1f141d;
  --shell-yellow: #faca16;
  --shell-top-h: 64px;
  --shell-rail-w: 76px;
  --shell-tabs-h: 66px;
}
html[data-theme="dark"] {
  --shell-bar: #1c121b;
  --shell-edge: #0d070c;
}

/* ── Frame ─────────────────────────────────────────────────── */
.fr-shell {
  display: flex;
  flex-direction: column;
}
.fr-shell .fr-shell__top { flex: none; position: relative; z-index: 50; }
.fr-shell .fr-shell__body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

/* ── Top bar ───────────────────────────────────────────────── */
.fr-shell-bar {
  height: var(--shell-top-h);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 0 16px 0 14px;
  background: var(--shell-bar);
  color: var(--shell-cream);
  border-bottom: 2px solid var(--shell-edge);
}
.fr-shell-bar .fr-shell-bar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.fr-shell-bar .fr-shell-bar__home {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--shell-cream);
  text-decoration: none;
  flex: none;
}
.fr-shell-bar .fr-shell-bar__home:focus-visible,
.fr-shell-bar .fr-shell-bar__signin:focus-visible,
.fr-shell-bar .fr-shell-avatar:focus-visible,
.fr-shell-bar .theme-toggle:focus-visible,
.fr-shell-nav:focus-visible {
  outline: 2px solid var(--shell-yellow);
  outline-offset: 3px;
}
.fr-shell-bar .fr-shell-bar__wordmark {
  font-family: var(--font-headline);
  font-weight: 500;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.fr-shell-bar .fr-shell-bar__area {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  line-height: 1.1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--shell-yellow);
  border: 2px solid var(--shell-yellow);
  border-radius: 50%;
  padding: 5px 14px;
  white-space: nowrap;
}
.fr-shell-bar .fr-shell-bar__center {
  min-width: 0;
  display: flex;
  justify-content: center;
}
.fr-shell-bar .fr-shell-bar__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* The gem's theme toggle, redrawn as the bar's round outlined button. */
.fr-shell-bar .theme-toggle,
html[data-theme="dark"] .fr-shell-bar .theme-toggle {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  border: 2px solid var(--shell-cream-30);
  background: transparent;
  color: var(--shell-cream);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 120ms ease, border-color 120ms ease;
}
.fr-shell-bar .theme-toggle:hover,
html[data-theme="dark"] .fr-shell-bar .theme-toggle:hover {
  background: transparent;
  color: var(--shell-cream);
  border-color: var(--shell-cream);
  transform: translate(-1px, -1px);
}

.fr-shell-bar .fr-shell-bar__signin {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--shell-on-pink);
  background: var(--shell-pink);
  border: 2px solid var(--shell-cream);
  border-radius: 999px;
  padding: 9px 18px;
  text-decoration: none;
  box-shadow: 2px 2px 0 var(--shell-edge);
}

/* ── Account avatar + menu ─────────────────────────────────── */
.fr-shell-account { position: relative; }
.fr-shell-bar .fr-shell-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--shell-pink);
  border: 2px solid var(--shell-cream);
  box-shadow: 2px 2px 0 var(--shell-edge);
  color: var(--shell-on-pink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 120ms ease;
}
.fr-shell-bar .fr-shell-avatar:hover { transform: translate(-1px, -1px); }

.fr-shell-account .fr-shell-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  left: auto;
  bottom: auto;
  width: 248px;
  padding: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--shell-edge);
  box-shadow: 4px 4px 0 var(--shell-edge);
  z-index: 70;
  animation: none;
}
html[data-theme="dark"] .fr-shell-account .fr-shell-menu {
  background: var(--surface);
  border-color: rgba(250, 220, 194, 0.2);
  box-shadow: 4px 4px 0 #100910;
}
.fr-shell-account .fr-shell-menu.hidden { display: none; }
.fr-shell-menu .fr-shell-menu__head {
  padding: 14px 16px 12px;
  border-bottom: 2px solid var(--border);
}
.fr-shell-menu .fr-shell-menu__name {
  font-family: var(--font-headline);
  font-weight: 500;
  font-size: 21px;
  line-height: 1.1;
  color: var(--text);
}
.fr-shell-menu .fr-shell-menu__email {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
  overflow-wrap: anywhere;
}
.fr-shell-menu .fr-shell-menu__group {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}
.fr-shell-menu .fr-shell-menu__group--foot { border-top: 2px solid var(--border); }
.fr-shell-menu .fr-shell-menu__group form { display: contents; }
.fr-shell-menu .fr-shell-menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.fr-shell-menu .fr-shell-menu__item:hover,
.fr-shell-menu .fr-shell-menu__item:focus-visible {
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}
.fr-shell-menu .fr-shell-menu__item svg { flex: none; color: var(--text-muted); }

/* ── Navigation items (rail and tab bar share one anatomy) ─── */
.fr-shell-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--shell-cream-70);
  text-decoration: none;
  transition: color 120ms ease;
}
.fr-shell-nav:hover { color: var(--shell-cream); }
.fr-shell-nav .fr-shell-nav__pill {
  width: 52px;
  height: 34px;
  border-radius: 999px;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 120ms ease;
}
.fr-shell-nav:hover .fr-shell-nav__pill { border-color: rgba(250, 220, 194, 0.35); }
.fr-shell-nav .fr-shell-icon { width: 19px; height: 19px; flex: none; }
.fr-shell-nav .fr-shell-nav__label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.fr-shell-nav[aria-current="page"] { color: var(--shell-cream); }
.fr-shell-nav[aria-current="page"] .fr-shell-nav__pill {
  background: var(--shell-pink);
  border-color: #30202d;
  box-shadow: 3px 3px 0 var(--shell-edge);
  color: var(--shell-on-pink);
}

/* ── Rail ──────────────────────────────────────────────────── */
.fr-shell-rail {
  display: none;
  flex: none;
  width: var(--shell-rail-w);
  background: var(--shell-bar);
  border-right: 2px solid var(--shell-edge);
}
.fr-shell-rail .fr-shell-rail__nav {
  height: 100%;
  padding: 18px 0;
}
.fr-shell-rail .fr-shell-rail__nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
@media (min-width: 768px) {
  .fr-shell-rail { display: block; }
}

/* ── Phone tab bar ─────────────────────────────────────────── */
.fr-shell-tabs {
  flex: none;
  height: calc(var(--shell-tabs-h) + env(safe-area-inset-bottom, 0px));
  padding: 0 4px env(safe-area-inset-bottom, 0px);
  background: var(--shell-bar);
  border-top: 2px solid var(--shell-edge);
  display: flex;
  align-items: center;
  justify-content: space-around;
}
.fr-shell-tabs .fr-shell-nav--tab {
  flex: 1 1 0;
  min-width: 0;
  gap: 4px;
  min-height: 48px;
  justify-content: center;
}
.fr-shell-tabs .fr-shell-nav--tab .fr-shell-nav__pill { width: 46px; height: 30px; }
.fr-shell-tabs .fr-shell-nav--tab .fr-shell-icon { width: 17px; height: 17px; }
.fr-shell-tabs .fr-shell-nav--tab .fr-shell-nav__label { font-size: 9.5px; letter-spacing: 0.05em; }
.fr-shell-tabs .fr-shell-nav--tab[aria-current="page"] .fr-shell-nav__pill { box-shadow: 2px 2px 0 var(--shell-edge); }
@media (min-width: 768px) {
  .fr-shell-tabs { display: none; }
}

/* ── Signed-out variant (public + auth layouts) ────────────── */
.fr-shell-bar.fr-shell-bar--public {
  grid-template-columns: minmax(0, 1fr) auto;
  position: sticky;
  top: 0;
  z-index: 50;
}
.fr-shell-bar .fr-shell-bar__brand { gap: 28px; }
.fr-shell-bar:not(.fr-shell-bar--public) .fr-shell-bar__brand { gap: 12px; }
.fr-shell-bar .fr-shell-bar__links {
  display: flex;
  align-items: center;
  gap: 24px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.fr-shell-bar .fr-shell-bar__links a {
  color: rgba(250, 220, 194, 0.75);
  text-decoration: none;
  padding-bottom: 3px;
  border-bottom: 2px solid transparent;
}
.fr-shell-bar .fr-shell-bar__links a:hover { color: var(--shell-cream); }
.fr-shell-bar .fr-shell-bar__links a[aria-current="page"] {
  color: var(--shell-cream);
  border-bottom-color: var(--shell-pink);
}
.fr-shell-bar .fr-shell-bar__textlink {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--shell-cream);
  text-decoration: none;
  white-space: nowrap;
}
.fr-shell-bar .fr-shell-bar__textlink:hover { color: var(--shell-yellow); }
.fr-shell-bar .fr-shell-bar__cta {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 18px;
  background: var(--shell-pink);
  color: var(--shell-on-pink);
  border: 2px solid #30202d;
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--shell-edge);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.fr-shell-bar .fr-shell-bar__cta:hover {
  color: var(--shell-on-pink);
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--shell-edge);
}
@media (max-width: 767px) {
  .fr-shell-bar .fr-shell-bar__links { display: none; }
  .fr-shell-bar.fr-shell-bar--public { height: 60px; }
  .fr-shell-bar .fr-shell-bar__cta { height: 36px; padding: 0 14px; font-size: 11px; }
}
@media (max-width: 420px) {
  .fr-shell-bar.fr-shell-bar--public .theme-toggle { display: none; }
}

/* ── Footer shared by the public and auth layouts ──────────── */
.footer.footer,
html[data-theme="dark"] .footer.footer {
  background: var(--shell-bar);
  border-top: 2px solid var(--shell-edge);
  padding: 22px 24px;
  text-align: center;
}
.footer.footer p {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(250, 220, 194, 0.7);
}
.footer.footer a { color: var(--shell-cream); }

/* ── Phone top bar: the brand shrinks, the centre slot drops ── */
@media (max-width: 767px) {
  .fr-shell-bar { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .fr-shell-bar .fr-shell-bar__center { display: none; }
  .fr-shell-bar .fr-shell-bar__wordmark { font-size: 24px; }
  .fr-shell-bar .fr-shell-bar__area { font-size: 10px; padding: 4px 10px; }
}
@media (max-width: 380px) {
  .fr-shell-bar .fr-shell-bar__area { display: none; }
}

/* ── Page nav: a page's own links, carried by the bar ────────
   One element (shared/_page_nav). At 900px and up it sits in the bar; under
   that the bar grows a second row and the links become a strip that scrolls
   sideways. Labels print as written -- no text-transform -- because a contest
   name carries the brand, and capitals turn "fRank" into "FRANK". */
.fr-shell-bar .fr-shell-pagenav {
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  /* No scrollbar is drawn, so the edges fade: a link cut off mid-word reads
     as "there is more this way". The fade is as wide as the track's own
     padding, so nothing is dimmed when everything fits. */
  --pagenav-fade-l: 24px;
  --pagenav-fade-r: 24px;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--pagenav-fade-l), #000 calc(100% - var(--pagenav-fade-r)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--pagenav-fade-l), #000 calc(100% - var(--pagenav-fade-r)), transparent);
}
.fr-shell-bar .fr-shell-pagenav::-webkit-scrollbar { display: none; }
.fr-shell-bar .fr-shell-pagenav__track {
  display: flex;
  align-items: center;
  gap: 22px;
  width: max-content;
  margin-inline: auto;
  padding-inline: var(--pagenav-fade-l) var(--pagenav-fade-r);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.fr-shell-bar.fr-shell-bar--public .fr-shell-pagenav__track { margin-inline: 0; }
.fr-shell-bar .fr-shell-pagenav a {
  display: inline-flex;
  align-items: center;
  height: 40px;
  color: rgba(250, 220, 194, 0.75);
  text-decoration: none;
  border-block: 2px solid transparent;
}
.fr-shell-bar .fr-shell-pagenav a:hover { color: var(--shell-cream); }
.fr-shell-bar .fr-shell-pagenav a:focus-visible {
  outline: 2px solid var(--shell-yellow);
  outline-offset: -2px;
}
.fr-shell-bar .fr-shell-pagenav a[aria-current="page"] {
  color: var(--shell-cream);
  border-bottom-color: var(--shell-pink);
}
.fr-shell-bar .fr-shell-pagenav__title {
  color: var(--shell-yellow);
  padding-right: 22px;
  border-right: 2px solid var(--shell-cream-30);
  line-height: 20px;
}
/* 4px, not the bar's usual gap: the track's own padding makes up the rest. */
.fr-shell-bar.fr-shell-bar--paged {
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px;
}
@media (max-width: 899px) {
  /* Two rows: the bar, then the strip. The 2px the first row gives up is the
     bar's own bottom border, so the whole thing is exactly
     --shell-top-h + --shell-strip-h tall -- the figure .fr-flow publishes. */
  .fr-shell-bar.fr-shell-bar--paged {
    height: auto;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: calc(var(--shell-top-h) - 2px) var(--shell-strip-h, 44px);
    column-gap: 10px;
    row-gap: 0;
  }
  .fr-shell-bar.fr-shell-bar--paged .fr-shell-pagenav {
    grid-column: 1 / -1;
    grid-row: 2;
    align-self: stretch;
    display: flex;
    align-items: center;
    margin: 0 -16px 0 -14px;
    border-top: 1px solid rgba(250, 220, 194, 0.16);
    --pagenav-fade-l: 14px;
  }
  .fr-shell-bar.fr-shell-bar--paged .fr-shell-pagenav__track { margin-inline: 0; }
}

/* ── Document-flow variant (the FYF layouts: marketing, games) ──
   The application layout's shell is a fixed-height box whose <main> scrolls.
   Contest, standings and game pages scroll the window instead -- anchors,
   position: sticky and the games' fit-the-window maths all depend on it -- so
   here the same three pieces are placed around a page that stays in normal
   flow: the bar sticks to the top, the rail is fixed down the left with the
   page padded clear of it, and the phone tab bar is fixed along the bottom.

   .fr-flow goes on <body> (AppNavHelper#flow_chrome_body_class) and publishes
   how much room the chrome takes, for anything that has to sit clear of it:
     --shell-chrome-top     bar, plus the link strip when the page has one
     --shell-chrome-bottom  the phone tab bar, 0 without one
     --shell-chrome-left    the rail, 0 without one
   All three are plain CSS, known before script runs. */
.fr-flow {
  --shell-strip-h: 0px;
  --shell-chrome-top: calc(var(--shell-top-h) + var(--shell-strip-h));
  --shell-chrome-bottom: 0px;
  --shell-chrome-left: 0px;
}
@media (max-width: 899px) {
  .fr-flow.fr-flow--paged { --shell-strip-h: 44px; }
}
@media (max-width: 767px) {
  /* The signed-out bar is 60px on a phone; the signed-in one stays 64px, as
     on the application layout. */
  .fr-flow:not(.fr-flow--app) { --shell-top-h: 60px; }
  .fr-flow.fr-flow--app {
    --shell-chrome-bottom: calc(var(--shell-tabs-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: var(--shell-chrome-bottom);
  }
}
@media (min-width: 768px) {
  .fr-flow.fr-flow--app {
    --shell-chrome-left: var(--shell-rail-w);
    padding-left: var(--shell-rail-w);
  }
}
/* The bar runs the full width, over the top of the rail: pull it back out of
   the padding that clears the rail. */
.fr-flow > .fr-shell-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  flex: none;
  margin-left: calc(var(--shell-chrome-left) * -1);
}
.fr-flow > .fr-shell-rail {
  position: fixed;
  top: var(--shell-chrome-top);
  bottom: 0;
  left: 0;
  z-index: 40;
}
.fr-flow > .fr-shell-tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 45;
}

/* These layouts load fyf_foundation.css last, and its `.fyf a` (colour,
   underline) and `.fyf a:hover` outrank the single-class rules above; it also
   re-points --font-display at the headline face. Restated here, one class
   deeper, so the chrome is the same on these pages as everywhere else. */
.fr-flow > .fr-shell-bar,
.fr-flow > .fr-shell-rail,
.fr-flow > .fr-shell-tabs {
  --font-headline: 'VC Henrietta', Georgia, serif;
  --font-display: 'Clash Display', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font: 'General Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* The account menu's secondary ink: the foundation swaps in a lighter one. */
  --text-muted: #5a4855;
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.5;
}
.fr-flow .fr-shell-nav,
.fr-flow .fr-shell-nav:hover { text-decoration: none; }
.fr-flow .fr-shell-nav { color: var(--shell-cream-70); }
.fr-flow .fr-shell-nav:hover,
.fr-flow .fr-shell-nav[aria-current="page"] { color: var(--shell-cream); }
.fr-flow .fr-shell-bar .fr-shell-bar__home:hover { color: var(--shell-cream); }

@media (prefers-reduced-motion: reduce) {
  .fr-shell-bar .theme-toggle,
  .fr-shell-bar .fr-shell-avatar,
  .fr-shell-nav,
  .fr-shell-nav .fr-shell-nav__pill { transition: none; }
}
