:root {
  --night: #0d1330;
  --night-2: #18204a;
  --ink: #f6f1e4;
  --muted: #b9b6c9;
  --shu: #d8352a;
  --shu-dark: #9e2219;
  --gold: #f5c542;
  --gold-dark: #b8860b;
  --paper: #fffaf0;
  --line: rgba(255, 255, 255, .14);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--night);
  background-image: radial-gradient(ellipse at 50% -10%, #2a3570 0%, var(--night) 60%);
  color: var(--ink);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  line-height: 1.7;
  overflow-x: hidden;
}
a { color: var(--gold); }
.wrap { max-width: 560px; margin: 0 auto; padding: 24px 16px 40px; }

/* 境内 */
.shrine { position: relative; text-align: center; padding-top: 8px; }
.stars { position: absolute; inset: 0; pointer-events: none; background-image:
  radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent 51%),
  radial-gradient(1px 1px at 78% 10%, #fff 50%, transparent 51%),
  radial-gradient(1.5px 1.5px at 63% 30%, #ffe9a8 50%, transparent 51%),
  radial-gradient(1px 1px at 30% 6%, #fff 50%, transparent 51%),
  radial-gradient(1px 1px at 90% 34%, #fff 50%, transparent 51%); opacity: .8; }
.title { font-size: 34px; font-weight: 900; letter-spacing: .12em; margin: 4px 0 0; text-shadow: 0 0 18px rgba(245, 197, 66, .55); }
.title small { display: block; font-size: 13px; letter-spacing: .3em; color: var(--gold); font-weight: 700; }
.lead { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.torii { width: 100%; max-width: 360px; height: auto; display: block; margin: 12px auto 0; }
.lantern { animation: sway 4s ease-in-out infinite; transform-origin: 50% 0; }
.lantern.r { animation-delay: -2s; }
@keyframes sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }

/* お賽銭 */
.card { background: var(--night-2); border: 1px solid var(--line); border-radius: 16px; padding: 20px 16px; margin-top: 16px; }
.card h2 { font-size: 17px; margin: 0 0 12px; }
.amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.amt { appearance: none; border: 2px solid var(--line); background: #10173a; color: var(--ink); border-radius: 12px; padding: 10px 4px; font: inherit; cursor: pointer; line-height: 1.3; }
.amt b { display: block; font-size: 18px; }
.amt span { font-size: 11px; color: var(--muted); }
.amt[aria-pressed="true"] { border-color: var(--gold); background: #2a2410; box-shadow: 0 0 0 2px rgba(245, 197, 66, .25); }
.free { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.free label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.free input { flex: 1; min-width: 0; font: inherit; font-size: 18px; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--line); background: #10173a; color: var(--ink); text-align: right; }
.free input:focus { outline: none; border-color: var(--gold); }
.tierhint { font-size: 13px; margin: 10px 0 0; min-height: 1.7em; color: var(--gold); }
.pay { display: block; width: 100%; margin-top: 14px; border: 0; border-radius: 999px; padding: 16px; font: inherit; font-size: 18px; font-weight: 900; letter-spacing: .1em; color: #fff; background: var(--shu); box-shadow: 0 6px 0 var(--shu-dark); cursor: pointer; }
.pay:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--shu-dark); }
.pay:disabled { background: #555a70; box-shadow: 0 6px 0 #33374a; cursor: not-allowed; }
.msg { font-size: 14px; margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(216, 53, 42, .15); border: 1px solid rgba(216, 53, 42, .5); }
.msg[hidden] { display: none; }
.note { font-size: 12px; color: var(--muted); margin: 12px 0 0; }

.how { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.how li { position: relative; padding-left: 34px; margin: 0 0 10px; font-size: 14px; }
.how li::before { counter-increment: s; content: counter(s); position: absolute; left: 0; top: 1px; width: 24px; height: 24px; border-radius: 50%; background: var(--gold); color: #222; font-weight: 900; font-size: 13px; text-align: center; line-height: 24px; }

footer { max-width: 560px; margin: 0 auto; padding: 16px 16px 32px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
footer nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 6px; }
footer a { color: var(--muted); }

/* 特商法 */
.legal h1 { font-size: 22px; }
.legal table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--night-2); border-radius: 12px; overflow: hidden; }
.legal th, .legal td { text-align: left; vertical-align: top; padding: 12px; border-bottom: 1px solid var(--line); }
.legal th { width: 34%; color: var(--muted); font-weight: 700; font-size: 13px; }
@media (max-width: 420px) {
  .legal th, .legal td { display: block; width: 100%; }
  .legal th { padding-bottom: 0; border-bottom: 0; }
}

/* 言語の切り替え（右上） */
.lang-switch { position: absolute; top: 12px; right: 16px; z-index: 5; font-size: 13px; color: var(--ink); text-decoration: none; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(13, 19, 48, .7); }

/* 参拝の入口 */
.start { max-width: 320px; margin: 16px auto 0; font-size: 20px; animation: startpulse 1.6s ease-in-out infinite; }
@keyframes startpulse { 0%, 100% { box-shadow: 0 6px 0 var(--shu-dark), 0 0 0 0 rgba(245, 197, 66, .5); } 50% { box-shadow: 0 6px 0 var(--shu-dark), 0 0 0 10px rgba(245, 197, 66, 0); } }
.skip-line { font-size: 13px; margin: 10px 0 0; }
.skip-line a { color: var(--muted); }
#saisen { scroll-margin-top: 16px; }
#saisen.glow { animation: glow 1.6s ease-out; }
@keyframes glow { 0% { box-shadow: 0 0 0 4px var(--gold), 0 0 40px rgba(245, 197, 66, .7); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* 参拝の作法（全画面） */
body.visiting { overflow: hidden; }
.visit { position: fixed; inset: 0; z-index: 20; background: var(--night); background-image: radial-gradient(ellipse at 50% 0%, #2a3570 0%, var(--night) 65%); display: flex; flex-direction: column; align-items: center; padding: 14px 16px 24px; overflow-y: auto; }
.visit[hidden] { display: none; }
.v-top { width: 100%; max-width: 520px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.v-dots { display: flex; gap: 6px; }
.v-dots i { width: 22px; height: 6px; border-radius: 3px; background: var(--line); }
.v-dots i.on { background: var(--gold); }
.v-skip { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.v-title { font-size: 26px; font-weight: 900; margin: 22px 0 4px; text-align: center; letter-spacing: .06em; }
.v-tip { color: var(--muted); font-size: 14px; text-align: center; margin: 0; max-width: 420px; min-height: 1.7em; }
.v-scene { width: 100%; max-width: 420px; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 260px; }
.v-actions { width: 100%; max-width: 360px; display: grid; gap: 10px; }
.v-actions .pay { margin: 0; }
.v-link { background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; }
.v-hint { text-align: center; font-size: 12px; color: var(--muted); margin: 0; }
.v-bar { width: 70%; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.v-bar i { display: block; height: 100%; background: var(--gold); animation: vbar 3s linear forwards; }
@keyframes vbar { from { width: 0; } to { width: 100%; } }

.walk { width: 100%; overflow: hidden; display: flex; justify-content: center; }
.v-torii { width: 80%; animation: walkin 3s ease-in forwards; transform-origin: 50% 60%; }
@keyframes walkin { 0% { transform: scale(.7); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(3.2); opacity: 0; } }
.bow { font-size: 110px; animation: bow 3s ease-in-out; }
@keyframes bow { 0%, 100% { transform: rotate(0); } 35%, 65% { transform: rotate(18deg) translateY(10px); } }
.basin { position: relative; width: 220px; height: 170px; }
.ladle { position: absolute; left: 70px; top: 0; font-size: 64px; transform: rotate(120deg); animation: pour 3s ease-in-out infinite; }
@keyframes pour { 0%, 100% { transform: rotate(120deg); } 50% { transform: rotate(150deg); } }
.drops i { position: absolute; top: 70px; width: 8px; height: 14px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: #7fd1ff; animation: drop .9s linear infinite; }
.drops i:nth-child(1) { left: 100px; } .drops i:nth-child(2) { left: 112px; animation-delay: .3s; } .drops i:nth-child(3) { left: 94px; animation-delay: .6s; }
@keyframes drop { from { transform: translateY(0); opacity: 1; } to { transform: translateY(60px); opacity: 0; } }
.water { position: absolute; left: 20px; right: 20px; bottom: 0; height: 40px; border-radius: 0 0 40px 40px; background: linear-gradient(#7fd1ff, #2a6fb0); border-top: 6px solid #8a5a2b; }
.seq { font-size: 28px; font-weight: 900; color: var(--gold); margin: 0; min-height: 1.4em; }
.seq.pop { animation: seqpop .3s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes seqpop { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.big-seq { font-size: 64px; }
.pick { display: flex; gap: 28px; font-size: 72px; }

.kuji-box { font-size: 100px; animation: shake .25s linear infinite; }
@keyframes shake { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }
.kuji { width: 100%; background: var(--paper); color: #222; border-radius: 6px; padding: 16px 18px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); border-top: 10px solid var(--shu); animation: unfold .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes unfold { from { transform: scaleY(.1); opacity: 0; } to { transform: scaleY(1); opacity: 1; } }
.kuji-name { margin: 0 0 8px; text-align: center; font-size: 44px; font-weight: 900; letter-spacing: .1em; }
.mood-good .kuji-name { color: var(--shu); }
.mood-bad .kuji-name { color: #3b4a6b; }
.kuji dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kuji dt { font-weight: 700; color: #8a5a2b; white-space: nowrap; }
.kuji dd { margin: 0; }
.gal { display: flex; align-items: flex-start; gap: 10px; width: 100%; animation: unfold .4s .2s both; }
.gal-face { flex: none; width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg, #ff8fc7, #ffd36e); font-size: 32px; display: flex; align-items: center; justify-content: center; }
.gal-say { position: relative; margin: 0; background: #fff0f7; color: #4a1636; border-radius: 14px; padding: 10px 12px; font-size: 14px; line-height: 1.6; }
.gal-say b { display: block; font-size: 11px; color: #d6338a; }
.ema-board { width: 100%; }
.ema-board textarea { width: 100%; font: inherit; font-size: 18px; padding: 14px; border-radius: 10px; border: 3px solid #a86e35; background: #f3dfbf; color: #3a2510; resize: none; }
.ema-count { text-align: right; font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.ema-hang { animation: swing 2.4s ease-in-out infinite; transform-origin: 50% 0; }
@keyframes swing { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
.ema-plate { width: 260px; min-height: 160px; padding: 40px 20px 18px; background: #f3dfbf; color: #3a2510; clip-path: polygon(50% 0, 100% 22%, 100% 100%, 0 100%, 0 22%); border-bottom: 6px solid #a86e35; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 18px; font-weight: 700; word-break: break-all; }
.ema-plate p { margin: 0; }
@media (prefers-reduced-motion: reduce) {
  .start, .v-torii, .bow, .ladle, .drops i, .kuji-box, .ema-hang { animation: none; }
}
