/* 「夏休みの自由研究」らしい配色: 青空・太陽・葉っぱ・クラフト紙をイメージした夏っぽいトーン */
:root {
  --paper: #fff8e7;
  --sky: #bfe6f5;
  --sky-deep: #7ec8e3;
  --sun: #ffd93d;
  --sun-deep: #ffa63d;
  --sun-pale: #fff3c4;
  --sun-pale-active: #ffe58a;
  --leaf: #8bc34a;
  --leaf-deep: #6ea83a;
  --leaf-pale: #cdeecb;
  --leaf-pale-active: #b3ddab;
  --ink: #5b4632;
}

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

html, body {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--sky) 0%, var(--paper) 100%);
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  touch-action: none;
  overscroll-behavior: none;
}

#game-container {
  position: relative;
  width: 400px;
  max-width: 100vw;
}

#hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 4px 8px;
  padding: 8px 12px;
  color: var(--ink);
  font-weight: bold;
}

#score {
  font-size: 1.1rem;
}

#stage-label {
  font-size: 0.75rem;
  opacity: 0.65;
}

#bgm-volume-container {
  display: flex;
  align-items: center;
  gap: 4px;
}

#bgm-volume {
  width: 60px;
  accent-color: var(--leaf);
}

#next-container {
  display: flex;
  align-items: center;
  gap: 4px;
}

#next-label {
  font-size: 0.8rem;
  opacity: 0.7;
}

/* 手前（次に落ちてくるもの）ほど大きく描画し、キューの順番が一目でわかるようにする */
.next-preview-canvas {
  background: #fff;
  border-radius: 50%;
  border: 2px solid var(--sky-deep);
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--sun-pale);
  color: var(--ink);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-button:active {
  background: var(--sun-pale-active);
}

.icon {
  display: block;
  flex-shrink: 0;
}

#canvas-stage {
  position: relative;
}

#game-canvas {
  display: block;
  width: 100%;
  background: var(--paper);
  border: 4px solid var(--sky-deep);
  border-radius: 16px;
  touch-action: none;
}

#game-over-overlay,
#stage-select-overlay,
#evolution-guide-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 248, 231, 0.92);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  color: var(--ink);
  font-weight: bold;
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

#game-over-overlay p:first-child,
.overlay-title {
  font-size: 1.5rem;
}

/* タイトル画面だけは不透明にする。他のオーバーレイは盤面が透けて見えるほうが自然だが、
   ステージ選択前のHUD（SCORE: 0・空のNEXT枠）は意味のある情報ではなく、
   半透明で透けると描画の不具合のように見えてしまうため */
#stage-select-overlay {
  background: var(--paper);
}

#stage-select-overlay .overlay-title {
  font-size: 1.1rem;
}

#title-logo {
  margin: 0;
  font-family: "Hachi Maru Pop", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  font-size: 2.6rem;
  font-weight: normal;
  color: var(--sun);
  /* paint-orderで縁取りを文字の背面に描く。既定では輪郭線が内側にも半分食い込み、
     細い丸文字フォントだと黄色の塗りが黒縁に潰されてしまうため */
  paint-order: stroke fill;
  -webkit-text-stroke: 6px #1c1c1c;
  filter: drop-shadow(0 4px 6px rgba(91, 70, 50, 0.35));
  letter-spacing: 0.02em;
  animation: cutin-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* タイトルの文字を1文字ずつ緩やかな弧を描くように配置する（game.jsのcurveTitleLogoで角度・高さを設定） */
.title-letter {
  display: inline-block;
  transform: translateY(var(--rise, 0)) rotate(var(--rotate, 0deg));
}

.stage-select-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.stage-best {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: -2px;
}

#best-score-label {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.75;
}

#new-record-label {
  margin: 0;
  font-size: 1rem;
  color: var(--sun-deep);
  animation: cutin-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#share-button {
  padding: 8px 20px;
  border: none;
  border-radius: 999px;
  background: var(--sky-deep);
  color: white;
  font-weight: bold;
  font-size: 0.9rem;
  cursor: pointer;
}

#share-button:active {
  background: #5aaecb;
}

#share-feedback {
  margin: 0;
  font-size: 0.8rem;
  opacity: 0.75;
}

.evolution-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 6px;
  max-width: 280px;
}

/* 円/楕円/スタンプの実シルエットをそのまま描画するcanvasなので、CSSで丸くクリップしない
   （クリップすると実際の当たり判定の形と見た目が食い違ってしまうため） */
.evolution-thumb {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #fff;
  border: 2px solid var(--sky-deep);
}

.evolution-arrow {
  font-size: 0.8rem;
  opacity: 0.7;
}

/* 8段階を上4つ・下4つの2行に固定するための強制改行（flex-wrap環境での折り返し依存を避ける） */
.evolution-row-break {
  flex-basis: 100%;
  height: 0;
}

.evolution-list--small .evolution-thumb {
  width: 22px;
  height: 22px;
  border-width: 1px;
}

.evolution-list--small .evolution-arrow {
  font-size: 0.6rem;
}

#evolution-guide-close {
  padding: 8px 24px;
  border: none;
  border-radius: 999px;
  background: var(--leaf-pale);
  color: var(--ink);
  font-weight: bold;
  cursor: pointer;
}

#evolution-guide-close:active {
  background: var(--leaf-pale-active);
}

#restart-button,
#change-stage-button,
.stage-select-button {
  padding: 10px 24px;
  border: none;
  border-radius: 999px;
  background: var(--leaf);
  color: white;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
}

#restart-button:active,
#change-stage-button:active,
.stage-select-button:active {
  background: var(--leaf-deep);
}

#change-stage-button {
  background: var(--leaf-pale);
  color: var(--ink);
  font-size: 0.85rem;
  padding: 8px 20px;
}

#change-stage-button:active {
  background: var(--leaf-pale-active);
}

.stage-select-button {
  width: 220px;
}

/* カットイン演出: スコアが1000点区切りを超えるたびに全画面で一瞬流す */
#cutin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 20, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

#cutin-image {
  max-width: 90vw;
  max-height: 80vh;
  animation: cutin-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#cutin-fallback {
  animation: cutin-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: linear-gradient(135deg, var(--sun-deep), var(--sun));
  color: white;
  font-size: 1.8rem;
  font-weight: bold;
  padding: 28px 44px;
  border-radius: 20px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  text-align: center;
  white-space: nowrap;
}

@keyframes cutin-pop {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  60% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* お祝いテロップ: BGM開始と同時に、ゲーム画面内（ゲームオーバーラインの少し上）を
   流れ続けるお祝いコメント。#canvas-stage基準の%配置にすることで、スマホで画面幅が
   縮んでcanvasが縮小されても常にゲームオーバーラインの少し上に来るようにしている。
   （画面外＝#game-containerの外側に置いていた版は、スマホだと上に余白がなく
   見えなくなってしまうため、canvas内に戻した）
   透過させて薄く流すことで、下の落下中キャラクターの視認を妨げないようにしている。 */
#telop-banner {
  position: absolute;
  top: 15%; /* GAME_OVER_LINE_Y(150) / HEIGHT(600) = 25%。バナー自身の高さ分を差し引いて
               ラインの少し上で収まるようにしている */
  left: 0;
  width: 100%;
  overflow: hidden;
  pointer-events: none;
  z-index: 5;
  opacity: 0.55;
  background: linear-gradient(90deg, rgba(255, 166, 61, 0) 0%, rgba(255, 166, 61, 0.7) 15%, rgba(255, 217, 61, 0.7) 85%, rgba(255, 217, 61, 0) 100%);
  padding: 8px 0;
}

#telop-text {
  display: inline-block;
  white-space: nowrap;
  font-size: 1.1rem;
  font-weight: bold;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  padding-left: 100%;
}

#telop-banner.scrolling #telop-text {
  /* 流れ続ける演出にするため、1周で止めず無限ループさせる */
  animation: telop-scroll 9s linear infinite;
}

@keyframes telop-scroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-200%);
  }
}
