/* Omikuji Shrine — the grounds, the shared header, the omikuji corner, the stick and the drawer cabinet */

/* ---------- shrine grounds (behind everything) ---------- */
.grounds { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
/* the hills and the ground belong to the spot views; the path draws its own */
.grounds .hill, .grounds .ground, .grounds .cloud, .grounds .kite, .grounds .far-mt { transition: opacity .45s ease; }
body[data-view="path"] .grounds .hill, body[data-view="path"] .grounds .ground, body[data-view="path"] .grounds .cloud,
body[data-view="path"] .grounds .kite, body[data-view="path"] .grounds .far-mt { opacity: 0; }
.ground {
  position: absolute; left: -12%; right: -12%; bottom: 0;
  height: calc(var(--ctl) + 64px + var(--lift, 0px) + env(safe-area-inset-bottom));
  transition: height .45s ease;
  border-radius: 50% 50% 0 0 / 46px 46px 0 0;
  background: linear-gradient(180deg, #d9f1e3 0, #e6f6ea 46px, #f3faf1 100%);
}
.hill { position: absolute; border-radius: 50%; transition: bottom .45s ease; }
.hill.h1 { left: -18%; width: 70%; height: 190px; bottom: calc(var(--ctl) + 12px + var(--lift, 0px)); background: #e6e0fb; }
.hill.h2 { right: -22%; width: 78%; height: 230px; bottom: calc(var(--ctl) - 6px + var(--lift, 0px)); background: #dceef6; }
.cloud {
  position: absolute; height: 26px; border-radius: 999px; background: rgba(255, 255, 255, .85);
  animation: cloudDrift 16s ease-in-out infinite alternate;
}
.cloud::before, .cloud::after { content: ''; position: absolute; border-radius: 50%; background: inherit; }
.cloud::before { width: 42%; aspect-ratio: 1; left: 16%; bottom: 30%; }
.cloud::after { width: 34%; aspect-ratio: 1; right: 16%; bottom: 20%; }
.cloud.c1 { width: 92px; left: 6%; top: 15%; }
.cloud.c2 { width: 70px; right: 8%; top: 24%; animation-duration: 21s; animation-direction: alternate-reverse; }
.cloud.c3 { width: 54px; left: 44%; top: 9%; animation-duration: 26s; opacity: .8; }
.cloud.c4, .cloud.c5 { display: none; }

/* kites: one small one on a phone, two on a wide screen */
.kite { position: absolute; width: 40px; overflow: visible; transform-origin: 50% 30%; animation: kiteFly 5.2s ease-in-out infinite alternate; }
.kite.k1 { right: 9%; top: calc(env(safe-area-inset-top) + var(--head) + 3.5%); }
.kite.k2 { display: none; animation-duration: 6.4s; animation-delay: -2.3s; }
.kt-body { fill: #ffd6c8; stroke: #f5b6a7; stroke-width: 2; stroke-linejoin: round; }
.kt-shade { fill: #ffe6dc; }
.kt-spar { fill: none; stroke: #f5b6a7; stroke-width: 1.6; stroke-linecap: round; }
.kt-dot { fill: #fff6d6; stroke: #f6dc96; stroke-width: 1.4; }
.kt-tail { fill: none; stroke: #cfc4ff; stroke-width: 2.4; stroke-linecap: round; transform-box: fill-box; transform-origin: 50% 0; animation: kiteTail 1.7s ease-in-out infinite alternate; }
.kt-bow { fill: #cfc4ff; transform-box: fill-box; transform-origin: 50% 0; animation: kiteTail 1.7s ease-in-out infinite alternate; }
.kite.k2 .kt-body { fill: #d4f3e6; stroke: #a9e2cb; } .kite.k2 .kt-shade { fill: #e6f8ef; } .kite.k2 .kt-spar { stroke: #a9e2cb; }
.kite.k2 .kt-tail { stroke: #ffc8ba; } .kite.k2 .kt-bow { fill: #ffc8ba; }
@keyframes kiteFly {
  0% { transform: translate(-16px, 10px) rotate(-12deg); }
  50% { transform: translate(6px, -12px) rotate(4deg); }
  100% { transform: translate(20px, 6px) rotate(13deg); }
}
@keyframes kiteTail { from { transform: rotate(-14deg); } to { transform: rotate(14deg); } }

/* far mountains: only where the sky is wide */
.far-mt { position: absolute; display: none; bottom: calc(var(--ctl) + 30px + var(--lift, 0px)); transition: opacity .45s ease, bottom .45s ease; }
.mt-body { fill: var(--mt-body); }
.mt-line { fill: none; stroke: var(--mt-edge); stroke-width: 1.4; stroke-linejoin: round; }
.mt-pa > * { fill: var(--mt-pa); } .mt-pb > * { fill: var(--mt-pb); } .mt-pc > * { fill: var(--mt-pc); }
.mt-patch { opacity: var(--mt-patch); }
.mt-snow { fill: #fffdfb; opacity: var(--mt-snow); }
.mt-snow-sm { fill: #fffdfb; opacity: var(--mt-snow-sm); }
.mt-body, .mt-line, .mt-pa > *, .mt-pb > *, .mt-pc > *, .mt-patch, .mt-snow, .mt-snow-sm { transition: fill .6s ease, stroke .6s ease, opacity .6s ease; }
@media (min-width: 760px) {
  .far-mt { display: block; }
  .far-mt.m1 { left: 3%; width: min(40vw, 640px); height: min(24vw, 384px); }
  .far-mt.m2 { right: 4%; width: min(30vw, 480px); height: min(15vw, 240px); bottom: calc(var(--ctl) + 110px + var(--lift, 0px)); opacity: .85; }
  .kite { width: 62px; }
  .kite.k1 { right: auto; left: 17%; top: 17%; }
  .kite.k2 { display: block; right: 15%; top: 27%; width: 50px; }
  .cloud.c4, .cloud.c5 { display: block; }
  .cloud.c4 { width: 120px; height: 32px; left: 26%; top: 34%; animation-duration: 24s; }
  .cloud.c5 { width: 84px; right: 28%; top: 12%; animation-duration: 19s; animation-direction: alternate-reverse; opacity: .85; }
}
@keyframes cloudDrift { from { transform: translateX(-22px); } to { transform: translateX(26px); } }
/* ---------- page frame: one column, at most --col wide, the sky around it ---------- */
.app {
  position: relative; z-index: 1;
  height: 100%;
  max-width: var(--col); margin: 0 auto;
  display: flex; flex-direction: column;
  padding-top: calc(env(safe-area-inset-top) + var(--head));
}
/* the shared header: fixed over every view */
.top {
  position: fixed; z-index: 30; top: 0; left: 0; right: 0;
  max-width: var(--col); margin: 0 auto;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: env(safe-area-inset-top) 12px 0 16px; min-height: 58px;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.top-left { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.top-actions { display: flex; gap: 8px; padding-top: 10px; }
.back-btn { margin-top: 10px; transition: opacity .2s; }
.back-btn svg { width: 22px; height: 22px; }
/* Back is there at every step of a spot; only while a coin is in the air (~0.6 s) it waits, a little faded */
.back-btn.wait { opacity: .55; cursor: default; }
/* while the stick card, the drawer cabinet or the slip is open, the header comes up over it with Back
   alone (the sign and the sound buttons were under the overlay anyway), in the same place */
body:has(#stickLayer:not([hidden]), #cabinet:not([hidden]), #reveal:not([hidden])) .top { z-index: 60; }
body:has(#stickLayer:not([hidden]), #cabinet:not([hidden]), #reveal:not([hidden])) .top .sign,
body:has(#stickLayer:not([hidden]), #cabinet:not([hidden]), #reveal:not([hidden])) .top .top-actions { visibility: hidden; }
/* the title hangs like a shrine sign board */
.sign {
  position: relative; margin: 14px 0 0; padding: 5px 16px 6px;
  display: flex; align-items: baseline; gap: 8px; white-space: nowrap;
  border-radius: 14px; background: #fff6ea; border: 2.5px solid #f6cdb9;
  box-shadow: 0 4px 0 #f6cdb9, 0 8px 16px rgba(110, 95, 170, .12);
  color: var(--coral-ink); font-size: 20px; font-weight: 700; letter-spacing: -.01em;
  transform-origin: 50% -14px; animation: signSway 5s ease-in-out infinite;
}
.sign::before, .sign::after { /* the two cords it hangs from */
  content: ''; position: absolute; top: -17px; width: 4px; height: 16px; border-radius: 2px; background: var(--straw-deep);
}
.sign::before { left: 18px; } .sign::after { right: 18px; }
.sign-ja { font-family: var(--kanji); font-size: 15px; font-weight: 600; color: #b3705f; letter-spacing: .04em; }
@keyframes signSway { 0%, 100% { transform: rotate(-1.4deg); } 50% { transform: rotate(1.4deg); } }
@media (max-width: 440px) {
  .sign { font-size: 18px; padding: 5px 14px 6px; gap: 7px; }
  .sign-ja { font-size: 14px; }
  .top .icon-btn { width: 40px; height: 40px; }
  .top .icon-btn svg { width: 20px; height: 20px; }
  .top-actions { gap: 6px; }
  .top-left { gap: 8px; }
}
/* after the 440px block so it wins on the narrowest phones */
@media (max-width: 370px) { .sign { font-size: 17px; padding: 5px 12px 6px; gap: 6px; } .sign-ja { font-size: 13px; } .top { padding-left: 12px; } }
/* 320px phones: "Mofu Mofu Shrine" and the two buttons were 8px wider than the screen */
@media (max-width: 340px) { .sign { font-size: 15.5px; padding: 5px 10px 6px; gap: 5px; } .sign-ja { font-size: 12px; } .top { padding: env(safe-area-inset-top) 8px 0 10px; } .top-actions { gap: 5px; } .top-left { gap: 6px; } }

/* ---------- the omikuji scene: a tall torii behind; the omikuji box and the rack in a row ---------- */
.view-omikuji {
  /* u = the width of one thing standing in the scene (the rack; the omikuji box is .9u; the visitor's
     avatar between them .33u, css/avatar.css .sp-omikuji) */
  --u: min(calc((var(--col) - 28px) / 2.2), 210px, calc((100dvh - 290px) * 0.58));
  --omw: var(--u);
}
.scene {
  flex: 1; min-height: 0; position: relative;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 10px 6px;
}
/* The torii's top (roof, beams, plaque) is drawn at the top of the scene and its legs stretch down to
   the ground, so it fills the sky on tall phones and still fits short ones. cqw = its own width. */
.torii {
  position: absolute; left: 50%; translate: -50% 0;
  top: clamp(6px, 2.2%, 20px); bottom: 2px;
  width: min(100% - 12px, 460px, 100cqh);
  container-type: inline-size;
  pointer-events: none;
}
.scene { container-type: size; }
.torii-top { position: absolute; left: 0; top: 0; width: 100%; overflow: hidden; }
.to-leg {
  position: absolute; top: 40cqw; bottom: 16px; width: 7.5cqw;
  background: #ffd3c8; border: 2px solid #f5b6a7; border-top: 0; border-radius: 0 0 11px 11px;
}
.to-leg.l { left: 20.5cqw; } .to-leg.r { left: 72cqw; }
.to-foot {
  position: absolute; bottom: 0; height: max(22px, 7cqw); width: 11.5cqw;
  background: #e3dcff; border: 2px solid #cfc4ff; border-radius: 9px;
}
.to-foot.l { left: 18.5cqw; } .to-foot.r { left: 70cqw; }
.to-lantern {
  position: absolute; top: 33.6cqw; width: 10cqw; overflow: visible;
  transform-origin: 50% 0; animation: lanternSway 3.8s ease-in-out infinite;
}
.to-lantern.l { left: 31cqw; } .to-lantern.r { left: 59cqw; animation-delay: -1.9s; }
@keyframes lanternSway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
/* paper lanterns (here and at the hall) */
.ch-cord { fill: none; stroke: var(--straw-deep); stroke-width: 2; stroke-linecap: round; }
.ch-cap { fill: #cfc4ff; stroke: #b9acf0; stroke-width: 1.6; }
.ch-body { fill: #fff3e6; stroke: #f5b6a7; stroke-width: 2; }
.ch-rib { fill: none; stroke: #ffd3c8; stroke-width: 1.6; }
.ch-tassel { fill: none; stroke: #ffbcab; stroke-width: 2; stroke-linecap: round; }
/* a short scene: the lanterns would hang into the rack */
@media (max-height: 700px) { .to-lantern { display: none; } }
.to-post { fill: #ffd3c8; stroke: #f5b6a7; stroke-width: 2; }
.to-base { fill: #e3dcff; stroke: #cfc4ff; stroke-width: 2; }
.to-beam { fill: #ffc8ba; stroke: #f5b6a7; stroke-width: 2; }
.to-roof { fill: #ffbcab; stroke: #f0a797; stroke-width: 2; stroke-linejoin: round; }
.to-cap { fill: #cfc4ff; stroke: #b9acf0; stroke-width: 2; stroke-linejoin: round; }
.to-plaque { fill: #fff6e6; stroke: #f6dc96; stroke-width: 2; }
.to-flower { fill: #ffc8ba; }
.to-shide { fill: #fffdf8; stroke: #e9ddd0; stroke-width: 1; stroke-linejoin: round; transform-box: fill-box; transform-origin: 50% 0; animation: shideSway 3.4s ease-in-out infinite; }
.to-shide:nth-of-type(2n) { animation-delay: -1.2s; }
@keyframes shideSway { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }

.row {
  position: relative; z-index: 1; width: 100%;
  display: flex; align-items: flex-end; justify-content: center; gap: clamp(2px, 1.6vw, 26px);
}
.saisen, .rack, .coinbox { transition: opacity .35s ease, transform .45s cubic-bezier(.3, 1.1, .4, 1), filter .2s, scale .2s; }
.scene.focus .rack, .scene.focus .coinbox { opacity: .2; transform: scale(.9); pointer-events: none; }
.scene .rack { flex: none; }

/* offering box (the worship hall: css/haiden.css places it) */
.saisen { position: relative; flex: none; aspect-ratio: 130 / 120; transform-origin: 50% 100%; }
.saisen svg { width: 100%; height: 100%; overflow: visible; }
.saisen.drop-target { scale: 1.06; filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 8px var(--coral-deep)); }
.saisen-slot { position: absolute; left: 30%; width: 40%; top: 20%; height: 14%; }
.sa-shadow, .bx-shadow { fill: rgba(90, 80, 140, .12); }
.sa-foot { fill: #f3c9b3; }
.sa-front { fill: #fff0de; stroke: #f3c9b3; stroke-width: 2; }
.sa-plank { fill: none; stroke: #f8dcc8; stroke-width: 2; }
.sa-plate { fill: #ffd9cd; stroke: #f5b6a7; stroke-width: 1.6; }
.sa-plate-text { font-family: var(--kanji); font-weight: 600; font-size: 15px; fill: var(--coral-ink); letter-spacing: .04em; }
.sa-topbox { fill: #ffe6d2; stroke: #f3c9b3; stroke-width: 2; stroke-linejoin: round; }
.sa-dark { fill: #e4dbf7; }
.sa-slat { fill: none; stroke: #fff0de; stroke-width: 5; stroke-linecap: round; }
.sa-rim { fill: #ffc8ba; stroke: #f0a797; stroke-width: 1.6; }

/* the little ¥100 coin box: stands in front of the lower right corner of the omikuji box's stand,
   inside the omikuji box's own width, so the row is no wider than before */
.obox-spot { position: relative; flex: none; display: flex; align-items: flex-end; }
.coinbox {
  position: absolute; z-index: 3; right: calc(var(--u) * -.04); bottom: 0;
  width: calc(var(--u) * .44); aspect-ratio: 100 / 84; transform-origin: 50% 100%;
}
.scene.focus .coinbox { z-index: 1; }   /* behind the omikuji box while it is big */
.coinbox svg { width: 100%; height: 100%; overflow: visible; }
.coinbox.drop-target { scale: 1.1; filter: drop-shadow(0 0 8px #fff) drop-shadow(0 0 6px var(--coral-deep)); }
.coinbox-slot { position: absolute; left: 31%; width: 38%; top: 18%; height: 10%; }
.cb-slot { fill: #c7b2d6; stroke: #f3c9b3; stroke-width: 1.4; }
.cb-plate-text { font-family: var(--font); font-weight: 700; font-size: 17px; fill: var(--coral-ink); letter-spacing: -.01em; }

/* omikuji box */
.obox {
  position: relative; flex: none; width: calc(var(--u) * .9); aspect-ratio: 120 / 200; z-index: 2;
  transform: translate(var(--zx, 0px), var(--zy, 0px)) scale(var(--zs, 1));
  transition: transform .55s cubic-bezier(.3, 1.12, .4, 1);
  border-radius: 18px; outline-offset: 6px;
}
body[data-state="shake"] .obox { cursor: grab; touch-action: none; }
.obox.grabbed { cursor: grabbing; }
.bx-art { width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.bx-cloth { fill: #cfc4ff; }
.bx-cloth-hem { fill: none; stroke: #b9acf0; stroke-width: 2.4; stroke-linecap: round; }
.bx-top { fill: #e3dcff; stroke: #cfc4ff; stroke-width: 1.4; }
.bx-face-l { fill: #ffe6c9; stroke: #efc79f; stroke-width: 1.4; stroke-linejoin: round; }
.bx-face-c { fill: #fff2de; stroke: #efc79f; stroke-width: 1.4; stroke-linejoin: round; }
.bx-face-r { fill: #f8d6b2; stroke: #efc79f; stroke-width: 1.4; stroke-linejoin: round; }
.bx-band { fill: #ffc8ba; stroke: #f0a797; stroke-width: 1.2; stroke-linejoin: round; }
.bx-lid { fill: #fff8ec; stroke: #efc79f; stroke-width: 1.4; stroke-linejoin: round; }
.bx-hole { fill: #c7b2d6; }
.bx-window { fill: #fffaf2; }
.bx-window-rim { fill: none; stroke: #efc79f; stroke-width: 1.6; }
.bx-glint { fill: none; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; opacity: .9; }
.bx-plate { fill: #ffd9cd; stroke: #f5b6a7; stroke-width: 1; }
.bx-plate-text { font-family: var(--kanji); font-weight: 600; font-size: 6.4px; fill: var(--coral-ink); }
.bx-stick { stroke: #bfe3c4; stroke-width: 3; stroke-linecap: round; }
.bx-stick.alt { stroke: #d6efcf; }
.bx-stick-end { stroke: #ffb9a8; stroke-width: 3; stroke-linecap: round; }
.bx-stick-out { fill: #d6efcf; stroke: #a9d7b0; stroke-width: 1; }
.bx-stick-tip { fill: #ffb9a8; }
.bx-tip { transform-box: view-box; transform-origin: 60px 104px; }
.bx-out { transform-box: view-box; }

/* ---------- controls under the scene ---------- */
.controls {
  position: relative; z-index: 1; flex: none;
  height: calc(var(--ctl) + env(safe-area-inset-bottom)); width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 8px;
  padding: 12px 14px calc(6px + env(safe-area-inset-bottom));
}
.coin-row { display: flex; align-items: center; justify-content: center; gap: 22px; min-height: 84px; }
.coins { display: flex; align-items: flex-end; justify-content: center; gap: 16px; height: 84px; }
.coin-spot { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; min-width: 62px; }
.coin-cap { font-size: 12px; line-height: 1.1; color: var(--ink-soft); white-space: nowrap; }
.coin-cap b { font-weight: 700; color: var(--ink); opacity: .75; }
/* keep the hint's room while the coin flies so the coin does not jump */
.controls .hint { min-height: 24px; font-size: 16px; }
.today-btn { min-height: 46px; font-size: 16px; border-color: #f3cfc2; box-shadow: 0 4px 0 #f3cfc2; color: var(--coral-ink); }
.today-btn:active { box-shadow: 0 1px 0 #f3cfc2; }
.credit { margin: auto 0 0; text-align: center; font-size: 11px; color: var(--ink-soft); }

/* ¥100 coin: pale silver-lilac */
.coin.yen100 {
  --size: 60px;
  background:
    repeating-conic-gradient(from 0deg, rgba(150, 140, 205, .12) 0 5deg, transparent 5deg 10deg),
    radial-gradient(circle at 35% 30%, #fff 0 16%, #eeedfb 52%, #dad7f1 100%);
  border-color: #cfcbea;
  box-shadow: inset 0 -4px 0 rgba(140, 130, 200, .2), 0 5px 12px rgba(130, 120, 190, .25);
  color: #8881bb;
}
.coin.yen100 .coin-face { border: 2px solid rgba(150, 140, 205, .45); background: radial-gradient(circle at 35% 30%, #fff 0 20%, #f1f0fc 100%); }
.coin.yen100 b { font-size: 19px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }

/* ¥5 coin: pale brass with a real hole (the disc is masked, so the hole shows what is behind it) */
.coin.yen5 {
  --size: 56px; border: 0; background: none;
  box-shadow: 0 5px 12px rgba(205, 170, 80, .22);
}
button.coin.yen5 { position: relative; animation-delay: -.8s; }
.coin-disc {
  position: absolute; inset: 0; border-radius: 50%;
  background:
    radial-gradient(circle closest-side, transparent 0 24%, rgba(214, 178, 92, .55) 24% 29%, transparent 29% 86%, rgba(226, 192, 110, .7) 86% 89%, transparent 89% 94%, #e8cd86 94% 100%),
    repeating-conic-gradient(from 6deg, rgba(214, 178, 92, .14) 0 6deg, transparent 6deg 15deg),
    radial-gradient(circle at 34% 28%, #fffdf2 0 12%, var(--gold-3) 30%, var(--gold-1) 66%, #f5dc93 100%);
  box-shadow: inset 0 -3px 0 rgba(205, 170, 80, .22);
  -webkit-mask: radial-gradient(circle closest-side, transparent 0 23%, #000 calc(23% + .6px));
  mask: radial-gradient(circle closest-side, transparent 0 23%, #000 calc(23% + .6px));
}
.coin.yen5.dragging { box-shadow: 0 14px 24px rgba(205, 170, 80, .3); }

/* shaking: progress */
.shake-ui { display: flex; flex-direction: column; align-items: center; gap: 7px; min-height: 72px; width: 100%; }
.meter {
  --e: 0;
  width: min(250px, 66vw); height: 16px; border-radius: 999px; overflow: hidden;
  background: rgba(255, 255, 255, .8); border: 2.5px solid #f3cfc2;
  box-shadow: 0 0 0 calc(var(--e) * 7px) rgba(255, 214, 200, .55);
}
.meter-fill {
  display: block; width: 100%; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #ffe1d6, #ffc0ae);
  transform: scaleX(0); transform-origin: 0 50%; transition: transform .2s cubic-bezier(.3, 1.4, .5, 1);
}
.meter.pulse { animation: meterPulse .26s ease-out; }
@keyframes meterPulse { 0% { scale: 1; } 40% { scale: 1.07 1.3; } 100% { scale: 1; } }
.sub { margin: 0; min-height: 17px; text-align: center; font-size: 13.5px; line-height: 1.3; color: var(--ink-soft); text-wrap: balance; }

/* ---------- the stick ---------- */
.stick-layer { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; }
.st-backdrop { position: absolute; inset: 0; background: rgba(255, 244, 238, .84); -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px); }
.st-card {
  position: relative; width: min(340px, calc(100vw - 32px));
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 0 calc(10px + env(safe-area-inset-bottom));
}
.st-title { margin: 0; padding: 5px 14px; border-radius: 999px; background: var(--coral); color: var(--coral-ink); font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; box-shadow: 0 2px 0 #f3bfae; }
.st-stick {
  position: relative; width: 66px; height: clamp(210px, 42dvh, 330px);
  display: grid; place-items: center; overflow: hidden;
  border-radius: 18px; border: 3px solid #a9d7b0;
  background: linear-gradient(90deg, #cfeacb 0, #e7f6df 38%, #dcf1d6 70%, #c6e5c4 100%);
  box-shadow: 0 6px 0 #a9d7b0, 0 18px 34px rgba(110, 95, 170, .2);
}
.st-cap { position: absolute; left: 0; right: 0; top: 0; height: 30px; background: #ffc3b4; border-bottom: 3px solid #f5a999; }
.st-kan {
  writing-mode: vertical-rl; margin-top: 26px;
  font-family: var(--kanji); font-weight: 600; font-size: clamp(30px, 5.6dvh, 40px); letter-spacing: .12em; color: var(--ink);
}
.st-no { margin: 4px 0 0; padding: 4px 16px; border-radius: 999px; background: #fff; box-shadow: 0 2px 0 #e6dfff; font-size: 20px; font-weight: 700; color: var(--logo); }
.st-note { margin: 0; max-width: 300px; text-align: center; font-size: 14px; line-height: 1.35; color: var(--ink-soft); text-wrap: balance; }

/* ---------- the drawer cabinet ---------- */
.cab { position: fixed; inset: 0; z-index: 45; }
.cab.leaving { pointer-events: none; }
.cab-backdrop { position: absolute; inset: 0; background: rgba(250, 242, 252, .9); -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px); }
.cab-panel {
  position: absolute; inset: 0; margin: 0 auto; max-width: 780px;
  display: flex; flex-direction: column;
  padding: calc(10px + env(safe-area-inset-top)) 0 env(safe-area-inset-bottom);
}
.cab-head { flex: none; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 0 14px 10px; }
.cab-stick {
  flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 0; overflow: hidden;
  border-radius: 12px; border: 2.5px solid #a9d7b0; background: #e2f4dc; color: var(--ink);
  box-shadow: 0 3px 0 #a9d7b0;
}
.cab-stick::before { content: ''; align-self: stretch; width: 12px; margin: -5px 0; background: #ffc3b4; border-right: 2.5px solid #f5a999; }
.cab-stick-kan { font-family: var(--kanji); font-weight: 600; font-size: 16px; }
.cab-stick b { font-size: 14px; font-weight: 700; color: var(--mint-ink); white-space: nowrap; }
.cab-hint { margin: 0; font-size: 16px; line-height: 1.25; font-weight: 600; min-width: 0; }
.cab-hint b { color: var(--logo); white-space: nowrap; }
/* a phone: the header's Back sits over the cabinet's top-left corner, so the head starts right of it */
@media (max-width: 600px) { .cab-head { justify-content: flex-start; padding-left: 70px; min-height: 54px; } }
@media (max-width: 370px) { .cab-stick-kan { display: none; } .cab-stick { padding-right: 10px; } }
.cab-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 4px 12px 14px; }
.cab-body {
  position: relative; margin: 0 auto; max-width: 720px; padding: 10px 10px 12px;
  border-radius: 20px; background: #ffe9d6; border: 3px solid #f6cdb4;
  box-shadow: 0 6px 0 #f6cdb4, 0 18px 36px rgba(110, 95, 170, .16);
}
.cab-roof { height: 16px; margin: -2px -2px 10px; border-radius: 10px; background: #cfc4ff; border: 2px solid #b9acf0; display: grid; place-items: center; }
.cab-roof span { width: 34px; height: 6px; border-radius: 3px; background: #ffc8ba; }
.cab-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px 7px; }
.cab-feet { display: flex; justify-content: space-between; margin: 10px 12% -18px; }
.cab-feet span { width: 34px; height: 12px; border-radius: 0 0 8px 8px; background: #f6cdb4; }
.drawer { position: relative; height: 54px; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 11px; -webkit-tap-highlight-color: transparent; }
.dr-hole { position: absolute; inset: 0; border-radius: 11px; background: #e6dcf4; box-shadow: inset 0 3px 5px rgba(120, 105, 180, .22); }
.dr-front {
  position: absolute; inset: 0; border-radius: 11px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  background: #fff8ee; border: 2px solid #f3d3b8; box-shadow: 0 3px 0 #f3d3b8;
  transition: transform .28s cubic-bezier(.3, 1.3, .5, 1), box-shadow .28s;
}
.dr-no { font-size: 18px; line-height: 1; font-weight: 700; color: var(--coral-ink); }
.dr-kan { font-family: var(--kanji); font-size: 10.5px; line-height: 1.25; font-weight: 600; color: var(--ink-soft); }
.dr-knob { width: 16px; height: 5px; margin-top: 2px; border-radius: 3px; background: #cfc4ff; }
.drawer:nth-child(even) .dr-knob { background: #a9e2cb; }
.drawer:active .dr-front { transform: translateY(2px); }
.drawer.open { z-index: 3; }
.drawer.open .dr-front { transform: translateY(20px) scale(1.1); box-shadow: 0 3px 0 #f3d3b8, 0 12px 20px rgba(110, 95, 170, .28); }
.drawer.wrong { z-index: 2; }
.drawer.wrong .dr-front { animation: drWrong .5s ease-in-out; }
@keyframes drWrong {
  0% { transform: none; } 22% { transform: translateY(9px) scale(1.05); }
  40% { transform: translateY(9px) rotate(-5deg) scale(1.05); } 58% { transform: translateY(7px) rotate(5deg) scale(1.04); }
  76% { transform: translateY(3px) rotate(-2deg); } 100% { transform: none; }
}
.drawer.hint { z-index: 1; }
.drawer.hint .dr-front { animation: drGlow 1.3s ease-in-out infinite; }
@keyframes drGlow {
  0%, 100% { box-shadow: 0 3px 0 #f3d3b8, 0 0 0 0 rgba(246, 207, 99, 0); transform: none; }
  50% { box-shadow: 0 3px 0 #f6cf63, 0 0 0 5px rgba(255, 233, 163, .9), 0 0 18px 6px rgba(246, 207, 99, .55); transform: scale(1.05); background: #fffbe8; }
}
.dr-slip { /* the folded slip inside the drawer */
  position: absolute; left: 50%; top: 50%; width: 30px; height: 40px; z-index: 4; opacity: 0; pointer-events: none;
  transform: translate(-50%, -96%);
  border-radius: 5px; background: #fffdf8; box-shadow: 0 5px 10px rgba(90, 80, 140, .22), inset 0 0 0 1.5px #f1e9f7;
}
.dr-slip::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 30%; border-radius: 5px 5px 0 0; background: var(--coral); }
.dr-slip span { position: absolute; inset: 0; background: repeating-linear-gradient(180deg, transparent 0 9px, rgba(170, 155, 210, .3) 9px 10px); }
.cab-status { flex: none; margin: 0; min-height: 30px; padding: 6px 14px; text-align: center; font-size: 14px; color: var(--ink-soft); }

/* narrow phones: smaller coins so both coins and the today button fit in one row */
@media (max-width: 370px) {
  .coin.yen100 { --size: 54px; }
  .coin.yen5 { --size: 50px; }
  .coin.yen100 b { font-size: 17px; }
  .coins, .coin-row { gap: 10px; }
  .coin-spot { min-width: 56px; }
  .today-btn { min-height: 42px; padding: 0 13px; font-size: 14.5px; }
  .controls .hint { font-size: 15px; }
  /* the credit wraps to two lines here: make room for it */
  .controls { padding-top: 8px; }
  .coin-row, .coins { min-height: 78px; height: 78px; }
}

/* ---------- larger screens ---------- */
@media (min-width: 700px) {
  .sign { font-size: 24px; }
  .sign-ja { font-size: 18px; }
  .hint { font-size: 18px; }
  .cab-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 8px; }
  .drawer { height: 50px; }
  .cab-hint { font-size: 19px; }
}
/* short screens (landscape phones, small laptops) */
@media (max-height: 620px) {
  :root { --ctl: 132px; }
  .view-omikuji { --u: min(calc((var(--col) - 28px) / 2.2), 210px, calc((100dvh - 240px) * 0.58)); }
  .credit { display: none; }
  .coin-row, .coins, .shake-ui { min-height: 64px; height: auto; }
  .coin-cap { font-size: 11px; }
  .st-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cloud, .sign, .to-shide, .kite, .kt-tail, .kt-bow, .to-lantern, .drawer.hint .dr-front, .drawer.wrong .dr-front, .meter.pulse { animation: none !important; }
  .obox, .saisen, .rack, .coinbox, .dr-front, .meter-fill { transition: none !important; }
  .drawer.hint .dr-front { box-shadow: 0 3px 0 #f6cf63, 0 0 0 5px rgba(255, 233, 163, .9); background: #fffbe8; }
}

/* The omikuji corner has no torii behind it: only the box, its coin box and the rack. On a tall phone
   they would stand at the very bottom under an empty sky, so the ground (and what stands on it) is
   lifted by a share of the spare height. */
body[data-view="omikuji"] { --lift: clamp(0px, calc((100dvh - 640px) * .32), 120px); }
.view-omikuji .scene { padding-bottom: calc(6px + var(--lift, 0px)); }
@media (prefers-reduced-motion: reduce) { .ground, .hill { transition: none; } }
