/* ===== 色やサイズの「変数」（ポートフォリオとおそろい） ===== */
:root {
  --ink: #2b2a26;
  --muted: #6b675c;
  --bg: #f7f2e6;
  --card: #fffdf7;
  --yellow: #f6efc4;
  --red: #d9534f;
  --radius: 20px;
  --ease: cubic-bezier(0.4, 0.4, 0, 1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Zen Maru Gothic", "Yu Gothic UI", "Meiryo", sans-serif;
  font-weight: 500;
  line-height: 1.7;
}

button {
  font-family: inherit;
  color: inherit;
}

kbd {
  display: inline-block;
  margin: 0 2px;
  padding: 0 6px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
  border: 1.5px solid currentColor;
  border-radius: 6px;
}

.button {
  padding: 12px 36px;
  font-size: 17px;
  color: var(--bg);
  background: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s, color 0.2s;
}

.button:hover {
  color: var(--ink);
  background: transparent;
  transform: translateY(-2px);
}

/* ===== ヘッダー ===== */
.app-header {
  padding: 16px 24px;
}

.brand {
  font-weight: 700;
  color: inherit;
  text-decoration: none;
}

.app {
  width: min(480px, 100% - 32px); /* 画面が狭いときは、左右に16pxずつ余白 */
  margin: 0 auto;
  padding-bottom: 48px;
}

/* ===== スコアなどの表示 ===== */
.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 12px;
}

.hud-item span {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.hud-item strong {
  font-size: 18px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.lives {
  color: var(--red);
  letter-spacing: 0.1em;
}

/* ===== ゲーム画面 ===== */
.board {
  position: relative; /* overlay を canvas の上に重ねる基準 */
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  touch-action: none; /* スマホで、指を動かしても画面がスクロールしないように */
  cursor: none;       /* マウスの矢印を消して、球に集中できるように */
}

/* 案内用の画面（スタート・一時停止・クリア・ゲームオーバー） */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: safe center; /* 中身が多いときは、上が切れずにスクロールできる */
  overflow-y: auto;
  align-items: center;
  padding: 24px;
  text-align: center;
  background: rgba(247, 242, 230, 0.9);
  animation: fade-in 0.3s var(--ease);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.overlay-kakapo {
  width: 120px;
  margin-bottom: 8px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  50% {
    transform: translateY(-8px);
  }
}

.overlay-title {
  margin: 0 0 8px;
  font-size: clamp(26px, 7vw, 34px);
  line-height: 1.35;
}

.overlay-text {
  margin: 0 0 20px;
  color: var(--muted);
}

.overlay-note {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ===== シェア（ゲームオーバー・全クリア） ===== */
.share {
  margin-top: 20px;
}

.share-title {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.share-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.share-button {
  display: inline-block;
  padding: 6px 16px;
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
}

.share-button:hover {
  background: var(--yellow);
}

.copy-message {
  min-height: 1.5em;
  margin: 6px 0 0;
  font-size: 13px;
  color: #4a6b22;
}

/* ===== ボタン・説明 ===== */
.controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.controls button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 18px;
  font-size: 14px;
  background: transparent;
  border: 2px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
}

.controls button:hover {
  background: var(--yellow);
}

/* 「やめる」は目立たせない */
.controls .quit {
  color: var(--muted);
  border-color: #c9c2b0;
}

.help {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

.help p {
  margin: 0 0 8px;
  text-align: center;
}


.help .tip {
  padding: 8px 14px;
  background: var(--card);
  border: 1.5px dashed #c9c2b0;
  border-radius: 12px;
}

/* ===== ステージを選ぶボタン ===== */
.stage-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(280px, 100%);
}

.stage-button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s;
}

.stage-button span {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  font-size: 13px;
  color: var(--bg);
  background: var(--ink);
  border-radius: 50%;
}

.stage-button:hover:not(:disabled) {
  background: var(--yellow);
  transform: translateX(4px);
}

.stage-button:disabled {
  color: var(--muted);
  border-color: #c9c2b0;
  cursor: default;
}

.stage-button:disabled span {
  background: #c9c2b0;
}

/* 「ステージを選ぶ」など、目立たせないボタン */
.sub-button {
  margin-top: 12px;
  padding: 4px 12px;
  font-size: 14px;
  color: var(--muted);
  background: transparent;
  border: none;
  text-decoration: underline;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* スマホでは、案内の画面の余白を少しつめる */
@media (max-width: 420px) {
  .overlay {
    padding: 16px;
  }

  .stage-list {
    gap: 6px;
  }
}

/* ===== 立体感（厚みと影） ===== */
/* 下に濃い色の影をずらして置くと、板に厚みがあるように見える。押すと沈む */
.board {
  box-shadow: 0 6px 0 var(--ink), 0 18px 32px rgba(43, 42, 38, 0.18);
}

.hud-item {
  box-shadow: 0 3px 0 var(--ink);
  background: linear-gradient(180deg, #ffffff, var(--card));
}

.button,
.stage-button,
.controls button,
.share-button {
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.12s var(--ease), box-shadow 0.12s var(--ease), background 0.2s, color 0.2s;
}

.button:hover,
.stage-button:hover:not(:disabled),
.controls button:hover,
.share-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--ink);
}

.button:active,
.stage-button:active:not(:disabled),
.controls button:active,
.share-button:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--ink);
}

.stage-button {
  background: linear-gradient(180deg, #ffffff, var(--card));
}

.stage-button:disabled,
.controls .quit {
  box-shadow: 0 4px 0 #c9c2b0;
}

/* 案内の画面：うしろの里が少し見える、すりガラス */
.overlay {
  background: rgba(247, 242, 230, 0.82);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.overlay-title {
  text-shadow: 0 3px 0 #ffffff, 0 5px 0 rgba(43, 42, 38, 0.18);
}

/* ===== ドット絵（スーファミ風）に合わせた見た目 ===== */
/* 角を丸めず、影はぼかさずに「ずらすだけ」。文字はドット風のフォント */
body {
  font-family: "DotGothic16", monospace;
  font-weight: 400;
  letter-spacing: 0.04em;
}

canvas,
.overlay-kakapo {
  image-rendering: pixelated; /* 大きくしても、ぼかさない */
}

.overlay-kakapo {
  width: 96px;
  height: 99px;
  animation: hop 1s steps(2) infinite; /* カクカク動く */
}

@keyframes hop {
  50% {
    transform: translateY(-6px);
  }
}

.board,
.hud-item,
.button,
.stage-button,
.controls button,
.share-button,
.help .tip,
kbd {
  border-radius: 0;
}

.board {
  border-width: 3px;
  box-shadow: 6px 6px 0 var(--ink);
}

.hud-item {
  border-width: 3px;
  background: var(--card);
  box-shadow: 3px 3px 0 var(--ink);
}

.hud-item strong {
  font-weight: 400;
}

.button,
.stage-button,
.controls button,
.share-button {
  border-width: 3px;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 0.05s steps(1), box-shadow 0.05s steps(1);
}

.button:hover,
.stage-button:hover:not(:disabled),
.controls button:hover,
.share-button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--ink);
}

.button:active,
.stage-button:active:not(:disabled),
.controls button:active,
.share-button:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--ink);
}

.stage-button {
  background: var(--card);
  font-weight: 400;
}

.stage-button span {
  border-radius: 0;
}

.stage-button:disabled,
.controls .quit {
  box-shadow: 4px 4px 0 #c9c2b0;
}

.overlay {
  background: rgba(247, 242, 230, 0.88);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.overlay-title {
  font-weight: 400;
  text-shadow: 3px 3px 0 #c9c2b0;
}
