/* ぴょこっと もぐら — 見た目。ライト=はれの はらっぱ・ダーク=よるの はらっぱ。外部フォントは使わない */
:root {
  --bg: #eaf7d8;
  --grass1: #dff5bd;
  --grass2: #b6e38e;
  --soil: #c99a67;
  --soil2: #a97a4c;
  --pit: #3a2a20;
  --ink: #2b2433;
  --sub: #5b6a52;
  --card: #ffffff;
  --card-sh: #b9d49a;
  --gold: #ffc53d;
  --focus: #2f7cf6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b261b;
    --grass1: #2f4a33;
    --grass2: #243b28;
    --soil: #7a5a3c;
    --soil2: #5d4329;
    --pit: #150e0a;
    --ink: #f1f5ec;
    --sub: #b4c6a9;
    --card: #2f3f2f;
    --card-sh: #0f170f;
    --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); 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: 560px) { .logo { display: none; } }
.sizes { display: flex; gap: 6px; }
.sbtn { width: 56px; height: 56px; padding: 6px; border-radius: 14px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh); }
.sbtn svg { fill: var(--ink); }
.sbtn[aria-pressed="true"] { box-shadow: 0 4px 0 var(--card-sh), 0 0 0 4px var(--gold); }
.count {
  position: relative; display: flex; align-items: center; gap: 4px; height: 56px; padding: 0 12px 0 8px; overflow: hidden;
  border-radius: 16px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh); font-weight: 900; font-size: 24px; line-height: 1;
}
.count .ci { width: 32px; height: 32px; flex-shrink: 0; }
.count .of { font-size: 14px; color: var(--sub); }
.count .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: var(--gold); transform: scaleX(0); transform-origin: 0 50%; transition: transform .25s ease-out; }
.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; }
.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; }
.sbtn:active, .snd:active { transform: translateY(3px); }

/* ---- はらっぱ ---- */
.stage {
  position: relative; min-height: 0; border: 3px solid var(--ink); border-radius: 22px; overflow: hidden;
  background: radial-gradient(circle at 18% 22%, rgba(255, 255, 255, .22) 0 6px, transparent 7px), radial-gradient(circle at 82% 70%, rgba(255, 255, 255, .18) 0 5px, transparent 6px), linear-gradient(var(--grass1), var(--grass2));
}
.board {
  position: absolute; inset: 0; padding: 8px; display: grid; gap: 2px; touch-action: none;
  grid-template-columns: repeat(var(--c), minmax(0, 1fr)); grid-template-rows: repeat(var(--r), minmax(0, 1fr));
}
.board.n4 { --c: 2; --r: 2; }
.board.n6 { --c: 3; --r: 2; }
.board.n9 { --c: 3; --r: 3; }
@media (orientation: portrait) { .board.n6 { --c: 2; --r: 3; } }

.hole { position: relative; container-type: size; width: 100%; height: 100%; min-width: 48px; min-height: 48px; border-radius: 18px; touch-action: none; }
.hole[data-up="1"] { z-index: 2; }
.well { position: absolute; left: 50%; top: 50%; width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); transform: translate(-50%, -50%); }
.well > svg, .clip, .fx { position: absolute; inset: 0; pointer-events: none; }
.soil { fill: var(--soil2); stroke: var(--ink); stroke-width: 2.4; }
.ring .soil2 { fill: var(--soil); }
.lip .soil2 { fill: var(--soil); stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; }
.pit { fill: var(--pit); }
.clip { height: 86%; bottom: auto; overflow: hidden; }
.crit {
  position: absolute; left: 12%; bottom: 0; width: 76%; aspect-ratio: 1; pointer-events: none;
  transform: translateY(105%); transition: transform .28s cubic-bezier(.3, 1.5, .6, 1);
}
.hole[data-up="1"] .crit { transform: translateY(-2%); }
.hole[data-st="down"] .crit { transition-duration: .3s; transition-timing-function: ease-in; }
.cb { position: absolute; inset: 0; transform-origin: 50% 100%; }

.hole[data-face="shy"] .cb { animation: shy .5s ease-in-out infinite; }
.hole[data-face="joy"] .cb { animation: hop .55s ease-in-out infinite var(--d, 0ms); }
.hole[data-face="sleep"] .cb { animation: snooze 2.4s ease-in-out infinite; }
.hole[data-face="yawn"] .cb { animation: stretch .75s ease-in-out 1 both; }
@keyframes shy { 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes hop { 50% { transform: translateY(-9%) rotate(-3deg); } }
@keyframes snooze { 50% { transform: scale(1.03, .97); } }
@keyframes stretch { 50% { transform: scale(.96, 1.1); } }
.zz { animation: zz 1.6s ease-in-out infinite; }
@keyframes zz { 0%, 100% { transform: translateY(0); opacity: .45; } 50% { transform: translateY(-5px); opacity: 1; } }
.tw { transform-box: fill-box; transform-origin: center; animation: tw 1.1s ease-in-out infinite alternate; }
@keyframes tw { from { transform: scale(.6) rotate(0); opacity: .6; } to { transform: scale(1.1) rotate(20deg); opacity: 1; } }
.acc { transform-box: fill-box; transform-origin: 50% 100%; animation: accpop .35s cubic-bezier(.3, 1.6, .6, 1) both; }
@keyframes accpop { from { transform: translateY(-30%) scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }

.say {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%); z-index: 3; white-space: nowrap;
  padding: .2em .6em; border-radius: 999px; background: #fff; color: #2b2433; border: 2.5px solid #2b2433;
  font-size: clamp(11px, min(13cqw, 13cqh), 22px); font-weight: 900; pointer-events: none;
}

/* きらきら・ハート(へやの かずは すくなく。ぜんぶで 60こ まで) */
.fx { overflow: visible; }
.fx i { position: absolute; left: 44%; top: 34%; width: 12%; height: 12%; animation: fly 1s ease-out both; }
.fx i.star { background: #ffd43b; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.fx i.heart {
  width: 14%; height: 13%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 34 32'%3E%3Cpath d='M13 24C-6 10 2-4 13 6C24-4 32 10 13 24Z' fill='%23ff6b9a' stroke='%23ffffff' stroke-width='3' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
@keyframes fly {
  from { transform: translate(0, 0) scale(.3); opacity: 1; }
  to { transform: translate(calc(var(--dx) * 1cqmin), calc(var(--dy) * 1cqmin)) scale(1.2) rotate(200deg); opacity: 0; }
}

.party {
  position: absolute; left: 50%; top: 8px; transform: translateX(-50%); z-index: 10; margin: 0; padding: 8px 18px; max-width: 94%;
  border-radius: 22px; background: #fff; color: #2b2433; border: 3px solid #2b2433; white-space: nowrap; pointer-events: none;
  font-size: clamp(16px, 5.4vw, 30px); font-weight: 900; animation: partyin .4s cubic-bezier(.3, 1.6, .6, 1) both;
}
.stage.partying .board { padding-top: 54px; } /* ひょうじの ぶん あける */
@keyframes partyin { from { transform: translateX(-50%) scale(.5); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }

/* スマホを 横に したとき */
@media (orientation: landscape) and (max-height: 600px) {
  #app { gap: 6px; }
  .logo img { width: 32px; height: 32px; }
  .sbtn, .snd, .count { height: 48px; }
  .sbtn { width: 48px; padding: 5px; }
  .snd { width: 48px; }
  .count { font-size: 20px; }
  .count .ci { width: 26px; height: 26px; }
  .board { padding: 4px; }
  .party { top: 4px; padding: 4px 14px; font-size: clamp(14px, 4vw, 20px); }
  .stage.partying .board { padding-top: 38px; }
}

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