/*
 * Transparent optics for the color picture tube. All drawing lives on this
 * fixed, pointer-transparent face. The game keeps its native paint and layout.
 */
#mi-crt-glass {
  display: none;
}

@media screen and (forced-colors: none) and (prefers-contrast: no-preference) {
  #mi-crt-glass {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 2147483646;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    pointer-events: none;
    user-select: none;
  }

  #mi-crt-glass > canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
  }

  #mi-crt-glass::before,
  #mi-crt-glass::after {
    content: "";
    display: block;
    position: absolute;
    inset: 0;
    pointer-events: none;
  }

  /* A dim, stationary reflection at the upper shoulder of the glass. */
  #mi-crt-glass::before {
    z-index: 2;
    background: radial-gradient(ellipse 69% 25% at 39% -19%, rgb(221 239 236 / .075), transparent 99%);
  }

  /*
   * CSS-only optical pass for a browser without either canvas renderer.
   * The outer SVG path is an aperture, with bowed edges even away from the
   * corners. Opposing radial rasters curve up and down around a central band
   * of straight lines. The three 1px color slots are static to avoid flicker.
   */
  #mi-crt-glass::after {
    z-index: 1;
    --mi-beam: repeating-linear-gradient(0deg, transparent 0 2px, rgb(3 6 9 / .14) 2.4px 3.4px, transparent 3.9px 4px);
    --mi-glass-radius: max(510vw, 275vh);
    --mi-raster-top: repeating-radial-gradient(circle at 50% calc(100% + var(--mi-glass-radius)), transparent 0 2px, rgb(3 6 9 / .14) 2.4px 3.4px, transparent 3.9px 4px);
    --mi-raster-bottom: repeating-radial-gradient(circle at 50% calc(0px - var(--mi-glass-radius)), transparent 0 2px, rgb(3 6 9 / .14) 2.4px 3.4px, transparent 3.9px 4px);
    --mi-slots: repeating-linear-gradient(90deg, rgb(234 54 51 / .055) 0 1px, rgb(42 192 118 / .055) 1px 2px, rgb(63 108 242 / .055) 2px 3px);
    --mi-aperture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 1000' preserveAspectRatio='none'%3E%3Cdefs%3E%3Cpath id='face' d='M500 2C270 2 111 5 44 11C19 13 12 20 9 45C4 143 2 319 2 500S4 857 9 955C12 980 19 987 44 989C111 995 270 998 500 998S889 995 956 989C981 987 988 980 991 955C996 857 998 681 998 500S996 143 991 45C988 20 981 13 956 11C889 5 730 2 500 2Z'/%3E%3Cmask id='edge'%3E%3Crect width='1000' height='1000' fill='white'/%3E%3Cuse href='%23face' fill='black'/%3E%3C/mask%3E%3C/defs%3E%3Crect width='1000' height='1000' fill='%23030608' mask='url(%23edge)'/%3E%3Cuse href='%23face' fill='none' stroke='%23060d10' stroke-opacity='.64' stroke-width='3' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
    background:
      var(--mi-aperture) center / 100% 100% no-repeat,
      linear-gradient(90deg, rgb(2 6 10 / .18), transparent 3%, transparent 97%, rgb(2 6 10 / .18)),
      radial-gradient(ellipse at center, transparent 56%, rgb(3 8 14 / .10) 87%, rgb(2 6 10 / .30) 100%),
      var(--mi-slots),
      var(--mi-raster-top) top / 100% 42% no-repeat,
      var(--mi-beam) center / 100% 16% no-repeat,
      var(--mi-raster-bottom) bottom / 100% 42% no-repeat;
  }

  html:is([data-mi-gl="ready"], [data-mi-gl="canvas"]) #mi-crt-glass::after {
    display: none;
  }
}

#mi-crt-map-defs { position: absolute; width: 0; height: 0; pointer-events: none; }
#mi-crt-lens { position: absolute; inset: 0; pointer-events: none; }
@media screen and (forced-colors: none) and (prefers-contrast: no-preference) {
  #mi-crt-lens { backdrop-filter: url("#mi-crt-distortion"); }
}

/* Keep the two existing project links in the reading order at the end of the page. */
html #uniflora-projects,
html .interior-thread {
  position: static;
  inset: auto;
  z-index: auto;
  vertical-align: top;
  box-sizing: border-box;
  margin: .3rem .25rem .4rem;
  max-width: calc(100% - .5rem);
  min-width: 0;
  overflow-wrap: anywhere;
}

html #uniflora-projects { display: inline-block; }
html .interior-thread:not([hidden]) {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  padding-block: 0;
}
html .interior-thread[hidden] { display: none; }
html .interior-thread a { display: inline-flex; align-items: center; min-height: 44px; }

html #uniflora-projects > summary {
  min-height: 44px;
  flex-wrap: wrap;
  justify-content: flex-start;
}
html #uniflora-projects[open] {
  display: block;
  width: min(32rem, calc(100% - .5rem));
}
html #uniflora-projects > nav {
  position: static;
  inset: auto;
  width: 100%;
  max-width: none;
  max-height: none;
  overflow: visible;
  box-sizing: border-box;
  margin: .35rem 0 0;
  box-shadow: none;
}

/* The workspace owns the viewport-bottom navigation, including its text size
   and safe-area insets. Carry its actual footprint below the final links. */
body[data-mi-footer-links] {
  --mi-footer-inset: max(1rem, calc((100% - 1500px) / 2 + 2rem));
  padding-bottom: calc(var(--mi-workspace-footprint, 5rem) + .65rem);
}
body[data-mi-footer-links] .app-shell { padding-bottom: .5rem; }
body[data-mi-footer-links] > #uniflora-projects,
body[data-mi-footer-links] > #root + .interior-thread {
  margin-inline-start: var(--mi-footer-inset);
  max-width: calc(100% - var(--mi-footer-inset) - .5rem);
}
html dialog.disclaimer-splash > #uniflora-projects {
  margin: .35rem 1rem 1rem;
  max-width: calc(100% - 2rem);
}
@media (max-width: 30rem) {
  body[data-mi-footer-links] > .interior-thread:not([hidden]) {
    display: flex;
    width: fit-content;
    margin-inline-start: var(--mi-footer-inset);
    max-width: calc(100% - var(--mi-footer-inset) - .5rem);
  }
}
