/* ==========================================================
   ちいさなポケットペット -Pocket Pixels- - style.css
   90年代携帯液晶ゲーム機モチーフのレトロポップ配色
   ========================================================== */

:root {
  --color-bg-top: #ffe1ef;
  --color-bg-bottom: #d9c8ff;
  --color-shell: #b48cff;
  --color-shell-dark: #7a55d1;
  --color-screen: #d8f5da;
  --color-screen-line: rgba(60, 120, 90, 0.16);
  --color-box: #fff2fb;
  --color-box-border: #b48cff;
  --color-primary: #ff6fae;
  --color-primary-2: #ffc36f;
  --color-good: #3fb98a;
  --color-warn: #ff5c5c;
  --color-text: #4a3466;
  --color-text-muted: #8877a8;
  --color-border: #cbb8ee;
  --header-h: 56px;
  --ad-h: 60px;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Segoe UI", Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, var(--color-bg-top), var(--color-bg-bottom));
  color: var(--color-text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* ---------- ヘッダー ---------- */
.game-header {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.8rem;
  background: rgba(255, 255, 255, 0.55);
  border-bottom: 3px solid var(--color-shell);
  z-index: 20;
}

.back-link {
  color: var(--color-text);
  text-decoration: none;
  font-size: 1.3rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(180, 140, 255, 0.15);
}
.back-link:active { background: rgba(180, 140, 255, 0.3); }

.game-title {
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--color-shell-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions { display: flex; align-items: center; gap: 0.4rem; flex: 0 0 auto; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(180, 140, 255, 0.15);
  color: var(--color-text);
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { background: rgba(180, 140, 255, 0.3); }
.icon-btn.is-muted { color: var(--color-text-muted); }

/* ---------- ステータス ---------- */
.stat-row {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem;
  padding: 0.5rem 0.6rem 0.2rem;
  z-index: 10;
}

.stat-mini {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--color-box);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  padding: 0.3rem 0.5rem;
}

.stat-mini__icon { font-size: 1rem; flex: 0 0 auto; }
.stat-mini__body { flex: 1 1 auto; min-width: 0; }
.stat-mini__label {
  display: block;
  font-size: 0.58rem;
  font-weight: bold;
  color: var(--color-text-muted);
}
.stat-mini__bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(122, 85, 209, 0.15);
  overflow: hidden;
  margin-top: 0.15rem;
}
.stat-mini__fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}
.stat-mini__fill--hunger { background: linear-gradient(90deg, #ffb37a, #ff8f4d); }
.stat-mini__fill--happy { background: linear-gradient(90deg, #ffd36f, #ffb84d); }
.stat-mini__fill--clean { background: linear-gradient(90deg, #7fd8ff, #4fb8f0); }
.stat-mini__fill--energy { background: linear-gradient(90deg, #b98cff, #8c5fe6); }

.stat-mini.is-warn {
  border-color: var(--color-warn);
  animation: warn-pulse 1s ease-in-out infinite;
}
@keyframes warn-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 92, 92, 0); }
  50% { box-shadow: 0 0 10px rgba(255, 92, 92, 0.55); }
}

/* ---------- レベル行 ---------- */
.level-row {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.15rem 0 0.1rem;
}
.level-row__level {
  font-size: 0.72rem;
  font-weight: 900;
  color: var(--color-shell-dark);
  background: rgba(180, 140, 255, 0.18);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}
.level-row__stage {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--color-primary);
}

/* ---------- ペット表示エリア ---------- */
.pet-view {
  flex: 1 1 40%;
  min-height: 150px;
  padding: 0.4rem 0.7rem;
}

.pet-view__screen {
  position: relative;
  height: 100%;
  border-radius: 20px;
  background:
    repeating-linear-gradient(0deg, var(--color-screen-line) 0px, var(--color-screen-line) 1px, transparent 1px, transparent 4px),
    radial-gradient(ellipse at 50% 30%, #eafff0, var(--color-screen));
  border: 6px solid var(--color-shell);
  box-shadow: inset 0 0 24px rgba(60, 120, 90, 0.25), 0 6px 0 var(--color-shell-dark);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pet-sprite {
  width: clamp(96px, 30vw, 170px);
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 10px rgba(60, 40, 100, 0.25));
  transition: transform 0.2s ease;
  cursor: pointer;
  z-index: 3;
}
.pet-sprite.is-tapped { animation: pet-bounce 0.24s ease; }
@keyframes pet-bounce {
  0% { transform: scale(1); }
  40% { transform: scale(0.9) translateY(4px); }
  100% { transform: scale(1); }
}

.is-egg-stage .pet-sprite { cursor: pointer; }

.sleep-zzz {
  position: absolute;
  top: 14%;
  right: 18%;
  font-size: 1.6rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 4;
}
.is-sleeping .sleep-zzz {
  opacity: 1;
  transform: translateY(0);
  animation: zzz-float 2.2s ease-in-out infinite;
}
@keyframes zzz-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.is-sleeping .pet-sprite { filter: drop-shadow(0 6px 10px rgba(60, 40, 100, 0.25)) brightness(0.85); }

.hatch-bar-wrap {
  display: none;
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 10%;
  z-index: 3;
  text-align: center;
}
.hatch-bar-wrap.is-visible { display: block; }
.hatch-bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(122, 85, 209, 0.18);
  border: 2px solid var(--color-shell);
  overflow: hidden;
}
.hatch-bar__fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary-2), var(--color-primary));
  transition: width 0.25s ease;
}
.hatch-hint {
  margin: 0.35rem 0 0;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--color-shell-dark);
}

.poop-layer { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.poop-icon {
  position: absolute;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 3px rgba(60, 40, 20, 0.3));
}

.float-layer { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 6; }
.float-text {
  position: absolute;
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--color-good);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  transform: translate(-50%, -50%);
  animation: float-up 0.85s ease-out forwards;
  white-space: nowrap;
}
@keyframes float-up {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.9); }
  20% { transform: translate(-50%, -80%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}

.evolve-toast {
  position: absolute;
  left: 50%;
  top: 8%;
  transform: translate(-50%, -14px);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2));
  color: #452a12;
  font-weight: 900;
  font-size: 0.78rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 7;
}
.evolve-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- お世話パネル ---------- */
.care-panel {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem 0.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.care-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.care-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  border: 2px solid var(--color-border);
  background: var(--color-box);
  border-radius: 14px;
  padding: 0.4rem 0.2rem;
  cursor: pointer;
}
.care-btn:active { filter: brightness(0.95); }
.care-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.care-btn.is-active { border-color: var(--color-primary); background: rgba(255, 111, 174, 0.15); }
.care-btn__icon { width: 30px; height: 30px; image-rendering: pixelated; object-fit: contain; }
.care-btn__label { font-size: 0.62rem; font-weight: 800; color: var(--color-text); }

.cartridge-panel__title {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--color-text);
}

.cartridge-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.cart-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  border: 2px solid var(--color-border);
  background: var(--color-box);
  border-radius: 14px;
  padding: 0.4rem 0.2rem;
  cursor: pointer;
}
.cart-btn:active { filter: brightness(0.95); }
.cart-btn.is-active {
  border-color: var(--color-shell-dark);
  background: rgba(180, 140, 255, 0.22);
  box-shadow: 0 0 0 2px rgba(180, 140, 255, 0.35);
}
.cart-btn__icon { width: 34px; height: 34px; image-rendering: pixelated; object-fit: contain; }
.cart-btn__name { font-size: 0.6rem; font-weight: 800; color: var(--color-text); text-align: center; }

/* ---------- オーバーレイ ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(60, 30, 80, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 1rem;
}
.overlay.is-visible { opacity: 1; pointer-events: auto; }

.overlay__box {
  text-align: center;
  padding: 1.8rem 2rem;
  background: var(--color-box);
  border: 3px solid var(--color-box-border);
  border-radius: 22px;
  max-width: 85%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.overlay__box--wide { max-width: min(92%, 460px); max-height: 88%; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.guide-section { text-align: left; margin: 1rem 0; }
.guide-section__title { font-size: 0.92rem; color: var(--color-primary); margin: 0 0 0.4rem; }
.guide-section__text { font-size: 0.82rem; color: var(--color-text-muted); margin: 0; line-height: 1.6; }
.guide-section__list { margin: 0; padding-left: 1.1rem; font-size: 0.8rem; color: var(--color-text-muted); line-height: 1.7; }
.guide-section__list li { margin-bottom: 0.3rem; }

.overlay__title { font-size: 1.3rem; font-weight: 900; margin: 0 0 0.5rem; color: var(--color-shell-dark); }
.overlay__result-emoji { font-size: 2.4rem; margin: 0 0 0.2rem; }
.overlay__desc { color: var(--color-text-muted); margin: 0 0 1.3rem; font-size: 0.88rem; font-weight: bold; line-height: 1.6; }
.overlay__btn {
  border: none;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2));
  color: #452a12;
  font-weight: bold;
  font-size: 0.95rem;
  padding: 0.8rem 1.8rem;
  border-radius: 999px;
  cursor: pointer;
}
.overlay__btn:active { filter: brightness(0.92); }
.overlay__btn-row { display: flex; gap: 0.6rem; justify-content: center; }
.overlay__btn--ghost { background: rgba(180, 140, 255, 0.18); color: var(--color-shell-dark); }

/* ---------- 広告スペース ---------- */
.ad-gap { flex: 0 0 8px; }
.ad-slot {
  flex: 0 0 var(--ad-h);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0.1rem 0.1rem;
  border: 2px dashed var(--color-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.4);
  color: var(--color-text-muted);
  font-size: 0.7rem;
  overflow: hidden;
}

@media (max-height: 640px) {
  .pet-view { flex-basis: 32%; min-height: 120px; }
  .pet-sprite { width: clamp(80px, 26vw, 130px); }
}
