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

body {
  background: #1a1a2e;
  font-family: 'Hiragino Maru Gothic ProN', 'BIZ UDPGothic', sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

/* ===== 画面管理 ===== */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
}
.screen.active {
  display: flex;
}

/* ===== タイトル ===== */
#screen-title {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}
.title-box {
  text-align: center;
  animation: fadeInUp 0.6s ease;
}
.title-box h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  color: #fff;
  text-shadow: 0 0 20px rgba(255,220,0,0.8);
  margin-bottom: 16px;
}
.subtitle {
  font-size: clamp(1rem, 3vw, 1.4rem);
  color: #aad4f5;
  margin-bottom: 40px;
  line-height: 1.7;
}

/* ===== ボタン ===== */
.btn-big {
  padding: 18px 60px;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  border-radius: 50px;
  border: none;
  background: linear-gradient(135deg, #f7971e, #ffd200);
  color: #333;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255,200,0,0.5);
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn-big:active {
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(255,200,0,0.4);
}
.btn-small {
  margin-top: 16px;
  padding: 12px 32px;
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  border-radius: 50px;
  border: 2px solid #aad4f5;
  background: transparent;
  color: #aad4f5;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-small:hover {
  background: rgba(170,212,245,0.15);
}

/* ===== ゲーム画面 ===== */
#screen-game {
  flex-direction: column;
  background: #000;
}

/* HUD */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  gap: 12px;
}
#mission-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.1);
  border-radius: 40px;
  padding: 6px 16px 6px 6px;
}
#mission-img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 2px solid #ffd200;
  flex-shrink: 0;
}
#mission-text {
  font-size: clamp(0.85rem, 2.5vw, 1.1rem);
  color: #fff;
  font-weight: bold;
  white-space: nowrap;
}
#count-box {
  display: flex;
  align-items: baseline;
  gap: 2px;
  background: rgba(255,255,255,0.1);
  border-radius: 40px;
  padding: 8px 18px;
  flex-shrink: 0;
}
#found-count {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: bold;
  color: #ffd200;
  transition: transform 0.2s;
}
#found-count.bump {
  transform: scale(1.4);
}
#total-count {
  font-size: clamp(1rem, 3vw, 1.4rem);
  color: #aaa;
}
.count-label {
  font-size: clamp(0.7rem, 2vw, 0.9rem);
  color: #ccc;
  margin-left: 4px;
}

/* ===== タイマー ===== */
#timer-box {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 40px;
  padding: 8px 16px;
  flex-shrink: 0;
}
.timer-icon {
  font-size: clamp(1rem, 3vw, 1.4rem);
}
#time-left {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: bold;
  color: #fff;
  min-width: 1.6em;
  text-align: center;
}
#timer-box.danger {
  animation: dangerPulse 0.5s infinite;
}
#timer-box.danger #time-left {
  color: #ff5252;
}
@keyframes dangerPulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.12); }
}

/* タイマーバー */
#timer-bar {
  position: fixed;
  top: 76px;
  left: 0;
  right: 0;
  height: 8px;
  background: rgba(0,0,0,0.4);
  z-index: 90;
}
#timer-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg,#4ade80,#22c55e);
  transition: width 1s linear, background 0.4s;
  border-radius: 0 4px 4px 0;
}

/* ===== ステージエリア ===== */
#stage-area {
  position: fixed;
  inset: 0;
  top: 84px; /* HUD + タイマーバー分 */
}
#bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
#chara-layer {
  position: absolute;
  inset: 0;
}

/* ===== キャラ ===== */
.chara {
  position: absolute;
  cursor: pointer;
  transition: filter 0.15s;
  touch-action: manipulation;
  /* デフォルトは少し暗め＋ぼかし気味にして難易度UP */
  filter: brightness(0.88) drop-shadow(0 2px 4px rgba(0,0,0,0.5));
  transform-origin: center center;
}
.chara:hover {
  filter: brightness(1) drop-shadow(0 2px 8px rgba(255,255,100,0.6));
}
.chara.found {
  pointer-events: none;
  animation: foundPop 0.5s forwards;
}
.chara.wrong {
  animation: wrongShake 0.4s forwards;
}
.chara.reveal {
  animation: revealPulse 0.6s infinite;
  z-index: 50;
}
@keyframes revealPulse {
  0%,100% { filter: brightness(1.4) drop-shadow(0 0 14px #ff5252); transform: var(--base-transform) scale(1.1); }
  50%     { filter: brightness(1.8) drop-shadow(0 0 22px #ff5252); transform: var(--base-transform) scale(1.25); }
}

/* ===== アニメーション ===== */
@keyframes foundPop {
  0%   { transform: var(--base-transform) scale(1); filter: brightness(1.5) drop-shadow(0 0 12px gold); }
  40%  { transform: var(--base-transform) scale(1.3); }
  70%  { transform: var(--base-transform) scale(0.9); opacity: 0.6; }
  100% { transform: var(--base-transform) scale(0); opacity: 0; }
}
@keyframes wrongShake {
  0%,100% { transform: var(--base-transform) translateX(0); }
  20%  { transform: var(--base-transform) translateX(-8px); }
  40%  { transform: var(--base-transform) translateX(8px); }
  60%  { transform: var(--base-transform) translateX(-6px); }
  80%  { transform: var(--base-transform) translateX(6px); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ミスフラッシュ */
#miss-flash {
  position: fixed;
  inset: 0;
  background: rgba(255,0,0,0.25);
  pointer-events: none;
  opacity: 0;
  z-index: 200;
}
#miss-flash.flash {
  animation: missFlash 0.3s forwards;
}
@keyframes missFlash {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* 残り5秒の画面全体点滅 */
#danger-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
  box-shadow: inset 0 0 120px 40px rgba(255,0,0,0.7);
  background: rgba(255,0,0,0.12);
  opacity: 0;
}
#danger-overlay.active {
  animation: dangerBlink 0.6s infinite;
}
@keyframes dangerBlink {
  0%,100% { opacity: 0; }
  50%     { opacity: 1; }
}

/* ===== クリア画面 ===== */
#screen-clear {
  background: radial-gradient(circle at 50% 40%, #1e3c72, #0f1b2d);
  flex-direction: column;
  gap: 0;
}
.clear-box {
  text-align: center;
  animation: fadeInUp 0.5s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 24px;
}
#clear-stars {
  font-size: clamp(2rem, 6vw, 3rem);
  letter-spacing: 4px;
}
#clear-title {
  font-size: clamp(1.8rem, 5vw, 3rem);
  color: #ffd200;
  text-shadow: 0 0 16px rgba(255,220,0,0.7);
}
#clear-msg {
  font-size: clamp(1rem, 3vw, 1.3rem);
  color: #cce4ff;
  line-height: 1.6;
}
