* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
}
/* 韓国語は韓国語の字体を先に引く(<html lang> は js/i18n.js が言語に合わせて書き換える) */
:root:lang(ko) body {
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Hiragino Sans", "Noto Sans JP", sans-serif;
  word-break: keep-all;   /* 韓国語は語(空白の間)の途中で折らない */
}
body {
  background: #cfe4f2;
  color: #3a3f47;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* 強制横画面(js/viewport.js)。**position:fixed の子は transform された body を包含ブロックに
   するので、inset:0 が回転後の box を満たす** — だから canvas も UI も個別に触らなくてよい。
   幅・高さ・transform は px で JS が入れる(モバイルの vh は innerHeight とズレるため)。 */
body.force-landscape { position: fixed; top: 0; left: 0; transform-origin: 0 0; overflow: hidden; }
.hidden { display: none !important; }

/* ---------- ロード ---------- */
#loading {
  position: fixed; inset: 0; z-index: 50;
  background: linear-gradient(160deg, #cfe4f2, #f2e8dc);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
}
.load-ball {
  width: 46px; height: 46px; border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #f2b8c6 12%, transparent 13%),
    radial-gradient(circle at 70% 40%, #a8d8c9 11%, transparent 12%),
    radial-gradient(circle at 45% 72%, #ffd75e 12%, transparent 13%),
    #f6f2ea;
  box-shadow: 0 6px 18px rgba(58,63,71,.18);
  animation: roll 1.1s linear infinite;
}
@keyframes roll { to { transform: rotate(360deg); } }
#loading-text { font-size: 14px; letter-spacing: .12em; color: #6a7078; }

/* ---------- 画面共通 ---------- */
.screen {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  overflow: auto;
}
.big-btn {
  display: block; margin: 0 auto 14px; border: none; cursor: pointer;
  font: inherit; font-size: 20px; font-weight: 800; letter-spacing: .2em;
  padding: 15px 64px; border-radius: 999px; color: #fff;
  background: linear-gradient(160deg, #4a90c2, #3a76a8);
  box-shadow: 0 6px 0 #2e5d85, 0 12px 26px rgba(58,118,168,.35);
  transition: transform .08s, box-shadow .08s;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #2e5d85; }
.sub-btn {
  border: none; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700;
  color: #5a636e; background: rgba(255,255,255,.7); border-radius: 999px; padding: 9px 26px;
}

/* ---------- HUD ---------- */
#hud > * { position: fixed; z-index: 30; }
#hud-left { top: 14px; left: 18px; }
#diameter {
  font-size: clamp(30px, 4.6vw, 44px); font-weight: 900; color: #2e3742;
  text-shadow: 0 2px 0 rgba(255,255,255,.9), 0 6px 16px rgba(46,55,66,.18);
  font-variant-numeric: tabular-nums; line-height: 1;
}
#diameter.roll { animation: numroll .28s ease-out; }
@keyframes numroll { 0% { transform: translateY(-6px) scale(1.12); } 100% { transform: none; } }
#timer {
  top: 14px; left: 50%; transform: translateX(-50%);
  font-size: clamp(26px, 4vw, 38px); font-weight: 900; color: #2e3742;
  text-shadow: 0 2px 0 rgba(255,255,255,.9); font-variant-numeric: tabular-nums;
}
#timer.warn { color: #d94f3d; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.08); } }
/* 止めている間(設定を開いている・カメラモード)。残り 30 秒の赤い点滅も止めて灰色にする(.warn より後に置く) */
#timer.paused { color: #9aa2ab; animation: none; }
#banner {
  top: 17%; left: 50%; z-index: 31;
  font-size: clamp(18px, 3vw, 26px); font-weight: 900; letter-spacing: .1em;
  background: rgba(255,255,255,.92); color: #2e3742;
  padding: 12px 34px; border-radius: 999px;
  box-shadow: 0 8px 26px rgba(46,55,66,.2);
  white-space: nowrap; pointer-events: none;
}
.banner-hide { opacity: 0; transform: translate(-50%,-12px) scale(.94); transition: all .25s; }
.banner-show { opacity: 1; transform: translate(-50%,0) scale(1); transition: all .22s cubic-bezier(.2,1.6,.4,1); }
#banner.goal { background: #e8734d; color: #fff; font-size: clamp(22px,3.6vw,32px); }
#combo {
  display: none; z-index: 29; font-size: 15px; font-weight: 900; color: #e8734d;
  text-shadow: 0 1px 0 #fff, 0 3px 8px rgba(232,115,77,.4);
  pointer-events: none; left: 0; top: 0; white-space: nowrap;
}

#compass {
  display: none; bottom: 26px; left: 50%; transform: translateX(-50%);
  font-size: 13px; font-weight: 800; color: #5a636e;
  background: rgba(255,255,255,.75); border-radius: 999px; padding: 7px 16px;
  pointer-events: none; letter-spacing: .08em;
}
#compass-arrow { display: inline-block; transition: transform .3s; color: #e8734d; }

/* ---------- カメラモード(js/photo.js) ---------- */
/* ⚙ の左のボタン(プレイ中だけ) */
#photo-btn {
  position: fixed; top: 14px; right: 60px; z-index: 44; touch-action: manipulation;
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0; border: none; border-radius: 50%;
  background: rgba(255,255,255,.85); box-shadow: 0 3px 10px rgba(46,55,66,.12); color: #5a636e; cursor: pointer;
}
#photo-btn:hover { background: #fff; }
/* カメラの間は ⚙・カメラボタン・fps・巻き込んだ物のラベルを隠す。UI ありのときだけ直径とタイマーを出す */
html.photo #settings, html.photo #photo-btn, html.photo #fps, html.photo #labels { display: none !important; }
html.photo-ui #hud.hidden { display: block !important; }
html.photo #hud > :not(#hud-left):not(#timer) { display: none !important; }
#photo-ui { position: fixed; inset: 0; z-index: 45; pointer-events: none; touch-action: manipulation; }
#photo-ui > button {
  position: absolute; pointer-events: auto; padding: 0; border: none; cursor: pointer;
  font: inherit; color: #fff; background: rgba(20,26,34,.45);
}
/* 3 分割線と中心の十字(DOM なので写真には入らない)。明るい空の上でも見えるよう、細い白に薄い影 */
#photo-grid { position: absolute; inset: 0; }
#photo-grid i, #photo-grid::before, #photo-grid::after {
  content: ''; position: absolute; background: rgba(255,255,255,.5); box-shadow: 0 0 2px rgba(0,0,0,.3);
}
#photo-grid i:nth-child(-n+2) { top: 0; bottom: 0; width: 1px; }
#photo-grid i:nth-child(n+3) { left: 0; right: 0; height: 1px; }
#photo-grid i:nth-child(1) { left: 33.333%; }
#photo-grid i:nth-child(2) { left: 66.667%; }
#photo-grid i:nth-child(3) { top: 33.333%; }
#photo-grid i:nth-child(4) { top: 66.667%; }
#photo-grid::before, #photo-grid::after { left: 50%; top: 50%; background: rgba(255,255,255,.85); }
#photo-grid::before { width: 26px; height: 2px; margin: -1px 0 0 -13px; }
#photo-grid::after { width: 2px; height: 26px; margin: -13px 0 0 -1px; }
/* 右上: 閉じる(⚙ と同じ白い丸)と、その左の「UI あり/なし」(タイトルのモード選びと同じ帯と札。左上は直径が出る) */
#photo-ui > #photo-close {
  top: 14px; right: 14px; width: 42px; height: 42px; border-radius: 50%; font-size: 26px; line-height: 1; color: #5a636e;
  background: rgba(255,255,255,.88); box-shadow: 0 3px 10px rgba(46,55,66,.18);
}
#photo-close:hover { background: #fff; }
#photo-uichoice {
  position: absolute; top: 14px; right: 66px; height: 42px; box-sizing: border-box; pointer-events: auto;
  display: flex; align-items: center; gap: 5px; padding: 5px 5px 5px 18px; border-radius: 999px; white-space: nowrap;
  background: rgba(251,246,236,.97); box-shadow: 0 4px 14px rgba(31,45,77,.24);
}
#photo-uichoice span { font-size: 14px; font-weight: 800; color: #1f2d4d; letter-spacing: .1em; margin-right: 7px; }
#photo-uichoice button {
  height: 100%; padding: 0 18px; border: none; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 800; letter-spacing: .06em; color: #1f2d4d;
  background: #f1eadc; box-shadow: inset 0 0 0 1.5px rgba(31,45,77,.06);
}
#photo-uichoice button[aria-pressed="true"] { background: #f2685a; color: #fff; box-shadow: 0 3px 10px rgba(242,104,90,.35); }
/* シャッター: 白い輪の中に白い丸。スマホを横に持ったカメラと同じ右端の中央(右の余白が広いのは #sling-btn と同じ理由) */
#photo-ui > #photo-shutter {
  right: 40px; top: 50%; width: 72px; height: 72px; margin-top: -36px; border-radius: 50%;
  background: transparent; border: 4px solid #fff; box-shadow: 0 3px 12px rgba(0,0,0,.3);
}
#photo-shutter i { position: absolute; inset: 5px; border-radius: 50%; background: #fff; transition: transform .08s; }
#photo-shutter:active i { transform: scale(.88); }
/* タッチの上下(キーボードは Space・Shift) */
#photo-up, #photo-down { display: none; right: 132px; width: 52px; height: 52px; border-radius: 50%; font-size: 17px; }
#photo-up { top: calc(50% - 60px); }
#photo-down { top: calc(50% + 8px); }
html.touch #photo-up, html.touch #photo-down { display: block; }
#photo-flash { position: fixed; inset: 0; z-index: 48; background: #fff; opacity: 0; pointer-events: none; }
/* 撮った写真(js/photo.js が画面と同じ大きさで置いて縮める)。白い縁と影で後ろの画面と分ける */
.photo-shot {
  position: fixed; left: 0; top: 0; z-index: 47; pointer-events: none;
  box-shadow: 0 0 0 6px #fff, 0 18px 44px rgba(0,0,0,.45);
}

/* ---------- 設定パネル ---------- */
/* z-index は .screen(40=タイトル/リザルト)より上、#bedit(46)と#loading(50)より下 */
#settings { position: fixed; top: 14px; right: 14px; z-index: 44; touch-action: manipulation; }
/* fps 表示(設定パネルの「fps 表示」)。⚙ とカメラボタンの左に並べる */
#fps {
  position: fixed; top: 22px; right: 106px; z-index: 44; pointer-events: none;
  font: 700 11px/1.6 ui-monospace, "SFMono-Regular", Menlo, monospace; font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,.85); color: #4a5560; border-radius: 999px; padding: 1px 10px;
  box-shadow: 0 3px 10px rgba(46,55,66,.12); white-space: nowrap;
}
#fps[hidden] { display: none; }
#settings-btn {
  display: block; width: 38px; height: 38px; padding: 0; border: none; border-radius: 50%;
  background: rgba(255,255,255,.85); box-shadow: 0 3px 10px rgba(46,55,66,.12);
  font-size: 18px; line-height: 1; color: #5a636e; cursor: pointer;
  transition: background .12s, transform .2s;
}
#settings-btn:hover { background: #fff; transform: rotate(35deg); }
#settings-btn[aria-expanded="true"] { background: #fff; transform: rotate(35deg); }
/* 横持ちのスマホでは画面の高さが足りないので、画面の下で切ってスクロールさせる。fixed の % は画面(強制横画面では回した body)の高さ */
#settings-panel {
  position: fixed; top: 60px; right: 14px; width: 258px;
  max-height: calc(100% - 74px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  background: rgba(250,248,244,.97); border-radius: 16px; padding: 12px 16px 14px;
  box-shadow: 0 14px 36px rgba(20,26,34,.28);
  animation: setpop .16s cubic-bezier(.2,1.4,.4,1);
}
@keyframes setpop { 0% { opacity: 0; transform: translateY(-6px) scale(.97); } 100% { opacity: 1; } }
.set-group {
  font-size: 10px; font-weight: 800; letter-spacing: .15em; color: #8a919a;
  margin: 8px 0 2px; text-transform: none;
}
.set-group:first-child, #set-run.hidden + .set-group { margin-top: 0; }
/* 一番上の「タイトルへ」「もう一回」(プレイ中だけ。main._syncPauseUi) */
#set-run { display: flex; gap: 8px; margin-bottom: 10px; }
#set-run button {
  flex: 1; height: 34px; border: none; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 800; color: #fff;
  background: linear-gradient(160deg, #4a90c2, #3a76a8); transition: transform .08s;
}
#set-run #set-title-btn { color: #4a5560; background: rgba(90,99,110,.14); }
#set-run button:active { transform: translateY(1px); }
.set-row { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.set-label { flex: 1; font-size: 13px; font-weight: 700; color: #4a5560; }
.set-val {
  flex: none; min-width: 34px; white-space: nowrap; text-align: right; font-size: 11px; font-weight: 800;
  color: #8a919a; font-variant-numeric: tabular-nums;
}
/* スライダー: トラックは7px、当たり判定は26px。塗りは --fill(JSが%で更新) */
.set-range {
  -webkit-appearance: none; appearance: none;
  flex: none; width: 96px; height: 26px; background: none; cursor: pointer; outline: none;
}
.set-range::-webkit-slider-runnable-track {
  height: 7px; border-radius: 999px;
  background: linear-gradient(90deg, #7fb6d9, #4a90c2) 0/var(--fill, 100%) 100% no-repeat, rgba(90,99,110,.22);
}
.set-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: -5px;
  width: 17px; height: 17px; border-radius: 50%; background: #fff;
  border: 3px solid #4a90c2; box-shadow: 0 1px 4px rgba(46,55,66,.3);
}
.set-range::-moz-range-track { height: 7px; border-radius: 999px; background: rgba(90,99,110,.22); }
.set-range::-moz-range-progress {
  height: 7px; border-radius: 999px; background: linear-gradient(90deg, #7fb6d9, #4a90c2);
}
.set-range::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 50%; background: #fff;
  border: 3px solid #4a90c2; box-shadow: 0 1px 4px rgba(46,55,66,.3);
}
.set-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(74,144,194,.4); }
.set-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px rgba(74,144,194,.4); }
/* 選択(言語) */
.set-select {
  flex: none; max-width: 120px; height: 26px; padding: 0 8px; border: none; border-radius: 8px;
  background: rgba(90,99,110,.12); color: #3a3f47; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.set-select:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(74,144,194,.4); }
/* トグル */
.set-switch {
  flex: none; width: 42px; height: 24px; padding: 3px; border: none; border-radius: 999px;
  background: rgba(90,99,110,.25); cursor: pointer; transition: background .15s;
}
.set-switch > i {
  display: block; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(46,55,66,.35); transition: transform .15s;
}
.set-switch[aria-checked="true"] { background: #4a90c2; }
.set-switch[aria-checked="true"] > i { transform: translateX(18px); }
.set-switch:focus-visible { box-shadow: 0 0 0 3px rgba(74,144,194,.4); }
/* トグルの状態は data-<id> でパネルに載る(settings.js の _sync)。CSSから他の行を反応させられる */
#settings-panel[data-muted="true"] #set-volume { filter: grayscale(1); opacity: .45; }

/* ---------- ワールドラベル ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 28; overflow: hidden; }
.fx-label {
  position: absolute; left: 0; top: 0; font-weight: 900; white-space: nowrap;
  transition: opacity .15s; will-change: transform;
}
.fx-grow { font-size: 14px; color: #3a76a8; text-shadow: 0 1px 0 #fff; }

/* ---------- チュートリアルの操作案内(js/keyguide.js) ---------- */
#keyguide {
  bottom: 9%; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 12px; pointer-events: none;
}
.kg-keys { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.kg-row { display: flex; align-items: center; gap: 7px; }
.kg-key {
  --w: 1;
  width: calc(48px * var(--w)); height: 48px; border-radius: 10px; display: grid; place-items: center;
  font-size: 19px; font-weight: 900; letter-spacing: .06em; color: #2e3742; background: rgba(255,255,255,.9);
  box-shadow: 0 5px 0 #aab4bf, 0 8px 16px rgba(46,55,66,.22);
  transition: transform .08s, box-shadow .08s, background .12s, color .12s;
}
.kg-key.on { background: #ffd84a; transform: translateY(4px); box-shadow: 0 1px 0 #c9a21e, 0 3px 8px rgba(46,55,66,.22); }
#keyguide.done .kg-key, #keyguide.done .kg-icon { background: #6cc283; color: #fff; }
.kg-plus { font-size: 24px; font-weight: 900; color: #fff; text-shadow: 0 2px 8px rgba(46,55,66,.45); padding: 0 2px; }
.kg-icon {
  position: relative; width: 58px; height: 58px; border-radius: 50%;
  background: rgba(255,255,255,.35); border: 2px solid rgba(255,255,255,.85); box-shadow: 0 3px 10px rgba(46,55,66,.2);
  transition: background .12s;
}
.kg-stick::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 24px; height: 24px; margin: -12px 0 0 -12px;
  border-radius: 50%; background: rgba(255,255,255,.9);
}
.kg-icon.on { background: #ffd84a; }
/* マウス(ボタンの境の線と左ボタン)と、ドラッグする指の絵 */
.kg-mouse { width: 40px; height: 58px; border-radius: 20px 20px 18px 18px; background: rgba(255,255,255,.9); border-color: #aab4bf; }
.kg-mouse::before { content: ''; position: absolute; left: 50%; top: 0; width: 2px; height: 22px; margin-left: -1px; background: #aab4bf; }
.kg-mouse::after { content: ''; position: absolute; left: 0; top: 0; width: 50%; height: 22px; border-radius: 18px 0 0 0; background: rgba(46,55,66,.18); }
.kg-drag::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border-radius: 50%; background: rgba(255,255,255,.9);
}
.kg-caption {
  font-size: clamp(14px, 2.1vw, 18px); font-weight: 800; letter-spacing: .06em; white-space: nowrap; color: #2e3742;
  background: rgba(255,255,255,.9); border-radius: 999px; padding: 7px 20px; box-shadow: 0 6px 18px rgba(46,55,66,.18);
}
.kg-done {
  display: none; position: absolute; left: 50%; top: -42px; transform: translateX(-50%);
  font-size: 20px; font-weight: 900; letter-spacing: .12em; color: #fff; background: #4fae69;
  border-radius: 999px; padding: 5px 18px; box-shadow: 0 6px 16px rgba(46,55,66,.25); white-space: nowrap;
}
#keyguide.done .kg-done { display: block; animation: kgpop .3s cubic-bezier(.2,1.6,.4,1); }
@keyframes kgpop { 0% { transform: translateX(-50%) scale(.6); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }

/* ---------- スティック ---------- */
#stick {
  display: none; position: fixed; z-index: 32; width: 120px; height: 120px;
  border-radius: 50%; background: rgba(255,255,255,.16);
  border: 2px solid rgba(255,255,255,.5); pointer-events: none;
}
#stick-knob {
  position: absolute; left: 34px; top: 34px; width: 52px; height: 52px;
  border-radius: 50%; background: rgba(255,255,255,.75);
  box-shadow: 0 3px 10px rgba(46,55,66,.25);
}
/* タッチの Space ボタン(#hud の中なのでプレイ中だけ)。右の余白が広いのは、強制横画面では右の縁が
   端末の上(ノッチ・ステータスバー)か下(ホームインジケータ)になり、セーフエリアに未対応だから */
#sling-btn {
  display: none; right: 56px; bottom: 28px; width: 76px; height: 76px;
  border-radius: 50%; background: rgba(255,255,255,.28);
  border: 2px solid rgba(255,255,255,.6); box-shadow: 0 3px 10px rgba(46,55,66,.18);
  transition: transform .08s, background .08s;
}
#sling-btn.held { transform: scale(.92); background: rgba(255,255,255,.6); }
html.touch #sling-btn { display: block; }   /* タッチ端末(js/platform.js TOUCH_DEVICE) */

/* ---------- 地図で開始地点を選ぶ画面(js/stagemap.js)。下の 3D の画面は雲の中なので、雲の板の色の地(js/stagemap.js が
   置く)から地図を溶かして出し、選んだら地の色へ戻す。ホイール・ドラッグ・二本指で拡大縮小と移動(ブラウザの拡大・スクロールは止める) ---------- */
#stage-map { z-index: 41; background: #fff; overflow: hidden; }
.sm-content { position: absolute; inset: 0; opacity: 0; transition: opacity .6s; touch-action: none; cursor: grab; }
.sm-content.dragging { cursor: grabbing; }
#stage-map.in .sm-content { opacity: 1; }
#stage-map.out .sm-content { opacity: 0; transition-duration: .5s; }
#stage-map.gone { opacity: 0; transition: opacity .6s; }
.sm-map { position: absolute; inset: 0; width: 100%; height: 100%; }
.sm-pins { position: absolute; inset: 0; pointer-events: none; }
.sm-pin {
  position: absolute; left: 0; top: 0; margin: -11px 0 0 -11px; padding: 0; border: none; background: none; font: inherit;
  display: flex; align-items: center; gap: 6px; cursor: pointer; pointer-events: auto;
}
.sm-dot {
  box-sizing: border-box; width: 22px; height: 22px; border-radius: 50%; background: #e8734d; border: 3px solid #fff;
  box-shadow: 0 3px 10px rgba(46,55,66,.35); transition: transform .12s;
}
.sm-label {
  font-size: clamp(14px, 2vw, 18px); font-weight: 800; letter-spacing: .06em; white-space: nowrap; color: #2e3742;
  background: rgba(255,255,255,.92); border-radius: 999px; padding: 4px 14px; box-shadow: 0 4px 12px rgba(46,55,66,.18);
}
.sm-pin:not(.locked):hover .sm-dot { transform: scale(1.25); }
.sm-pin.chosen .sm-dot { animation: smpulse .5s ease-out infinite; }
@keyframes smpulse { 0% { box-shadow: 0 0 0 0 rgba(232,115,77,.7); } 100% { box-shadow: 0 0 0 18px rgba(232,115,77,0); } }
.sm-pin.locked { cursor: not-allowed; }
.sm-pin.locked .sm-dot { background: #a0a8b0; }
.sm-pin.locked .sm-label { color: #8a939c; }
.sm-title {
  position: absolute; top: 7%; left: 50%; transform: translateX(-50%); pointer-events: none; white-space: nowrap;
  font-size: clamp(20px, 3.4vw, 32px); font-weight: 900; letter-spacing: .12em; color: #2e3742;
  background: rgba(255,255,255,.88); border-radius: 999px; padding: 8px 28px; box-shadow: 0 8px 26px rgba(46,55,66,.18);
}

/* ---------- リザルト ---------- */
#result { background: rgba(46,55,66,.45); backdrop-filter: blur(6px); }
.result-inner {
  background: rgba(250,248,244,.97); border-radius: 22px; padding: 26px 30px;
  width: min(680px, 92vw); max-height: 92vh; overflow: auto; text-align: center;
  box-shadow: 0 24px 60px rgba(20,26,34,.35);
}
.rank {
  display: inline-block; font-size: 64px; font-weight: 900; line-height: 1;
  width: 96px; height: 96px; border-radius: 50%; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 8px; transform: rotate(-8deg);
  animation: stamp .4s cubic-bezier(.2,1.8,.4,1);
}
@keyframes stamp { 0% { transform: rotate(-8deg) scale(2.4); opacity: 0; } 60% { opacity: 1; } 100% { transform: rotate(-8deg) scale(1); } }
.rank-S { background: #e8b23d; box-shadow: 0 0 0 6px rgba(232,178,61,.35); }
.rank-A { background: #e8734d; }
.rank-B { background: #4a90c2; }
.rank-C { background: #8fa3b8; }
.rank-D { background: #9aa0a6; }
#result h2 { font-size: clamp(18px, 3vw, 24px); font-weight: 900; color: #2e3742; margin-bottom: 4px; }
.best-update { color: #b8860b; font-weight: 800; font-size: 14px; min-height: 1.3em; margin-bottom: 10px; }
.result-cols { display: flex; gap: 20px; text-align: left; margin-bottom: 18px; }
.result-cols > * { flex: 1; min-width: 0; }
#result-stats { max-height: 240px; overflow: auto; }
.stat-row {
  display: flex; justify-content: space-between; font-size: 13px; font-weight: 700;
  padding: 5px 10px; border-radius: 8px; color: #4a5560;
}
.stat-row:nth-child(odd) { background: rgba(74,144,194,.08); }
.result-right h3 {
  font-size: 12px; letter-spacing: .15em; color: #8a919a; margin-bottom: 6px;
}
#result-chart { width: 100%; height: 130px; background: rgba(74,144,194,.06); border-radius: 10px; }
.result-btns { display: flex; gap: 12px; justify-content: center; align-items: center; }

/* ---------- クレジット(js/credits.js) ---------- */
/* z-index は ⚙(44)・#debug(45)・#bedit(46)より上、#loading(50)より下。画面を覆うので、開いている間は ⚙ を
   押せない(設定パネルとは同時に開かない)。**大きさは vw/vh で決めない** — 縦持ちのスマホで body を回すと vw/vh は
   回す前の向きを指す。.screen(inset:0 で回した箱を満たす)の % で決める */
#credits { z-index: 47; padding: 16px; background: rgba(46,55,66,.45); backdrop-filter: blur(6px); }
.credits-inner {
  display: flex; flex-direction: column; width: 100%; max-width: 760px; max-height: 100%; margin: auto;
  background: rgba(250,248,244,.98); border-radius: 18px; box-shadow: 0 24px 60px rgba(20,26,34,.35);
  -webkit-user-select: text; user-select: text;   /* 出典と URL を写せるように(body は選択不可) */
}
.credits-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none;
  padding: 14px 18px 10px; border-bottom: 1px solid rgba(90,99,110,.15);
}
.credits-head h2 { font-size: 17px; font-weight: 900; letter-spacing: .12em; color: #2e3742; }
#credits-close { padding: 7px 18px; background: rgba(90,99,110,.1); }
#credits-body { overflow: auto; min-height: 0; padding: 12px 20px 18px; overscroll-behavior: contain; }
.credits-lead { font-size: 13px; font-weight: 700; color: #3a3f47; margin-bottom: 10px; }
.credits-sec h3 { font-size: 11px; font-weight: 800; letter-spacing: .15em; color: #8a919a; margin: 18px 0 6px; }
.credits-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.credits-extra { margin-top: 8px; }
.credits-list li { font-size: 12.5px; line-height: 1.55; color: #3a3f47; overflow-wrap: anywhere; }
.credits-detail, .credits-links { display: block; font-size: 11px; line-height: 1.5; color: #6a7078; }
.credits-links a { color: #3a76a8; }

/* ---------- ショップ(js/shop.js) ---------- */
/* 枠はクレジットと同じ流儀(z-index 47・大きさは % で決める・中身だけスクロール)。開いているのはどちらか一方 */
#shop { z-index: 47; padding: 16px; background: rgba(46,55,66,.45); backdrop-filter: blur(6px); }
.shop-inner {
  display: flex; flex-direction: column; width: 100%; max-width: 640px; max-height: 100%; margin: auto;
  background: rgba(250,248,244,.98); border-radius: 18px; box-shadow: 0 24px 60px rgba(20,26,34,.35);
}
.shop-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none;
  padding: 14px 18px 10px; border-bottom: 1px solid rgba(90,99,110,.15);
}
.shop-head h2 { font-size: 17px; font-weight: 900; letter-spacing: .12em; color: #2e3742; }
#shop-close { padding: 7px 18px; background: rgba(90,99,110,.1); }
#shop-body { overflow: auto; min-height: 0; padding: 12px 20px 20px; overscroll-behavior: contain; }
.shop-sec h3 { font-size: 11px; font-weight: 800; letter-spacing: .15em; color: #8a919a; margin: 4px 0 10px; }
.skin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.skin-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px 10px;
  border: 2px solid rgba(90,99,110,.15); border-radius: 16px; background: #fff; cursor: pointer;
  font: inherit; color: #3a3f47; transition: transform .08s, border-color .12s, box-shadow .12s;
}
.skin-card:hover:not(:disabled) { transform: translateY(-1px); }
.skin-card.equipped { border-color: #e8734d; box-shadow: 0 3px 12px rgba(232,115,77,.3); }
.skin-card.locked { cursor: default; background: rgba(255,255,255,.5); }
.skin-preview { width: 76px; height: 76px; }   /* js/shop.js PREVIEW_CSS_PX */
.skin-name { font-size: 13px; font-weight: 800; letter-spacing: .04em; }
.skin-card.locked .skin-name { color: #8a919a; }
.skin-state { font-size: 11px; font-weight: 700; color: #6a7078; }
.skin-card.equipped .skin-state { color: #e8734d; }

/* ---------- デバッグ ---------- */
#debug {
  display: none; position: fixed; bottom: 8px; left: 8px; z-index: 45;
  font: 11px/1.5 ui-monospace, monospace; color: #2e3742;
  background: rgba(255,255,255,.8); padding: 5px 9px; border-radius: 6px;
  pointer-events: none;   /* ?edit でも出るので、クリックは下の画面へ通す(HUD の下の棟も選べる) */
}
@media (max-width: 700px) {
  .result-cols { flex-direction: column; }
}

/* ---------- タイトル ----------
   並べ方は index.html の #title の説明。文字を読ませる洗いは掛けない(ロゴは縁取り、帯とボタンは不透明)。ロゴの幅・ロゴと帯の
   高さ・帯の縮め方は js/main.js _resize が論理サイズから入れる(回した画面では vw・vh が端末の縦横を指す) */
#title { display: block; overflow: hidden; }
.title-logo {
  position: absolute; left: 50%; top: var(--title-logo-top, 20%); transform: translateX(-50%);
  width: var(--title-logo-w, 520px); pointer-events: none;
}
.title-logo img { display: block; width: 100%; height: auto; }
.title-shop {
  position: absolute; top: 14px; left: 14px;   /* 右上の ⚙(#settings)と高さを揃える */
  display: flex; align-items: center; gap: 8px;
  border: none; cursor: pointer; font: inherit; font-size: 15px; font-weight: 800; letter-spacing: .1em; color: #1f2d4d;
  background: #fbf6ec; border-radius: 999px; padding: 9px 22px 9px 16px;
  box-shadow: 0 4px 14px rgba(31,45,77,.2);
  transition: transform .08s;
}
.title-shop:active { transform: translateY(2px); }
.title-shop-icon { width: 20px; height: 20px; }
.title-bar {   /* ロゴのすぐ下。狭い画面は帯ごと縮める(--title-bar-k) */
  position: absolute; left: 50%; top: var(--title-bar-top, 62%); transform: translateX(-50%) scale(var(--title-bar-k, 1)); transform-origin: 50% 0;
  display: flex; align-items: center; gap: 14px; white-space: nowrap;
  background: rgba(251,246,236,.97); border-radius: 999px; padding: 10px 10px 10px 28px;
  box-shadow: 0 8px 28px rgba(31,45,77,.24);
}
#start-mode { display: flex; align-items: center; gap: 8px; }
.title-bar .choice-label { font-size: 16px; font-weight: 800; color: #1f2d4d; letter-spacing: .1em; margin-right: 8px; }
.title-bar .choice-chip {
  border: none; font-size: 17px; font-weight: 800; color: #1f2d4d; letter-spacing: .06em;
  background: #f1eadc; padding: 10px 24px; box-shadow: inset 0 0 0 1.5px rgba(31,45,77,.06);
}
.title-bar .choice-chip.sel { background: #f2685a; color: #fff; box-shadow: 0 3px 10px rgba(242,104,90,.35); }
.title-bar-sep { width: 1.5px; align-self: stretch; margin: 8px 4px; background: rgba(31,45,77,.14); }
.title-bar.no-mode { padding: 10px; }   /* 体験版: モードを出さずスタートだけ(js/ui.js fixMode) */
.title-bar.no-mode #start-mode, .title-bar.no-mode .title-bar-sep { display: none; }
.title-start {
  display: flex; align-items: center; gap: 14px;
  border: none; cursor: pointer; font: inherit; font-size: 21px; font-weight: 900; letter-spacing: .16em; color: #fff;
  background: linear-gradient(180deg, #3592f6, #1769e0); border-radius: 999px; padding: 14px 44px 14px 34px;
  box-shadow: 0 5px 0 #0f4fae, 0 10px 22px rgba(23,105,224,.35);
  transition: transform .08s, box-shadow .08s;
}
.title-start::before {   /* ▶ */
  content: ''; border-left: .8em solid #fff; border-top: .5em solid transparent; border-bottom: .5em solid transparent;
}
.title-start:active { transform: translateY(4px); box-shadow: 0 1px 0 #0f4fae, 0 4px 12px rgba(23,105,224,.3); }
.title-credits {   /* 文字は帯の「モード」と同じ大きさ(帯と一緒に縮む) */
  position: absolute; right: 22px; bottom: 16px;
  border: none; background: none; cursor: pointer; font: inherit; font-size: calc(16px * var(--title-bar-k, 1)); font-weight: 800; letter-spacing: .1em;
  color: #fff; text-decoration: underline; text-underline-offset: 6px; text-shadow: 0 1px 4px rgba(20,30,50,.55);
}
/* 縦長の窓は帯を 2 段に折り返す */
body.narrow-view .title-bar { flex-wrap: wrap; justify-content: center; white-space: normal; border-radius: 28px; padding: 12px; }
body.narrow-view .title-bar-sep { display: none; }

.choice-label { font-size: 12px; font-weight: 700; color: #6a7078; margin-right: 2px; letter-spacing: .08em; white-space: nowrap; }
.choice-chip {
  border: 2px solid rgba(90,99,110,.25); cursor: pointer; font: inherit; white-space: nowrap;
  font-size: 13px; font-weight: 700; color: #5a636e;
  background: rgba(255,255,255,.75); border-radius: 999px; padding: 6px 14px;
  transition: transform .08s, background .12s, border-color .12s;
}
.choice-chip:hover { transform: translateY(-1px); }
.choice-chip.sel {
  background: #e8734d; border-color: #e8734d; color: #fff;
  box-shadow: 0 3px 10px rgba(232,115,77,.35);
}
