@font-face {
  font-family: "Touhou Brush";
  src: url("assets/touhou-brush.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: block;
  /* 30px fallback text fits five characters; the custom wordmark uses 150px. */
  size-adjust: 500%;
  unicode-range: U+20, U+5E7B, U+60F3, U+65B9, U+6771, U+9109;
}

:root {
  color-scheme: light;
  font-family: Arial, "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: #30383e;
  background: #8cbeef;
  --panel: #fcfdfe;
  --panel-border: #668099;
  --panel-shadow: 0 0 6px rgb(48 48 48 / 60%);
  --focus: #125d91;
}

* { box-sizing: border-box; }
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
}

/* Divide spare height 40:60, while keeping both ends accessible on short screens. */
body::before,
body::after {
  content: "";
  min-height: 16px;
}
body::before { flex: 2 0 0; }
body::after { flex: 3 0 0; }
a { color: inherit; }

.page {
  flex: none;
  width: min(986px, calc(100% - 32px));
  margin: 0 auto;
}

.home-panel,
.footer-panel {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: var(--panel-shadow);
}

.home-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  grid-template-rows: 150px auto;
  grid-template-areas: "art brand" "art navigation";
  gap: 19px 27px;
  align-items: start;
  min-height: 611px;
  padding: 39px 41px 114px 26px;
  background: var(--panel);
}

.brand {
  grid-area: brand;
  position: relative;
  justify-self: center;
  width: 150px;
  height: 150px;
  isolation: isolate;
}

.brand-jade {
  position: absolute;
  top: 22px;
  left: 13px;
  width: 120px;
  height: 120px;
}

/* dlig composes the five real characters into the reviewed calligraphic logo.
   Its 1000-unit em corresponds exactly to the source's 150px square. */
.brand h1 {
  position: absolute;
  inset: 0;
  margin: 0;
  font-family: "Touhou Brush", serif;
  font-size: 30px;
  font-weight: 400;
  font-style: normal;
  font-synthesis: none;
  font-variant-ligatures: discretionary-ligatures;
  line-height: 150px;
  white-space: nowrap;
  color: #252927;
  text-shadow: 0 0 5.56px #f8312f;
  pointer-events: none;
}

/* The fallback is ordinary text if the browser cannot shape the logo ligature. */
@supports not (font-variant-ligatures: discretionary-ligatures) {
  .brand h1 { font-family: serif; }
}

.illustration {
  grid-area: art;
  display: block;
  margin-top: 64px;
}

.illustration img {
  display: block;
  width: 100%;
  /* Keep the original 640 × (731 / 1200) height as the art column narrows. */
  height: 389.87px;
  object-fit: cover;
  object-position: 66.67%;
}

.navigation {
  grid-area: navigation;
  display: grid;
  gap: 5px;
  scroll-margin: 24px;
}

.glass-button {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 3px 12px;
  border: 0;
  border-radius: 7px;
  color: #414343;
  text-shadow: 0 1px 0 #fff;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  -webkit-tap-highlight-color: #badcf8;
}

/* The old 40px button includes a thin outer rim and two bottom shadow rows.
   Keep that depth inside the link's box, independent of text and hit area. */
.glass-button::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 1px 1px 2px;
  border: 1px solid;
  border-color: #b7b7b7 #b9b9b9 #d7d7d7;
  border-radius: 5px;
  background: linear-gradient(to bottom,
    #f7f7f7 0%, #e8e8e8 50%, #ddd 54%, #dfdfdf 100%);
  box-shadow: inset 0 0 0 1px #fff,
    0 1px 0 #c5c5c5, 0 2px 0 #dadada, 0 0 0 1px #dbdbdb;
}

@media (hover: hover) {
  .glass-button:hover {
    text-shadow: 0 0 2px #fff, 0 0 4px #eaf5ff, 0 1px 1px #fff;
  }
  .glass-button:hover::before {
    background: linear-gradient(to bottom,
      #c9e1f0 0%, #798db7 50%, #415985 54%,
      #45618d 72%, #436b97 84%, #3389af 96%, #3192b6 100%);
  }
}

.glass-button:active::before {
  background: linear-gradient(#c7dce9, #edf6fc);
  box-shadow: inset 0 1px 3px #486a8759, inset 0 0 0 1px #fff9;
}

a:focus-visible,
.navigation:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.footer-panel {
  min-height: 124px;
  margin-top: 14px;
  padding: 27px clamp(0px, calc(100% - 352px), 58px) 20px
    clamp(0px, calc(100% - 410px), 186px);
  /* Give up the left gutter first to retain a 350px credits box. */
  border-color: #54728e;
  box-shadow: inset 0 0 0 1px #f1f1f1, var(--panel-shadow);
  background-color: #dfeefa;
  background-image: url("assets/9829083_p0.jpg");
  background-size: calc(100% + 18px) auto;
  background-position: center 45%;
  background-repeat: no-repeat;
}

.credits {
  min-width: 350px;
  min-height: 48px;
  padding: 3px 22.5px;
  border: 1px solid rgb(0 0 0 / 23%);
  border-radius: 6px;
  color: #000;
  background: rgb(240 240 240 / 57%);
  background-clip: padding-box;
  box-shadow: 0 0 6px rgb(0 0 0 / 28%);
  font-size: 12px;
  line-height: 19.2px;
}

.credits p { margin: 0; }
.credits a { font-weight: 700; text-decoration: none; }
.credits a:hover { text-decoration: underline; text-underline-offset: 2px; }

.skip-link {
  position: fixed;
  z-index: 2;
  top: 8px;
  left: 16px;
  padding: 10px 16px;
  border-radius: 4px;
  color: #fff;
  background: #164b72;
  transform: translateY(calc(-100% - 16px));
}

.skip-link:focus { transform: none; }

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

/* xs: below 576px. The full layout is visible from sm (576px) onward. */
@media (width < 576px) {
  .home-panel {
    width: min(332px, 100%);
    margin-inline: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "brand" "navigation";
    gap: 24px;
    min-height: auto;
    padding: 20px 16px;
  }
  .illustration,
  .footer-panel { display: none; }
  .navigation {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    width: min(250px, 100%);
    justify-self: center;
  }
  .glass-button { min-height: 44px; font-size: 18px; padding-inline: 6px; }
}

@media (width < 576px) and (height >= 616px) {
  .footer-panel {
    display: block;
    width: 332px;
    margin-inline: auto;
    padding: 14px 0 28px 19px;
  }
  .credits {
    padding: 3px;
    border-radius: 0;
  }
}

@media (width < 576px) and (height >= 750px) {
  .footer-panel { min-height: 0; }
  .credits {
    min-width: 0;
    min-height: 0;
  }
  .credits p:nth-child(2) { display: none; }
}

@media (forced-colors: active) {
  .glass-button::before, .credits { border-color: ButtonText; }
  .brand h1 { text-shadow: none; }
}
