:root {
  --bg: #070B24;
  --bg2: #120A3A;
  --panel: #0F1640;
  --line: #3A4170;
  --text: #F4F6FF;
  --sub: #B8BEE0;
  --cyan: #22E4FF;
  --purple: #8B5CF6;
  --gold: #FFC94A;
  --gold2: #FFE08A;
  --blue: #4D9BFF;
  --rainbow: linear-gradient(90deg, #22E4FF, #8B5CF6, #FF7AD9, #FFC94A, #22E4FF);
  --tier: #FFC94A;
}
body[data-tier="blue"] { --tier: #4D9BFF; }
body[data-tier="gold"] { --tier: #FFC94A; }
body[data-tier="rainbow"] { --tier: #E9A8FF; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%) fixed;
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 16px; line-height: 1.7;
  overflow-x: hidden;
  -webkit-user-select: none; user-select: none;
}
h1, h2, p { margin: 0; }
h1, h2 { word-break: auto-phrase; text-wrap: balance; line-break: strict; }

/* ---- 背景：神殿の床と光の柱 ---- */
.bg { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.floor {
  position: absolute; left: 50%; bottom: -18vh; width: 150vmin; height: 56vmin;
  -webkit-mask: radial-gradient(ellipse at center, #000 30%, transparent 70%); mask: radial-gradient(ellipse at center, #000 30%, transparent 70%);
  transform: translateX(-50%);
  border-radius: 50%;
  background:
    repeating-radial-gradient(ellipse at center, transparent 0 26px, rgba(34, 228, 255, .32) 26px 28px),
    radial-gradient(ellipse at center, rgba(34, 228, 255, .16), transparent 65%);
  opacity: 1;
}
.pillar { position: absolute; top: 0; width: 2px; height: 60vh; background: linear-gradient(180deg, rgba(139, 92, 246, .9), transparent); box-shadow: 0 0 18px 4px rgba(139, 92, 246, .45); }
.pillar-l { left: 8%; }
.pillar-r { right: 12%; height: 45vh; }
body.is-result .pillar { opacity: .35; }

/* ---- 上部 ---- */
.top {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  max-width: 520px; margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 16px 0;
}
.logo { color: var(--text); text-decoration: none; font-weight: 900; font-size: 18px; letter-spacing: .06em; }
.top-btns { display: flex; gap: 6px; }
.chip {
  min-height: 36px; padding: 4px 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(7, 11, 36, .7); color: var(--sub);
  font: inherit; font-size: 12px; cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--cyan); color: var(--cyan); }
.chip:focus-visible, .btn:focus-visible, .crystal:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }

main { position: relative; z-index: 2; max-width: 520px; margin: 0 auto; padding: 0 16px calc(28px + env(safe-area-inset-bottom)); }

/* ---- 割る画面 ---- */
.stage { text-align: center; padding-top: 3vh; }
.taps { display: flex; justify-content: center; gap: 8px; padding: 0; margin: 0 0 10px; list-style: none; }
.taps li { width: 28px; height: 4px; border-radius: 2px; background: var(--line); transition: background .3s; }
.taps li.on { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.guide { font-size: clamp(24px, 7vw, 32px); font-weight: 900; letter-spacing: .02em; min-height: 1.4em; }
.guide-sub { color: var(--sub); font-size: 14px; margin-top: 2px; min-height: 1.6em; }
.streak-hint { color: var(--sub); font-size: 13px; margin-top: 4px; min-height: 1.6em; }
.streak-hint strong { color: var(--gold); }

.altar { position: relative; height: min(62vh, 520px); margin-top: 8px; }

.crystal {
  position: absolute; bottom: 14%;
  width: 24%; max-width: 120px; aspect-ratio: 100 / 160;
  padding: 0; border: 0; background: none; cursor: pointer;
  transform: translateX(-50%);
  transition: left .55s cubic-bezier(.2, .9, .25, 1.15), bottom .55s cubic-bezier(.2, .9, .25, 1.15), width .55s cubic-bezier(.2, .9, .25, 1.15), max-width .55s, opacity .4s, filter .3s;
  filter: drop-shadow(0 0 14px rgba(139, 92, 246, .55));
  z-index: 2;
}
.crystal svg { width: 100%; height: 100%; display: block; overflow: visible; animation: bob 3.2s ease-in-out infinite; }
.c-0 { left: 17%; } .c-1 { left: 50%; bottom: 20%; } .c-2 { left: 83%; }
.c-0 svg { animation-delay: -.6s; } .c-2 svg { animation-delay: -1.7s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.is-pick .crystal:hover { filter: drop-shadow(0 0 22px rgba(34, 228, 255, .8)); }

.crystal.chosen { left: 50%; bottom: 24%; width: 48%; max-width: 230px; z-index: 3; filter: drop-shadow(0 0 26px rgba(34, 228, 255, .7)); }
.crystal.chosen svg { animation-duration: 2.4s; }
.crystal.gone { opacity: 0; bottom: 4%; pointer-events: none; }
.crystal.hit svg { animation: knock .22s ease-out; }
@keyframes knock { 0% { transform: translateX(0) scale(1); } 30% { transform: translateX(-5px) scale(1.03); } 60% { transform: translateX(4px); } 100% { transform: none; } }

/* 亀裂 */
.crack { fill: none; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 260; stroke-dashoffset: 260; opacity: 0; }
.crack.thin { stroke-width: 1.6; }
.is-cracked .crack, .is-charge .crack { opacity: 1; animation: drawCrack .38s ease-out forwards; }
.is-cracked .crack.thin, .is-charge .crack.thin { animation-delay: .12s; }
@keyframes drawCrack { to { stroke-dashoffset: 0; } }
.crack { stroke: var(--tier); filter: drop-shadow(0 0 4px var(--tier)); }
body[data-tier="rainbow"] .crack { stroke: url(#rbw); }

/* 漏れる光 */
.leak {
  position: absolute; left: 50%; bottom: calc(24% + var(--ch, 150px) / 2);
  width: 120%; max-width: 560px; aspect-ratio: 1;
  transform: translate(-50%, 50%) scale(.6);
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--tier) 70%, transparent) 0%, color-mix(in srgb, var(--tier) 22%, transparent) 30%, transparent 62%);
  opacity: 0; transition: opacity .4s, transform .6s;
  pointer-events: none; z-index: 1; mix-blend-mode: screen;
}
body[data-tier="rainbow"] .leak {
  background: radial-gradient(circle, rgba(255, 255, 255, .8) 0%, rgba(255, 122, 217, .55) 16%, rgba(139, 92, 246, .35) 32%, rgba(34, 228, 255, .18) 46%, transparent 62%);
}
body[data-tier="rainbow"].is-cracked .leak, body[data-tier="rainbow"].is-charge .leak { animation: hue 2.4s linear infinite; }
@keyframes hue { to { filter: hue-rotate(360deg); } }
@keyframes spin { to { rotate: 360deg; } }
.is-cracked .leak { opacity: .85; transform: translate(-50%, 50%) scale(.9); animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 50% { transform: translate(-50%, 50%) scale(1); } }

/* 溜め：光が中心に集まる */
.converge {
  position: absolute; left: 50%; bottom: calc(24% + var(--ch, 150px) / 2);
  width: 150%; max-width: 640px; aspect-ratio: 1; transform: translate(-50%, 50%) scale(1.4);
  border-radius: 50%;
  border: 2px solid var(--tier);
  box-shadow: 0 0 30px var(--tier), inset 0 0 40px var(--tier);
  opacity: 0; pointer-events: none; z-index: 4;
}
.is-charge .converge { animation: gather 1.15s cubic-bezier(.5, 0, .9, .4) forwards; }
@keyframes gather { 0% { opacity: 0; transform: translate(-50%, 50%) scale(1.4); } 25% { opacity: .9; } 100% { opacity: 1; transform: translate(-50%, 50%) scale(.04); } }
.is-charge .leak { opacity: 1; transform: translate(-50%, 50%) scale(.5); transition: transform 1.1s ease-in, opacity .3s; }
.is-charge .crystal.chosen { filter: drop-shadow(0 0 36px var(--tier)) brightness(1.25); }
.is-charge .crystal.chosen svg { animation: tremble .08s linear infinite; }
@keyframes tremble { 0% { transform: translate(0, 0); } 25% { transform: translate(1.5px, -1px); } 50% { transform: translate(-1.5px, 1px); } 75% { transform: translate(1px, 1px); } }

/* 一瞬の静けさ */
.hush { position: fixed; inset: 0; background: #02030c; opacity: 0; pointer-events: none; z-index: 8; transition: opacity .18s; }
.is-hush .hush { opacity: .72; }
.is-hush .crystal.chosen svg { animation: none; }

/* 開封 */
.flash { position: fixed; inset: 0; pointer-events: none; z-index: 9; opacity: 0; background: radial-gradient(circle at var(--fx, 50%) var(--fy, 45%), #fff 0%, var(--tier) 30%, transparent 75%); }
body[data-tier="rainbow"] .flash { background: radial-gradient(circle at var(--fx, 50%) var(--fy, 45%), #fff 0%, transparent 40%), conic-gradient(from 90deg at var(--fx, 50%) var(--fy, 45%), #22E4FF, #8B5CF6, #FF7AD9, #FFC94A, #22E4FF); }
.flash.go { animation: flash .75s ease-out forwards; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.shards { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }
.shake { animation: shake .42s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake { 10%, 90% { transform: translate(-2px, 1px); } 20%, 80% { transform: translate(4px, -2px); } 30%, 50%, 70% { transform: translate(-7px, 3px); } 40%, 60% { transform: translate(7px, -3px); } }

/* 昇格 */
.promote-ping { animation: ping .5s ease-out; }
@keyframes ping { 0% { filter: brightness(2.2); } 100% { filter: none; } }

/* ---- 結果 ---- */
.result { padding-top: 2vh; text-align: center; }
.done-note { display: inline-block; font-size: 13px; color: var(--cyan); border: 1px solid var(--cyan); border-radius: 999px; padding: 2px 12px; margin-bottom: 10px; }
.card {
  position: relative; overflow: hidden;
  border: 1.5px solid var(--gold); border-radius: 18px;
  background: linear-gradient(180deg, rgba(15, 22, 64, .92), rgba(11, 16, 48, .96));
  padding: 26px 20px 22px;
  box-shadow: 0 0 40px rgba(255, 201, 74, .18);
}
body[data-rank="超大吉"] .card { border: 2px solid transparent; background: linear-gradient(180deg, #0F1640, #0B1030) padding-box, var(--rainbow) border-box; box-shadow: 0 0 50px rgba(233, 168, 255, .3); }
.emblem { position: absolute; left: 50%; top: 92px; width: 230px; aspect-ratio: 1; transform: translate(-50%, -50%); opacity: 0; pointer-events: none; }
.emblem svg { width: 100%; height: 100%; animation: spin 40s linear infinite; }
body[data-rank="超大吉"] .emblem { opacity: .9; }
.r-date { position: relative; font-size: 12px; color: var(--sub); letter-spacing: .12em; }
.rank { position: relative; font-size: clamp(64px, 22vw, 104px); font-weight: 900; line-height: 1.1; margin: 6px 0 4px; letter-spacing: .04em; }
.rank.land { animation: land .55s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes land { 0% { opacity: 0; transform: scale(1.9); filter: blur(6px); } 60% { opacity: 1; filter: none; } 100% { transform: scale(1); } }
body[data-rank="超大吉"] .rank { background: var(--rainbow); -webkit-background-clip: text; background-clip: text; color: transparent; }
body[data-rank="大吉"] .rank { color: var(--gold); text-shadow: 0 0 24px rgba(255, 201, 74, .5); }
body[data-rank="中吉"] .rank { color: #C7B2FF; text-shadow: 0 0 22px rgba(139, 92, 246, .55); }
body[data-rank="吉"] .rank { color: var(--cyan); text-shadow: 0 0 22px rgba(34, 228, 255, .45); }
body[data-rank="小吉"] .rank { color: #9DB6FF; text-shadow: 0 0 22px rgba(77, 124, 255, .5); }
.rank-msg { position: relative; font-size: 15px; color: var(--text); }

.step { opacity: 0; transform: translateY(10px); transition: opacity .35s, transform .35s cubic-bezier(.2, 1.3, .4, 1); }
.step.in { opacity: 1; transform: none; }

.title-box { margin-top: 18px; padding: 14px 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.t-label { font-size: 12px; color: var(--sub); letter-spacing: .08em; }
.new { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; background: var(--gold); color: var(--bg); font-size: 11px; font-weight: 700; letter-spacing: 0; }
.t-name { font-size: clamp(22px, 6.4vw, 28px); font-weight: 800; margin-top: 2px; line-height: 1.4; }

.lucks { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; text-align: left; }
.luck { display: grid; grid-template-columns: 4.2em 1fr; gap: 2px 10px; align-items: center; }
.luck-name { font-size: 14px; font-weight: 700; }
.bars { display: flex; gap: 4px; }
.bars i { flex: 1; height: 8px; border-radius: 2px; background: #1E2658; }
.bars i.on { background: var(--cyan); box-shadow: 0 0 6px rgba(34, 228, 255, .7); }
body[data-rank="超大吉"] .bars i.on { background: var(--rainbow); background-size: 500% 100%; }
.luck-text { grid-column: 2; font-size: 13px; color: var(--sub); }

.lucky { margin-top: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.lucky-text { font-size: 17px; font-weight: 700; color: var(--gold); margin-top: 2px; }

.after { margin-top: 18px; display: grid; gap: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 50px; padding: 10px 14px; border-radius: 12px;
  font: inherit; font-weight: 700; font-size: 15px; line-height: 1.3;
  text-decoration: none; cursor: pointer;
}
.btn-gold { background: linear-gradient(90deg, var(--gold), var(--gold2)); color: var(--bg); border: 0; box-shadow: 0 0 18px rgba(255, 201, 74, .35); font-size: 17px; }
.btn-line { background: rgba(7, 11, 36, .6); color: var(--text); border: 1.5px solid var(--cyan); }
.btn-ghost { background: transparent; color: var(--sub); border: 0; text-decoration: underline; font-weight: 400; }
.btn.big { min-height: 60px; font-size: 20px; width: 100%; }

.next { border: 1.5px solid var(--cyan); border-radius: 12px; padding: 8px; }
.next-label { font-size: 12px; color: var(--sub); }
.next-time { font-size: 28px; color: var(--cyan); font-variant-numeric: tabular-nums; letter-spacing: .06em; line-height: 1.3; }
.streak { padding: 6px 0; }
.streak-label { font-size: 14px; }
.streak-label strong { font-size: 22px; color: var(--gold); margin: 0 2px; }
.dots { display: flex; justify-content: center; gap: 10px; list-style: none; padding: 0; margin: 8px 0 4px; }
.dots li { width: 18px; height: 28px; clip-path: polygon(50% 0, 100% 18%, 100% 82%, 50% 100%, 0 82%, 0 18%); background: #262E66; }
.dots li.on { background: linear-gradient(180deg, #B79BFF, var(--purple)); }
.dots li.rainbow { background: conic-gradient(#22E4FF, #8B5CF6, #FF7AD9, #FFC94A, #22E4FF); opacity: .55; }
.dots li.rainbow.on { opacity: 1; box-shadow: 0 0 10px #fff; }
.streak-sub { font-size: 12px; color: var(--sub); }
.ent { font-size: 12px; color: #8A90B8; margin-top: 4px; }

/* ---- シート ---- */
.sheet {
  width: min(92vw, 440px); max-height: 86vh;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--cyan); border-radius: 18px; padding: 22px;
}
.sheet::backdrop { background: rgba(3, 5, 18, .78); }
.sheet h2 { font-size: 22px; margin-bottom: 8px; }
.sheet .btn { width: 100%; margin-top: 10px; }
.sheet-logo { font-weight: 900; color: var(--cyan); letter-spacing: .08em; font-size: 14px; }
.small { font-size: 14px; color: var(--sub); }
.how { padding-left: 1.2em; margin: 0 0 8px; }
.how li { margin-bottom: 8px; }
.zukan-count { color: var(--gold); font-weight: 700; margin-bottom: 8px; }
.zukan { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.zukan li { font-size: 13px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; min-height: 44px; display: flex; align-items: center; gap: 6px; line-height: 1.35; }
.zukan li.got { border-color: var(--cyan); }
.zukan li.lock { color: #5A6196; }
.zukan .no { font-size: 11px; color: var(--sub); flex: 0 0 auto; }
.card-img { display: block; width: 100%; max-height: 52vh; object-fit: contain; border-radius: 10px; margin: 10px 0; -webkit-user-select: auto; user-select: auto; -webkit-touch-callout: default; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translate(-50%, 16px); width: min(90vw, 400px);
  background: var(--panel); border: 1px solid var(--gold); border-radius: 12px;
  padding: 10px 14px; font-size: 14px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- 動きを抑える ---- */
body.calm .crystal svg, body.calm .leak, body.calm .emblem svg, body.calm .crystal.chosen svg { animation: none !important; }
body.calm .crystal { transition-duration: .01s !important; }
body.calm .step { transition: none; }
body.calm .rank.land { animation: none; }
body.calm .converge { display: none; }
body.calm .crack { animation-duration: .01s !important; }
@media (prefers-reduced-motion: reduce) {
  .crystal svg, .leak, .emblem svg { animation: none !important; }
  .rank.land, .shake { animation: none !important; }
}
