/* ==========================================================
   猫と段ボール箱 - style.css
   ========================================================== */

:root {
  --color-bg-top: #fff6e5;
  --color-bg-mid: #ffd9a8;
  --color-bg-bottom: #ffb3c6;
  --color-primary: #ff7a3d;
  --color-primary-2: #e85f28;
  --color-accent: #ff6f91;
  --color-accent-2: #e0507a;
  --color-safe: #6bcb77;
  --color-danger: #ff5d5d;
  --color-text: #6b4a3a;
  --color-text-muted: #b08a72;
  --color-border: #ffffff;
  --color-panel: #fffaf3;
  --header-h: 56px;
  --score-h: 52px;
  --ad-h: 64px;
  --ad-gap-h: 18px;
}

* {
  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: radial-gradient(circle at 50% 0%, var(--color-bg-top) 0%, var(--color-bg-mid) 55%, var(--color-bg-bottom) 100%);
  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.7rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.5));
  backdrop-filter: blur(6px);
  border-bottom: 3px solid rgba(255, 255, 255, 0.85);
  z-index: 20;
}

.back-link {
  color: var(--color-text);
  text-decoration: none;
  font-size: 1.3rem;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 0 rgba(224, 80, 122, 0.2);
  flex: 0 0 auto;
}

.back-link:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(224, 80, 122, 0.2);
}

.game-title {
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  margin: 0 0.4rem;
  color: var(--color-accent-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: var(--color-text);
  font-size: 1.02rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 rgba(224, 80, 122, 0.2);
}

.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(224, 80, 122, 0.2);
}

.icon-btn.is-muted {
  color: var(--color-text-muted);
  opacity: 0.65;
}

/* ---------- スコアバー ---------- */
.score-bar {
  height: var(--score-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  z-index: 15;
  flex-wrap: wrap;
}

.stat-box {
  background: linear-gradient(135deg, #fffdf9, #fff0e2);
  border: 2px solid #ffe0bf;
  border-radius: 999px;
  padding: 0.2rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 2px 0 rgba(224, 80, 122, 0.12);
}

.stat-box__label {
  font-size: 0.64rem;
  font-weight: bold;
  color: var(--color-text-muted);
}

.stat-box__value {
  font-size: 1rem;
  font-weight: 900;
  color: var(--color-accent-2);
}

.lives-box {
  display: flex;
  gap: 0.1rem;
  font-size: 0.95rem;
}

/* ---------- インクゲージ ---------- */
.ink-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0 0.9rem 0.35rem;
  z-index: 15;
}

.ink-bar__label {
  font-size: 0.62rem;
  font-weight: bold;
  color: var(--color-text-muted);
  white-space: nowrap;
  flex: 0 0 auto;
}

.ink-bar__track {
  flex: 1 1 auto;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 2px solid #ffe0bf;
  overflow: hidden;
}

.ink-bar__fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffc48c, var(--color-primary));
  transition: width 0.08s linear, background 0.25s ease;
}

.ink-bar__fill.is-low {
  background: linear-gradient(90deg, #ff9a9a, var(--color-danger));
}

.level-chip {
  flex: 0 0 auto;
  font-size: 0.62rem;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, #ffb347, var(--color-accent));
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- 難易度セレクタ（ガイド画面・ゲームオーバー画面） ---------- */
.difficulty-row {
  margin: 1.1rem 0 1.2rem;
  text-align: center;
}

.difficulty-row__label {
  display: block;
  font-size: 0.7rem;
  font-weight: bold;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
}

.difficulty-btns {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.difficulty-btn {
  border: 2px solid #ffd9bf;
  background: #fff;
  color: var(--color-text-muted);
  font-family: inherit;
  font-weight: 900;
  font-size: 0.82rem;
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  min-width: 74px;
  box-shadow: 0 2px 0 rgba(224, 80, 122, 0.12);
}

.difficulty-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.difficulty-btn.is-active {
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 0 var(--color-accent-2);
}

/* ---------- ゲームステージ ---------- */
.game-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

/* ふわふわ漂うハート/キラキラの装飾レイヤー */
.stage-decor {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.deco-item {
  position: absolute;
  bottom: -10%;
  opacity: 0;
  filter: drop-shadow(0 2px 3px rgba(224, 80, 122, 0.15));
  animation: deco-float linear infinite;
}

@keyframes deco-float {
  0% { transform: translateY(0) scale(0.8) rotate(-8deg); opacity: 0; }
  12% { opacity: 0.8; }
  88% { opacity: 0.7; }
  100% { transform: translateY(-120vh) scale(1.15) rotate(14deg); opacity: 0; }
}

.deco-item:nth-child(1) { left: 6%;  font-size: 1.15rem; animation-duration: 15s; animation-delay: 0s; }
.deco-item:nth-child(2) { left: 20%; font-size: 0.85rem; animation-duration: 11s; animation-delay: 2.5s; }
.deco-item:nth-child(3) { left: 36%; font-size: 1.4rem;  animation-duration: 17s; animation-delay: 5s; }
.deco-item:nth-child(4) { left: 60%; font-size: 0.95rem; animation-duration: 12.5s; animation-delay: 1s; }
.deco-item:nth-child(5) { left: 76%; font-size: 1.25rem; animation-duration: 16s; animation-delay: 7s; }
.deco-item:nth-child(6) { left: 90%; font-size: 0.8rem;  animation-duration: 13s; animation-delay: 3.5s; }
.deco-item:nth-child(7) { left: 48%; font-size: 1rem;    animation-duration: 18s; animation-delay: 9s; }
.deco-item:nth-child(8) { left: 12%; font-size: 0.75rem; animation-duration: 10.5s; animation-delay: 6s; }

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
}

/* ---------- 連続キャッチのバッジ ---------- */
.combo-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  font-size: 0.82rem;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, #ffb347, var(--color-accent));
  padding: 0.32rem 0.85rem;
  border-radius: 999px;
  white-space: nowrap;
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(107, 74, 58, 0.2);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.combo-badge.is-visible {
  opacity: 1;
  transform: scale(1);
  animation: combo-pop 0.6s ease-in-out infinite;
}

@keyframes combo-pop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

/* ---------- 操作ヒント ---------- */
.control-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 0.74rem;
  font-weight: bold;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid #ffd9e8;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  white-space: nowrap;
  opacity: 1;
  box-shadow: 0 3px 10px rgba(224, 80, 122, 0.15);
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.control-hint.is-hidden {
  opacity: 0;
}

/* ---------- オーバーレイ ---------- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(107, 74, 58, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay__box {
  text-align: center;
  padding: 1.8rem 2rem;
  background: linear-gradient(165deg, #fffdf9, #fff0e2);
  border: 4px solid #fff;
  border-radius: 30px;
  max-width: 85%;
  box-shadow: 0 20px 50px rgba(224, 80, 122, 0.3);
}

.overlay__box--wide {
  max-width: min(92%, 460px);
  max-height: 88%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.overlay__title {
  font-size: 1.4rem;
  font-weight: 900;
  margin: 0 0 0.5rem;
  color: var(--color-accent-2);
}

.overlay__desc {
  color: var(--color-text-muted);
  margin: 0 0 1.3rem;
  font-size: 1rem;
  font-weight: bold;
}

.overlay__btn {
  border: none;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: #fff;
  font-weight: 900;
  font-size: 0.95rem;
  padding: 0.8rem 1.8rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--color-accent-2);
}

.overlay__btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--color-accent-2);
}

/* ---------- ガイド画面 ---------- */
.guide-section {
  text-align: left;
  margin: 1rem 0;
}

.guide-section__title {
  font-size: 0.92rem;
  color: var(--color-accent-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;
}

/* ---------- 広告スペース ---------- */
.ad-gap {
  flex: 0 0 var(--ad-gap-h);
  background: transparent;
}

.ad-slot {
  flex: 0 0 var(--ad-h);
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 2px dashed var(--color-accent);
  background: rgba(255, 255, 255, 0.6);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  z-index: 20;
  overflow: hidden;
}

@media (max-height: 640px) {
  .ad-slot {
    --ad-h: 44px;
    font-size: 0.65rem;
  }
  .ad-gap {
    --ad-gap-h: 10px;
  }
}

@media (max-width: 360px) {
  .game-title {
    font-size: 0.74rem;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
}
