/* ==========================================================
   ドット絵ミニプラント -Pixel Plant- - style.css
   ========================================================== */

:root {
  --color-bg-top: #1a3320;
  --color-bg-bottom: #0c1a10;
  --color-box: #17331f;
  --color-box-border: #6fd68a;
  --color-primary: #4caf6d;
  --color-primary-2: #a3e8b0;
  --color-coin: #7ee0a0;
  --color-water: #4fb8ff;
  --color-sun: #ffcd4f;
  --color-text: #eafff0;
  --color-text-muted: #9dc4a8;
  --color-border: #2b5c3a;
  --header-h: 56px;
  --ad-h: 58px;
}

* {
  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(10, 26, 16, 0.8);
  border-bottom: 2px solid var(--color-box-border);
  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(255, 255, 255, 0.08);
}

.back-link:active { background: rgba(255, 255, 255, 0.18); }

.game-title {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--color-primary-2);
  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(255, 255, 255, 0.08);
  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(255, 255, 255, 0.18); }
.icon-btn.is-muted { color: var(--color-text-muted); }

/* ---------- HUD ---------- */
.stat-row {
  flex: 0 0 auto;
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem 0.3rem;
  z-index: 10;
}

.stat-box {
  flex: 1 1 0;
  min-width: 0;
  background: rgba(23, 51, 31, 0.8);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  padding: 0.3rem 0.5rem;
  text-align: center;
  line-height: 1.25;
}

.stat-box__label {
  display: block;
  font-size: 0.6rem;
  font-weight: bold;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.stat-box__value {
  display: block;
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--color-coin);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-box:last-child .stat-box__value { color: var(--color-primary-2); }

/* ---------- ベランダビュー ---------- */
.balcony-view {
  position: relative;
  flex: 1 1 50%;
  min-height: 220px;
  overflow: hidden;
  border-bottom: 2px solid var(--color-border);
}

.balcony-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  pointer-events: none;
}

.planter-row {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 0.4rem;
  padding: 0.5rem;
  overflow-y: auto;
}

.planter-slot {
  position: relative;
  background: rgba(10, 26, 16, 0.35);
  border: 2px dashed rgba(163, 232, 176, 0.35);
  border-radius: 12px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 90px;
  cursor: pointer;
  overflow: hidden;
}

.planter-slot.is-planted {
  border-style: solid;
  border-color: var(--color-border);
  cursor: default;
}

.planter-slot.is-locked {
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.planter-slot__lock-label {
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--color-text-muted);
  text-align: center;
  padding: 0 0.3rem;
}

.planter-slot__empty-hint {
  font-size: 1.6rem;
  opacity: 0.6;
}

.planter-slot__plant {
  width: 68%;
  height: auto;
  max-height: 82%;
  image-rendering: pixelated;
  pointer-events: none;
  animation: plant-sway 3.4s ease-in-out infinite;
  transform-origin: bottom center;
}

@keyframes plant-sway {
  0%, 100% { transform: rotate(-2.5deg); }
  50% { transform: rotate(2.5deg); }
}

.planter-slot__progress {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 4px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.planter-slot__progress-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--color-water), var(--color-primary-2));
  border-radius: 999px;
  transition: width 0.2s ease;
}

.planter-slot__care {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 3;
}

.care-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(10, 26, 16, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  padding: 0;
  cursor: pointer;
}

.care-btn img { width: 60%; height: 60%; object-fit: contain; image-rendering: pixelated; pointer-events: none; }

.care-btn--water { border-color: var(--color-water); }
.care-btn--sun { border-color: var(--color-sun); }

.planter-slot__gauges {
  position: absolute;
  top: 4px;
  left: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 24px;
  z-index: 3;
}

.gauge-bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}

.gauge-bar__fill { display: block; height: 100%; border-radius: 999px; }
.gauge-bar__fill--water { background: var(--color-water); }
.gauge-bar__fill--sun { background: var(--color-sun); }

.planter-slot.is-bloomed .planter-slot__care,
.planter-slot.is-bloomed .planter-slot__progress {
  display: none;
}

/* ---------- コイン浮遊 ---------- */
.coin-float {
  position: absolute;
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
  cursor: pointer;
  filter: drop-shadow(0 2px 6px rgba(126, 224, 160, 0.6));
  animation: coin-bob 2.4s ease-in-out infinite;
  touch-action: manipulation;
  z-index: 4;
}

@keyframes coin-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

.coin-float.is-collected {
  animation: coin-collected 0.4s ease-out forwards;
  pointer-events: none;
}

@keyframes coin-collected {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.8) translateY(-26px); opacity: 0; }
}

/* ---------- 飛び出す +N エフェクト ---------- */
.float-layer { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 6; }

.float-text {
  position: absolute;
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--color-coin);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5), 0 2px 8px rgba(126, 224, 160, 0.5);
  transform: translate(-50%, -50%);
  animation: float-up 0.9s ease-out forwards;
  white-space: nowrap;
}

.float-text.is-bloom { color: #ffe066; font-size: 1.05rem; }

@keyframes float-up {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.9); }
  20% { transform: translate(-50%, -70%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(1); }
}

/* ---------- ショップ ---------- */
.shop-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(9, 22, 14, 0.5);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.shop-panel__title {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.5rem 0.8rem 0.2rem;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--color-text);
}

.shop-list {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.1rem 0.65rem 0.4rem;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--color-box);
  border: 2px solid var(--color-border);
  border-radius: 14px;
  padding: 0.42rem 0.6rem;
}

.shop-item__icon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background-color: rgba(163, 232, 176, 0.08);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 78%;
  image-rendering: pixelated;
}

.shop-item__info { flex: 1 1 auto; min-width: 0; }

.shop-item__name {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.shop-item__badge {
  font-size: 0.6rem;
  font-weight: 800;
  color: #0a2a10;
  background: var(--color-primary-2);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  white-space: nowrap;
}

.shop-item__desc {
  font-size: 0.64rem;
  color: var(--color-text-muted);
  margin: 0.12rem 0 0;
}

.shop-item__buy {
  flex: 0 0 auto;
  border: none;
  border-radius: 12px;
  padding: 0.42rem 0.55rem;
  min-width: 78px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2));
  color: #0a2a10;
  font-weight: 900;
  font-size: 0.72rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.3;
}

.shop-item__buy:active { filter: brightness(0.92); }

.shop-item__buy:disabled {
  background: #33453a;
  color: #7d947f;
  cursor: not-allowed;
}

.shop-item__buy-label { font-size: 0.58rem; opacity: 0.85; }

/* ---------- タネ選択グリッド ---------- */
.species-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0.8rem 0 1.2rem;
  max-height: 50vh;
  overflow-y: auto;
}

.species-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  padding: 0.5rem 0.3rem;
  cursor: pointer;
  color: var(--color-text);
}

.species-option:active { border-color: var(--color-primary-2); }

.species-option__icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  image-rendering: pixelated;
}

.species-option__name { font-size: 0.62rem; font-weight: 800; text-align: center; line-height: 1.25; }

/* ---------- オーバーレイ ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 14, 8, 0.72);
  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.5);
}

.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-2); 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.35rem; font-weight: 900; margin: 0 0 0.5rem; color: var(--color-primary-2); }
.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; white-space: pre-line; line-height: 1.6; }

.overlay__btn {
  border: none;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-2));
  color: #0a2a10;
  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(163, 232, 176, 0.12); color: var(--color-primary-2); margin-top: 0.4rem; }

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

@media (max-height: 640px) {
  .balcony-view { flex-basis: 42%; min-height: 170px; }
}
