/* ミニゲーム共通の見た目。videoshop（紺のパネル・黄色の縁・立体感のあるボタン）に寄せた、写実寄りのトーン。
   色は変数にしてあるので、ゲームごとに :root の --accent だけ差し替えれば雰囲気を変えられる。
   ドット絵はやめた（流行らないため）。盤面は高解像度のキャンバスで描く。 */
:root {
  color-scheme: dark;
  --bg: #0f1c32; --panel: #192b48; --panel-deep: #12223b;
  --ink: #e8e6dc; --mist: #8fa6bf; --line: rgba(233, 199, 74, .55);
  --accent: #e9c74a; --amber: var(--accent); --cyan: #7fd6f0; --danger: #e0634f;
  --font: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic', system-ui, sans-serif;
  --display: 'Oswald', 'Bebas Neue', 'Arial Narrow', 'Helvetica Neue', var(--font);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font);
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: none; touch-action: pan-y; /* ゲームは画面いっぱい。広告は下（スクロールの先）に置く。盤面(#view)は touch-action:none なので、盤面のドラッグではスクロールしない */
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

#app { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100dvh; }
/* コンパクト表示：Xアプリ内ブラウザ等。下端のバー（約1割）に隠れないよう全体を上 94% に収める。実機の画面では、以前の 2/3 だと小さすぎて下が余った */
.compact #app { height: 94dvh; bottom: auto; }
/* Xのアプリ内ブラウザは、ページが状態バーの下から始まるのに safe-area-inset-top を返すため、上に大きな空きができる。コンパクト表示では上の余白を詰める */
.compact #hud { padding-top: 8px; min-height: 40px; }
#hud {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) 8px max(14px, env(safe-area-inset-left, 0px));
  position: relative; min-height: 48px; background: linear-gradient(#162744, #0f1c32); border-bottom: 1px solid rgba(233, 199, 74, .25); font-variant-numeric: tabular-nums;
}
#hud .l { font-size: 14px; color: var(--mist); }
#hud .c { font-family: var(--display); font-size: 40px; font-weight: 700; line-height: 1; text-align: center; color: var(--accent); min-width: 3ch; text-shadow: 0 2px 6px rgba(0,0,0,.5); }
#hud .r { font-size: 14px; color: var(--mist); text-align: right; padding-right: 40px; }
#stage { position: relative; min-height: 0; display: grid; place-items: center; overflow: hidden; background: #070d18; }
#view { max-width: 100%; max-height: 100%; display: block; touch-action: none; }

/* タイトル／リザルトのカード。盤面を完全には隠さない（リザルトは盤面の上にカードで出す） */
.screen { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: rgba(4, 8, 16, .55); }
.screen.result { place-items: end center; background: rgba(4, 8, 16, .2); } /* 結果は下寄せにして、盤面の笑いどころ（最後の絵）を隠さない */
.card {
  width: min(360px, 100%); max-height: 100%; overflow-y: auto; overflow-x: hidden; touch-action: pan-y; /* 横スクロールバーを出さない */
  background: linear-gradient(#1d3252, var(--panel)); border: 2px solid var(--accent); border-radius: 10px;
  padding: 20px 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; text-align: center; /* minmax(0,…): 長い題名が枠を押し広げて横にはみ出さないように */
  box-shadow: 0 10px 30px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.12);
}
.card h1 { margin: 0; font-family: var(--display); font-size: clamp(28px, 10vw, 40px); font-weight: 700; letter-spacing: .1em; white-space: normal; text-wrap: balance; overflow-wrap: anywhere; color: #fff; text-shadow: 0 0 18px rgba(233,199,74,.45), 0 2px 0 rgba(0,0,0,.5); }
.card .tag, .card .how { white-space: pre-line; word-break: auto-phrase; text-wrap: balance; overflow-wrap: anywhere; } /* 辞書の \n はそのまま改行。文節の途中で改行しない（未対応の端末でも行の長さをそろえる） */
.card .tag { margin: 0; color: var(--mist); font-size: 15px; line-height: 1.6; }
.card .how { margin: 0; font-size: 15px; line-height: 1.7; }
.card .score { font-family: var(--display); font-size: 84px; font-weight: 700; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; text-shadow: 0 3px 0 rgba(0,0,0,.45); }
.card .unit { font-family: var(--font); font-size: 20px; font-weight: 400; margin-left: 6px; color: var(--ink); }
.card .line { font-size: 18px; font-weight: 700; color: var(--cyan); margin: 0; text-wrap: balance; }
.card .cardimg { width: 100%; height: auto; border-radius: 6px; border: 1px solid rgba(255,255,255,.18); }
.card .sub { font-size: 14px; color: var(--mist); margin: 0; text-wrap: balance; }
.btn {
  min-height: 50px; padding: 10px 14px; font-size: 18px; font-weight: 700; color: var(--ink);
  background: linear-gradient(#2a4166, #213556); border: 1px solid rgba(255,255,255,.18); border-bottom-width: 3px; border-radius: 8px;
}
.btn:active { transform: translateY(1px); border-bottom-width: 2px; }
.btn.primary { background: linear-gradient(#f4dd7a, #e0b93a); color: #2b2208; border-color: #f7e9a8; border-bottom-color: #a98a1f; text-shadow: 0 1px 0 rgba(255,255,255,.4); }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; }
/* 3つ並んでも「画像を保存」が語の途中で折れないよう、日本語を1語として扱い左右の余白を詰める */
.row .btn { flex: 1; padding-left: 6px; padding-right: 6px; word-break: keep-all; }
.rank { text-align: left; font-size: 15px; display: grid; gap: 3px; font-variant-numeric: tabular-nums; }
.rank div { display: flex; justify-content: space-between; gap: 8px; }
.rank .me { color: var(--accent); font-weight: 700; }
.namebox { display: flex; gap: 8px; }
.namebox input {
  flex: 1; min-width: 0; font: inherit; font-size: 18px; color: var(--ink); background: var(--panel-deep);
  border: 1px solid rgba(255,255,255,.2); border-radius: 8px; padding: 8px 10px; touch-action: manipulation; user-select: text; -webkit-user-select: text;
}
.toast { font-size: 14px; color: var(--mist); min-height: 1.4em; margin: 0; }
/* 上の帯なし（cfg.noHud）：盤面だけを並べ、切り欠きの分だけ上をあける。音量ボタンは盤面の右下 */
#app.nohud { grid-template-rows: minmax(0, 1fr); }
#app.nohud #stage { padding-top: env(safe-area-inset-top, 0px); }
#app.nohud .mute { top: auto; bottom: max(6px, env(safe-area-inset-bottom, 0px)); }
.mute { position: absolute; right: max(4px, env(safe-area-inset-right, 0px)); bottom: 2px; z-index: 6; min-width: 44px; min-height: 44px; background: none; border: 0; font-size: 20px; color: var(--mist); }
/* cfg.reserveMute：結果カードの下に音量ボタン（44px）の分の帯をあけ、「もう一度」ボタンの角と重ならないようにする */
#app.reserve-mute .screen.screen-card { padding-bottom: calc(44px + max(6px, env(safe-area-inset-bottom, 0px))); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* 結果は画像のみ（runGame の resultMode:'card'）。文字は読み上げ・検査用に DOM へ残し、画面からは隠す。画像を主役に大きく出す */
.card.card-only { width: min(560px, 100%); padding: 12px; gap: 8px; }
.card.card-only > .tag, .card.card-only > .score, .card.card-only > .line, .card.card-only > .sub:not(.best) { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.card.card-only .cardimg { border: 0; }
/* 画面用の結果カード（runGame の結果に screenCard を渡したゲーム）：画面の幅いっぱいに、余白を詰めて大きく見せる。絵の大きさは JS（makeScreenCard）が決める */
.screen.screen-card { padding: 8px; }
.card.card-screen { width: min(660px, 100%); padding: 8px; gap: 6px; justify-items: center; }
.card.card-screen > .tag, .card.card-screen > .score, .card.card-screen > .line, .card.card-screen > .sub:not(.best) { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.card.card-screen .cardimg { border: 0; max-width: 100%; }
.card.card-screen > .row { width: 100%; position: sticky; bottom: -8px; z-index: 1; padding-bottom: 8px; background: linear-gradient(rgba(25, 43, 72, 0), var(--panel) 30%); } /* 背の低い画面でカードが縦にスクロールしても、ボタンは下に見えている */
.card.card-screen > .toast { min-height: 0; }
/* 画像をコピー／保存したときの通知（cfg.shareImage のゲームだけ。shell.js が toast-float を付ける）。結果カードの中は縦に隠れてスクロールの先になるので、画面の上に浮かせて必ず見えるようにする */
.toast.toast-float { position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); width: max-content; max-width: min(92vw, 560px); box-sizing: border-box; text-align: center; z-index: 30; padding: 8px 14px; border-radius: 12px; background: var(--panel, #192b48); color: var(--ink, #e8e6dc); border: 1px solid var(--line, rgba(255, 255, 255, .3)); box-shadow: 0 4px 16px rgba(0, 0, 0, .5); pointer-events: none; }
@media (max-height: 480px) { .card.card-screen { gap: 4px; } .card.card-screen > .btn, .card.card-screen .row .btn { min-height: 44px; padding: 6px 10px; } }

/* 多言語（runGame に i18n を渡したゲームだけ）。html の lang に合わせて字体の違う言語は font を切り替える */
:root:lang(zh-Hans) { --font: 'PingFang SC', 'Hiragino Sans GB', 'Noto Sans CJK SC', 'Noto Sans SC', 'Microsoft YaHei', system-ui, sans-serif; }
:root:lang(zh-Hant) { --font: 'PingFang TC', 'Noto Sans CJK TC', 'Noto Sans TC', 'Microsoft JhengHei', system-ui, sans-serif; }
:root:lang(ko) { --font: 'Apple SD Gothic Neo', 'Noto Sans CJK KR', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif; }
:root:lang(en), :root:lang(es), :root:lang(pt), :root:lang(fr), :root:lang(de) { --font: system-ui, -apple-system, 'Segoe UI', 'Noto Sans', 'Helvetica Neue', Arial, sans-serif; }
/* 題名：英語など語の長い言語は折り返しを許し、字間を詰める（日本語・中国語・韓国語は従来どおり1行・広い字間） */
.card h1.fit1, .card h1.i18n.fit1 { white-space: nowrap; text-wrap: nowrap; overflow-wrap: normal; word-break: keep-all; letter-spacing: .06em; } /* titleFit：1行固定。はみ出す分は JS（fitTitle）が文字を縮める */
.card h1.i18n { white-space: normal; text-wrap: balance; overflow-wrap: anywhere; line-height: 1.12; }
:root:lang(en) .card h1.i18n, :root:lang(es) .card h1.i18n, :root:lang(pt) .card h1.i18n, :root:lang(fr) .card h1.i18n, :root:lang(de) .card h1.i18n { letter-spacing: .03em; font-size: clamp(24px, 8vw, 34px); }
:root:lang(ko) .card h1.i18n { letter-spacing: .06em; font-size: clamp(26px, 9vw, 38px); }
:root:lang(zh-Hans) .card h1.i18n, :root:lang(zh-Hant) .card h1.i18n { letter-spacing: .1em; }
/* 言語切替：タイトル画面の右上の地球ボタンと、2列のメニュー。操作領域（#app）の内側に絶対配置するので、上 2/3 の表示でも収まる */
.screen.hasLang { padding-top: 54px; }
.langbtn { position: absolute; top: 6px; right: max(6px, env(safe-area-inset-right, 0px)); z-index: 8; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 22px; background: rgba(18, 34, 59, .78); border: 1px solid rgba(255,255,255,.22); color: var(--ink); }
.langbtn:active { transform: translateY(1px); }
.langmenu { position: absolute; top: 54px; right: 8px; z-index: 9; width: min(300px, calc(100% - 16px)); max-height: calc(100% - 62px); overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px; background: var(--panel-deep); border: 2px solid var(--accent); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.6); touch-action: pan-y; }
.langitem { min-height: 42px; padding: 6px 8px; font-size: 15px; font-weight: 700; background: linear-gradient(#2a4166, #213556); border: 1px solid rgba(255,255,255,.18); border-radius: 8px; color: var(--ink); }
.langitem.on { border-color: var(--accent); color: var(--accent); }
/* 多言語で文が長くなっても、遊ぶボタンがカードの下に隠れないよう、ボタンはカードの下端に貼り付ける。背の低い画面（Xアプリ内など）では余白と字を少し詰める */
.screen.hasLang .card > .btn.primary { position: sticky; bottom: -20px; z-index: 1; box-shadow: 0 -8px 10px -4px rgba(25, 43, 72, .95); }
@media (max-height: 640px) {
  .screen.hasLang { padding-top: 50px; }
  .screen.hasLang .card { padding: 12px 14px; gap: 8px; }
  .screen.hasLang .card .tag, .screen.hasLang .card .how { font-size: 14px; line-height: 1.45; }
}

/* 広告帯（The Moneytizer MEGABANNER BOTTOM。docs/ads.md）：ゲームの下（スクロールの先）に置く（ディレクター判断 2026-10-31）。
   ゲームは画面いっぱいに使い、広告は被せない・場所も取らない。広告が出ないときは adbar.js が .adbar-empty を付けて畳む */
:root { --adh: 50px; } /* スマホの高さ。広告の大きさに合わせて帯の高さを確保する */
@media (min-width: 768px) { :root { --adh: 90px; } } /* PC は 728x90 */
#adbar { position: relative; z-index: 2; width: 100%; min-height: var(--adh); box-sizing: content-box; padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px)); display: flex; justify-content: center; align-items: center; overflow: hidden; background: #070d18; touch-action: manipulation; }
#adbar.adbar-empty { display: none; }

/* 「Ver.2」の印（大きく作り直したゲーム）。ステッカーのように右上に斜めに貼る。題名と重ならないよう、カードの上に余白を足す */
.card.hasVer { position: relative; padding-top: 58px; }
.verBadge {
  position: absolute; top: 10px; right: 10px; transform: rotate(8deg);
  font: 900 30px/1 Oswald, 'Arial Narrow', sans-serif; letter-spacing: .04em; color: #2b2208;
  background: linear-gradient(#ffe98a, #f2b632); border: 3px solid #fff6c8; border-radius: 10px; padding: 6px 12px 7px;
  box-shadow: 0 4px 0 #a9761a, 0 8px 18px rgba(0, 0, 0, .45); pointer-events: none;
}
