/* Omikuji Shrine — the grounds, 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; }
.ground {
  position: absolute; left: -12%; right: -12%; bottom: 0;
  height: calc(var(--ctl) + 64px + env(safe-area-inset-bottom));
  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%; }
.hill.h1 { left: -18%; width: 70%; height: 190px; bottom: calc(var(--ctl) + 12px); background: #e6e0fb; }
.hill.h2 { right: -22%; width: 78%; height: 230px; bottom: calc(var(--ctl) - 6px); 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; }
@keyframes cloudDrift { from { transform: translateX(-22px); } to { transform: translateX(26px); } }
.petal {
  position: absolute; top: -20px; width: 11px; height: 9px;
  border-radius: 80% 10% 80% 10%; background: #ffd3da; opacity: .85;
  animation: petalFall 11s linear infinite;
}
.petal.p1 { left: 8%; animation-delay: -1s; }
.petal.p2 { left: 27%; animation-delay: -6s; animation-duration: 13s; background: #ffe1d6; }
.petal.p3 { left: 46%; animation-delay: -3s; animation-duration: 15s; }
.petal.p4 { left: 63%; animation-delay: -9s; animation-duration: 12s; background: #e7dcff; }
.petal.p5 { left: 80%; animation-delay: -4.5s; animation-duration: 14s; }
.petal.p6 { left: 93%; animation-delay: -11s; animation-duration: 16s; background: #ffe1d6; }
@keyframes petalFall {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(26px, 24vh) rotate(160deg); }
  50% { transform: translate(-14px, 48vh) rotate(300deg); }
  75% { transform: translate(22px, 72vh) rotate(470deg); }
  100% { transform: translate(-8px, 104vh) rotate(640deg); }
}

/* ---------- page frame ---------- */
.app {
  position: relative; z-index: 1;
  height: 100vh; height: 100dvh;
  max-width: 820px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 0 12px 0 16px; min-height: 58px;
}
.top-actions { display: flex; gap: 8px; padding-top: 10px; }
/* 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: 370px) { .sign { font-size: 17px; padding: 5px 12px 6px; gap: 6px; } .sign-ja { font-size: 13px; } .top { padding-left: 12px; } }
@media (max-width: 440px) {
  .top .icon-btn { width: 40px; height: 40px; }
  .top .icon-btn svg { width: 20px; height: 20px; }
  .top-actions { gap: 6px; }
}

/* ---------- the scene: torii behind; offering box, omikuji box and rack in a row ---------- */
.scene {
  flex: 1; min-height: 0; position: relative;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 10px 6px;
}
.torii {
  position: absolute; left: 50%; bottom: 2px; translate: -50% 0;
  height: min(96%, calc(var(--u) * 3.3)); max-width: 100%; aspect-ratio: 400 / 340;
  overflow: visible;
}
.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 { transition: opacity .35s ease, transform .45s cubic-bezier(.3, 1.1, .4, 1), filter .2s, scale .2s; }
.scene.focus .saisen, .scene.focus .rack { opacity: .2; transform: scale(.9); pointer-events: none; }
.scene .rack { flex: none; }

/* offering box */
.saisen { position: relative; flex: none; width: calc(var(--u) * 1.08); 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; }

/* 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: 18px; min-height: 72px; }
.coins { display: flex; align-items: center; justify-content: center; height: 72px; }
.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; }

/* 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; }
.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); }

/* ---------- 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: 138px; --u: min(calc((100vw - 28px) / 3.02), 190px, calc((100dvh - 250px) * 0.5)); }
  .credit { display: none; }
  .coin-row, .coins, .shake-ui { min-height: 64px; height: auto; }
  .st-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cloud, .petal, .sign, .to-shide, .drawer.hint .dr-front, .drawer.wrong .dr-front, .meter.pulse { animation: none !important; }
  .petal { display: none; }
  .obox, .saisen, .rack, .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; }
}
