:root {
  --kinari: #fbf4e6;
  --kinari-dark: #efe4cf;
  --wakakusa: #a7c76b;
  --ink: #5a4630;
  --gold: #e3a832;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--kinari-dark);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: system-ui, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

/* 縦長のゲーム画面（横に広い画面では中央に、幅は高さの3/4まで） */
#col {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw, 75vh);
  width: min(100vw, 75dvh);
  overflow: hidden;
  background: var(--kinari);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hidden { display: none !important; }

#hud {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 0 #fff;
  font-variant-numeric: tabular-nums;
}
#hudScore { font-size: 38px; font-weight: 800; line-height: 1.1; }
#hudSub { font-size: 14px; font-weight: 700; opacity: 0.8; }
#hudBest {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--gold);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-shadow: none;
  animation: blink 0.8s ease-in-out infinite;
}

#pop {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 96px);
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  color: #6f8f3a;
  text-shadow: 0 2px 0 #fff;
  pointer-events: none;
  animation: pop 1.6s ease-out forwards;
}
@keyframes pop {
  0% { opacity: 0; transform: translateY(8px) scale(0.9); }
  15% { opacity: 1; transform: translateY(0) scale(1.08); }
  25% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}

.panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: none;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
  box-sizing: border-box;
}

#title {
  padding-top: calc(env(safe-area-inset-top) + 7vh);
  background: var(--kinari) url("art/scene/title.jpg") center bottom / cover no-repeat; /* ChatGPT で作ったタイトルの絵（上の3分の1は空） */
}
#title .how, #title .blink, #title .titleBest { text-shadow: 0 0 4px #fff, 0 0 8px #fff; }
#title h1 {
  margin: 0 0 12px;
  font-size: 56px;
  letter-spacing: 0.08em;
  color: #6f8f3a;
  text-shadow: 0 3px 0 #fff, 0 5px 0 rgba(90, 70, 48, 0.25);
}
.how { margin: 0 0 24px; font-size: 16px; line-height: 1.7; }
#title h1 .logo { display: block; width: min(76vw, 300px); height: auto; } /* ChatGPT で作ったロゴ */
.big { font-size: 22px; font-weight: 700; margin: 30vh 0 12px; }

.blink {
  font-size: 18px;
  font-weight: 700;
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: 0.35; } }

.titleBest { margin-top: 18px; font-size: 15px; font-weight: 700; }
/* はじめの画面の下：ページへのリンクと smallpaddy の統一バナー */
.titleFoot { pointer-events: auto; margin-top: auto; width: min(100%, 300px); }
.titleFoot .footLinks { display: flex; justify-content: center; gap: 4px 14px; flex-wrap: wrap; font-size: 12px; }
.titleFoot .footLinks a, .overFoot a { color: var(--ink); background: rgba(255, 255, 255, 0.8); padding: 1px 8px; border-radius: 999px; }
.titleFoot > a { margin-top: 8px !important; }
/* 結果の画面の下：応援（外部のサイトが開く） */
.overFoot { pointer-events: auto; margin: 0 0 4px; font-size: 12px; }

#over { padding-top: calc(env(safe-area-inset-top) + 6vh); background: rgba(251, 244, 230, 0.82); }
#over .line { font-size: 16px; line-height: 1.6; margin: 0 0 6px; white-space: pre-line; min-height: 3.2em; }
#over .scoreLabel { margin: 0; font-size: 13px; font-weight: 700; opacity: 0.7; }
#over .score { font-size: 52px; font-weight: 800; margin: 0; line-height: 1.1; font-variant-numeric: tabular-nums; }
#over .detail { margin: 4px 0 0; font-size: 14px; }
#over .bestLine { margin: 6px 0 8px; font-size: 14px; font-weight: 700; }
.top5 { border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.top5 td { padding: 2px 8px; text-align: right; }
.top5 td:nth-child(3), .top5 td:nth-child(4) { text-align: left; opacity: 0.75; }
.top5 tr.now td { color: #b9761a; font-weight: 800; }

#record { justify-content: center; background: rgba(60, 46, 30, 0.35); }
.newRecord {
  margin: 0;
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #ffd84a;
  -webkit-text-stroke: 2px #6b5233;
  text-shadow: 0 4px 0 #6b5233;
  animation: record 0.35s steps(2) infinite, zoom 0.5s ease-out;
}
@keyframes record { 50% { color: #ff9a3c; } }
@keyframes zoom { from { transform: scale(2.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.recordScore {
  margin: 10px 0 0;
  font-size: 60px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 #6b5233;
  font-variant-numeric: tabular-nums;
}
.skip { margin-top: 18px; font-size: 13px; color: #fff; opacity: 0.85; }

.overTop { display: flex; align-items: center; gap: 8px; }
#overNae { width: 72px; height: 96px; }
.subBtn {
  pointer-events: auto;
  margin-top: 10px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 8px 22px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
}

/* 共有（スコアカード） */
#share {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 14px);
  box-sizing: border-box;
  background: rgba(60, 46, 30, 0.6);
  overflow-y: auto;
}
#cardImg {
  max-width: 100%;
  max-height: 56vh;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  background: var(--kinari);
  -webkit-touch-callout: default; /* 長押しで保存できるように */
  user-select: auto;
  -webkit-user-select: auto;
}
.shareHint { margin: 6px 0 8px; font-size: 12px; color: #fff; }
.shareBtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: min(100%, 320px); }
.shareBtns button {
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 10px 6px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: var(--wakakusa);
  color: #3d2f1c;
}
.shareMsg { min-height: 1.4em; margin: 8px 0 0; font-size: 13px; color: #fff; }
#share .subBtn { margin-top: 4px; }

#retry {
  pointer-events: auto;
  margin-top: auto;
  margin-bottom: 3vh;
  font: inherit;
  font-size: 24px;
  font-weight: 800;
  padding: 18px 56px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  background: var(--wakakusa);
  color: #3d2f1c;
  box-shadow: 0 4px 0 var(--ink);
}
#retry:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
#retry:disabled { opacity: 0.45; }

/* 音のオン／オフ（いつでも押せる。押してもナエは跳ばない） */
.soundBtn {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  right: 10px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: rgba(255, 255, 255, 0.8);
  font-size: 18px;
  line-height: 1;
  padding: 0;
  z-index: 5;
  touch-action: manipulation;
}

#rotate {
  display: none;
  position: absolute;
  top: calc(env(safe-area-inset-top) + 64px);
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 13px;
  opacity: 0.7;
  pointer-events: none;
}
@media (orientation: landscape) and (pointer: coarse) {
  #rotate { display: block; }
}

/* 開発用の帯（?dev=1・手元のときだけ） */
#dev {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: calc(env(safe-area-inset-bottom) + 4px);
  padding: 6px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #ccc;
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  touch-action: manipulation;
}
#dev label { white-space: nowrap; }
#dev input[type="number"] { width: 56px; font-size: 11px; }
