/* びんの もりっこ — 見た目。外部フォントは使わない(びんの なかは canvas に かく) */
:root {
  --bg: #e9f6ff;
  --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; gap: 8px; }
.logo { display: flex; align-items: center; gap: 8px; margin: 0 auto 0 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: 400px) { .logo span { display: none; } }
.hbtn { flex-shrink: 0; min-width: 52px; height: 56px; border-radius: 16px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh); display: grid; place-items: center; }
.hbtn svg { width: 32px; height: 32px; }
.hbtn:active { transform: translateY(3px); }
.zkb { display: flex; gap: 4px; padding: 0 12px 0 8px; font-weight: 900; font-size: 16px; }
.zkb svg { width: 30px; height: 30px; }
.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-radius: 22px; overflow: hidden; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.clear {
  position: absolute; left: 50%; top: 3%; transform: translateX(-50%); z-index: 3; pointer-events: none; max-width: 92%;
  padding: 10px 22px; border-radius: 22px; background: #fff; color: #2b2433; border: 3px solid #2b2433; text-align: center;
  animation: pop .4s cubic-bezier(.3, 1.6, .6, 1) both;
}
.clear p { margin: 0; font-size: clamp(20px, 5.4vw, 32px); 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; }
@keyframes poke { 50% { translate: -6px -10px; } }

/* ---- せわ ---- */
.tray { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: min(100%, 560px); justify-self: center; }
.cbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 72px; padding: 4px 2px; border-radius: 18px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh);
}
.cbtn:active { transform: translateY(3px); }
.ci { width: 46px; height: 46px; border-radius: 14px; padding: 3px; }
.cn { font-size: clamp(12px, 3.6vw, 16px); font-weight: 900; white-space: nowrap; }
.tray.egg .cbtn { opacity: .55; }

/* ---- ずかん ---- */
.zukan { position: fixed; inset: 0; z-index: 6; background: rgba(20, 24, 36, .55); display: grid; place-items: start center; padding: calc(env(safe-area-inset-top) + 12px) 12px 15vh; }
.zkbox { width: min(100%, 560px); max-height: calc(100svh - 15vh - 24px); overflow: auto; background: var(--bg); border: 3px solid var(--ink); border-radius: 22px; padding: 12px; display: grid; gap: 10px; }
.zkhead { display: flex; align-items: center; gap: 10px; }
.zkhead b { font-size: 22px; }
.zkhead span { margin-right: auto; color: var(--sub); font-weight: 800; }
.zkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.zk { background: var(--card); border-radius: 16px; padding: 4px; display: grid; justify-items: center; text-align: center; font-weight: 800; font-size: 13px; word-break: keep-all; overflow-wrap: anywhere; }
.zk canvas { width: 88px; height: 82px; }
.zk.unknown span { color: var(--sub); font-size: 22px; }
.neweg { min-height: 56px; border-radius: 18px; background: #ffe8cc; color: #2b2433; box-shadow: 0 4px 0 #e8b98a; font-weight: 900; font-size: 18px; }
.neweg.arm { background: #ffc9c9; }

/* スマホを横にしたとき: せわを みぎに 2×2 */
@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; }
  .hbtn { height: 48px; }
  .tray { grid-column: 2; grid-row: 2; width: auto; grid-template-columns: repeat(2, 76px); align-content: center; gap: 6px; }
  .cbtn { min-height: 48px; height: min(calc((100svh - 15vh - 90px) / 2), 92px); }
}

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