* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: 'Hiragino Maru Gothic ProN', 'Yu Gothic', -apple-system, sans-serif;
  background: linear-gradient(160deg, #fef6f0, #eaf3ff 60%, #f3ecff);
  color: #2b2b2b;
}
#app {
  max-width: 420px; margin: 0 auto; min-height: 100vh;
  display: flex; flex-direction: column;
  background: rgba(255,255,255,0.55);
  box-shadow: 0 0 40px rgba(0,0,0,0.06);
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: rgba(255,255,255,0.75);
  backdrop-filter: blur(6px);
  border-bottom: 2px solid rgba(0,0,0,0.05);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; margin: 0; }
.points {
  font-weight: 700; background: #fff3cf; border: 2px solid #f6c445;
  padding: 4px 12px; border-radius: 20px; font-size: 14px;
}
#screens { flex: 1; padding: 18px; padding-bottom: 90px; }
.screen { display: none; animation: fadeIn .25s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: translateY(0);} }

/* ---- ホーム ---- */
.pet-stage {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #ffffffcc; border-radius: 24px; padding: 24px 12px 16px;
  margin-bottom: 16px; min-height: 220px; position: relative;
  border: 3px solid rgba(0,0,0,0.06);
}
.pet-stage.empty { color: #888; text-align: center; }
.pet-stage .egg { font-size: 64px; animation: bob 2.4s ease-in-out infinite; }
.pet-stage.rarity-legendary { box-shadow: 0 0 26px rgba(246,196,69,.55); }
.pet-stage.rarity-epic { box-shadow: 0 0 18px rgba(181,123,242,.4); }
.pet-stage.rarity-rare { box-shadow: 0 0 14px rgba(91,157,249,.35); }
.pet-stage.stage-max { box-shadow: 0 0 22px rgba(63,184,145,.5); }
.creature-svg { animation: bob 3s ease-in-out infinite; filter: drop-shadow(0 6px 4px rgba(0,0,0,0.12)); transition: width .3s ease, height .3s ease; }
@keyframes bob { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-6px);} }
.pet-name { margin-top: 10px; font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.badge-growth { background: #3fb891; }
.badge-row { display: flex; gap: 4px; }
.growth-hint { text-align: center; font-size: 12px; color: #3fb891; font-weight: 700; margin: -4px 0 14px; }

.stats-panel { background: #ffffffcc; border-radius: 18px; padding: 14px 16px; margin-bottom: 14px; }
.stat-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.stat-label { width: 68px; font-size: 13px; font-weight: 700; color: #555; white-space: nowrap; }
.stat-track { flex: 1; height: 12px; background: #eee; border-radius: 8px; overflow: hidden; }
.stat-fill { height: 100%; border-radius: 8px; transition: width .4s ease; }

.care-buttons { display: flex; gap: 10px; }
.care-btn {
  flex: 1; padding: 14px 6px; border: none; border-radius: 16px;
  background: #fff; box-shadow: 0 3px 0 rgba(0,0,0,0.08);
  font-size: 13px; font-weight: 700; color: #444; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform .1s ease;
}
.care-btn .emoji { font-size: 22px; }
.care-btn:active:not(:disabled) { transform: translateY(2px); }
.care-btn:disabled { opacity: .5; cursor: default; }
.link-btn {
  display: block; margin: 14px auto 0; background: none; border: none;
  color: #7c6fd6; font-weight: 700; font-size: 13px; cursor: pointer;
  text-align: center; text-decoration: none;
}

.save-io { margin-top: 22px; padding-top: 14px; border-top: 1px dashed rgba(0,0,0,0.1); }
.save-io-row { display: flex; gap: 10px; }
.save-io-row .link-btn { flex: 1; margin: 0; }
.save-io-panel { margin-top: 12px; }
.save-io-textarea {
  width: 100%; min-height: 70px; border-radius: 12px; border: 2px solid rgba(0,0,0,0.08);
  padding: 10px; font-size: 12px; font-family: monospace; resize: vertical;
  box-sizing: border-box; margin-bottom: 8px; background: #fff;
}

/* ---- ガチャ ---- */
.gacha-banner { text-align: center; margin-bottom: 12px; }
.gacha-title { font-size: 22px; font-weight: 800; }
.gacha-sub { font-size: 13px; color: #666; margin: 4px 0 10px; }
.rarity-rates { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.rate-chip { font-size: 11px; padding: 3px 8px; border-radius: 12px; border: 2px solid; background: #fff; }
.gacha-stage {
  min-height: 210px; display: flex; align-items: center; justify-content: center;
  background: #ffffffcc; border-radius: 22px; margin: 10px 0; padding: 16px;
}
.gacha-egg { font-size: 60px; animation: shake 1.8s ease-in-out infinite; }
@keyframes shake { 0%,100% { transform: rotate(0);} 25% { transform: rotate(-6deg);} 75% { transform: rotate(6deg);} }
.reveal { display: flex; flex-direction: column; align-items: center; gap: 6px; animation: pop .4s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.3); opacity: 0;} to { transform: scale(1); opacity: 1;} }
.reveal.rarity-legendary .creature-svg { filter: drop-shadow(0 0 14px rgba(246,196,69,.85)); }
.reveal.rarity-epic .creature-svg { filter: drop-shadow(0 0 10px rgba(181,123,242,.7)); }
.reveal-name { font-weight: 800; font-size: 17px; }
.new-tag { color: #e8567c; font-size: 12px; background: #ffe1ea; padding: 2px 8px; border-radius: 10px; margin-left: 4px; }
.reveal-hint { font-size: 12px; color: #888; margin: 2px 0 6px; }
.dup-bonus { font-size: 12px; color: #a97c3f; background: #fff3cf; padding: 3px 10px; border-radius: 10px; }
.pull-btn {
  width: 100%; padding: 16px; border: none; border-radius: 18px;
  background: linear-gradient(135deg, #ff9db5, #f6c445); color: #fff;
  font-size: 16px; font-weight: 800; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,0.1);
}
.pull-btn:disabled { opacity: .45; cursor: default; }
.pull-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.1); }
.pull-hint { text-align: center; font-size: 12px; color: #777; margin-top: 8px; }

/* ---- 図鑑 ---- */
.collection-header {
  font-size: 18px; font-weight: 800; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.collection-header span { font-size: 14px; color: #777; }
.collection-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.card {
  background: #ffffffcc; border-radius: 16px; padding: 10px 6px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 2px solid transparent;
}
.card.active-card { border-color: #f6c445; }
.card.locked { color: #aaa; min-height: 148px; justify-content: center; }
.silhouette {
  width: 72px; height: 72px; border-radius: 50%; background: #dcdcdc;
  display: flex; align-items: center; justify-content: center; font-size: 26px; color: #fff;
}
.card-name { font-size: 12px; font-weight: 700; text-align: center; }
.card .count { color: #e8567c; }
.raise-btn {
  margin-top: 2px; font-size: 10.5px; padding: 4px 8px; border-radius: 10px;
  border: none; background: #efeafc; color: #5b3a99; font-weight: 700; cursor: pointer;
}
.raise-btn:disabled { background: #fff3cf; color: #a97c3f; cursor: default; }

.badge {
  font-size: 10px; font-weight: 800; padding: 1px 8px; border-radius: 10px; color: #fff;
}
.badge-common { background: #9aa5b1; }
.badge-rare { background: #5b9df9; }
.badge-epic { background: #b57bf2; }
.badge-legendary { background: #f6c445; color: #5c4400; }
.badge-secret { background: linear-gradient(135deg, #3a2f54, #eeb64a); color: #fff; }
.secret-header { font-size: 15px; font-weight: 800; margin: 20px 0 12px; color: #6b4fa0; }
.card.rarity-secret { box-shadow: 0 0 18px rgba(238,182,74,.5), inset 0 0 0 1px rgba(0,0,0,.03); }

/* ---- タブバー ---- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 420px; display: flex;
  background: #fff; border-top: 2px solid rgba(0,0,0,0.06);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; border: none; background: none; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 20px; color: #aaa; cursor: pointer;
}
.tab span { font-size: 11px; font-weight: 700; }
.tab.active { color: #e8567c; }

/* ---- ミニゲーム ---- */
.game-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.game-tab-btn {
  flex: 1; padding: 11px 6px; border: none; border-radius: 14px;
  background: #fff; font-weight: 700; font-size: 12.5px; color: #888; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.06);
}
.game-tab-btn.active { background: linear-gradient(135deg, #ff9db5, #f6c445); color: #fff; }

.timing-area { margin: 4px 0 14px; }
.timing-track {
  position: relative; height: 56px; background: #ffffffcc; border-radius: 16px;
  border: 3px solid rgba(0,0,0,0.06); overflow: hidden;
}
.timing-zone {
  position: absolute; top: 6px; bottom: 6px;
  background: rgba(63,184,145,.3); border: 2px solid #3fb891; border-radius: 8px;
}
.timing-marker {
  position: absolute; top: 4px; width: 10px; height: 46px; margin-left: -5px;
  background: #e8567c; border-radius: 5px; box-shadow: 0 2px 4px rgba(0,0,0,.25);
}
.timing-result { text-align: center; min-height: 24px; font-weight: 700; margin: 10px 0 0; font-size: 14px; }
.timing-tier { font-size: 16px; margin-right: 4px; }

/* ---- 完全体バトル ---- */
.battle-locked {
  background: #ffffffcc; border-radius: 20px; padding: 30px 20px; text-align: center;
  color: #888; font-size: 13px; line-height: 1.7;
}
.battle-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.picker-card {
  background: #ffffffcc; border: 2px solid transparent; border-radius: 16px;
  padding: 10px 6px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; font-family: inherit;
}
.picker-card:active { border-color: #f6c445; }
.picker-stats { font-size: 10.5px; color: #888; text-align: center; }
.battle-ready {
  background: #ffffffcc; border-radius: 20px; padding: 20px; margin-bottom: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.battle-hud {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 13px; margin-bottom: 8px; color: #555;
}
.guardian-player-hud { margin-bottom: 0; margin-top: 10px; }
.battle-area {
  position: relative; height: 300px; background: linear-gradient(180deg, #dcefff, #fdfaf0);
  border-radius: 20px; border: 3px solid rgba(0,0,0,0.06); overflow: hidden; touch-action: none;
}
.battle-player {
  position: absolute; bottom: 6px; transform: translateX(-50%); width: 44px; height: 44px;
  pointer-events: none;
}
.bullet {
  position: absolute; width: 6px; height: 14px; margin-left: -3px; border-radius: 3px;
  background: #ff9db5; box-shadow: 0 0 6px rgba(255,157,181,.8); pointer-events: none;
}
.enemy {
  position: absolute; margin-left: -14px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; transform: translateY(0); pointer-events: none; line-height: 1;
}
.enemy-tank { font-size: 24px; }
.enemy-bonus { font-size: 16px; filter: drop-shadow(0 0 6px rgba(246,196,69,.9)); }

/* ---- 図鑑の守護者 ---- */
.guardian-tab { background: linear-gradient(135deg, #3a2f54, #7c5fb0); color: #fff; }
.guardian-boss-label { font-size: 12px; font-weight: 700; color: #6b4fa0; margin-bottom: 4px; }
.guardian-hpbar { height: 14px; background: #eee; border-radius: 8px; overflow: hidden; margin-bottom: 10px; }
.guardian-hpfill { height: 100%; background: linear-gradient(90deg, #eeb64a, #e8567c); transition: width .15s ease; }
.guardian-boss {
  position: absolute; top: 6px; transform: translateX(-50%); font-size: 44px;
  filter: drop-shadow(0 0 10px rgba(58,47,84,.6)); pointer-events: none;
}
.bullet-fusion {
  width: 8px; height: 18px; margin-left: -4px; border-radius: 4px;
  background: linear-gradient(180deg, #fff2b0, #eeb64a, #e8567c);
  box-shadow: 0 0 10px rgba(238,182,74,.9), 0 0 4px rgba(255,255,255,.8);
}

/* ---- 合体演出 ---- */
.fusion-stage {
  position: relative; height: 300px; border-radius: 20px; overflow: hidden;
  background: radial-gradient(circle at 50% 55%, #2c2440, #14101f);
  display: flex; align-items: center; justify-content: center;
}
.fusion-flash {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle, rgba(238,182,74,.95), transparent 60%);
  opacity: 0; animation: fusion-pulse 1.4s ease .9s forwards;
}
@keyframes fusion-pulse { 0% { opacity: 0; } 55% { opacity: 1; } 100% { opacity: 0; } }
.fusion-icons {
  display: flex; flex-wrap: wrap; justify-content: center; align-content: center;
  gap: 5px; max-width: 260px; padding: 20px;
}
.fusion-icon {
  width: 24px; height: 24px; display: flex;
  transition: transform .9s cubic-bezier(.5,0,.4,1), opacity .9s ease;
}
.fusion-icon.converge { transform: scale(0) translateY(24px) rotate(30deg); opacity: 0; }
.fusion-reveal {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  animation: pop .45s cubic-bezier(.2,1.4,.4,1);
}
.fusion-title { font-size: 18px; font-weight: 800; color: #f6c445; }
.fusion-name { font-size: 14px; color: #fff; }

.game-area {
  position: relative; height: 260px; overflow: hidden;
  background: #ffffffcc; border-radius: 20px; margin: 10px 0 16px;
  border: 3px solid rgba(0,0,0,0.06);
}
.game-area::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 30px;
  border-top: 2px dashed rgba(0,0,0,0.12);
}
.game-status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #999; font-size: 14px; }
.game-hud {
  position: absolute; top: 10px; left: 12px; right: 12px; z-index: 2;
  display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 700; color: #666;
}
.treat {
  position: absolute; top: 0; font-size: 30px; line-height: 1;
  transform: translateY(0); transition-property: transform; transition-timing-function: linear;
  cursor: pointer; user-select: none;
}
.treat.caught { animation: pop-out .18s ease forwards; }
.treat.missed { opacity: .25; filter: grayscale(1); }
@keyframes pop-out { to { transform: scale(1.6); opacity: 0; } }
.game-result { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.result-score { font-size: 20px; font-weight: 800; }
.result-reward { font-size: 14px; color: #3fb891; font-weight: 700; }
.battle-note { font-size: 11.5px; color: #a97c3f; background: #fff3cf; padding: 8px 12px; border-radius: 12px; margin: 10px 0 0; line-height: 1.6; text-align: left; }

/* ---- 完全体覚醒エフェクト ---- */
.celebrate-overlay {
  position: fixed; inset: 0; background: rgba(20,14,30,0.6); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  animation: fadeIn .25s ease;
}
.confetti-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti {
  position: absolute; top: -10%; animation-name: confetti-fall; animation-timing-function: ease-in;
  animation-iteration-count: 1; animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  from { transform: translateY(0) rotate(0deg); opacity: 1; }
  to { transform: translateY(115vh) rotate(280deg); opacity: 0; }
}
.celebrate-card {
  position: relative; background: #fffdf6; border-radius: 24px; padding: 28px 26px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: 0 0 40px rgba(246,196,69,.6); max-width: 300px; text-align: center;
  animation: pop .4s cubic-bezier(.2,1.4,.4,1);
}
.celebrate-title { font-size: 20px; font-weight: 800; color: #b8860b; margin-top: 4px; }
.celebrate-name { font-size: 13px; color: #777; margin-bottom: 8px; }
@media (prefers-reduced-motion: reduce) {
  .confetti { animation: none; opacity: .7; }
  .creature-svg, .egg, .gacha-egg { animation: none; }
}

#toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #2b2b2b; color: #fff; padding: 8px 18px; border-radius: 20px;
  font-size: 13px; opacity: 0; transition: all .25s ease; pointer-events: none; z-index: 20;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
