:root {
  --sky-top: #3f8fd8;
  --sky-bottom: #bfe3fb;
  --ink: #17324a;
  --sub: #5b7389;
  --accent: #026881;
  --cloud: #ffffff;
  --cloud-shade: #dbe9f5;
  --card: rgba(255, 255, 255, 0.94);
  --font: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky-top: #123a63;
    --sky-bottom: #4f86b4;
    --ink: #eaf3fb;
    --sub: #a9c0d4;
    --accent: #7cc6d8;
    --cloud: #f4f8fc;
    --cloud-shade: #c8d8e6;
    --card: rgba(18, 38, 58, 0.94);
  }
}
:root[data-theme="dark"] {
  --sky-top: #123a63; --sky-bottom: #4f86b4; --ink: #eaf3fb; --sub: #a9c0d4;
  --accent: #7cc6d8; --cloud: #f4f8fc; --cloud-shade: #c8d8e6; --card: rgba(18, 38, 58, 0.94);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--sky-top);
  overflow: hidden;
}

.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 11;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 40, 80, 0.25);
}
.name { font-size: 18px; font-weight: 700; margin: 0; letter-spacing: 0.08em; }
.stats { display: flex; gap: 20px; font-variant-numeric: tabular-nums; }
.stat { display: flex; align-items: baseline; gap: 6px; font-size: 22px; font-weight: 600; }
.stat .label { font-size: 12px; font-weight: 500; opacity: 0.85; }

.sky {
  position: fixed; inset: 0;
  background: linear-gradient(to bottom, var(--sky-top), var(--sky-bottom));
  overflow: hidden;
}
.sun {
  position: absolute; top: 9%; right: 9%;
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, #fffbe6 0 40%, rgba(255, 246, 200, 0.5) 55%, rgba(255, 246, 200, 0) 72%);
}
.far i {
  position: absolute; left: 100%;
  width: var(--w); height: calc(var(--w) * 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  filter: blur(6px);
  animation: drift var(--d) linear infinite;
}
@keyframes drift { to { transform: translateX(calc(-100vw - 300px)); } }

/* 流れてくる雲 */
.cloud {
  position: absolute; left: 0; top: 0;
  padding: 18px 30px 14px;
  min-width: 170px;
  border-radius: 999px;
  background: var(--cloud);
  box-shadow: inset 0 -8px 0 var(--cloud-shade), 0 6px 18px rgba(20, 60, 100, 0.12);
  color: #17324a;
  text-align: center;
  white-space: nowrap;
  will-change: transform;
}
.cloud::before, .cloud::after {
  content: ""; position: absolute; z-index: -1;
  background: var(--cloud); border-radius: 50%;
}
.cloud::before { height: 92%; aspect-ratio: 1; top: -42%; left: 16%; }
.cloud::after { height: 70%; aspect-ratio: 1; top: -28%; right: 18%; }
.cloud { isolation: isolate; }
.cloud .word { display: block; font-size: 22px; font-weight: 700; letter-spacing: 0.04em; }
.cloud .kana { display: block; font-size: 12px; color: #5b7389; margin-top: 2px; }
.cloud .roma { display: block; font-family: var(--mono); font-size: 15px; margin-top: 4px; letter-spacing: 0.03em; }
.cloud .roma .t { color: #026881; font-weight: 700; }
.cloud .roma .r { color: #9fb2c3; }
body.nohint .cloud .roma .r { visibility: hidden; }
.cloud.target { box-shadow: inset 0 -8px 0 var(--cloud-shade), 0 0 0 3px #026881, 0 6px 18px rgba(20, 60, 100, 0.18); }
.cloud.shake { animation: shake 0.18s; }
@keyframes shake { 25% { margin-left: -5px; } 75% { margin-left: 5px; } }
.cloud.pop { animation: pop 0.32s ease-out forwards; }
@keyframes pop {
  0% { scale: 1; opacity: 1; }
  40% { scale: 1.22; opacity: 0.9; }
  100% { scale: 1.45; opacity: 0; filter: blur(4px); }
}
.cloud.gone { animation: gone 0.5s ease-in forwards; }
@keyframes gone { to { opacity: 0; } }

.puff {
  position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; pointer-events: none;
  animation: puff 0.45s ease-out forwards;
}
@keyframes puff { to { transform: translate(var(--x), var(--y)) scale(0.2); opacity: 0; } }

.ime {
  position: absolute; left: 50%; bottom: 32px; translate: -50% 0;
  margin: 0; padding: 10px 18px; border-radius: 999px;
  background: rgba(0, 30, 60, 0.75); color: #fff; font-size: 14px;
}

/* 始まりと終わりの小窓 */
.sheet {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: end center;
  padding: 16px 16px max(24px, env(safe-area-inset-bottom));
  background: rgba(10, 40, 70, 0.18);
}
.sheet[hidden] { display: none; }
.card {
  width: min(440px, 100%);
  padding: 28px 24px 22px;
  border-radius: 24px;
  background: var(--card);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 40px rgba(10, 40, 70, 0.25);
}
.card h2 { margin: 0 0 12px; font-size: 26px; letter-spacing: 0.06em; }
.card p { margin: 0 0 10px; line-height: 1.7; font-size: 15px; }
.note { color: var(--sub); font-size: 13px !important; }
.warn { color: #b0482b; }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 8px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.keys { color: var(--sub); font-size: 12px !important; text-align: center; margin: 10px 0 0 !important; }

.btn {
  display: block; width: 100%; margin-top: 16px;
  padding: 14px 20px; border-radius: 999px;
  font: inherit; font-size: 17px; font-weight: 700;
  border: 1.5px solid var(--accent); background: transparent; color: var(--accent);
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #0b2236; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #0b2236; } }
.btn:focus-visible { outline: 3px solid #3a8dff; outline-offset: 3px; }

.nums { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 8px 0 14px; }
.nums div { padding: 12px; border-radius: 14px; background: rgba(2, 104, 129, 0.08); }
.nums dt { font-size: 12px; color: var(--sub); }
.nums dd { margin: 4px 0 0; font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }

@media (max-width: 520px) {
  .stats { gap: 12px; }
  .stat { font-size: 18px; }
  .cloud .word { font-size: 18px; }
  .cloud { padding: 14px 22px 12px; }
}

/* samsara のボタン（絶対押してはいけないボタン）。いちばん目立つ赤で点滅させる。押すと金に変わる */
.samsara {
  font: inherit; font-size: 15px; font-weight: 900; letter-spacing: 0.04em;
  padding: 8px 18px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  border: 3px solid #ffe600; background: #ff1638; color: #fff;
  text-shadow: 0 1px 0 #8a0014; align-self: center;
  box-shadow: 0 0 0 3px #111, 0 0 18px 4px rgba(255, 22, 56, 0.9);
  animation: alarm 0.9s ease-in-out infinite;
}
@keyframes alarm {
  50% { background: #ff5a00; box-shadow: 0 0 0 3px #111, 0 0 32px 10px rgba(255, 230, 0, 0.95); transform: scale(1.06); }
}
.samsara[aria-pressed="true"] { animation: none; background: #d9a520; border-color: #fff3b0; color: #2a1a00; text-shadow: none; box-shadow: 0 0 0 3px #111, 0 0 18px rgba(255, 210, 90, 0.9); }
.samsara:focus-visible { outline: 3px solid #3a8dff; outline-offset: 5px; }
@media (max-width: 620px) { .bar { flex-wrap: wrap; gap: 8px; } .samsara { font-size: 13px; padding: 6px 12px; } }
@media (prefers-reduced-motion: reduce) { .samsara { animation: none; } }

/* 励ます仁王（samsara の style.css から）。下の両すみに立ち、雲は前を流れる */
.nio {
  position: absolute; bottom: -2vh; z-index: 0; height: min(62vh, 620px); width: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 10px;
  pointer-events: none; --beat: 1.6s; --k: 0.6;
}
.nio[hidden] { display: none; }
.nio.left { left: max(-2vw, -20px); }
.nio.right { right: max(-2vw, -20px); }
.nio .fig { height: 100%; display: flex; align-items: flex-end; animation: breathe var(--beat) ease-in-out infinite; transform-origin: 50% 100%; }
.nio img {
  height: 100%; width: auto; transform-origin: 50% 60%;
  filter: drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(6px 6px 0 rgb(0 0 0 / 0.3));
  transition: transform 0.5s cubic-bezier(.3, 1.6, .5, 1);
}
@keyframes breathe { 0%, 100% { transform: scale(1, 1); } 45% { transform: scale(1.02, 0.99); } }
.nio[data-pose="side"] img { transform: perspective(900px) rotateY(16deg) scale(0.96); }
.nio.right[data-pose="side"] img { transform: perspective(900px) rotateY(-16deg) scale(0.96); }
.nio[data-pose="double"] img { transform: scale(1.04); }
.nio[data-pose="lat"] img { transform: scale(1.05, 0.99); }
.nio.flex .fig { animation: flex 0.9s cubic-bezier(.3, 1.7, .5, 1), breathe var(--beat) ease-in-out 0.9s infinite; }
@keyframes flex {
  25% { transform: scale(calc(1 + var(--k) * 0.04), calc(1 - var(--k) * 0.015)) rotate(calc(var(--k) * -1deg)); }
  55% { transform: scale(calc(1 + var(--k) * 0.025), 1) rotate(calc(var(--k) * 0.6deg)); }
}
.nio .call {
  position: relative; margin: 0; opacity: 0; transform: scale(0.8);
  padding: 8px 14px; border-radius: 18px; max-width: 260px; width: max-content;
  background: #17324a; color: #fff; font-weight: 900; font-size: 17px; text-align: center;
}
.nio .call::after {
  content: ""; position: absolute; left: 50%; bottom: -8px; margin-left: -8px;
  border: 8px solid transparent; border-top-color: #17324a; border-bottom: 0;
}
.nio .call.in { animation: call 3.6s cubic-bezier(.3, 1.6, .5, 1) forwards; }
@keyframes call {
  0% { opacity: 0; transform: translateY(10px) scale(0.6); }
  10%, 80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-6px) scale(0.95); }
}
#clouds { position: absolute; inset: 0; z-index: 1; }
@media (max-width: 700px) {
  .nio { height: 34vh; }
  .nio .call { font-size: 13px; max-width: 44vw; }
}
@media (prefers-reduced-motion: reduce) { .nio .fig, .nio.flex .fig { animation: none; } }

@media (prefers-reduced-motion: reduce) {
  .far i { animation: none; }
  .cloud.pop { animation-duration: 0.01s; }
}
