/* ============================================================
   モグラパニック DELUXE - style.css
   ============================================================ */

:root {
  --bg-deep: #150827;
  --bg-mid: #2a1050;
  --accent-pink: #ff3d9a;
  --accent-purple: #8b5cf6;
  --accent-cyan: #35e8e0;
  --accent-gold: #ffd23f;
  --accent-red: #ff4757;
  --text-main: #f5f0ff;
  --text-dim: #b6a8d9;
  --panel-bg: rgba(30, 14, 58, 0.72);
  --panel-border: rgba(255, 255, 255, 0.12);
  --hole-color: #1a0e10;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', 'Segoe UI', sans-serif;
  user-select: none;
  touch-action: manipulation;
}

button { font-family: inherit; }

#bg-fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 20% 15%, rgba(255,61,154,0.25), transparent 45%),
    radial-gradient(circle at 85% 20%, rgba(53,232,224,0.18), transparent 40%),
    radial-gradient(circle at 50% 90%, rgba(139,92,246,0.28), transparent 50%),
    linear-gradient(160deg, var(--bg-deep), var(--bg-mid) 60%, var(--bg-deep));
  background-size: 200% 200%;
  animation: bgDrift 18s ease-in-out infinite alternate;
}
@keyframes bgDrift {
  0% { background-position: 0% 0%; }
  100% { background-position: 100% 100%; }
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: max(14px, env(safe-area-inset-top)) 16px calc(20px + var(--safe-bottom));
}
.screen.active { display: flex; }

/* ---------- タイトル画面 ---------- */
.title-wrap {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto;
  gap: 14px;
  padding-top: 4px;
}

.game-logo {
  margin: 6px 0 0;
  text-align: center;
  line-height: 1.05;
}
.logo-line1 {
  display: block;
  font-size: clamp(26px, 7vw, 34px);
  font-weight: 700;
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, var(--accent-pink), var(--accent-gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 10px rgba(255,61,154,0.35));
}
.logo-line2 {
  display: block;
  font-size: clamp(38px, 12vw, 58px);
  font-weight: 900;
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 14px rgba(139,92,246,0.45));
}
.tagline {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 0.05em;
}

.rank-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,210,63,0.18), rgba(255,61,154,0.18));
  border: 1px solid rgba(255,210,63,0.4);
  box-shadow: 0 0 18px rgba(255,210,63,0.15);
  font-size: 13px;
  font-weight: 700;
}
.rank-icon { font-size: 16px; }
.rank-name { color: var(--accent-gold); }

.best-score-row {
  display: flex;
  gap: 10px;
  width: 100%;
}
.stat-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 8px;
  border-radius: 14px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(6px);
}
.chip-label { font-size: 11px; color: var(--text-dim); letter-spacing: 0.04em; }
.chip-value { font-size: 22px; font-weight: 900; color: var(--accent-cyan); }

.level-select { width: 100%; }
.section-label {
  margin: 4px 0 8px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  letter-spacing: 0.08em;
}
.level-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.level-step-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1.5px solid var(--panel-border);
  background: rgba(255,255,255,0.06);
  color: var(--text-main);
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.level-step-btn:active { transform: scale(0.9); }
.level-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 130px;
}
.level-num {
  font-size: 26px;
  font-weight: 900;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.level-tier {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--accent-gold);
}
.level-slider {
  width: 100%;
  margin: 12px 0 6px;
  accent-color: var(--accent-pink);
  height: 6px;
  cursor: pointer;
}
.level-meta {
  margin: 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
}

.btn-primary {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(90deg, var(--accent-pink), var(--accent-purple));
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(255,61,154,0.4), inset 0 1px 0 rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease;
}
.btn-primary:active { transform: scale(0.97); }
.btn-icon { font-size: 15px; }

.title-menu-row {
  display: flex;
  gap: 8px;
  width: 100%;
}
.btn-secondary {
  flex: 1;
  padding: 10px 6px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
  transition: transform 0.12s ease;
}
.btn-secondary:active { transform: scale(0.95); }
.badge-count {
  font-size: 10px;
  background: rgba(53,232,224,0.2);
  color: var(--accent-cyan);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 2px;
}

.footer-note {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.7;
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent-cyan);
  text-decoration: underline;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
}

/* ---------- ゲーム画面 ---------- */
#screen-game { justify-content: flex-start; padding-top: max(10px, env(safe-area-inset-top)); }

.hud {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.hud-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 76px;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
}
.hud-label { font-size: 10px; color: var(--text-dim); letter-spacing: 0.08em; }
.hud-value { font-size: 22px; font-weight: 900; color: var(--text-main); }
#hud-score { color: var(--accent-gold); }
#hud-combo { color: var(--accent-cyan); }

.timer-wrap { position: relative; width: 64px; height: 64px; }
.timer-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring-bg, .timer-ring-fg {
  fill: none;
  stroke-width: 8;
}
.timer-ring-bg { stroke: rgba(255,255,255,0.12); }
.timer-ring-fg {
  stroke: var(--accent-pink);
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s linear, stroke 0.3s ease;
}
.timer-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
}

.game-sub-row {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 2px;
  min-height: 20px;
}
.level-tag {
  font-size: 11.5px;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(139,92,246,0.2);
  border: 1px solid rgba(139,92,246,0.4);
  color: var(--accent-purple);
}
.combo-multiplier {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-gold);
  opacity: 0;
  transform: scale(0.7);
  transition: all 0.2s ease;
  text-shadow: 0 0 10px rgba(255,210,63,0.6);
}
.combo-multiplier.show { opacity: 1; transform: scale(1); }

.board {
  --cols: 3;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 10px;
  width: 100%;
  max-width: 560px;
  flex: 1;
  align-content: center;
  padding: 8px 0;
}

.hole {
  position: relative;
  aspect-ratio: 1 / 0.82;
  border-radius: 50% / 40%;
  background: radial-gradient(ellipse at 50% 35%, #3b1f1a 0%, var(--hole-color) 70%);
  box-shadow:
    inset 0 8px 14px rgba(0,0,0,0.7),
    inset 0 -3px 6px rgba(255,255,255,0.04),
    0 6px 10px rgba(0,0,0,0.4);
  overflow: visible;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.hole::before {
  content: '';
  position: absolute;
  bottom: -6%;
  left: 6%;
  right: 6%;
  height: 22%;
  background: radial-gradient(ellipse, #4a2e1a, transparent 75%);
  border-radius: 50%;
  z-index: 0;
}

.mole-pop {
  position: absolute;
  bottom: 0;
  width: 74%;
  aspect-ratio: 1/1;
  font-size: min(11vw, 46px);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(100%);
  transition: transform 0.16s cubic-bezier(.34,1.56,.64,1);
  z-index: 1;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}
.hole.up .mole-pop { transform: translateY(6%); }
.hole.hit .mole-pop { animation: hitPop 0.28s ease forwards; }
@keyframes hitPop {
  0% { transform: translateY(6%) scale(1); }
  40% { transform: translateY(-18%) scale(1.25) rotate(-8deg); }
  100% { transform: translateY(120%) scale(0.6) rotate(10deg); opacity: 0; }
}

.mole-pop.type-gold { filter: drop-shadow(0 0 10px rgba(255,210,63,0.9)); animation: goldPulse 0.5s ease-in-out infinite alternate; }
@keyframes goldPulse { from { filter: drop-shadow(0 0 6px rgba(255,210,63,0.6)); } to { filter: drop-shadow(0 0 16px rgba(255,210,63,1)); } }

.mole-pop.type-bomb { filter: drop-shadow(0 0 8px rgba(255,71,87,0.7)); }

.hole.bomb-hit { animation: shake 0.35s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px) rotate(-2deg); }
  40% { transform: translateX(6px) rotate(2deg); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.floater {
  position: absolute;
  left: 50%;
  top: -6px;
  transform: translateX(-50%);
  font-weight: 900;
  font-size: 18px;
  pointer-events: none;
  animation: floatUp 0.7s ease-out forwards;
  z-index: 5;
  white-space: nowrap;
}
.floater.plus { color: var(--accent-gold); text-shadow: 0 0 8px rgba(255,210,63,0.8); }
.floater.minus { color: var(--accent-red); text-shadow: 0 0 8px rgba(255,71,87,0.8); }
@keyframes floatUp {
  0% { opacity: 1; transform: translate(-50%, 0) scale(0.8); }
  30% { transform: translate(-50%, -18px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

.particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 4;
  animation: particleBurst 0.5s ease-out forwards;
}
@keyframes particleBurst {
  0% { opacity: 1; transform: translate(0,0) scale(1); }
  100% { opacity: 0; transform: translate(var(--px), var(--py)) scale(0.2); }
}

.lives-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 6px;
  font-size: 18px;
  min-height: 22px;
}
.life-lost { opacity: 0.25; filter: grayscale(1); }

#screen-game.flash-red::after {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(255,71,87,0.25);
  z-index: 3;
  pointer-events: none;
  animation: flashOut 0.35s ease forwards;
}
@keyframes flashOut { from { opacity: 1; } to { opacity: 0; } }

/* ---------- リザルト画面 ---------- */
.result-wrap {
  width: 100%;
  max-width: 460px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.result-title { margin: 0; font-size: 22px; font-weight: 900; color: var(--accent-pink); }
.result-score-big {
  font-size: 54px;
  font-weight: 900;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1;
}
.result-newbest {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-gold);
  opacity: 0;
  height: 16px;
}
.result-newbest.show { opacity: 1; animation: pulseText 1s ease-in-out infinite; }
@keyframes pulseText { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

.result-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
.result-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border-radius: 12px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
}
.result-stat span { font-size: 11px; color: var(--text-dim); }
.result-stat b { font-size: 18px; color: var(--accent-cyan); }

.result-new-achievements {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mini-ach {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(255,210,63,0.15), rgba(255,61,154,0.1));
  border: 1px solid rgba(255,210,63,0.35);
  font-size: 12.5px;
  text-align: left;
}
.mini-ach .m-icon { font-size: 20px; }
.mini-ach b { color: var(--accent-gold); }

.result-buttons { display: flex; gap: 10px; width: 100%; margin-top: 6px; }
.result-buttons .btn-primary, .result-buttons .btn-secondary { flex: 1; width: auto; }

/* ---------- モーダル ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8,3,18,0.72);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
}
.modal-box {
  width: 100%;
  max-width: 520px;
  max-height: 82vh;
  background: linear-gradient(180deg, #241040, #180a2c);
  border: 1px solid var(--panel-border);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  animation: modalUp 0.22s ease;
  padding-bottom: var(--safe-bottom);
}
@media (min-width: 640px) {
  .modal-box { border-radius: 20px; max-height: 78vh; }
}
@keyframes modalUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--panel-border);
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.08);
  color: var(--text-main);
  font-size: 14px;
  cursor: pointer;
}
.modal-body { padding: 14px 18px 20px; overflow-y: auto; }

.ach-summary {
  text-align: center;
  font-weight: 800;
  color: var(--accent-gold);
  margin-bottom: 10px;
  font-size: 14px;
}
.ach-list { display: flex; flex-direction: column; gap: 8px; }
.ach-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 2px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--panel-border);
  font-size: 13px;
  font-weight: 900;
  color: var(--accent-cyan);
}
.ach-cat-header:first-child { margin-top: 0; }
.ach-cat-header .cat-count { font-size: 11px; color: var(--text-dim); font-weight: 700; }
.ach-lv-subheader {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-dim);
  margin: 8px 0 -2px 2px;
}
.ach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  opacity: 0.5;
}
.ach-item.unlocked {
  opacity: 1;
  background: linear-gradient(90deg, rgba(255,210,63,0.12), rgba(255,61,154,0.08));
  border-color: rgba(255,210,63,0.3);
}
.ach-icon { font-size: 26px; width: 34px; text-align: center; flex-shrink: 0; }
.ach-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ach-info .a-name { font-weight: 800; font-size: 13.5px; }
.ach-info .a-desc { font-size: 11.5px; color: var(--text-dim); }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats-grid .s-item {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  display: flex; flex-direction: column; gap: 2px;
}
.stats-grid .s-item span { font-size: 11px; color: var(--text-dim); }
.stats-grid .s-item b { font-size: 19px; color: var(--accent-cyan); }

.howto-body p { font-size: 13.5px; line-height: 1.7; margin: 0 0 10px; }
.howto-icon { display: inline-block; width: 30px; }

#changelog-body .cl-entry { margin-bottom: 14px; }
#changelog-body .cl-ver { font-weight: 900; color: var(--accent-cyan); font-size: 13.5px; }
#changelog-body .cl-date { font-size: 11px; color: var(--text-dim); margin-left: 6px; }
#changelog-body ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; line-height: 1.6; color: var(--text-main); }

/* ---------- 実績トースト ---------- */
.achievement-toast {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 14px;
  background: linear-gradient(90deg, #2a1250, #3a1650);
  border: 1px solid var(--accent-gold);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 20px rgba(255,210,63,0.35);
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1);
  max-width: 90vw;
}
.achievement-toast.show { transform: translateX(-50%) translateY(0); }
.toast-icon { font-size: 26px; }
.toast-text { display: flex; flex-direction: column; }
.toast-label { font-size: 10px; color: var(--accent-gold); letter-spacing: 0.05em; }
.toast-name { font-size: 13.5px; font-weight: 800; }

/* ---------- レスポンシブ調整 ---------- */
@media (min-width: 480px) {
  .board { --cols: 3; }
}
@media (min-width: 760px) {
  .board { --cols: 4; gap: 14px; }
  .title-wrap, .result-wrap { max-width: 520px; }
}
@media (max-height: 620px) {
  .game-logo { transform: scale(0.85); margin-top: -4px; }
  .best-score-row, .rank-badge { transform: scale(0.9); }
}
