:root {
  --yama: #F2B233; --navy: #1F3A5F; --sunset: #F7B98A; --cream: #FFF1D6; --rain: #8FA6C8;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --u: min(1vw, 1vh * 0.62);
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #F7B98A; overscroll-behavior: none; }
body { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#c { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; color: var(--navy); }
.hidden { display: none !important; }
.screen { position: absolute; inset: 0; }
button { font: inherit; color: inherit; cursor: pointer; pointer-events: auto; white-space: nowrap; border: none; }

/* ---------------- タイトル */
.sign-wrap { position: absolute; top: calc(var(--sat) + 8px); left: 50%; transform: translateX(-50%); width: min(88vw, 440px, 70vh); animation: sway 5s ease-in-out infinite; transform-origin: 50% -40px; }
@keyframes sway { 0%,100% { transform: translateX(-50%) rotate(-0.8deg); } 50% { transform: translateX(-50%) rotate(0.8deg); } }
.sign-strings { display: flex; justify-content: space-around; height: clamp(14px, 5vh, 46px); padding: 0 16%; }
.sign-strings i { width: 3px; background: #7C8AA8; border-radius: 2px; }
.sign { background: #fff; border-radius: 10px; box-shadow: 0 4px 0 #cfd6e6, 0 8px 18px rgba(80, 60, 40, .25); overflow: hidden; border: 3px solid #E0E4EE; }
.sign-main { font-size: clamp(22px, 8.2vw, 46px); font-weight: 800; text-align: center; letter-spacing: .06em; padding: .38em .2em .3em; color: var(--navy); white-space: nowrap; }
.sign-band { background: var(--yama); color: #fff; display: flex; justify-content: space-between; gap: .5em; padding: .35em .7em; font-size: clamp(9px, 2.9vw, 15px); font-weight: 700; white-space: nowrap; }
.sign-band span { overflow: hidden; text-overflow: clip; }
.title-bottom { position: absolute; left: 50%; bottom: calc(var(--sab) + clamp(10px, 3vh, 34px)); transform: translateX(-50%); width: min(92vw, 460px); display: flex; flex-direction: column; align-items: center; gap: clamp(4px, 1.3vh, 12px); }
.diffs { display: flex; gap: clamp(2px, 1.5vw, 10px); justify-content: center; background: rgba(255, 241, 214, .9); border-radius: 999px; padding: 2px clamp(6px, 2vw, 12px); box-shadow: 0 2px 8px rgba(120, 80, 30, .18); }
.diff { background: rgba(255, 255, 255, .0); font-size: clamp(14px, 4.4vw, 21px); font-weight: 800; padding: .3em .45em; color: rgba(31, 58, 95, .62); text-shadow: 0 1px 0 rgba(255, 255, 255, .6); transition: color .2s, text-shadow .2s; }
.diff.on { color: #C9780F; text-shadow: 0 0 8px #FFE9A8, 0 0 2px #FFFFFF; }
.diff-desc { font-size: clamp(10px, 3.1vw, 14px); font-weight: 700; color: var(--navy); background: rgba(255, 241, 214, .82); padding: .3em .8em; border-radius: 999px; white-space: nowrap; max-width: 100%; overflow: hidden; }
.big { background: linear-gradient(#FFCB5C, var(--yama)); color: var(--navy); font-size: clamp(20px, 7vw, 34px); font-weight: 900; padding: .28em 1.6em; border-radius: 999px; box-shadow: 0 5px 0 #C98A1A, 0 10px 20px rgba(120, 70, 20, .25); letter-spacing: .15em; transition: transform .12s; }
.big:active { transform: translateY(3px); box-shadow: 0 2px 0 #C98A1A; }
.small-row { display: flex; gap: clamp(6px, 2.4vw, 14px); justify-content: center; flex-wrap: nowrap; }
.small { background: rgba(255, 255, 255, .88); font-size: clamp(11px, 3.4vw, 16px); font-weight: 800; padding: .45em .9em; border-radius: 999px; box-shadow: 0 3px 0 rgba(31, 58, 95, .2); color: var(--navy); }
.icon { width: clamp(34px, 9vw, 46px); height: clamp(34px, 9vw, 46px); border-radius: 50%; background: rgba(255, 255, 255, .8); color: var(--navy); display: grid; place-items: center; padding: 0; box-shadow: 0 2px 0 rgba(31, 58, 95, .2); }
.icon svg { width: 60%; height: 60%; }
.corner-tr { position: absolute; right: calc(var(--sar) + 10px); bottom: calc(var(--sab) + 10px); display: flex; flex-direction: column; gap: 8px; }

/* ---------------- HUD */
#hud { position: absolute; inset: 0; }
#btnPause { position: absolute; top: calc(var(--sat) + 10px); left: calc(var(--sal) + 10px); }
#ruler { position: absolute; left: calc(var(--sal) + 14px); top: calc(var(--sat) + 70px); bottom: calc(var(--sab) + 18%); width: 26px; }
.ruler-line { position: absolute; left: 11px; top: 26px; bottom: 0; width: 4px; border-radius: 3px; background: linear-gradient(#fff, rgba(255, 255, 255, .5)); box-shadow: 0 0 0 1.5px rgba(31, 58, 95, .35); }
.ruler-top { position: absolute; left: -10px; top: -14px; width: 46px; height: 36px; filter: drop-shadow(0 1px 1.5px rgba(31, 58, 95, .55)); }
.ruler-ticks { position: absolute; left: 7px; top: 26px; bottom: 0; width: 12px; }
.ruler-ticks i { position: absolute; left: 0; width: 12px; height: 2px; background: rgba(31, 58, 95, .45); }
#rulerMark { position: absolute; left: 3px; width: 20px; height: 20px; margin-top: -10px; border-radius: 50%; background: var(--yama); box-shadow: 0 0 0 2px #fff, 0 0 10px #FFD36B; }
#rulerNum { position: absolute; left: 28px; font-size: 12px; font-weight: 800; margin-top: -8px; color: var(--navy); text-shadow: 0 0 3px #fff, 0 0 3px #fff; white-space: nowrap; }
#fallCount { position: absolute; top: calc(var(--sat) + 16px); right: calc(var(--sar) + 12px); font-size: clamp(11px, 3.2vw, 14px); font-weight: 700; color: rgba(31, 58, 95, .8); text-shadow: 0 0 3px #fff, 0 0 3px #fff; white-space: nowrap; }
#distBox { position: absolute; top: calc(var(--sat) + 14px); left: 50%; transform: translateX(-50%); font-size: clamp(14px, 4.4vw, 22px); font-weight: 800; color: #fff; text-shadow: 0 1px 3px rgba(31, 58, 95, .8), 0 0 8px rgba(31, 58, 95, .5); white-space: nowrap; }
#distBox b { font-size: 1.35em; color: #FFE7A8; }
#distBox .lbl { font-size: .8em; }
#hint, #toast { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); font-size: clamp(13px, 3.9vw, 18px); font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(31, 58, 95, .9), 0 0 6px rgba(31, 58, 95, .6); white-space: nowrap; opacity: 0; transition: opacity .25s; }
#hint.on, #toast.on { opacity: 1; }
#toast { color: #FFF1C0; }
#skipText { position: absolute; bottom: calc(var(--sab) + 16px); left: 50%; transform: translateX(-50%); font-size: clamp(11px, 3.2vw, 14px); font-weight: 700; color: rgba(31, 58, 95, .75); text-shadow: 0 0 4px #fff; opacity: 0; white-space: nowrap; }
#skipText.on { opacity: 1; }

/* ---------------- 窓（モーダル） */
.modal { background: rgba(255, 241, 214, .55); display: grid; place-items: center; pointer-events: auto; padding: calc(var(--sat) + 10px) calc(var(--sar) + 10px) calc(var(--sab) + 10px) calc(var(--sal) + 10px); }
.card { background: #fff; border-radius: 22px; box-shadow: 0 8px 0 #E8D7B8, 0 14px 30px rgba(80, 60, 40, .25); padding: clamp(10px, 3vh, 22px) clamp(12px, 4vw, 26px); width: min(92vw, 470px); max-height: 100%; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: clamp(6px, 1.6vh, 12px); }
.card-title { font-size: clamp(18px, 5.6vw, 26px); font-weight: 900; white-space: nowrap; }
.steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: clamp(4px, 1.2vh, 10px); width: 100%; }
.steps li { display: flex; align-items: center; gap: 10px; font-size: clamp(11px, 3.4vw, 15px); font-weight: 700; line-height: 1.35; }
.step-pic { width: clamp(64px, 20vw, 96px); height: auto; aspect-ratio: 4/3; flex: none; border-radius: 12px; background: #EAF6FF; }
.joy { font-size: clamp(13px, 4vw, 18px); font-weight: 900; color: #C98A1A; white-space: nowrap; }
.tapclose { font-size: 12px; color: rgba(31, 58, 95, .6); font-weight: 700; }
.vol { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: clamp(13px, 4vw, 17px); width: 100%; white-space: nowrap; pointer-events: auto; }
.vol input { flex: 1; min-width: 0; accent-color: var(--yama); }

/* ---------------- 結果 */
#result { display: grid; place-items: end center; padding: calc(var(--sat) + 10px) calc(var(--sar) + 10px) calc(var(--sab) + 12px) calc(var(--sal) + 10px); background: linear-gradient(rgba(255, 241, 214, 0) 30%, rgba(255, 241, 214, .75)); pointer-events: auto; }
.res-card { width: min(92vw, 470px); display: flex; flex-direction: column; align-items: center; gap: clamp(4px, 1.2vh, 10px); }
#resLine { font-size: clamp(22px, 7vw, 36px); font-weight: 900; color: var(--navy); text-shadow: 0 0 10px #fff, 0 0 4px #fff; white-space: nowrap; }
#resFact { font-size: clamp(12px, 3.7vw, 17px); font-weight: 800; background: rgba(255, 255, 255, .9); padding: .35em .9em; border-radius: 999px; white-space: nowrap; }
#resStats { font-size: clamp(10px, 3vw, 13px); font-weight: 700; color: rgba(31, 58, 95, .85); text-align: center; white-space: nowrap; text-shadow: 0 0 4px #fff; }
#resStats b { color: #C98A1A; }
#fade { position: absolute; inset: 0; background: #FFF1D6; opacity: 0; pointer-events: none; transition: opacity .35s; }

@media (orientation: landscape) and (max-height: 500px) {
  .sign-wrap { width: min(52vw, 420px); }
  .sign-strings { height: 8px; }
  .sign-main { font-size: clamp(18px, 5.6vh, 36px); padding: .25em .2em .2em; }
  .sign-band { font-size: clamp(8px, 2.4vh, 13px); }
  .title-bottom { width: min(70vw, 460px); gap: 4px; bottom: calc(var(--sab) + 8px); }
  .big { font-size: clamp(16px, 6vh, 28px); padding: .2em 1.4em; }
  .diff { font-size: clamp(12px, 4.2vh, 18px); padding: .15em .4em; }
  .diff-desc { font-size: clamp(9px, 3vh, 13px); }
  .small { font-size: clamp(10px, 3.4vh, 14px); padding: .35em .8em; }
  .card { width: min(80vw, 560px); padding: 8px 14px; gap: 5px; }
  .steps li { font-size: clamp(10px, 3.4vh, 14px); }
  .step-pic { width: clamp(48px, 14vh, 80px); }
  .card-title { font-size: clamp(14px, 5vh, 22px); }
          .res-card { gap: 3px; }
  #resLine { font-size: clamp(18px, 6vh, 30px); }
    #ruler { top: calc(var(--sat) + 58px); bottom: calc(var(--sab) + 10px); }
  .corner-tr { flex-direction: row; }
}

/* 横風の予告: 画面の端に風の線が流れる */
.windside { position: absolute; top: 18%; bottom: 18%; width: 12%; opacity: 0; transition: opacity .4s; pointer-events: none;
  background: repeating-linear-gradient(180deg, transparent 0 22px, rgba(255,255,255,.75) 22px 24px, transparent 24px 46px);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 40%, #000 60%, transparent); mask-image: linear-gradient(90deg, transparent, #000 40%, #000 60%, transparent); }
#windL { left: 0; } #windR { right: 0; }
.windside.on { opacity: 1; }
.windside.to-r { background: repeating-linear-gradient(90deg, transparent 0 18px, rgba(255,255,255,.8) 18px 44px, transparent 44px 70px); background-size: 70px 23px; animation: windR .5s linear infinite; }
.windside.to-l { background: repeating-linear-gradient(90deg, transparent 0 18px, rgba(255,255,255,.8) 18px 44px, transparent 44px 70px); background-size: 70px 23px; animation: windL .5s linear infinite; }
@keyframes windR { from { background-position: 0 0; } to { background-position: 70px 0; } }
@keyframes windL { from { background-position: 0 0; } to { background-position: -70px 0; } }
