/* ゲームの「まわり」(トップページ、タイトル・結果・ランキング・設定などの画面) の共通デザイン。
   ゲーム本体 (キャンバス、プレイ中の HUD と操作ボタン) は nintendo-design.md。
   もとはマテリアルデザイン 3 だったので、クラス名 (.m3-*) と色の変数名 (--md-*) はそのまま残している。

   決めたこと (理由は nintendo-design.md の「シェル」):
   - 色は4つだけ。白い紙 / 墨 (文字と太い縁) / ひよこ黄 (いちばん押してほしいボタン。cheep = ひよこの鳴き声) / 赤 (エラー)
   - 字は M PLUS Rounded 1c ひとつ。太さの差 (500 と 900) で強弱をつける
   - 面は白地に墨の太い縁。影は真下にずらした墨のベタ1枚だけ。押すとその分沈む
   - グラデーション、ぼかした影、半透明のすりガラス、波紋 (ripple)、ダークモードは使わない
   アイコンは Material Symbols を使う分だけ読む。増やすときは icon_names にアルファベット順で足す。 */
@import url("https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@500;700;800;900&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,500,1,0&icon_names=add_photo_alternate,agriculture,arrow_back,arrow_downward,arrow_upward,beach_access,block,brush,bubble_chart,camping,candle,castle,celebration,check,check_circle,chevron_right,child_care,child_friendly,close,coffee,construction,content_copy,content_cut,cooking,cottage,dark_mode,delete,deployed_code,directions_car,directions_run,directions_walk,diversity_1,download,edit,edit_note,elderly,emoji_events,face,family_restroom,favorite,fitness_center,flag,flight,fullscreen,grid_view,group,groups,handshake,heart_broken,help,highlight,home,hourglass_empty,icecream,image,info,ios_share,language,layers,leaderboard,light_mode,link,local_florist,local_hospital,local_pizza,local_taxi,location_city,luggage,mail,map,menu,menu_book,moving,music_note,newspaper,open_in_new,outdoor_grill,paid,palette,park,pause,person,pest_control_rodent,pets,phishing,photo_camera,photo_library,piano,play_arrow,public,radio_button_unchecked,ramen_dining,refresh,replay,restart_alt,restaurant,rocket_launch,sailing,savings,school,screen_rotation,search,self_improvement,send,sentiment_dissatisfied,sentiment_neutral,sentiment_satisfied,sentiment_very_dissatisfied,sentiment_very_satisfied,set_meal,share,sick,skip_next,speed,sports_esports,sports_soccer,stacks,storefront,toys_fan,travel_explore,trending_up,tune,undo,verified,verified_user,view_in_ar,visibility,volume_off,volume_up,volunteer_activism,water_drop,weekend,work,work_off,workspace_premium,yard&display=block");

:root {
  /* 4色。ほかの変数はぜんぶここから作る */
  --cg-paper: #ffffff;
  --cg-ink: #17150f;
  --cg-chick: #ffd21f;
  --cg-red: #d7261e;
  --cg-ink-soft: #5e5a50;   /* 補足の文字 */
  --cg-wash: #f1f0ec;       /* 紙の地より一段下げた面 (リストのしま、無効のボタン) */
  --cg-chick-wash: #fff3bf; /* 自分の行 */
  --cg-line: 3px;           /* 太い縁 */
  --cg-drop: 4px;           /* 押せる物の厚み */

  --md-font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", system-ui, sans-serif;
  /* ゲームの CSS が文字色に使うので、primary は読める墨にしておく。黄色は塗りだけに使う */
  --md-primary: var(--cg-ink);
  --md-on-primary: var(--cg-ink);
  --md-primary-container: var(--cg-chick);
  --md-on-primary-container: var(--cg-ink);
  --md-secondary: var(--cg-ink);
  --md-on-secondary: var(--cg-paper);
  --md-secondary-container: var(--cg-wash);
  --md-on-secondary-container: var(--cg-ink);
  --md-tertiary: var(--cg-ink);
  --md-on-tertiary: var(--cg-paper);
  --md-tertiary-container: var(--cg-chick);
  --md-on-tertiary-container: var(--cg-ink);
  --md-error: var(--cg-red);
  --md-on-error: #ffffff;
  --md-error-container: #ffe1dc;
  --md-on-error-container: #6e0b06;
  --md-surface: var(--cg-paper);
  --md-surface-container-lowest: var(--cg-paper);
  --md-surface-container-low: var(--cg-paper);
  --md-surface-container: var(--cg-wash);
  --md-surface-container-high: var(--cg-paper);
  --md-surface-container-highest: var(--cg-wash);
  --md-on-surface: var(--cg-ink);
  --md-on-surface-variant: var(--cg-ink-soft);
  --md-outline: var(--cg-ink);
  --md-outline-variant: #d6d4cc;
  --md-inverse-surface: var(--cg-ink);
  --md-inverse-on-surface: var(--cg-paper);
  --md-inverse-primary: var(--cg-chick);
  --md-scrim: var(--cg-ink);
}

/* ---------- 文字 ----------
   見出しと数字は 900、本文は 500。中間の太さはあまり使わない */
.m3-display-large   { font: 900 56px/1.1 var(--md-font); letter-spacing: -.01em; }
.m3-display-medium  { font: 900 44px/1.1 var(--md-font); letter-spacing: -.01em; }
.m3-display-small   { font: 900 36px/1.15 var(--md-font); }
.m3-headline-large  { font: 900 30px/1.25 var(--md-font); }
.m3-headline-medium { font: 900 26px/1.3 var(--md-font); }
.m3-headline-small  { font: 900 22px/1.35 var(--md-font); }
.m3-title-large     { font: 800 20px/1.4 var(--md-font); }
.m3-title-medium    { font: 800 16px/1.5 var(--md-font); }
.m3-title-small     { font: 800 14px/1.45 var(--md-font); }
.m3-body-large      { font: 500 16px/1.6 var(--md-font); }
.m3-body-medium     { font: 500 14px/1.6 var(--md-font); }
.m3-body-small      { font: 500 12px/1.5 var(--md-font); }
.m3-label-large     { font: 800 14px/1.4 var(--md-font); }
.m3-label-medium    { font: 800 12px/1.35 var(--md-font); }
.m3-variant { color: var(--md-on-surface-variant); }
.m3-num { font-variant-numeric: tabular-nums; }

.m3-icon { font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal; font-size: 24px;
  line-height: 1; letter-spacing: normal; text-transform: none; white-space: nowrap; direction: ltr;
  display: inline-block; flex: none; -webkit-font-feature-settings: "liga"; font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased; user-select: none; }

/* ---------- 面 ----------
   .m3-scrim は表示/非表示 (display) を決めない。ゲーム側の .on や hidden の切り替えをそのまま使い、
   表示するときは display: flex にする */
.m3-scrim { position: fixed; inset: 0; z-index: 50; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgb(23 21 15 / .5); }
/* ダイアログは白い紙1枚。縁と真下の影は墨 */
.m3-dialog { position: relative; width: 100%; max-width: 400px; max-height: calc(100% - var(--cg-drop)); overflow: auto;
  padding: 24px 20px 20px; border: var(--cg-line) solid var(--cg-ink); border-radius: 18px;
  box-shadow: 0 6px 0 var(--cg-ink); background: var(--cg-paper); color: var(--cg-ink);
  font: 500 15px/1.6 var(--md-font); -webkit-user-select: none; user-select: none; }
.m3-dialog p { margin: 10px 0 0; }
/* 見出しの上に飾りのアイコンを置かない (書いてあっても出さない) */
.m3-dialog > .m3-icon:first-child { display: none; }
.m3-card { border: var(--cg-line) solid var(--cg-ink); border-radius: 14px; padding: 16px; background: var(--cg-paper);
  color: var(--cg-ink); font-family: var(--md-font); }
.m3-card.outlined { border-width: 2px; }
.m3-sheet { border-top: var(--cg-line) solid var(--cg-ink); border-radius: 18px 18px 0 0; padding: 16px 20px max(20px, env(safe-area-inset-bottom));
  background: var(--cg-paper); color: var(--cg-ink); font-family: var(--md-font); }
.m3-divider { height: 2px; border: 0; margin: 16px 0; background: var(--cg-ink); }

/* ---------- ボタン ----------
   押せる物は厚み (真下の墨1枚) があって、押すとその分沈む */
.m3-btn, .m3-icon-btn, .m3-fab { position: relative; appearance: none; border: 0; margin: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; text-decoration: none;
  font: 800 15px/1.2 var(--md-font); white-space: nowrap; -webkit-tap-highlight-color: transparent;
  outline: none; touch-action: manipulation; transition: transform .06s, box-shadow .06s, background-color .1s; }
.m3-btn:focus-visible, .m3-icon-btn:focus-visible, .m3-fab:focus-visible, .m3-segmented > button:focus-visible {
  outline: 3px solid var(--cg-ink); outline-offset: 3px; }

/* 文字だけのボタン (やめる・とじる) */
.m3-btn { height: 44px; padding: 0 14px; border-radius: 12px; background: transparent; color: var(--cg-ink); }
.m3-btn > .m3-icon { font-size: 20px; margin-left: -2px; }
@media (hover: hover) { .m3-btn:not(.filled):not(.tonal):hover { background: var(--cg-wash); } }
.m3-btn:not(.filled):not(.tonal):active { background: var(--cg-wash); }
/* filled = 画面でいちばん押してほしいもの (ひよこ黄)。tonal = その次 (白) */
.m3-btn.filled, .m3-btn.tonal, .m3-fab, .m3-icon-btn.filled, .m3-icon-btn.tonal {
  border: var(--cg-line) solid var(--cg-ink); box-shadow: 0 var(--cg-drop) 0 var(--cg-ink); margin-bottom: var(--cg-drop); }
.m3-btn.filled, .m3-fab, .m3-icon-btn.filled { background: var(--cg-chick); color: var(--cg-ink); }
.m3-btn.tonal, .m3-icon-btn.tonal { background: var(--cg-paper); color: var(--cg-ink); }
.m3-btn.filled:active, .m3-btn.tonal:active, .m3-fab:active, .m3-icon-btn.filled:active, .m3-icon-btn.tonal:active {
  transform: translateY(var(--cg-drop)); box-shadow: 0 0 0 var(--cg-ink); }
/* outlined = 並べるだけの選択肢。厚みはつけない */
.m3-btn.outlined { border: 2px solid var(--cg-ink); }
.m3-btn.text { padding: 0 10px; }
.m3-btn.lg { height: 58px; padding: 0 26px; border-radius: 16px; font-size: 18px; font-weight: 900; }
.m3-btn.lg > .m3-icon { font-size: 26px; }
.m3-btn.block { display: flex; width: 100%; }
.m3-btn:disabled, .m3-btn[aria-disabled="true"] { cursor: default; pointer-events: none; color: #a9a59a; box-shadow: none;
  transform: none; }
.m3-btn.filled:disabled, .m3-btn.tonal:disabled { background: var(--cg-wash); border-color: #c9c6bc; box-shadow: 0 var(--cg-drop) 0 #c9c6bc; }
.m3-btn.outlined:disabled { border-color: #c9c6bc; }

.m3-icon-btn { width: 44px; height: 44px; padding: 0; border-radius: 12px; background: transparent; color: var(--cg-ink); }
@media (hover: hover) { .m3-icon-btn:not(.filled):not(.tonal):hover { background: var(--cg-wash); } }
.m3-icon-btn.surface { background: var(--cg-paper); border: 2px solid var(--cg-ink); }
.m3-icon-btn:disabled { pointer-events: none; color: #a9a59a; }

.m3-fab { height: 58px; min-width: 58px; padding: 0 18px; border-radius: 16px; }

/* ボタンの並び。縦に積むときは .col */
.m3-actions { display: flex; gap: 10px; margin-top: 20px; align-items: flex-start; }
.m3-actions > .m3-btn { flex: 1; }
.m3-actions.col { flex-direction: column; align-items: stretch; }
.m3-actions.col > .m3-btn { flex: none; }
.m3-actions.end { justify-content: flex-end; }
.m3-actions.end > .m3-btn { flex: none; }

/* セグメントボタン。選ばれているものに .on か aria-pressed="true"。選ばれたものは墨で塗る */
.m3-segmented { display: flex; border: 2px solid var(--cg-ink); border-radius: 12px; overflow: hidden; }
.m3-segmented > button { position: relative; flex: 1; appearance: none; margin: 0; height: 40px; padding: 0 12px;
  border: 0; border-left: 2px solid var(--cg-ink); background: var(--cg-paper); color: var(--cg-ink);
  font: 800 14px/1 var(--md-font); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.m3-segmented > button:first-child { border-left: 0; }
.m3-segmented > button.on, .m3-segmented > button[aria-pressed="true"] { background: var(--cg-ink); color: var(--cg-paper); }

/* ---------- 入力 ---------- */
.m3-input { box-sizing: border-box; height: 52px; min-width: 0; padding: 0 14px; border: 2px solid var(--cg-ink); border-radius: 12px;
  outline: none; background: var(--cg-paper); color: var(--cg-ink); font: 700 17px/1.4 var(--md-font);
  caret-color: var(--cg-ink); -webkit-user-select: text; user-select: text; }
.m3-input::placeholder { color: #9b978c; opacity: 1; font-weight: 500; }
.m3-input:focus { border-width: 3px; padding: 0 13px; }
textarea.m3-input { height: auto; padding: 14px; resize: none; }
textarea.m3-input:focus { padding: 13px; }
.m3-slider { width: 100%; accent-color: var(--cg-ink); }

/* 入力 + ボタンを1行に (ランキングの名前登録など) */
.m3-field-row { display: flex; gap: 8px; align-items: flex-start; }
.m3-field-row > .m3-input { flex: 1; }
.m3-field-row > .m3-btn { height: 52px; }

/* ---------- チップ ---------- */
.m3-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 8px;
  border: 2px solid var(--cg-ink); color: var(--cg-ink); background: var(--cg-paper); font: 800 13px/1 var(--md-font); }
.m3-chip > .m3-icon { font-size: 18px; margin-left: -4px; }
.m3-chip.tonal { background: var(--cg-wash); border-color: var(--cg-wash); }
/* 記録 (自己ベスト更新・1位) は黄 */
.m3-chip.record { background: var(--cg-chick); }

/* ---------- リスト (ランキング) ----------
   ゲームの JS が作る <ol><li class="me"><span class="n"> <span class="nm"> <span class="s"></li></ol> と <div class="msg"> の形に合わせてある */
.m3-list { overflow: auto; border: 2px solid var(--cg-ink); border-radius: 14px; background: var(--cg-paper); color: var(--cg-ink);
  padding: 4px 0; font: 700 16px/1.4 var(--md-font); }
.m3-list ol, .m3-list ul { list-style: none; margin: 0; padding: 0; }
.m3-list li { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 6px 14px; }
.m3-list li:nth-child(even) { background: var(--cg-wash); }
.m3-list li .n { width: 26px; flex: none; text-align: right; font: 900 15px/1 var(--md-font); font-variant-numeric: tabular-nums; }
.m3-list li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m3-list li .s { flex: none; font-weight: 900; font-variant-numeric: tabular-nums; }
.m3-list li.me { background: var(--cg-chick-wash); }
.m3-list .msg { padding: 10px 14px; text-align: center; color: var(--cg-ink-soft); font: 500 14px/1.5 var(--md-font); }
.m3-list-label { margin: 22px 0 8px; color: var(--cg-ink); font: 900 15px/1.4 var(--md-font); }

/* ---------- 読み込み中 ---------- */
.m3-progress { position: relative; overflow: hidden; height: 12px; border: 2px solid var(--cg-ink); border-radius: 6px; background: var(--cg-paper); }
.m3-progress > i { position: absolute; inset: 0 auto 0 0; background: var(--cg-chick); width: 0; transition: width .2s; }
.m3-progress.indeterminate > i, .m3-progress:empty::after { content: ""; position: absolute; top: 0; bottom: 0; width: 40%;
  background: var(--cg-chick); animation: m3-indet 1.4s cubic-bezier(.4, 0, .2, 1) infinite; }
@keyframes m3-indet { 0% { left: -40%; } 100% { left: 100%; } }
.m3-spinner { width: 36px; height: 36px; border-radius: 50%; border: 5px solid var(--cg-wash);
  border-top-color: var(--cg-ink); animation: m3-spin .9s linear infinite; }
@keyframes m3-spin { to { transform: rotate(360deg); } }

/* ---------- スナックバー ---------- */
.m3-snackbar { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 60;
  max-width: calc(100% - 32px); min-height: 48px; display: flex; align-items: center; padding: 12px 16px; border-radius: 12px;
  background: var(--cg-ink); color: var(--cg-paper); font: 700 14px/1.5 var(--md-font);
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.m3-snackbar.on { transform: translate(-50%, 0); opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .m3-btn, .m3-icon-btn, .m3-fab, .m3-snackbar { transition: none; }
  .m3-progress.indeterminate > i, .m3-progress:empty::after, .m3-spinner { animation-duration: 3s; }
}
