/* ライバルは同年代 共通スタイル */
:root {
  --bg: #fff8ec;
  --card: #ffffff;
  --ink: #2b2a33;
  --sub: #6b6875;
  --line: #e8dfcf;
  --main: #ff7a00;
  --main-dark: #e06600;
  --ok: #18a058;
  --ng: #e0343a;
  --blue: #2f6fdb;
  --shadow: 0 4px 0 rgba(0, 0, 0, .08);
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--blue); }
button { font-family: inherit; }

/* ヘッダー */
.top {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: #fff; border-bottom: 3px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.top .logo { font-weight: 800; font-size: 20px; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 6px; }
.top .logo b { color: var(--main); }
.top .spacer { flex: 1; }
.top .back { text-decoration: none; font-weight: 700; color: var(--sub); font-size: 15px; }

.wrap { max-width: 860px; margin: 0 auto; padding: 16px; }

/* トップページ */
.hero { text-align: center; padding: 18px 0 8px; }
.hero h1 { font-size: clamp(26px, 6vw, 40px); margin: 0 0 6px; }
.hero h1 b { color: var(--main); }
.hero p { color: var(--sub); margin: 0; }
h2.cat { font-size: 20px; margin: 26px 0 -6px; padding-left: 4px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.gcard {
  display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink);
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); transition: transform .1s;
}
.gcard:hover { transform: translateY(-2px); border-color: var(--main); }
.gcard .icon { font-size: 34px; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 14px; background: #fff1de; flex: none; }
.gcard { flex-wrap: wrap; }
.gcard .txt { flex: 1; min-width: 0; }
.gcard .play { width: 100%; text-align: center; background: var(--main); color: #fff; font-weight: 900; font-size: 18px;
  border-radius: 12px; padding: 10px 0; box-shadow: 0 4px 0 var(--main-dark); margin-top: 4px; }
.gcard:active .play { transform: translateY(3px); box-shadow: 0 1px 0 var(--main-dark); }
.steps { list-style: none; padding: 0; margin: 14px auto 0; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.steps li { background: #fff; border: 3px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: 15px; }
.steps b { color: var(--main); margin-right: 4px; }
.gcard h3 { margin: 0 0 3px; font-size: 20px; }
.gcard p { margin: 0; font-size: 13px; color: var(--sub); line-height: 1.5; }
.gcard .best { font-size: 12px; color: var(--main-dark); font-weight: 700; margin-top: 4px; }
.foot { text-align: center; color: var(--sub); font-size: 12px; padding: 30px 0 40px; }

/* ゲーム画面 */
.panel { background: var(--card); border: 3px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.gtitle { text-align: center; }
.gtitle .icon { font-size: 52px; }
.gtitle h1 { margin: 4px 0 6px; font-size: 28px; }
.gtitle .howto { color: var(--sub); line-height: 1.8; margin: 0 auto 16px; max-width: 560px; }
.levels { display: flex; flex-direction: column; gap: 10px; max-width: 360px; margin: 0 auto; }
.btn {
  border: none; border-radius: 14px; padding: 14px 18px; font-size: 18px; font-weight: 800; cursor: pointer;
  background: #f1ece3; color: var(--ink); box-shadow: 0 4px 0 rgba(0, 0, 0, .12); touch-action: manipulation;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .12); }
.btn.main { background: var(--main); color: #fff; box-shadow: 0 4px 0 var(--main-dark); }
.btn.lv { display: grid; grid-template-columns: 1fr auto; text-align: left; padding: 14px 18px; position: relative; }
.btn.lv .lvname { font-size: 22px; font-weight: 900; }
.btn.lv .lvnote { font-size: 14px; font-weight: 700; opacity: .75; grid-column: 1; }
.btn.lv .lvbest { font-size: 13px; font-weight: 800; color: var(--main-dark); grid-column: 1; }
.btn.lv .go { grid-column: 2; grid-row: 1 / span 3; align-self: center; font-size: 26px; color: var(--main); }
.howbox { background: #fffaf2; border: 3px solid var(--line); border-radius: 16px; padding: 10px 14px; max-width: 560px; margin: 0 auto 14px; text-align: left; }
.howbox b { display: block; font-size: 15px; color: var(--main-dark); }
.howbox .howto { margin: 4px 0 0; text-align: left; }
h2.pick { font-size: 18px; margin: 4px 0 10px; }
.btn.lv.easy { background: #dff5e7; }
.btn.lv.normal { background: #fff1c9; }
.btn.lv.hard { background: #ffd9d9; }
.btn:disabled { opacity: .4; }

.hud { display: flex; align-items: center; gap: 10px; font-weight: 800; margin-bottom: 10px; }
.hud .q { background: var(--ink); color: #fff; border-radius: 999px; padding: 4px 12px; font-size: 14px; }
.hud .bar { flex: 1; height: 10px; background: #efe6d6; border-radius: 99px; overflow: hidden; }
.hud .bar i { display: block; height: 100%; background: var(--main); width: 0; transition: width .3s; }
.hud .time { font-variant-numeric: tabular-nums; color: var(--sub); font-size: 15px; }
.ask { text-align: center; font-size: clamp(18px, 4.6vw, 24px); font-weight: 800; margin: 4px 0 12px; }
.stage { min-height: 180px; display: flex; justify-content: center; align-items: center; flex-direction: column; }

/* 答える部分 */
.answer-box {
  min-width: 200px; text-align: center; font-size: 40px; font-weight: 800; letter-spacing: 2px;
  border: 3px dashed var(--line); border-radius: 14px; padding: 4px 14px; margin: 12px auto 10px; min-height: 64px;
  font-variant-numeric: tabular-nums;
}
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 320px; margin: 0 auto; }
.keypad .btn { font-size: 26px; padding: 12px 0; }
.keypad .ok { background: var(--main); color: #fff; box-shadow: 0 4px 0 var(--main-dark); }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; width: 100%; max-width: 560px; margin: 10px auto 0; }
.choices .btn { font-size: 22px; }

/* ○× */
.judge {
  position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 50;
  font-size: min(60vw, 320px); font-weight: 900; opacity: 0; transition: opacity .15s;
}
.judge.show { opacity: .9; }
.judge.ok { color: var(--ok); }
.judge.ng { color: var(--ng); }
.reveal { text-align: center; font-size: 20px; font-weight: 800; margin-top: 12px; min-height: 30px; }
.reveal .ok { color: var(--ok); }
.reveal .ng { color: var(--ng); }

/* 結果 */
.result { text-align: center; }
.result .score { font-size: 64px; font-weight: 900; color: var(--main); margin: 6px 0; }
.result .rank { font-size: 26px; font-weight: 900; }
.result .detail { color: var(--sub); margin: 8px 0 16px; line-height: 1.8; }
.result .btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.newbest { display: inline-block; background: #ffe36b; border-radius: 999px; padding: 2px 12px; font-weight: 900; margin-top: 4px; }
.review { text-align: left; max-width: 520px; margin: 16px auto 0; font-size: 14px; }
.review li { margin: 3px 0; }
.review .x { color: var(--ng); }

/* 大きなボタン（上に何をするか・下に説明） */
.btn.big { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 16px; text-decoration: none; text-align: center; }
.btn.big .bl { font-size: 20px; font-weight: 900; }
.btn.big .bs { font-size: 13px; font-weight: 600; opacity: .8; }
.bigbtns { display: grid; gap: 10px; max-width: 420px; margin: 0 auto; }

/* ランキング */
.rankbox { border-top: 3px dashed var(--line); margin-top: 20px; padding-top: 14px; }
.rankbox h3 { margin: 0 0 8px; }
input.name { display: block; width: 100%; max-width: 420px; margin: 0 auto 10px; font-size: 20px; padding: 12px 14px;
  border: 3px solid var(--line); border-radius: 14px; font-family: inherit; text-align: center; }
.rankmsg { margin-top: 10px; font-weight: 700; min-height: 24px; line-height: 1.7; }
.rankmsg .band { margin: 8px auto 0; max-width: 420px; background: #eaf3ff; border: 3px solid #bcd6ff; border-radius: 14px; padding: 8px 12px; }
.rankmsg .band b { color: var(--blue); font-size: 22px; }
.rankmsg .band small { display: block; color: var(--sub); }
.rankhelp { color: var(--sub); font-size: 13px; line-height: 1.6; max-width: 420px; margin: 0 auto 10px; text-align: left; }
.gender { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 420px; margin: 0 auto 12px; }
.gender .btn { font-size: 16px; padding: 12px 4px; background: #fff; border: 3px solid var(--line); box-shadow: none; }
.gender .btn.on { background: var(--main); border-color: var(--main); color: #fff; }
.ranktable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ranktable th, .ranktable td { padding: 8px 6px; border-bottom: 2px solid #f1ebe0; text-align: left; }
.ranktable td.no { width: 3em; font-weight: 900; text-align: center; }
.ranktable tr.me td { background: #fff1de; }
/* スイッチ（切り替えボタン）。--n = ボタンの数、--i = 選んでいる番号（-1 = まだ選んでいない）は JS で入れる */
.tabs { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #efe4d1; border-radius: 999px;
  padding: 4px; margin: 8px auto; width: 100%; max-width: 460px; box-sizing: border-box; box-shadow: inset 0 2px 4px rgba(43, 42, 51, .12); }
.tabs::before { content: ""; position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / var(--n, 1));
  transform: translateX(calc(100% * var(--i, 0))); background: var(--main); border-radius: 999px; box-shadow: 0 3px 6px rgba(224, 102, 0, .35);
  transition: transform .25s cubic-bezier(.3, 1.3, .5, 1), background-color .25s; }
.tabs[data-none]::before { opacity: 0; }
.tabs[data-v="m"]::before { background: #2f6fdb; box-shadow: 0 3px 6px rgba(47, 111, 219, .35); }
.tabs[data-v="f"]::before { background: #e0457b; box-shadow: 0 3px 6px rgba(224, 69, 123, .35); }
.tabs button { position: relative; z-index: 1; border: 0; background: none; border-radius: 999px; padding: 10px 4px; font-size: 15px; line-height: 1.25;
  font-weight: 800; font-family: inherit; color: var(--ink); cursor: pointer; transition: color .2s; -webkit-tap-highlight-color: transparent; }
.tabs button.on { color: #fff; }
.sw { display: grid; grid-template-columns: 6em 1fr; align-items: center; gap: 8px; max-width: 560px; margin: 0 auto; }
.sw .swl { font-weight: 800; color: var(--sub); font-size: 14px; text-align: right; }
.sw .tabs { margin: 5px 0; max-width: none; }
@media (max-width: 480px) {
  .sw { grid-template-columns: 1fr; gap: 0; }
  .sw .swl { text-align: left; font-size: 12px; margin: 6px 0 -2px 10px; }
  .tabs button { font-size: 14px; }
}
select.big { font-size: 18px; padding: 10px 12px; border-radius: 12px; border: 3px solid var(--line); font-family: inherit; width: 100%; max-width: 420px; }

/* 同じもの探し */
.same-grid { display: grid; gap: 8px; width: 100%; max-width: 520px; }
.same-cell { border: 3px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 0; cursor: pointer;
  font-size: clamp(24px, 7vw, 36px); font-weight: 800; font-family: inherit; color: var(--ink); touch-action: manipulation; }
.same-cell.two { font-size: clamp(20px, 5.6vw, 30px); }
.same-cell.long { font-size: clamp(18px, 5vw, 28px); font-variant-numeric: tabular-nums; }
.same-cell.on { border-color: var(--main); background: #fff1de; }
.same-cell.hit { border-color: var(--ok); background: #dff5e7; }

@media (max-width: 520px) {
  .wrap { padding: 10px; }
  .panel { padding: 12px; }
  .answer-box { font-size: 32px; }
}

/* ---------- このサイトについて（about.html） ---------- */
.doc h1 { margin: 0 0 10px; font-size: 24px; }
.doc h2 { font-size: 19px; margin: 26px 0 8px; padding-left: 10px; border-left: 6px solid var(--main); scroll-margin-top: 70px; }
.doc p, .doc li { line-height: 1.8; }
.doc ul { padding-left: 1.3em; margin: 0; }
.doc .box { background: #fffaf2; border: 3px solid var(--line); border-radius: 16px; padding: 10px 14px; }
.doc .note { color: var(--sub); font-size: 13px; }
.toc { display: flex; flex-wrap: wrap; gap: 6px; }
.toc a { background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 700; color: var(--ink); text-decoration: none; }
.foot a { color: var(--sub); margin: 0 4px; }
.rankhelp a { color: var(--main-dark); font-weight: 700; }

/* ---------- 広告（assets/ads.js）。遊んでいる最中の画面には置かない ---------- */
.ad { display: block; height: 0; overflow: hidden; }           /* 広告が無い時は場所を取らない（幅は測れるように） */
.ad.ad-live { height: auto; margin: 32px 0; }
.ad.ad-live::before { content: "スポンサーリンク"; display: block; font-size: 11px; color: var(--sub); margin-bottom: 4px; letter-spacing: .05em; }
.ad.ad-live:has(ins[data-ad-status="unfilled"]) { display: none; }

/* ---------- ロゴ画像（img/ は 開発用\画像書き出し.py で作る） ---------- */
.top .logo img { height: 40px; width: auto; display: block; }
.hero h1.emblem { margin: 0 auto 4px; max-width: 460px; }
.hero h1.emblem img { width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 10px rgba(43, 42, 51, .12)); }
h1.withimg { display: flex; align-items: center; justify-content: center; gap: 8px; }
h1.withimg img { height: 1.6em; width: auto; }
.result .trophy { height: 84px; width: auto; display: block; margin: 0 auto 4px; animation: pop .5s ease-out; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.15); } to { transform: scale(1); opacity: 1; } }

/* ---------- ご要望フォーム（about.html） ---------- */
.feedback { display: grid; gap: 6px; }
.feedback > label { font-weight: 800; margin-top: 8px; }
.feedback textarea { font: inherit; font-size: 16px; border: 3px solid var(--line); border-radius: 14px; padding: 10px 12px; width: 100%; box-sizing: border-box; resize: vertical; background: #fff; }
.feedback textarea:focus { outline: none; border-color: var(--main); }
.feedback input.name, .feedback select { width: 100%; max-width: none; box-sizing: border-box; }
.fbtypes { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 6px; }
.fbtypes label { background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 10px; font-weight: 700; cursor: pointer; }
.fbtypes label:has(input:checked) { border-color: var(--main); background: #fff1e0; }
.feedback .btn { margin-top: 10px; }
.feedback .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.fbmsg { text-align: center; font-weight: 800; color: var(--sub); min-height: 1.5em; margin: 4px 0 0; }

/* ---------- 性別のマーク（♂♀） ---------- */
.gm { color: #2f6fdb; font-weight: 900; margin-right: 2px; }
.gf { color: #e0457b; font-weight: 900; margin-right: 2px; }
.gender .btn.gm.on { background: #2f6fdb; border-color: #2f6fdb; color: #fff; }
.gender .btn.gf.on { background: #e0457b; border-color: #e0457b; color: #fff; }

/* ---------- じぶんの記録（me.html） ---------- */
.mesearch { margin-top: 0; }
.mesum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 6px; }
.mesum:empty { display: none; }
.mesum div { background: #fff1e0; border: 3px solid var(--line); border-radius: 16px; padding: 10px 4px; }
.mesum b { display: block; font-size: 26px; color: var(--main); line-height: 1.2; }
.mesum span { font-size: 12px; color: var(--sub); font-weight: 700; line-height: 1.3; display: block; }
.melist { display: grid; gap: 10px; margin-top: 10px; text-align: left; }
.mecard { display: block; background: #fff; border: 3px solid var(--line); border-radius: 18px; padding: 12px 14px; color: var(--ink); text-decoration: none; }
.mecard:hover { border-color: var(--main); }
.mehead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mehead .icon { font-size: 26px; }
.mehead b { font-size: 18px; }
.mehead small { color: var(--sub); font-weight: 700; }
.merank { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 6px; text-align: center; }
.merank div { background: #fffaf2; border-radius: 12px; padding: 6px; }
.merank span { display: block; font-size: 12px; color: var(--sub); font-weight: 700; }
.merank b { font-size: 26px; color: var(--main); }
.merank small { color: var(--sub); margin-left: 4px; }
.mescore { font-weight: 800; font-size: 14px; }
.mescore small { color: var(--sub); font-weight: 700; }
@media (max-width: 420px) { .mesum { grid-template-columns: repeat(2, 1fr); } }

/* ---------- ランキング：ゲームを選ぶボタン（rank.html） ---------- */
.gamepick { max-width: 640px; margin: 4px auto 10px; text-align: left; }
.gprow { margin: 8px 0; }
.gpcat { font-weight: 800; color: var(--sub); font-size: 13px; margin: 0 0 4px 6px; }
.gpgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.gpgrid button { display: flex; align-items: center; gap: 6px; border: 3px solid var(--line); background: #fff; border-radius: 14px;
  padding: 8px 10px; font: inherit; font-size: 15px; font-weight: 800; color: var(--ink); cursor: pointer; text-align: left; line-height: 1.2;
  -webkit-tap-highlight-color: transparent; transition: transform .1s; }
.gpgrid button:active { transform: scale(.96); }
.gpgrid button .gi { font-size: 20px; }
.gpgrid button.on { background: var(--main); border-color: var(--main); color: #fff; box-shadow: 0 3px 6px rgba(224, 102, 0, .35); }
@media (max-width: 480px) { .gpgrid { grid-template-columns: repeat(2, 1fr); } .gpgrid button { font-size: 14px; padding: 8px; } }
.sw { scroll-margin-top: 72px; }   /* 上のヘッダーに隠れないように */
