:root {
  --navy: #102A43;
  --ink: #071525;
  --ice: #73C7E8;
  --glacier: #D9F4FF;
  --aurora: #56D6A4;
  --coral: #FF725E;
  --snow: #FFFFFF;
  color-scheme: dark;
  font-family: Outfit, "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--glacier);
  background: var(--navy) url("bg-night.jpg") center/cover fixed;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--aurora); outline-offset: 3px; }
::selection { background: var(--aurora); color: var(--ink); }
h1, h2, .hud strong, .splash-title {
  font-family: Fraunces, "Iowan Old Style", Palatino, serif;
  font-weight: 500;
  color: var(--snow);
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#splash {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(115, 199, 232, 0.16), transparent 42%),
    var(--navy);
}
.crack-svg {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 150vmin;
  height: 150vmin;
  transform: translate(-50%, -50%);
}
.crack-svg path {
  fill: none;
  stroke: var(--glacier);
  stroke-width: 0.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 80;
  stroke-dashoffset: 80;
  animation: crack 0.7s ease-out forwards;
}
.crack-svg path:nth-child(2),
.crack-svg path:nth-child(5) { stroke: var(--ice); animation-delay: 0.12s; }
.crack-svg path:nth-child(3),
.crack-svg path:nth-child(6) { animation-delay: 0.22s; }
.slit {
  position: absolute;
  width: 16px;
  height: 0;
  border-radius: 20px;
  background: var(--ink);
  box-shadow: 0 0 0 7px rgba(217, 244, 255, 0.78), 0 0 28px rgba(86, 214, 164, 0.45);
  animation: slit 0.62s ease-out forwards;
}
.glow {
  position: absolute;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(86, 214, 164, 0.55), transparent 68%);
  filter: blur(2px);
  opacity: 0;
  animation: fade 0.45s 0.5s forwards;
}
.splash-lure {
  position: relative;
  z-index: 2;
  width: 46px;
  height: 74px;
  border-radius: 50% 50% 46% 46% / 58% 58% 42% 42%;
  background: radial-gradient(circle at 35% 28%, #fff 0 8%, #ffb1a6 9%, var(--coral) 46%, #d24536 100%);
  box-shadow: 0 12px 28px rgba(255, 114, 94, 0.48);
  transform: translateY(92px) scale(0.86);
  opacity: 0;
  animation: rise 0.9s 0.42s cubic-bezier(0.16, 0.84, 0.32, 1) forwards;
}
.splash-lure::after {
  content: "";
  position: absolute;
  right: -10px;
  bottom: 8px;
  width: 16px;
  height: 16px;
  border: 2px solid var(--glacier);
  border-left-color: transparent;
  border-radius: 50%;
  transform: rotate(24deg);
}
.splash-title {
  position: absolute;
  bottom: 11%;
  margin: 0;
  letter-spacing: 0.01em;
  font-size: clamp(2rem, 7vw, 3.2rem);
  opacity: 0;
  animation: fade 0.4s 1.05s forwards;
}
@keyframes crack { to { stroke-dashoffset: 0; } }
@keyframes slit { to { height: 132px; } }
@keyframes rise {
  0% { transform: translateY(92px) scale(0.86); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: translateY(-6px) scale(1); opacity: 1; }
}
@keyframes fade { to { opacity: 1; } }

#onboard {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(16, 42, 67, 0.55), rgba(16, 42, 67, 0.92)),
    url("bg-night.jpg") center/cover;
  user-select: none;
}
.eyebrow, .ob-count {
  margin: 0;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ice);
}
.ob-count { margin-top: 6px; color: var(--snow); letter-spacing: 0.08em; }
.steps { display: flex; gap: 8px; margin: 12px 0; }
.steps i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(217, 244, 255, 0.28);
}
.steps i.is-done { background: var(--ice); }
.steps i.is-on { background: var(--aurora); transform: scale(1.35); }
.ob-body { flex: 1; min-height: 0; overflow: auto; }
.scene { display: grid; align-content: start; gap: 8px; }
.scene h2 { margin: 6px 0 0; font-size: clamp(1.8rem, 6vw, 2.5rem); }
.scene p { margin: 0; line-height: 1.45; }
.ob-actions { display: flex; gap: 10px; padding-top: 12px; }
.ob-actions button { flex: 1; }
.stage, #drill-plate, #trial-canvas {
  border-radius: 28px;
  box-shadow: inset 0 0 0 1px rgba(217, 244, 255, 0.28);
}
.stage, #drill-plate { position: relative; height: 280px; overflow: hidden; touch-action: none; }
#drill-plate {
  --p: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #f4fbff 0%, #8ed0ee 68%, #102a43 100%);
}
.bore {
  position: absolute;
  width: 104px;
  height: 78px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, var(--ink) 0 56%, var(--glacier) 58% 72%, var(--ice) 74%);
  transform: scale(0.15);
  opacity: 0;
}
#drill-plate.is-open .bore {
  opacity: 1;
  transform: scale(1);
  transition: transform 0.4s ease, opacity 0.4s ease;
}
#auger {
  position: relative;
  z-index: 1;
  width: 96px;
  height: 96px;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  font-weight: 700;
  background: conic-gradient(var(--coral) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.82) 0);
  box-shadow: inset 0 0 0 8px rgba(16, 42, 67, 0.12), 0 10px 18px rgba(7, 21, 37, 0.2);
}
#drill-plate.is-open #auger { opacity: 0; pointer-events: none; }
#arc-dots { position: absolute; inset: 0; }
#arc-dots i {
  position: absolute;
  width: 9px;
  height: 9px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--coral);
  opacity: 0.16;
}
#arc-dots i.is-on { opacity: 1; box-shadow: 0 0 10px rgba(255, 114, 94, 0.7); }
#arc-stage, #release-stage {
  background:
    radial-gradient(90px 60px at 50% 36%, rgba(7, 21, 37, 0.18), transparent 72%),
    linear-gradient(180deg, rgba(217, 244, 255, 0.3), rgba(115, 199, 232, 0.14));
}
#arc-hold {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  background: var(--coral);
  color: var(--ink);
  font-weight: 700;
}
#lesson-hole {
  position: absolute;
  left: 50%;
  top: 34%;
  width: 96px;
  height: 72px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, var(--ink) 0 46%, var(--glacier) 48% 63%, var(--ice) 65% 82%, transparent 83%);
}
#lesson-lure {
  position: absolute;
  left: 50%;
  bottom: 36px;
  width: 22px;
  height: 34px;
  margin-left: -11px;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--coral) 46%, #c44736);
  box-shadow: 0 8px 16px rgba(255, 114, 94, 0.35);
}
#trial-canvas {
  width: 100%;
  height: 320px;
  display: block;
  background: var(--ink);
  touch-action: none;
}

.cut, .ghost, .choice button, .tiny {
  border-radius: 999px;
  padding: 14px 16px;
  font-weight: 700;
}
.cut {
  border: 0;
  background: var(--coral);
  color: var(--ink);
}
.ghost {
  border: 1px solid rgba(217, 244, 255, 0.35);
  background: transparent;
  color: var(--glacier);
}
.tiny { padding: 8px 12px; font-size: 0.85rem; }
.fine { margin: 8px 0 0; color: var(--ice); font-size: 0.92rem; line-height: 1.45; }
.pale { color: rgba(255, 255, 255, 0.9); }

#shell {
  width: min(560px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(16, 42, 67, 0.78), rgba(16, 42, 67, 0.94));
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}
.top { padding-top: env(safe-area-inset-top); }
.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 0;
}
.mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.28);
}
.titles { flex: 1; min-width: 0; }
.titles h1 { margin: 0; font-size: clamp(1.55rem, 5vw, 2.05rem); line-height: 0.95; }
.frost-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 5px 0 0;
  color: var(--snow);
  font-weight: 700;
}
.frost-line img { width: 16px; height: 16px; object-fit: contain; }
#mute {
  border-radius: 999px;
  border: 1px solid rgba(217, 244, 255, 0.32);
  background: transparent;
  color: var(--glacier);
  padding: 8px 12px;
}
.hole-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  justify-items: center;
  padding: 10px 8px 6px;
  user-select: none;
}
.hole-tab {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--glacier);
}
.rim {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 40%, #12344e 0 42%, #e9f8ff 43% 54%, #73c7e8 55% 68%, rgba(16, 42, 67, 0) 69%);
  box-shadow: inset 0 6px 10px rgba(255, 255, 255, 0.35), 0 10px 16px rgba(0, 0, 0, 0.28);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s ease;
}
.hole-tab.is-on .rim {
  transform: scale(1.26);
  background:
    radial-gradient(circle at 50% 40%, var(--aurora) 0 40%, #f4fffb 42% 54%, #7fe0c0 55% 68%, rgba(16, 42, 67, 0) 69%);
  box-shadow:
    0 0 0 6px rgba(86, 214, 164, 0.28),
    0 0 28px rgba(86, 214, 164, 0.72),
    inset 0 6px 10px rgba(255, 255, 255, 0.55);
}
.label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.hole-tab.is-on .label { color: var(--aurora); }

.hero {
  position: relative;
  overflow: hidden;
  min-height: 280px;
  margin: 8px 12px 0;
  padding: 16px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(16, 42, 67, 0.08), rgba(7, 21, 37, 0.78)),
    url("bg-dawn.jpg") center/cover;
  box-shadow: inset 0 0 0 1px rgba(217, 244, 255, 0.24);
}
.flake {
  position: absolute;
  width: 34px;
  pointer-events: none;
  opacity: 0.85;
  animation: floaty 8s ease-in-out infinite;
}
.f1 { top: 14px; right: 14px; }
.f2 { top: 78px; right: 64px; width: 20px; animation-duration: 11s; }
.f3 { bottom: 18px; left: 12px; width: 26px; animation-duration: 9s; }
@keyframes floaty { 50% { transform: translateY(8px); } }
.hud {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.hud span, .subhud {
  color: var(--ice);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.hud strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 700;
  line-height: 0.9;
  text-shadow: 0 2px 12px rgba(7, 21, 37, 0.55);
}
.chain-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
#chain { display: flex; gap: 7px; }
.pip {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(217, 244, 255, 0.55);
}
.pip.is-on {
  background: var(--aurora);
  box-shadow: 0 0 12px rgba(86, 214, 164, 0.85);
}
#chain-note {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--snow);
}
.subhud {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 0 0;
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 0.82rem;
}
#latest {
  position: relative;
  margin: 8px 0 0;
  font-family: Fraunces, Palatino, serif;
  font-size: 1.15rem;
  color: var(--snow);
}

.card {
  margin: 14px 12px 0;
  padding: 16px;
  border-radius: 22px;
  background: rgba(217, 244, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(217, 244, 255, 0.14);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.card-head h2 { margin: 0; font-size: 1.55rem; }
.card-head span { color: var(--ice); font-size: 0.82rem; letter-spacing: 0.08em; }
.choice { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.choice button {
  flex: 1;
  min-width: 88px;
  border: 1px solid rgba(115, 199, 232, 0.4);
  background: rgba(115, 199, 232, 0.08);
  color: var(--glacier);
}
#bell-status { margin: 12px 0 0; }
.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 12px 0;
  padding: 12px;
  border-radius: 18px;
  background: rgba(86, 214, 164, 0.16);
  box-shadow: inset 0 0 0 1px rgba(86, 214, 164, 0.45);
}
.banner img { width: 36px; height: 36px; object-fit: contain; }
.banner strong { display: block; color: var(--snow); }
.banner p { margin: 2px 0 0; }
.banner button { margin-left: auto; }
.trail {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 4px;
  margin-top: 12px;
}
.bead {
  display: block;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(217, 244, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(217, 244, 255, 0.28);
}
.bead.is-miss { background: transparent; box-shadow: inset 0 0 0 2px var(--coral); }
.bead.is-hit { background: var(--ice); }
.bead.rarity-common { background: var(--glacier); }
.bead.rarity-uncommon { background: var(--ice); }
.bead.rarity-rare, .bead.rarity-aurora { background: var(--aurora); }
.bead.rarity-epic { background: var(--coral); }

#journal, #guide { list-style: none; margin: 8px 0 0; padding: 0; }
#journal li, #guide li {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(217, 244, 255, 0.12);
}
#journal li.empty { display: block; color: var(--ice); }
#journal img, #guide img { width: 42px; height: 42px; object-fit: contain; }
#guide li.is-out img { opacity: 0.4; }
#journal strong, #guide strong { display: block; color: var(--snow); font-weight: 700; }
#journal span, #guide span, #journal time, #guide b {
  display: block;
  color: var(--ice);
  font-size: 0.82rem;
  font-weight: 500;
}
.rarity { font-style: normal; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.72rem; }
.rarity-common { color: var(--glacier); }
.rarity-uncommon { color: var(--ice); }
.rarity-rare { color: var(--aurora); }
.rarity-epic { color: var(--coral); }
.rarity-aurora { color: var(--snow); text-shadow: 0 0 10px var(--aurora); }

.aim-wrap {
  position: relative;
  height: calc(100dvh - 214px);
  min-height: 460px;
  margin: 8px 12px 0;
  border-radius: 28px;
  overflow: hidden;
  background: var(--ink);
  touch-action: none;
  user-select: none;
  box-shadow: inset 0 0 0 1px rgba(217, 244, 255, 0.16);
}
#aim-canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.aim-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
}
.aim-hud span {
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(16, 42, 67, 0.78);
  color: var(--snow);
  font-size: 12px;
  letter-spacing: 0.03em;
  box-shadow: inset 0 0 0 1px rgba(217, 244, 255, 0.2);
}
#aim-time.is-low { color: var(--coral); }
#aim-chain { color: var(--ink); background: var(--aurora); font-weight: 700; }
.aim-hint {
  position: absolute;
  top: 54px;
  left: 12px;
  right: 12px;
  margin: 0;
  text-align: center;
  color: var(--snow);
  text-shadow: 0 2px 8px var(--ink);
  pointer-events: none;
}
.veil {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(16, 42, 67, 0.86);
  box-shadow: inset 0 0 0 1px rgba(217, 244, 255, 0.2);
  backdrop-filter: blur(8px);
}
.veil h2 { margin: 0; font-size: 1.8rem; }
.veil p { margin: 8px 0 14px; line-height: 1.45; }
.veil .cut { width: 100%; }

@media (min-width: 400px) {
  .rim { width: 78px; height: 78px; }
}
@media (min-width: 760px) {
  body { padding: 28px 0; }
  #shell {
    min-height: calc(100dvh - 56px);
    border-radius: 32px;
    overflow: clip;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(217, 244, 255, 0.16);
  }
}
@media (prefers-reduced-motion: reduce) {
  .splash-lure, .crack-svg path, .splash-title, .slit, .glow, .flake, .rim {
    animation-duration: 0.01s;
    animation-delay: 0s;
    transition: none;
  }
}
