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

html, body {
  height: 100%;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: #fff3df;
  overscroll-behavior: none;
}

#app {
  max-width: 440px;
  margin: 0 auto;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #fff8ef;
}

/* ---------- 画面切り替え ---------- */
.screen { display: none; height: 100%; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- タイトル ---------- */
#screen-title { justify-content: center; align-items: center; text-align: center;
  background: linear-gradient(#fff8ef, #ffeed8); }
.title-wrap { padding: 24px; }
.title-logo svg { width: 260px; height: auto; }
#screen-title h1 {
  font-size: 30px; color: #e07038; line-height: 1.35; margin: 8px 0 10px;
  text-shadow: 2px 2px 0 #ffe0c0;
}
.subtitle { color: #a08060; font-size: 14px; margin-bottom: 28px; }
.credit { color: #c0a888; font-size: 12px; margin-top: 22px; }

/* ---------- ボタン ---------- */
.btn {
  display: block; width: 240px; margin: 10px auto 0; padding: 16px;
  font-size: 19px; font-weight: bold; font-family: inherit;
  border: none; border-radius: 999px; cursor: pointer;
}
.btn-primary { background: #ff9f68; color: #fff; box-shadow: 0 4px 0 #e07d45; }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #e07d45; }
.btn-sub { background: #fff; color: #e07038; border: 2px solid #ffc9a0; }
.btn-versus { background: #8fc474; color: #fff; box-shadow: 0 4px 0 #6fa058; }
.btn-versus:active { transform: translateY(3px); box-shadow: 0 1px 0 #6fa058; }

/* ---------- ヘッダーバー ---------- */
.bar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; background: #ffdcb8;
}
.bar h2 { font-size: 17px; color: #7a5a38; flex: 1; }
.btn-back {
  width: 40px; height: 40px; border-radius: 12px; border: none;
  background: #fff; color: #e07038; font-size: 20px; font-weight: bold; cursor: pointer;
  box-shadow: 0 2px 0 #e8c9a8;
}

/* ---------- モード切り替え ---------- */
#mode-toggle {
  display: flex; gap: 8px; padding: 14px 20px 0;
}
.mode-btn {
  flex: 1; padding: 11px 6px; border-radius: 999px; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: bold;
  background: #fff; color: #b09070; border: 2px solid #ffe0c0;
}
.mode-btn.active[data-mode="easy"] { background: #8fc474; color: #fff; border-color: #8fc474; }
.mode-btn.active[data-mode="time"] { background: #ff7a59; color: #fff; border-color: #ff7a59; }
.mode-btn.active[data-mode="adult"] { background: #7a6ae8; color: #fff; border-color: #7a6ae8; }
#mode-note { text-align: center; font-size: 12px; color: #a08060; padding: 8px 20px 0; }

/* ---------- ステージ選択 ---------- */
#stage-list { padding: 14px 20px 20px; overflow-y: auto; }
.stage-card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: #fff; border: 2px solid #ffe0c0; border-radius: 18px;
  padding: 16px 14px; margin-bottom: 12px; cursor: pointer;
  font-family: inherit; font-size: 16px; color: #7a5a38; font-weight: bold;
  box-shadow: 0 3px 0 #f0dcc4;
}
.stage-card .done { font-size: 14px; white-space: nowrap; }
.stage-card:active { transform: translateY(2px); box-shadow: 0 1px 0 #f0dcc4; }
.stage-card .icon { font-size: 28px; }
.stage-card .name { flex: 1; text-align: left; }
.stage-card .done { color: #ffb020; font-size: 20px; }

/* ---------- ゲーム画面 ---------- */
#screen-game { background: #fff; }
.game-bar { justify-content: space-between; }
#game-title { font-size: 13px; font-weight: bold; color: #7a5a38; flex: 1; }
#game-count {
  background: #fff; border-radius: 999px; padding: 6px 12px;
  font-size: 13px; font-weight: bold; color: #e07038; white-space: nowrap;
}
#scene-wrap { flex: 1; overflow: hidden; position: relative; background: #fff; }
#scene { position: relative; height: 100%; }
#scene svg { width: 100%; height: 100%; display: block; }

.game-footer { padding: 10px 16px 16px; background: #ffdcb8; text-align: center; }
#btn-hint {
  padding: 10px 26px; font-size: 16px; font-weight: bold; font-family: inherit;
  border: none; border-radius: 999px; background: #fff; color: #e07038;
  box-shadow: 0 3px 0 #e8c9a8; cursor: pointer;
}
#btn-hint:disabled { opacity: .45; }
#btn-hint.pulse { animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.hint-note { font-size: 11px; color: #a08060; margin-top: 6px; }

/* ---------- 動物の演出 ---------- */
.animal { cursor: pointer; }
.animal .hit { pointer-events: all; }
.abody { transform-box: fill-box; transform-origin: center; }
.animal.found .abody { animation: pop .55s ease; }
@keyframes pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.25) rotate(-4deg); }
  70% { transform: scale(.95) rotate(3deg); }
  100% { transform: scale(1); }
}
.animal.found { filter: drop-shadow(0 0 6px #ffd050); }

/* はじける火花 */
.spark {
  position: absolute; z-index: 25; width: 11px; height: 11px; border-radius: 50%;
  transform: translate(-50%, -50%); pointer-events: none;
  animation: spark .6s ease-out forwards;
}
@keyframes spark {
  to { transform: translate(calc(-50% + var(--sx)), calc(-50% + var(--sy))) scale(.2); opacity: 0; }
}

/* コンボ表示 */
.combo-pop {
  position: absolute; z-index: 35; transform: translate(-50%, -100%);
  font-size: 20px; font-weight: bold; color: #ff5a3c;
  text-shadow: 0 2px 0 #fff, 0 0 8px #ffd050; pointer-events: none;
  animation: combopop .9s ease-out forwards;
}
@keyframes combopop {
  0% { transform: translate(-50%, -80%) scale(.5); opacity: 0; }
  30% { transform: translate(-50%, -120%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -180%) scale(1); opacity: 0; }
}

/* クリア時：動物が吹っ飛ぶ */
.abody.erupt {
  animation: erupt 1s cubic-bezier(.2,.7,.3,1) forwards;
}
@keyframes erupt {
  0% { transform: translate(0,0) rotate(0) scale(1); }
  18% { transform: translate(0,-12px) scale(1.2); }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.35); opacity: 0; }
}

.animal.hintglow { animation: glow .8s ease-in-out 3; }
@keyframes glow {
  50% { filter: drop-shadow(0 0 10px #ffb020) brightness(1.15); }
}

/* みつけたときのふきだし */
.bubble {
  position: absolute; z-index: 30; max-width: 230px;
  background: #fff; border: 2.5px solid #ffb878; border-radius: 16px;
  padding: 10px 14px; font-size: 14px; color: #6a4a30; line-height: 1.5;
  box-shadow: 0 4px 10px rgba(160, 100, 40, .18);
  animation: bubblein .3s ease; pointer-events: none;
}
.bubble b { color: #e07038; display: block; font-size: 13px; }
.bubble::after {
  content: ""; position: absolute; bottom: -9px; left: 26px;
  border: 9px solid transparent; border-top-color: #ffb878; border-bottom: none;
}
@keyframes bubblein { from { opacity: 0; transform: translateY(8px) scale(.9); } }

/* おとなモード：お手つきペナルティ */
.penalty-pop {
  position: absolute; z-index: 35; transform: translate(-50%, -100%);
  font-size: 17px; font-weight: bold; color: #e8433c;
  text-shadow: 0 2px 0 #fff; pointer-events: none;
  animation: penaltyup .9s ease-out forwards;
}
@keyframes penaltyup {
  0% { transform: translate(-50%, -60%); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translate(-50%, -170%); opacity: 0; }
}

/* はずれタップの波紋 */
.ripple {
  position: absolute; z-index: 20; width: 40px; height: 40px;
  border: 3px solid #ffb878; border-radius: 50%;
  transform: translate(-50%, -50%); pointer-events: none;
  animation: rip .5s ease-out forwards;
}
@keyframes rip { to { opacity: 0; transform: translate(-50%, -50%) scale(1.8); } }

/* ---------- クリア画面 ---------- */
.overlay {
  display: none; position: absolute; inset: 0; z-index: 50;
  background: rgba(120, 70, 20, .35);
  justify-content: center; align-items: center;
}
.overlay.active { display: flex; }
.clear-card {
  background: #fff; border-radius: 24px; padding: 26px 24px;
  width: min(88%, 340px); text-align: center;
  animation: cardin .4s ease; max-height: 86%; overflow-y: auto;
}
@keyframes cardin { from { opacity: 0; transform: scale(.85); } }
.clear-stars { font-size: 34px; animation: pulse 1.4s infinite; }
.clear-card h2 { color: #e07038; font-size: 24px; margin: 6px 0 14px; }
#clear-recap { text-align: left; margin-bottom: 14px; }
.time-line {
  background: #fff2ec; border: 2px solid #ffcbb8; border-radius: 12px;
  padding: 10px 12px; font-size: 14px; color: #c94a2c; text-align: center;
  margin-bottom: 10px;
}
.time-line b { font-size: 18px; }
.recap-item {
  background: #fff6ec; border-radius: 12px; padding: 9px 12px;
  font-size: 13px; color: #6a4a30; margin-bottom: 7px; line-height: 1.5;
}
.recap-item b { color: #e07038; }
.clear-card .btn { width: 100%; }

/* ---------- ふたりでかくれんぼ ---------- */
#screen-hide { background: #fff; }
#hide-scene-wrap { flex: 1; overflow: hidden; position: relative; background: #fff; }
#hide-scene { height: 100%; }
#hide-scene svg { width: 100%; height: 100%; display: block; }
#hider-preview { cursor: pointer; filter: drop-shadow(0 0 5px rgba(255, 176, 32, .8)); }

.hide-footer { padding: 10px 14px 14px; background: #ffdcb8; text-align: center; }
.hide-note { font-size: 11px; color: #a08060; margin-bottom: 8px; }
#palette { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-bottom: 8px; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  border: 3px solid #fff; box-shadow: 0 2px 4px rgba(120, 70, 20, .25);
}
.swatch.sel { border-color: #e07038; transform: scale(1.15); }
.size-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 10px; }
.size-btn {
  padding: 7px 14px; border-radius: 999px; border: 2px solid #ffe0c0;
  background: #fff; color: #b09070; font-family: inherit; font-size: 13px;
  font-weight: bold; cursor: pointer;
}
.size-btn.active { background: #ff9f68; color: #fff; border-color: #ff9f68; }
.hide-footer .btn { width: 100%; margin-top: 0; padding: 13px; }

#screen-pass { justify-content: center; align-items: center; text-align: center;
  background: linear-gradient(#fff8ef, #ffeed8); }
.pass-wrap { padding: 24px; width: 100%; }
.pass-emoji { font-size: 56px; margin-bottom: 12px; }
#pass-title { font-size: 21px; color: #e07038; line-height: 1.5; margin-bottom: 8px; }
#pass-sub { color: #a08060; font-size: 14px; margin-bottom: 22px; }
#challenge-note { font-size: 12px; color: #6fa058; margin-top: 14px; word-break: break-all; padding: 0 10px; }

/* 紙ふぶき */
.confetti {
  position: absolute; top: -14px; z-index: 60; width: 10px; height: 14px;
  border-radius: 3px; pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: .6; }
}

/* ---------- どっかーん！の全画面演出（スカッと） ---------- */
.boom-flash {
  position: absolute; inset: 0; z-index: 55; pointer-events: none;
  background: radial-gradient(circle at 50% 46%, #fff 0%, #fff6d8 42%, rgba(255,246,216,0) 74%);
  animation: boomflash .5s ease-out forwards;
}
@keyframes boomflash {
  0% { opacity: 0; }
  12% { opacity: .95; }
  100% { opacity: 0; }
}

.boom-wave {
  position: absolute; left: 50%; top: 46%; z-index: 54; pointer-events: none;
  width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%;
  border: 10px solid #ffd24f;
  animation: boomwave .72s cubic-bezier(.15,.6,.3,1) forwards;
}
@keyframes boomwave {
  0% { transform: scale(.2); opacity: .9; border-width: 12px; }
  100% { transform: scale(11); opacity: 0; border-width: 1px; }
}

#scene-wrap.shake { animation: shake .6s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake {
  10%,90% { transform: translate(-2px, 1px); }
  20%,80% { transform: translate(4px, -2px); }
  30%,50%,70% { transform: translate(-7px, 2px); }
  40%,60% { transform: translate(7px, -1px); }
}

.boom-word {
  position: absolute; left: 50%; top: 40%; z-index: 58; pointer-events: none;
  transform: translate(-50%,-50%); white-space: nowrap;
  font-size: clamp(34px, 13vw, 60px); font-weight: 900; color: #ff5a2c;
  text-shadow: 3px 3px 0 #fff, -3px 3px 0 #fff, 3px -3px 0 #fff, -3px -3px 0 #fff, 0 6px 14px rgba(255,90,44,.4);
  animation: boomword 1.1s cubic-bezier(.2,.8,.3,1) forwards;
}
@keyframes boomword {
  0% { transform: translate(-50%,-50%) scale(.3) rotate(-8deg); opacity: 0; }
  25% { transform: translate(-50%,-50%) scale(1.15) rotate(-3deg); opacity: 1; }
  70% { transform: translate(-50%,-50%) scale(1) rotate(-3deg); opacity: 1; }
  100% { transform: translate(-50%,-58%) scale(1.05) rotate(-3deg); opacity: 0; }
}
