:root { color-scheme: light; font-family: system-ui, sans-serif; }
body { margin: 0; background: #F3F8FE; color: #243247; text-align: center; line-height: 1.8; }
main { margin: 1.25rem auto 2.5rem; max-width: 900px; padding: 0 1rem; }

/* --- M4d-PUB-UI: タイトル・サブタイトル・作者サイトへのリンク（ページ右上） --- */
.page-header { position: relative; padding: .4rem 0 1rem; border-bottom: 1px solid #D8E4F0; }
.game-title { margin: .2rem 0 .4rem; color: #234C73; font-size: clamp(1.45rem, 4.6vw, 2.1rem); letter-spacing: .04em; }
.game-subtitle { margin: 0 auto; max-width: 34rem; color: #41536B; font-size: .98rem; }
.author-link { position: absolute; top: .3rem; right: 0; display: inline-block; padding: .3rem .8rem; border: 1px solid #D8E4F0; border-radius: 999px; background: #FFFFFF; color: #1763A6; font-size: .84rem; line-height: 1.5; text-decoration: none; }
.author-link:hover { background: #E7F1FB; border-color: #9CC4E4; text-decoration: underline; }
.author-link:focus-visible { outline: 3px solid #1668B2; outline-offset: 2px; }

canvas { display: block; width: 100%; max-width: 800px; height: auto; margin: 1.25rem auto; background: #080a16; border: 1px solid #B7D3EA; border-radius: 14px; box-shadow: 0 6px 18px rgba(35, 76, 115, 0.1); }
canvas:focus-visible { outline: 3px solid #1668B2; outline-offset: 2px; }
.controls { display: flex; gap: .75rem; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.controls button { font: inherit; letter-spacing: .04em; padding: .55rem 1.4rem; border-radius: 10px; border: 1px solid #1668B2; background: #1668B2; color: #FFFFFF; cursor: pointer; }
.controls button:hover:not(:disabled) { background: #12568F; border-color: #12568F; }
.controls button:focus-visible { outline: 3px solid #234C73; outline-offset: 2px; }
.controls button:disabled { opacity: .5; cursor: not-allowed; }
/* 主要ボタン（スタート・一時停止）だけ塗りつぶし、「最初から」「続投」は白地の補助ボタンにする */
#restart-btn,
#continue-btn { background: #FFFFFF; border-color: #9CC4E4; color: #16466E; }
#restart-btn:hover:not(:disabled),
#continue-btn:hover:not(:disabled) { background: #E7F1FB; }
#status { min-height: 1.4em; max-width: 44rem; margin: .4rem auto 0; color: #2F4560; }
#status, .howto { overflow-wrap: anywhere; }

/* --- 設定欄（難易度・ゲームモード・背景。白地のチップ状にしてホバーとフォーカスを出す） --- */
.modes { display: flex; gap: 1rem; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: .9rem; color: #243247; }
.modes + .modes { margin-top: .5rem; }
.modes-label { font-size: .85rem; font-weight: 700; letter-spacing: .1em; color: #234C73; }
.mode-option { display: inline-flex; gap: .4rem; align-items: center; cursor: pointer; padding: .22rem .7rem; border: 1px solid #D8E4F0; border-radius: 999px; background: #FFFFFF; color: #243247; font-size: .92rem; }
.mode-option:hover { background: #E7F1FB; border-color: #9CC4E4; }
.mode-option input { accent-color: #1668B2; }
.mode-option:has(input:checked) { border-color: #1668B2; color: #16466E; font-weight: 600; }
.mode-option:has(input:focus-visible) { outline: 3px solid #1668B2; outline-offset: 2px; }
.mode-option:has(input:disabled) { opacity: .55; cursor: not-allowed; background: #EAF1F8; color: #4F6076; }
.controls button[hidden] { display: none; }

/* --- 効果音の ON / OFF（操作ボタン・難易度選択とは別の行に置く） --- */
.sound-bar { display: flex; gap: .75rem; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 1rem; color: #243247; }
.sound-bar-label { font-size: .85rem; font-weight: 700; letter-spacing: .1em; color: #234C73; }
.sound-bar-note { font-size: .78rem; color: #4F6076; }
#sound-btn { font: inherit; letter-spacing: .04em; padding: .35rem 1.05rem; border-radius: 10px; border: 1px solid #9CC4E4; background: #FFFFFF; color: #16466E; cursor: pointer; }
#sound-btn:hover:not(:disabled) { background: #E7F1FB; }
#sound-btn:focus-visible { outline: 3px solid #1668B2; outline-offset: 2px; }
#sound-btn.sound-off { color: #4F6076; border-style: dashed; }
#sound-btn:disabled { opacity: .55; cursor: not-allowed; }

/* --- M4b-HISCORE: 最高獲得金額（難易度 × モードの6区分を localStorage に保存） --- */
.hiscore { margin: .5rem auto 0; max-width: 46rem; color: #8A5A00; font-weight: 600; letter-spacing: .02em; overflow-wrap: anywhere; }
.hiscore.new-record { color: #B54708; }


/* --- M4c-TRAIL-BG-2a: 背景テーマ選択（背景 行。4種を radio、B キーでも切り替え） --- */
.themes .mode-option { font-size: .9rem; }
.themes-note { font-size: .78rem; color: #4F6076; letter-spacing: .02em; overflow-wrap: anywhere; }
/* 盤面外（ページ地色と盤面のふち）だけテーマの差し色に寄せる。盤面の中は Canvas がそのまま描く。 */
body[data-theme="vegas"] { background: #FDF3F8; }
body[data-theme="hawaii"] { background: #FFF6EC; }
body[data-theme="space"] { background: #EEF5FD; }
body[data-theme="vegas"] canvas { border-color: #F07CB8; }
body[data-theme="hawaii"] canvas { border-color: #E8944A; }
body[data-theme="space"] canvas { border-color: #6FA8DC; }

/* --- M4d-PUB-UI: あそびかた（白地の説明エリア。行間を広めて子どもにも読みやすく） --- */
.howto { margin: 1.4rem auto 0; padding: 1rem 1.15rem 1.1rem; border: 1px solid #D8E4F0; border-radius: 14px; background: #FFFFFF; color: #243247; font-size: .95rem; line-height: 1.9; text-align: left; }
.howto-title { margin: 0 0 .5rem; color: #234C73; font-size: 1.05rem; letter-spacing: .04em; }
.howto p { margin: 0 0 .65rem; }
.key-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .3rem .9rem; margin: 0 0 .7rem; padding: 0; list-style: none; }
.key-name { display: inline-block; min-width: 3.4em; margin-right: .45rem; padding: 0 .4rem; border: 1px solid #D8E4F0; border-radius: 6px; background: #F3F8FE; color: #16466E; font-size: .84rem; font-weight: 700; text-align: center; }
.howto .time-note { margin: 0; padding-top: .7rem; border-top: 1px dashed #D8E4F0; color: #3B4C63; }

/* --- M4d-PUB-UI: 狭い画面（作者リンクをタイトルの上へ出し、ボタンと文字が重ならないようにする） --- */
@media (max-width: 720px) {
  main { padding: 0 .75rem; }
  .page-header { padding-top: .25rem; }
  .author-link { position: static; margin: 0 0 .7rem; }
  .game-subtitle { font-size: .94rem; }
  .modes { gap: .45rem; }
  .mode-option { font-size: .88rem; padding: .2rem .6rem; }
  .controls { gap: .5rem; }
  .controls button { padding: .5rem 1rem; }
  .howto { padding: .85rem .8rem .9rem; font-size: .92rem; }
}
