:root {
  color-scheme: dark;
  --bg: #111126;
  --ink: #fff8ee;
  --muted: #c9c4e0;
  --gold: #ffdb9d;
  --line: #40395e;
  --lilac: #e0c9fa;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100svh;
  background: radial-gradient(ellipse 85% 470px at 45% 34px, #332451, transparent 100%), var(--bg);
  background-repeat: no-repeat;
  color: var(--ink);
  font: 1rem/1.65 "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
}
h1, h2, p, figure { margin: 0; }
h1, h2 { font-family: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, serif; }
a { color: inherit; }
button, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
[hidden] { display: none !important; }

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

.header, main, footer { width: min(940px, calc(100% - 32px)); margin-inline: auto; }
.header {
  min-height: 58px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}
.brand { font-size: .875rem; font-weight: 750; text-decoration: none; }
.brand > span[aria-hidden], .eyebrow > span[aria-hidden] { color: var(--gold); margin-right: .3em; }
.header-meta, .result-nav { display: flex; align-items: center; }
.header-meta { color: var(--lilac); font-size: .875rem; white-space: nowrap; }
.change-sign { display: inline-flex; align-items: center; min-height: 44px; text-underline-offset: .2em; }
@media (max-width: 420px) {
  .header:has(.result-nav:not([hidden])) .brand-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

.hero { display: grid; gap: 16px; padding-top: 22px; }
.intro { text-align: center; }
h1 {
  font-size: clamp(1.75rem, 7.9vw, 3.65rem);
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: .035em;
}
h1 span { color: var(--gold); white-space: nowrap; }
.intro h1 { font-size: clamp(1.375rem, 6.5vw, 2.65rem); }
.intro p { color: var(--muted); margin-top: 7px; }

.sky {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 528 / 330;
  border: 1px solid #54416e;
  border-radius: 20px;
  background: radial-gradient(ellipse at 31% 44%, #513671 0%, #292247 49%, #16172f 87%);
}
.sky-art { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none; }
.sky canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.constellation { position: absolute; inset: 0; }
#constellation-image {
  position: absolute;
  left: 31.1%;
  top: 43.6%;
  width: 34%;
  height: auto;
  transform: translate(-50%, -50%);
  mix-blend-mode: screen;
}
.mascot {
  position: absolute;
  right: 7%;
  bottom: 0;
  width: 35%;
  padding: 0;
  border: 0;
  background: none;
  touch-action: manipulation;
  filter: drop-shadow(0 0 12px #e4a6fa4a);
}
.mascot img { display: block; width: 100%; height: auto; }
/* Keep the body outline above the tail where they meet. */
.mascot-body {
  position: relative;
  clip-path: polygon(0 0, 100% 0, 100% 87.8%, 79.20% 87.8%, 78.87% 91.8%, 78.33% 95.1%, 77.64% 98.4%, 77.44% 100%, 0 100%);
}
.mascot-tail {
  position: absolute;
  inset: 0;
  clip-path: polygon(77.64% 87.65%, 92.50% 87.65%, 93.48% 93%, 91.32% 97%, 76.75% 99%);
  transform-origin: 77.74% 91.5%;
  animation: shippei-tail-wag 30s ease-in-out 30s infinite;
}
@keyframes shippei-tail-wag {
  0%, 4.2%, 100% { transform: rotate(0); }
  .65% { transform: rotate(-13deg); }
  1.3% { transform: rotate(9deg); }
  1.95% { transform: rotate(-11deg); }
  2.6% { transform: rotate(8deg); }
  3.25% { transform: rotate(-5deg); }
  3.75% { transform: rotate(3deg); }
}
.mascot-sparkles { position: absolute; z-index: 1; inset: 0; pointer-events: none; }
.mascot-sparkle {
  position: absolute;
  width: var(--size);
  aspect-ratio: 1;
  background: #ffe7a3;
  clip-path: polygon(50% 0, 61% 38%, 100% 50%, 61% 62%, 50% 100%, 39% 62%, 0 50%, 39% 38%);
  animation: mascot-sparkle .9s var(--delay) ease-out both;
}
.mascot-sparkle:nth-child(even) { background: #f5d6ff; }
@keyframes mascot-sparkle {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.25); }
  25% { opacity: 1; transform: translate(-50%, -65%) scale(1.1); }
  45% { opacity: .52; }
  64% { opacity: .92; transform: translate(-50%, -85%) scale(.9); }
  100% { opacity: 0; transform: translate(-50%, -115%) scale(.3); }
}
.sky-caption {
  position: absolute;
  left: 10.1%;
  bottom: 10%;
  width: 42%;
  text-align: center;
  color: #f6dcae;
  font-size: clamp(.825rem, 3.6vw, 1rem);
  font-weight: 700;
  letter-spacing: .09em;
}
.twinkle {
  position: absolute;
  width: 14px;
  aspect-ratio: 1;
  background: #ffe4a9;
  clip-path: polygon(50% 0, 61% 38%, 100% 50%, 61% 62%, 50% 100%, 39% 62%, 0 50%, 39% 38%);
  animation: twinkle 4s ease-in-out infinite;
}
.twinkle-first { top: 17%; left: 52%; }
.twinkle-second { top: 23%; left: 9%; animation-delay: -1.7s; width: 10px; }
@keyframes twinkle {
  0%, 100% { opacity: .43; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1.15); }
}

.meteor {
  position: absolute;
  top: 0;
  right: -34%;
  width: 40%;
  height: 4px;
  border-radius: 100%;
  opacity: 0;
  background: linear-gradient(90deg, #fffaf0, #ffd393 9%, #e8c0fe 30%, transparent 100%);
  box-shadow: -9px 0 18px #ffd49c;
}
.meteor::before {
  content: "";
  position: absolute;
  left: -3px;
  top: -6px;
  width: 16px;
  aspect-ratio: 1;
  background: #fff9dc;
  clip-path: polygon(50% 0, 61% 38%, 100% 50%, 61% 62%, 50% 100%, 39% 62%, 0 50%, 39% 38%);
}
.is-reading.with-meteor .meteor { animation: meteor-pass .78s .34s cubic-bezier(.32,.1,.58,1) both; }
@keyframes meteor-pass {
  0% { opacity: 0; transform: translate(0, 0) rotate(-22deg); }
  15%, 70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-365%, 4800%) rotate(-22deg); }
}
.is-reading #constellation { animation: constellation-appear .65s ease-out both; }
@keyframes constellation-appear {
  from { opacity: 0; filter: brightness(1.65); }
  to { opacity: 1; }
}

.pick { display: grid; gap: 8px; scroll-margin-top: 16px; }
.pick label { font-weight: 750; font-size: .9375rem; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: "";
  position: absolute;
  top: 21px;
  right: 20px;
  width: 9px;
  height: 9px;
  border: solid var(--gold);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  pointer-events: none;
}
select {
  width: 100%;
  min-height: 54px;
  appearance: none;
  padding: 10px 45px 10px 15px;
  background: #211c3b;
  border: 1px solid #75618d;
  border-radius: 11px;
}
select:invalid { color: var(--muted); }
select option { color: var(--ink); background: #211c3b; }
.read-fortune {
  min-height: 54px;
  margin-top: 2px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .6em;
  background: linear-gradient(110deg, #ffe5af, #ffd28d);
  border: 1px solid #ffdf9e;
  border-radius: 11px;
  color: #2c1c33;
  box-shadow: 0 6px 22px #f9b86128;
  font-weight: 800;
  letter-spacing: .13em;
  animation: button-appear .22s ease-out both;
}
.read-fortune:hover { background: #ffebc6; }
.read-fortune[aria-disabled="true"] { cursor: wait; }
@keyframes button-appear { from { opacity: 0; transform: translateY(-4px); } }

.result-screen {
  width: min(100%, 720px);
  margin-inline: auto;
  padding-top: 16px;
}
.fortune {
  position: relative;
  isolation: isolate;
  padding: clamp(18px, 4.4vw, 34px);
  border: 1px solid #a482b5;
  border-radius: 18px;
  background: radial-gradient(ellipse at top right, #50396a, transparent 77%), #231e3c;
  box-shadow: 0 12px 36px #09071654;
  animation: fortune-appear .4s ease-out both;
}
@keyframes fortune-appear { from { opacity: 0; transform: translateY(12px); } }
.result-meteors {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}
.viewport-meteors {
  position: fixed;
  z-index: 3;
  inset: 0;
  height: 100dvh;
  overflow: hidden;
  pointer-events: none;
}
.viewport-meteors:empty { display: none; }
.result-meteor {
  top: var(--start-y);
  right: auto;
  left: var(--start-x);
  width: var(--trail);
  height: 3px;
  transform-origin: left center;
  animation: result-meteor-fall var(--duration, .84s) var(--delay) linear both;
}
.result-meteor::before { width: 13px; top: -5px; }
.viewport-meteors .result-meteor {
  --duration: 1.65s;
  --fall-x: calc(-1 * min(65vw, 520px));
  --fall-y: min(51vw, 408px);
}
@keyframes result-meteor-fall {
  0% { opacity: 0; transform: translate3d(0,0,0) rotate(-38deg); }
  23%, 65% { opacity: .92; }
  100% { opacity: 0; transform: translate3d(var(--fall-x, -155px), var(--fall-y, 121px), 0) rotate(-38deg); }
}
.fortune-head, .dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.eyebrow { color: var(--gold); font-weight: 700; font-size: .9375rem; letter-spacing: .04em; }
h2 { line-height: 1.2; }
.fortune h1 { margin-top: 4px; font-size: clamp(2.125rem, 9vw, 3.8rem); color: #fff3d9; }
.fortune h1:focus { outline: none; }
.rank-badge {
  position: relative;
  flex: none;
  width: clamp(4.25rem, 21vw, 6.25rem);
  text-align: center;
}
.rank-badge img { display: block; width: 100%; height: auto; }
.rank-label {
  position: absolute;
  inset: 45% 0 auto;
  color: #282038;
  font-size: clamp(.875rem, 3.8vw, 1.1875rem);
  line-height: 1.2;
  font-weight: 750;
  white-space: nowrap;
}
.summary {
  margin: 16px 0 19px;
  font-size: clamp(1.075rem, 4.5vw, 1.35rem);
  line-height: 1.85;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.ratings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ratings > div {
  padding: 9px 5px;
  text-align: center;
  border: 1px solid #4e416c;
  border-radius: 8px;
  background: #1c1934;
}
.ratings strong { display: block; color: var(--muted); font-size: .875rem; }
.stars { color: var(--gold); letter-spacing: .09em; white-space: nowrap; }
.luck { display: grid; gap: 9px; margin: 19px 0 0; }
.luck div { min-width: 0; padding-top: 8px; border-top: 1px solid #55436f; }
dt { color: var(--lilac); font-size: .875rem; }
dd { margin: 2px 0 0; }
.luck dd { overflow-wrap: anywhere; }
#item a { color: var(--gold); text-underline-offset: .2em; overflow-wrap: anywhere; }
#item a:hover { color: var(--ink); }
.swatch {
  display: inline-block;
  width: .85em;
  height: .85em;
  border: 1px solid #ffffff65;
  border-radius: 50%;
  margin-right: .45em;
  vertical-align: -.02em;
}
.ranking-action { display: flex; justify-content: center; margin: 17px 0 0; }
.quiet, .close {
  min-height: 44px;
  padding: 7px 14px;
  background: #211c39;
  border: 1px solid #64557f;
  border-radius: 9px;
  font-size: .875rem;
}
.quiet:hover, .close:hover { border-color: var(--gold); }
.shop-action {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-top: 17px;
  text-align: center;
}
.shop-action p { color: var(--muted); font-size: .875rem; }
.shop-link {
  display: inline-flex;
  align-items: center;
  border-color: #aa854d;
  color: var(--gold);
  text-decoration: none;
}

dialog {
  background: #211d39;
  color: var(--ink);
  border: 1px solid #6a5d8e;
  border-radius: 15px;
  padding: 18px;
  width: min(480px, calc(100% - 28px));
  max-height: 85dvh;
}
dialog::backdrop { background: #0b0b20ba; }
.dialog-head { margin-bottom: 10px; }
.dialog-head h2 { font-size: clamp(1.25rem, 5.6vw, 1.8rem); }
.close { min-width: 44px; font-size: 1.35rem; line-height: 1; padding: 6px 9px; }
ol { margin: 0; padding: 0; list-style: none; }
ol button {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: 3.5em 1.6em 1fr;
  align-items: center;
  text-align: left;
  padding: 7px 6px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
}
ol button:hover { background: #30274d; }
.glyph { color: var(--gold); font: 1.35rem/1.15 "Georgia", serif; }
.pos { color: var(--lilac); font-size: .875rem; }

footer {
  margin-top: 24px;
  padding: 14px 0 24px;
  border-top: 1px solid var(--line);
  font-size: .8125rem;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 680px) {
  .hero {
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
    align-items: start;
    gap: 16px clamp(24px, 5vw, 65px);
    padding-top: 36px;
  }
  .intro { grid-area: 1 / 1; align-self: end; text-align: left; }
  .intro h1 { font-size: clamp(2rem, 4.4vw, 3.35rem); }
  .intro p { margin-top: 12px; }
  .sky { grid-area: 1 / 2 / span 2; align-self: center; }
  .pick { grid-area: 2 / 1; }
  .ratings { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .luck { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; }
}
