/* かずのもり — 共通スタイル（トークン・部品・演出） */

:root {
  --bg: #FBF4E4;
  --ink: #4A3B2E;
  --ink-soft: #7A6A58;
  --panel: #FFFDF6;
  --wood: #C89B6B;
  --wood-dark: #A87B4F;
  --leaf: #8FCB8F;
  --leaf-dark: #7BA05B;
  --coral: #F2788F;
  --shadow: 0 6px 0 rgba(74, 59, 46, 0.12);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button {
  font-family: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

#app { position: fixed; inset: 0; overflow: hidden; }

.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }
.hidden { display: none !important; }

.draggable { touch-action: none; cursor: grab; }
.dragging { z-index: 60; cursor: grabbing; }

/* ============ コロン（数のつぶ） ============ */
.koron { width: 100%; height: 100%; display: block; transition: transform 0.18s ease, opacity 0.35s ease; }
.koron-svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 3px 2px rgba(74, 59, 46, 0.18)); }
.km-eye {
  animation: km-blink 4.2s infinite;
  transform-origin: center;
  transform-box: fill-box;
}
@keyframes km-blink {
  0%, 93%, 100% { transform: scaleY(1); }
  95%, 97% { transform: scaleY(0.12); }
}

.emoji-dot {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  font-size: calc(var(--cell, 54px) * 0.78);
  line-height: 1;
  transition: transform 0.18s ease, opacity 0.35s ease;
}

.lit { transform: scale(1.18); }
.counting { transform: scale(1.22); filter: drop-shadow(0 0 8px #FFD54F); }
.taken { opacity: 0 !important; transform: translateY(-70px) scale(0.4) rotate(24deg) !important; }

/* ============ トレイ（5のまとまり） ============ */
.tray {
  position: relative;
  display: inline-block;
  background: #FFF9EC;
  border: 3px solid #E8D3A8;
  border-radius: 20px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.tray-grid {
  display: grid;
  gap: 8px;
  justify-content: center;
}
.tray-cell { width: var(--cell, 54px); height: var(--cell, 54px); position: relative; }
.tray-small { --cell: 40px; padding: 10px; }

.tray-slots .tray-cell {
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell, 54px) * 0.74);
  line-height: 1;
  transition: transform 0.18s ease;
}
.tray-cell.lit { transform: scale(1.18); }
.slot-empty {
  border: 3px dashed #D9C193;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}

.num-badge {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--c, #B98A5E);
  color: #fff;
  font-weight: 800;
  font-size: 25px;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid #FFFDF6;
  box-shadow: 0 3px 0 rgba(74, 59, 46, 0.15);
  z-index: 3;
}

/* ============ ボタン ============ */
.btn-primary {
  min-height: 70px;
  padding: 12px 36px;
  border-radius: 999px;
  background: #7DC87E;
  color: #fff;
  font-size: 25px;
  font-weight: 800;
  box-shadow: 0 6px 0 rgba(74, 59, 46, 0.25);
  transition: transform 0.08s;
}
.btn-primary:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(74, 59, 46, 0.25); }

.btn-secondary {
  min-height: 60px;
  padding: 10px 28px;
  border-radius: 999px;
  background: #EAE0CC;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 5px 0 rgba(74, 59, 46, 0.16);
  transition: transform 0.08s;
}
.btn-secondary:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(74, 59, 46, 0.16); }

.btn-corner {
  width: 64px; height: 64px;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 30px;
  transition: transform 0.08s;
}
.btn-corner:active { transform: scale(0.92); }

/* 数字の回答ボタン（3択） */
.choice-row {
  display: flex;
  gap: clamp(16px, 3vw, 32px);
  justify-content: center;
  padding: 8px 0 20px;
}
.btn-choice {
  width: clamp(88px, 10vw, 108px);
  height: clamp(88px, 10vw, 108px);
  border-radius: 50%;
  background: var(--c, #B98A5E);
  color: #fff;
  font-size: clamp(38px, 5vw, 48px);
  font-weight: 800;
  box-shadow: 0 7px 0 rgba(74, 59, 46, 0.28);
  transition: transform 0.08s;
}
.btn-choice:active { transform: translateY(5px); box-shadow: 0 2px 0 rgba(74, 59, 46, 0.28); }
.btn-choice.wrong { opacity: 0.35; filter: grayscale(0.6); animation: shake 0.4s; }
.btn-choice.right { animation: pulse 0.5s; }
.choice-row.locked .btn-choice { pointer-events: none; }

/* 数字カード（しき用） */
.num-card {
  width: clamp(88px, 10vw, 112px);
  height: clamp(106px, 12vw, 132px);
  border-radius: 24px;
  background: #fff;
  border: 5px solid var(--c, #C89B6B);
  color: var(--c, #C89B6B);
  font-size: clamp(52px, 6.5vw, 66px);
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  position: relative;
  transition: transform 0.08s;
}
.num-card:active { transform: scale(0.95); }
.num-card.wrong { opacity: 0.35; animation: shake 0.4s; }
.num-card.bursting { animation: burst-pop 0.45s ease; }
.num-card.burst-done {
  width: auto; height: auto;
  padding: 8px;
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}
.q-card { background: #F5ECD8; border-style: dashed; border-color: #CDB58A; color: #B49A72; }
.q-card.answered {
  background: #fff;
  border-style: solid;
  border-color: var(--c);
  color: var(--c);
  animation: pulse 0.5s;
}
.eq-op { font-size: clamp(44px, 6vw, 64px); font-weight: 800; color: var(--ink-soft); }
.num-inline { color: var(--c, var(--wood-dark)); font-size: 1.25em; padding: 0 3px; }

/* ============ 出題バー ============ */
.prompt-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px 6px;
}
.prompt-tet { font-size: clamp(44px, 6vw, 60px); line-height: 1; }
.prompt-bubble {
  background: var(--panel);
  border-radius: 22px;
  padding: 12px 26px;
  font-size: clamp(21px, 3vw, 30px);
  font-weight: 800;
  box-shadow: var(--shadow);
  line-height: 1.4;
}
.prompt-bubble.speakable { cursor: pointer; }
.prompt-bubble.speakable::after { content: '🔊'; font-size: 0.72em; margin-left: 12px; opacity: 0.5; }

/* ============ ほめ・おしい・紙吹雪 ============ */
.pop-feedback {
  position: fixed;
  left: 50%; top: 40%;
  transform: translate(-50%, -50%);
  z-index: 400;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  animation: pop-in 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
  pointer-events: none;
}
.pop-emoji { font-size: 70px; }
.pop-word {
  font-size: clamp(34px, 5vw, 46px);
  font-weight: 800;
  color: #fff;
  background: var(--coral);
  padding: 10px 36px;
  border-radius: 999px;
  box-shadow: 0 6px 0 rgba(74, 59, 46, 0.2);
  white-space: nowrap;
}
.pop-oshii .pop-word { background: var(--leaf); }

.confetti {
  position: fixed;
  width: 13px; height: 13px;
  border-radius: 4px;
  z-index: 390;
  pointer-events: none;
  animation: confetti-fly 1.15s ease-out forwards;
}
@keyframes confetti-fly {
  to { transform: translate(var(--fx, 0), var(--fy, 120px)) rotate(320deg); opacity: 0; }
}

.acorn-fall {
  position: fixed;
  top: -60px;
  z-index: 390;
  pointer-events: none;
  animation: acorn-fall 2.9s ease-in forwards;
}
@keyframes acorn-fall {
  to { transform: translateY(115vh) rotate(260deg); }
}

/* ============ オーバーレイ ============ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(74, 59, 46, 0.45);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

/* ============ 共通アニメーション ============ */
@keyframes pop-in {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-26px); }
  70% { transform: translateY(-8px); }
}
.bounce { animation: bounce 0.6s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-5px); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-9deg); }
  60% { transform: rotate(9deg); }
}
.wiggle { animation: wiggle 0.5s; }
@keyframes burst-pop {
  40% { transform: scale(1.28); }
  100% { transform: scale(1); }
}
