* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cfd9e2; font-family: "Zen Kaku Gothic New", system-ui, sans-serif; color: #fff; user-select: none; -webkit-user-select: none; touch-action: none; }
#app, #app canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(40,28,0,.35), rgba(20,14,0,.7)); z-index: 10; }
.panel { max-width: 640px; width: 100%; text-align: center; padding: 28px 24px; border-radius: 14px;
  background: rgba(30,22,6,.55); border: 1px solid rgba(255,214,90,.35); backdrop-filter: blur(6px); box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.panel.small { max-width: 320px; }
.sub { letter-spacing: .3em; font-size: 13px; color: #ffe18a; }
h1, h2 { font-family: "Shippori Mincho", serif; margin: 10px 0 14px; color: #ffd84a; text-shadow: 0 2px 12px rgba(0,0,0,.5); }
h1 { font-size: clamp(30px, 7vw, 52px); line-height: 1.2; }
h1 span { display: block; font-size: .55em; color: #fff3c4; letter-spacing: .4em; margin-top: 6px; }
h2 { font-size: clamp(26px, 6vw, 38px); }
.story { font-size: 14px; line-height: 1.9; color: #fff8e0; margin: 0 0 14px; }
.story b { color: #ffd84a; }
.keys { list-style: none; padding: 0; margin: 0 0 18px; font-size: 13px; line-height: 2; color: #f6ecd0; }
kbd { display: inline-block; padding: 0 6px; border-radius: 4px; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3); font-family: inherit; font-size: 12px; }
button { font-family: "Shippori Mincho", serif; font-size: 18px; font-weight: 700; cursor: pointer; padding: 12px 28px; border-radius: 999px; border: none;
  color: #3a2800; background: linear-gradient(#ffe57a, #f2b705); box-shadow: 0 4px 16px rgba(242,183,5,.45); }
button:hover { filter: brightness(1.07); }
.note { margin-top: 14px; font-size: 12px; color: #e8d9a8; opacity: .85; }
#result { font-size: 15px; line-height: 2; margin-bottom: 18px; color: #fff8e0; }
#result .big { font-family: "Shippori Mincho", serif; font-size: 34px; color: #ffd84a; }
#result .rank { font-family: "Shippori Mincho", serif; font-size: 22px; color: #fff; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.7); transition: transform .1s, border-color .1s; }
#crosshair.ready { border-color: #ffd84a; transform: scale(1.4); box-shadow: 0 0 10px #ffd84a; }
#stats { position: absolute; left: 14px; top: 14px; padding: 10px 14px; border-radius: 10px; background: rgba(30,22,6,.45); font-size: 13px; min-width: 190px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
#stats .row { display: flex; justify-content: space-between; gap: 12px; line-height: 1.7; }
#stats .row span:not(.lbl) { font-weight: 700; color: #ffe27a; font-size: 15px; }
#stats small { opacity: .7; margin-left: 2px; align-self: center; }
#stats .lbl { color: #f2e6c4; }
#phase { margin-top: 6px; font-family: "Shippori Mincho", serif; font-size: 18px; color: #ffd84a; text-align: center; border-top: 1px solid rgba(255,216,74,.3); padding-top: 4px; }
#gaugeWrap { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); width: min(320px, 70vw); text-align: center; font-size: 12px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
#gauge { height: 10px; border-radius: 6px; background: rgba(0,0,0,.35); overflow: hidden; border: 1px solid rgba(255,255,255,.35); margin-top: 3px; }
#gaugeFill { height: 100%; width: 0%; background: linear-gradient(90deg, #bde8ff, #ffffff); }
#minimap { position: absolute; right: 14px; top: 14px; width: 96px; height: 300px; border-radius: 8px; background: rgba(30,22,6,.45); }
#toast { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-family: "Shippori Mincho", serif; font-size: clamp(20px, 4vw, 30px);
  color: #ffd84a; text-shadow: 0 2px 10px rgba(0,0,0,.7); opacity: 0; transition: opacity .4s; white-space: nowrap; }
#toast.show { opacity: 1; }
#hint { position: absolute; left: 50%; bottom: 66px; transform: translateX(-50%); font-size: 13px; padding: 4px 12px; border-radius: 999px; background: rgba(30,22,6,.45); white-space: nowrap; transition: opacity 1s; }
#touchUI { display: none; }
body.touch #touchUI { display: block; }
#stick { position: absolute; left: 24px; bottom: 60px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.3); }
#knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.4); }
#btnJump { position: absolute; right: 24px; bottom: 70px; pointer-events: auto; font-size: 16px; padding: 22px 18px; border-radius: 50%; width: 96px; height: 96px; opacity: .85; }
@media (max-width: 600px) {
  #stats { font-size: 11px; min-width: 150px; padding: 8px 10px; }
  #minimap { width: 64px; height: 200px; }
  #hint { font-size: 11px; bottom: 170px; white-space: normal; width: 80vw; text-align: center; }
}
#gaugeFill.max { background: linear-gradient(90deg, #ffd84a, #fff4b0); box-shadow: 0 0 8px #ffd84a; }
#gaugeFill { transition: width .05s; }
#climb { position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%); font-size: 13px; padding: 4px 12px; border-radius: 999px; background: rgba(60,40,10,.6); color: #ffe27a; white-space: nowrap; }
.overlay { overflow-y: auto; align-items: flex-start; touch-action: pan-y; }
.overlay .panel { margin: auto; }
@media (max-height: 560px) {
  .panel { padding: 14px 16px; }
  h1 { font-size: 28px; margin: 4px 0 6px; }
  .story, .keys { font-size: 12px; line-height: 1.6; margin-bottom: 8px; }
}
.btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; align-items: center; }
.btn2 { font-family: "Shippori Mincho", serif; font-size: 16px; font-weight: 700; padding: 11px 24px; border-radius: 999px; color: #ffe27a; text-decoration: none; border: 1px solid rgba(255,216,74,.6); background: rgba(0,0,0,.2); }
.btn2:hover { background: rgba(255,216,74,.15); }
#bgmBtn { position: absolute; right: 14px; top: 324px; pointer-events: auto; font-family: "Zen Kaku Gothic New", sans-serif; font-size: 12px; padding: 6px 12px; border-radius: 999px; box-shadow: none; }
#bgmBtn.off { background: rgba(30,22,6,.55); color: #e8d9a8; border: 1px solid rgba(255,216,74,.4); }
@media (max-width: 600px) { #bgmBtn { top: 222px; } }
.btn3 { font-size: 13px; padding: 7px 16px; box-shadow: none; }
.btn3.off { background: rgba(0,0,0,.25); color: #e8d9a8; border: 1px solid rgba(255,216,74,.4); }
.story { font-family: "Shippori Mincho", serif; font-size: 20px; letter-spacing: .15em; margin: 6px 0 18px; }
#stats .row span#alive.danger { color: #ff7a5a; }
.goal { font-size: 14px; color: #ffe27a; margin: -8px 0 16px; }
#result .big small { font-size: 16px; color: #f2e6c4; }
#result .sub2 { font-size: 17px; margin-bottom: 6px; }
#result .sub2 b { color: #ffd84a; font-size: 22px; }
#fps { position: absolute; left: 14px; bottom: 12px; font-size: 11px; padding: 2px 8px; border-radius: 6px; background: rgba(30,22,6,.45); color: #cfe8c0; font-variant-numeric: tabular-nums; }
#fps.slow { color: #ff9a7a; }
#btnJump { white-space: nowrap; font-size: 14px; padding: 0; }
@media (max-width: 600px) {
  #toast { top: auto; bottom: 200px; font-size: 18px; white-space: normal; width: 86vw; text-align: center; }
}

/* ---- アプリ版・タイトル・ポーズ ---- */
.best { font-size: 15px; color: #fff3c4; margin: -6px 0 14px; }
.best b { color: #ffd84a; font-size: 20px; }
.legal { margin-top: 14px; font-size: 11px; color: #e8d9a8; opacity: .85; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.legal a { color: #ffe27a; }
#pauseBtn { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); pointer-events: auto; width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 16px; box-shadow: none; background: rgba(30,22,6,.55); color: #ffe27a; border: 1px solid rgba(255,216,74,.5); display: none; }
body.touch #pauseBtn { display: block; }
.redoMsg { font-size: 15px; color: #fff8e0; }
#howtoPanel { padding: 0; background: #fff9e8; flex-direction: column; }
#howtoFrame { flex: 1; width: 100%; border: 0; background: #fff9e8; }
#howtoClose { margin: 10px auto calc(10px + env(safe-area-inset-bottom)); }
.overlay.withBanner { padding-bottom: 66px; }
/* スマホでは木登り中の案内を折り返して、画面からはみ出さないようにする */
@media (max-width: 600px) {
  #climb { white-space: normal; width: 86vw; max-width: 420px; text-align: center; border-radius: 12px; line-height: 1.5; font-size: 12px; bottom: 200px; }
}
/* スマホでは一時停止ボタンをミニマップの左に置き、左上の枠（時刻）と重ならないようにする */
@media (max-width: 600px) {
  #pauseBtn { left: auto; right: 88px; transform: none; top: 14px; }
}
/* スマホの縦画面で結果画面がはみ出さないように詰める */
@media (max-width: 600px) {
  .panel { padding: 18px 16px; }
  #over .sub { letter-spacing: .12em; font-size: 12px; }
  #over h2 { font-size: 24px; margin: 6px 0 8px; }
  #result { font-size: 13px; line-height: 1.7; margin-bottom: 12px; }
  #result .big { font-size: 30px; }
  #result .sub2 { font-size: 13px; }
  #result .sub2 b { font-size: 18px; }
  #result .rank { font-size: 17px; }
  #over button, #over .btn2 { font-size: 15px; padding: 9px 20px; }
}
/* 言語の切り替え */
.langs { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.langBtn { font-family: "Zen Kaku Gothic New", sans-serif; font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 999px; box-shadow: none; background: rgba(0,0,0,.25); color: #e8d9a8; border: 1px solid rgba(255,216,74,.4); }
.langBtn.on { background: linear-gradient(#ffe57a, #f2b705); color: #3a2800; }
h1 .h1a { display: inline; font-size: 1em; letter-spacing: normal; color: inherit; margin: 0; }
html[lang="en"] h1 span:not(.h1a) { letter-spacing: .12em; }
html[lang="en"] .sub { letter-spacing: .12em; }
html[lang="en"] .story { letter-spacing: .01em; font-size: 18px; }
/* Web 版だけ：Google Play へのリンク（アプリ用のビルドでは HTML ごと取り除く） */
.storeLink { display: inline-flex; align-items: center; gap: 10px; margin-top: 14px; padding: 7px 16px; border-radius: 10px; background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.35); color: #fff; text-decoration: none; }
.storeLink .gp { font-size: 18px; color: #ffd84a; }
.storeLink span:last-child { display: flex; flex-direction: column; line-height: 1.25; text-align: left; }
.storeLink small { font-size: 10px; opacity: .85; } .storeLink b { font-size: 14px; }
