/* ぴょんぴょん うさぎ — 見た目。ライト=ひるの そら・ダーク=ゆうやけ ごろの そら。外部フォントは使わない */
:root {
  --bg: #e6f6ff;
  --sky1: #bfe7ff;
  --sky2: #f1fbff;
  --ink: #2b2433;
  --sub: #55607a;
  --card: #ffffff;
  --card-sh: #b5d6ec;
  --gold: #ffc53d;
  --focus: #2f7cf6;
  --go: #4cc36a;
  --go-sh: #2f8f49;
  --go2: #ffb42e;
  --go2-sh: #c7820a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141b33;
    --sky1: #1b2550;
    --sky2: #2d3b73;
    --ink: #f1f1ff;
    --sub: #b9c1e2;
    --card: #26325f;
    --card-sh: #0b1022;
    --focus: #ffc53d;
    --go: #3fae5d;
    --go-sh: #1f6b36;
    --go2: #f0a21c;
    --go2-sh: #8f5a05;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "BIZ UDPGothic", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
  overflow: hidden;
}
#app {
  position: fixed; inset: 0;
  display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  /* 画面の下 15% には押すものを置かない(手首が当たる) */
  padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + 10px) 15vh calc(env(safe-area-inset-left) + 10px);
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
svg { display: block; width: 100%; height: 100%; overflow: visible; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.logo { display: flex; align-items: center; gap: 8px; margin: 0; min-width: 0; font-size: clamp(16px, 4.4vw, 24px); font-weight: 900; white-space: nowrap; }
.logo img { width: 40px; height: 40px; flex-shrink: 0; }
@media (max-width: 440px) { .logo span { display: none; } }
.btns { display: flex; gap: 8px; }
.ibtn { flex-shrink: 0; width: 56px; height: 56px; border-radius: 16px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh); display: grid; place-items: center; }
.ibtn svg { width: 32px; height: 32px; }
.ibtn:active { transform: translateY(3px); }
#menuBtn rect { fill: var(--ink); }
.spk { fill: var(--ink); }
.wave, .slash { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; }
.snd.off .wave, .snd:not(.off) .slash { display: none; }

/* ---- ステージ ---- */
.stage {
  position: relative; min-height: 0; border: 3px solid var(--ink); border-radius: 22px; overflow: hidden;
  background: linear-gradient(var(--sky1), var(--sky2));
  touch-action: none;
}
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---- コースを えらぶ ---- */
.sel { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 10px; }
@media (orientation: landscape) { .sel { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); } }
.course {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 0; min-width: 0;
  padding: 8px; border-radius: 22px; background: var(--card); box-shadow: 0 6px 0 var(--card-sh);
}
.course svg { flex: 1 1 0; min-height: 0; width: 100%; border-radius: 14px; overflow: hidden; }
.course .cn { flex: none; font-size: clamp(20px, 5vw, 30px); font-weight: 900; line-height: 1.1; }
.course[aria-pressed="true"] { box-shadow: 0 6px 0 var(--card-sh), 0 0 0 5px var(--gold); }
.course:active { transform: translateY(4px); }

/* ---- あそんでいる あいだ ---- */
.hud { position: absolute; left: 10px; right: 10px; top: 8px; display: flex; align-items: center; gap: 12px; pointer-events: none; z-index: 3; }
.prog { position: relative; flex: 1 1 0; min-width: 40px; height: 14px; margin-right: 14px; border-radius: 7px; background: rgba(255, 255, 255, .7); border: 3px solid #2b2433; }
.prog .fill { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--p, 0) * 1%); border-radius: 4px; background: #4cc36a; }
.prog .dot { position: absolute; top: 50%; left: calc(var(--p, 0) * 1%); width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; background: #fff; border: 3px solid #2b2433; }
.pflag { position: absolute; right: -16px; top: -17px; width: 24px; height: 30px; }
.cnt { display: flex; align-items: center; gap: 4px; padding: 3px 10px 3px 6px; border-radius: 16px; background: rgba(255, 255, 255, .85); border: 3px solid #2b2433; color: #2b2433; }
.cnt svg { width: 22px; height: 26px; }
.cnt b { min-width: 1ch; font-size: 22px; font-weight: 900; line-height: 1; }

.hint { position: absolute; left: 50%; top: 42%; width: 0; height: 0; pointer-events: none; z-index: 3; }
.hint .ring { position: absolute; left: -36px; top: -36px; width: 72px; height: 72px; border-radius: 50%; border: 5px solid #fff; box-shadow: 0 0 0 3px #2b2433; animation: ring 1.2s ease-out infinite; }
.hint .r2 { animation-delay: .6s; }
.hint .hand { position: absolute; left: -2px; top: -4px; width: 48px; height: 58px; animation: poke 1.2s ease-in-out infinite; }
.hint .hl { position: absolute; left: 0; top: 62px; transform: translateX(-50%); white-space: nowrap; padding: 6px 14px; border-radius: 16px; background: #fff; color: #2b2433; border: 3px solid #2b2433; font-size: clamp(16px, 4.4vw, 22px); font-weight: 900; }
@keyframes ring { from { transform: scale(.4); opacity: .95; } to { transform: scale(1.25); opacity: 0; } }
@keyframes poke { 50% { transform: translate(-4px, -10px); } }

/* ---- ゴール ---- */
.goal { position: absolute; inset: 0; display: grid; place-items: start center; padding: 6% 12px 12px; z-index: 5; pointer-events: none; }
.gc {
  pointer-events: auto; width: min(100%, 420px); padding: 14px 14px 16px; border-radius: 26px; background: var(--card); color: var(--ink);
  border: 4px solid var(--ink); box-shadow: 0 8px 0 var(--card-sh); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px;
  animation: pop .45s cubic-bezier(.3, 1.5, .6, 1) both;
}
.gt { flex: 1 1 100%; margin: 0; text-align: center; font-size: clamp(30px, 8vw, 44px); font-weight: 900; line-height: 1.1; color: var(--ink); }
.gn { flex: 1 1 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }
.gn b { font-size: clamp(28px, 7vw, 38px); font-weight: 900; line-height: 1; min-width: 1.2ch; margin-right: 10px; }
.gi { width: 34px; height: 40px; }
.gb { flex: 1 1 100%; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.gbtn {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 68px; padding: 8px 12px; border-radius: 20px;
  font-size: clamp(20px, 5.4vw, 26px); font-weight: 900; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
}
.gbtn span { white-space: nowrap; }
.gbtn svg { width: 30px; height: 30px; flex: none; }
.gbtn.again { background: var(--go); box-shadow: 0 5px 0 var(--go-sh); }
.gbtn.next { background: var(--go2); box-shadow: 0 5px 0 var(--go2-sh); }
.gbtn:active { transform: translateY(4px); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

/* スマホを 横に したとき */
@media (orientation: landscape) {
  .goal { place-items: center end; padding: 8px 3% 8px 8px; }
  .gc { width: min(100%, 560px); }
  .gb { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (orientation: landscape) and (max-height: 600px) {
  .logo img { width: 32px; height: 32px; }
  .ibtn { width: 48px; height: 48px; }
  .gc { padding: 8px 10px 12px; gap: 4px 12px; border-radius: 22px; }
  .gt { flex: 1 1 auto; font-size: 30px; text-align: right; }
  .gn { flex: 1 1 auto; justify-content: flex-start; }
  .gb { gap: 8px; }
  .gbtn { min-height: 56px; font-size: 20px; padding: 4px 8px; }
  .gbtn svg { width: 24px; height: 24px; }
  .hint .hl { font-size: 16px; padding: 4px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .hint .ring { opacity: .9; }
}
