* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #dfe8f2;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", sans-serif;
  color: #1f2d3d;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;           /* スワイプでページがスクロール・拡大しないように */
  overscroll-behavior: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; left: 0; top: 0; right: 0;
  padding: max(12px, env(safe-area-inset-top)) 16px 0 max(14px, env(safe-area-inset-left));
  pointer-events: none;
}
.hud-score {
  font-size: clamp(30px, 7vmin, 52px); font-weight: 900; line-height: 1;
  color: #fff; text-shadow: 0 2px 0 #b45a1d, 0 4px 10px rgba(30,40,60,.35);
  letter-spacing: .02em;
}
.hud-score small { font-size: .45em; margin-left: .2em; }
.hud-sub { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: rgba(255,255,255,.78); border-radius: 999px; padding: 3px 10px;
  font-size: 13px; color: #3a4a5c; box-shadow: 0 1px 4px rgba(30,50,80,.15);
}
.chip b { color: #d0602a; font-size: 15px; }

#topButtons {
  position: fixed; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right));
  display: flex; gap: 8px; z-index: 30;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.8); box-shadow: 0 2px 8px rgba(30,50,80,.2);
  display: grid; place-items: center; touch-action: manipulation;
}
.icon-btn svg { fill: #34465a; stroke: #34465a; }
#muteBtn .cross { display: none; }
#muteBtn.muted .wave { display: none; }
#muteBtn.muted .cross { display: inline; }

#flash {
  position: fixed; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255,255,255,.2) 0%, rgba(214,60,40,.55) 100%);
}
#popLayer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.pop {
  position: absolute; transform: translate(-50%, -50%);
  font-weight: 900; font-size: 22px; color: #ff7a3c;
  text-shadow: 0 2px 0 #fff, 0 0 8px rgba(255,255,255,.9);
  animation: popUp .8s ease-out forwards;
}
@keyframes popUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  20% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(1); }
}
#toast {
  position: fixed; left: 50%; top: 22%; transform: translateX(-50%);
  font-size: clamp(22px, 6vmin, 38px); font-weight: 900; color: #fff;
  text-shadow: 0 3px 0 #2f6fae, 0 6px 16px rgba(20,40,80,.4);
  pointer-events: none; white-space: nowrap;
  animation: toastIn 1.6s ease-out forwards;
}
@keyframes toastIn {
  0% { opacity: 0; transform: translateX(-50%) scale(.5); }
  15% { opacity: 1; transform: translateX(-50%) scale(1.1); }
  25% { transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* ---------- 画面（タイトル・ゲームオーバー・一時停止） ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(40,70,110,.18), rgba(20,40,70,.35));
}
#titleScreen {
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(30,60,100,.35) 0%, rgba(30,60,100,0) 35%, rgba(30,60,100,0) 55%, rgba(20,40,70,.35) 100%);
}
.title-top { text-align: center; margin-top: 2vh; }
.kicker {
  margin: 0 0 6px; font-size: clamp(13px, 3.4vmin, 18px); color: #fff; letter-spacing: .15em;
  text-shadow: 0 1px 4px rgba(20,40,70,.6);
}
h1 {
  margin: 0; line-height: 1.05; font-weight: 900; color: #fff;
  font-size: clamp(40px, 11vmin, 88px);
  text-shadow: 0 4px 0 #c65a1c, 0 8px 22px rgba(20,40,70,.45);
  display: flex; flex-direction: column; align-items: center;
}
h1 span:first-child { color: #ffb25e; text-shadow: 0 4px 0 #9a3f12, 0 8px 22px rgba(20,40,70,.45); }
.card {
  width: min(520px, 100%);
  background: rgba(255,255,255,.9); border-radius: 18px; padding: 18px 20px;
  box-shadow: 0 10px 30px rgba(20,40,70,.25);
  text-align: center; backdrop-filter: blur(4px);
}
.howto { display: flex; gap: 14px; justify-content: center; text-align: left; }
.howto-col { flex: 1; min-width: 0; }
.howto h2 { font-size: 13px; margin: 0 0 4px; color: #d0602a; }
.howto p { margin: 3px 0; font-size: 13px; line-height: 1.5; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 0 5px; margin-right: 2px;
  border: 1px solid #b9c6d4; border-bottom-width: 2px; border-radius: 5px;
  background: #f5f8fb; font-family: inherit; font-size: 12px; text-align: center;
}
.rule { font-size: 13px; line-height: 1.6; margin: 10px 0 12px; color: #3a4a5c; }
.salmon { color: #e0603a; }
.big-btn {
  display: block; width: 100%; padding: 14px; border: none; border-radius: 14px; cursor: pointer;
  font: inherit; font-size: 22px; font-weight: 900; letter-spacing: .1em; color: #fff;
  background: linear-gradient(180deg, #ff9a4d, #e2672a);
  box-shadow: 0 5px 0 #a8461a, 0 8px 16px rgba(160,70,20,.35);
  touch-action: manipulation;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #a8461a; }
.sub-btn {
  margin-top: 12px; padding: 8px 18px; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 15px; color: #4a6078; text-decoration: underline; touch-action: manipulation;
}
.hi { margin: 10px 0 0; font-size: 14px; color: #4a6078; }
.hi b { color: #d0602a; font-size: 18px; }

.over-card { max-width: 400px; }
.over-title { margin: 0 0 6px; font-size: 26px; color: #2c4460; }
.new-record {
  display: inline-block; margin: 2px 0 6px; padding: 4px 14px; border-radius: 999px;
  background: #ffd84d; color: #7a4a00; font-weight: 900; animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.08); } }
.result { margin: 6px 0 16px; }
.result-main { font-size: 56px; font-weight: 900; color: #e2672a; line-height: 1.1; }
.result-main small { font-size: 20px; margin-left: 4px; }
.result-sub { font-size: 14px; color: #3a4a5c; margin-top: 4px; }
.result-hi { font-size: 15px; color: #4a6078; margin-top: 6px; }
.result-hi b { color: #2c4460; font-size: 18px; }

#errorBox {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
  background: #dfe8f2; font-size: 16px; line-height: 1.7; text-align: center;
}
#fps {
  position: fixed; left: 8px; bottom: 8px; z-index: 40; font: 12px monospace;
  background: rgba(0,0,0,.55); color: #fff; padding: 2px 6px; border-radius: 4px;
}

/* スマホ（横向き含む）ではパソコンの操作説明を出さない */
@media (pointer: coarse) { .pc-only { display: none; } }

/* 縦長・小さい画面 */
@media (max-width: 560px) {
  .howto { flex-direction: column; gap: 6px; }
  .pc-only { display: none; }
  .card { padding: 14px 16px; }
}
@media (max-height: 460px) {
  h1 { font-size: 36px; flex-direction: row; gap: .3em; }
  .title-top { margin-top: 0; }
  .rule { margin: 6px 0 8px; }
  .big-btn { padding: 9px; font-size: 18px; }
}

/* タイトル画面の「ほかのゲーム」へのリンク */
.back { display: block; text-align: center; margin-top: 6px; font-size: 13px; color: #6b7a86; text-decoration: none; }
.back:hover { text-decoration: underline; }
