/* ぞろぞろ ひよこ — 見た目。ライト=ひるの そら・ダーク=ゆうがた。外部フォントは使わない(みちは canvas に かく) */
:root {
  --bg: #dff3ff;
  --ink: #2b2433;
  --sub: #5c6577;
  --card: #ffffff;
  --card-sh: #b9d6ea;
  --gold: #ffc53d;
  --focus: #2f7cf6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18202c;
    --ink: #f3eefc;
    --sub: #b8c2d4;
    --card: #2c3646;
    --card-sh: #0d1118;
    --focus: #ffc53d;
  }
}

* { 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) auto; 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(17px, 4.6vw, 24px); font-weight: 900; white-space: nowrap; }
.logo img { width: 40px; height: 40px; flex-shrink: 0; }
@media (max-width: 440px) { .logo span { display: none; } }
.map { flex: 1; min-width: 0; height: 48px; border-radius: 12px; border: 2.5px solid var(--ink); background: #bfe6ff; touch-action: none; cursor: pointer; }
.snd { flex-shrink: 0; width: 52px; height: 56px; border-radius: 16px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh); display: grid; place-items: center; }
.snd svg { width: 32px; height: 32px; }
.wx { margin-right: -2px; }
.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; }
.snd:active { transform: translateY(3px); }

/* ---- みち ---- */
.stage { position: relative; min-height: 0; border: 3px solid var(--ink); border-radius: 22px; overflow: hidden; background: #bfe6ff; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.odai {
  position: absolute; left: 8px; top: 8px; right: 8px; z-index: 2; pointer-events: none;
  display: flex; align-items: center; gap: 6px; width: fit-content; max-width: calc(100% - 16px);
  padding: 4px 10px 4px 4px; border-radius: 14px; background: rgba(255, 255, 255, .92); color: #2b2433; border: 2px solid #2b2433;
  font-size: clamp(13px, 3.6vw, 17px); font-weight: 900;
}
.odai .ol { padding: 2px 8px; border-radius: 10px; background: #ff922b; color: #fff; font-size: .8em; white-space: nowrap; }
.odai b { margin-left: 2px; color: #e8590c; white-space: nowrap; }
.arrow {
  position: absolute; top: 50%; z-index: 2; width: 48px; height: 72px; margin-top: -36px;
  border-radius: 16px; background: rgba(255, 255, 255, .8); border: 2.5px solid #2b2433; display: grid; place-items: center;
}
.arrow.left { left: 6px; } .arrow.right { right: 6px; }
.arrow svg { width: 30px; height: 30px; }
.arrow:active { transform: scale(.94); }
.clear {
  position: absolute; left: 50%; top: 30%; transform: translateX(-50%); z-index: 3; pointer-events: none;
  padding: 12px 26px; border-radius: 22px; background: #fff; color: #2b2433; border: 3px solid #2b2433;
  animation: pop .4s cubic-bezier(.3, 1.6, .6, 1) both;
}
.clear p { margin: 0; font-size: clamp(24px, 6vw, 34px); font-weight: 900; color: #e8590c; }
@keyframes pop { from { transform: translateX(-50%) scale(.5); opacity: 0; } }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.confetti i {
  position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px;
  animation-name: fall; animation-timing-function: cubic-bezier(.3, .6, .6, 1); animation-fill-mode: forwards;
}
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--r)); } }

.hand { position: fixed; left: 0; top: 0; width: 48px; height: 58px; pointer-events: none; opacity: 0; z-index: 4; }
.hand.on { opacity: 1; animation: poke 1s ease-in-out infinite; }
.hand.on.draw { animation: drawing 1.8s ease-in-out infinite; }
@keyframes poke { 50% { translate: -6px -10px; } }
@keyframes drawing { 0%, 15% { translate: 0 0; } 70%, 100% { translate: 56px -40px; } }

/* ---- どうぐ ---- */
.tray { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; width: min(100%, 640px); justify-self: center; }
.tbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 62px; padding: 3px 2px; border-radius: 18px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh);
}
.tbtn[aria-pressed="true"] { box-shadow: 0 4px 0 var(--card-sh), 0 0 0 4px var(--gold); }
.tbtn:active { transform: translateY(3px); }
.ti { width: 40px; height: 40px; }
#clearBtn.arm { background: #ffc9c9; }
@media (min-width: 700px) { .tray { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
.tn { font-size: clamp(12px, 3.4vw, 16px); font-weight: 900; white-space: nowrap; }

/* スマホを横にしたとき: どうぐを みぎに たてに */
@media (orientation: landscape) and (max-height: 600px) {
  #app { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); column-gap: 10px; }
  .top { grid-column: 1 / -1; }
  .logo img { width: 32px; height: 32px; }
  .snd, .map { height: 48px; }
  .tray { grid-column: 2; grid-row: 2; width: auto; grid-template-columns: repeat(2, 64px); align-content: center; gap: 5px; }
  .tbtn { min-height: 48px; height: min(calc((100svh - 15vh - 96px) / 4), 66px); }
  .ti { width: 32px; height: 32px; }
  .tn { font-size: 11px; }
}

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