/* 33msec games の見た目。決まりは docs/design-rules.md（デジタル庁デザインシステムに沿う）。
   背景は白、灰色は #f2f2f2・#e6e6e6・#cccccc だけ。青はリンクとボタンだけ。文字は 14px 以上。影は使わない。
   余白は 4/8/16/24/40px、角丸は箱 8px・部品 4px。
   例外: ぴた停の運転席からの景色（絵）とその上に重ねる計器、貨車・列車の種別の色（見分けるための色）。 */
:root {
  --bg: #ffffff;
  --card-bg: #ffffff;
  --card-border: #cccccc;
  --card-border-hover: #999999;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --text: #0f172a;
  --text-sub: #555555;
  --keyword: #b45309;
  --link-visited: #7e22ce;
  --control-border: #767676;
  --gray-50: #f2f2f2;
  --gray-100: #e6e6e6;
  --ok: #047857;
  --danger: #dc2626;
  --attention: #ffd43d;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; padding: 24px 16px; overflow-wrap: anywhere; font-weight: 500; }
.container { max-width: 880px; margin: 0 auto; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
a:visited { color: var(--link-visited); }
h1 { font-size: 1.75rem; line-height: 1.35; font-weight: 800; }
h2 { font-size: 1.25rem; line-height: 1.45; margin: 0 0 16px; font-weight: 700; }
h3 { font-size: 1.125rem; margin: 24px 0 8px; font-weight: 700; }
p, ul, ol, table { margin-bottom: 16px; }
ul, ol { padding-left: 1.4em; }
.note { color: var(--text-sub); font-size: 0.875rem; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kicker { display: block; font-size: 0.875rem; font-weight: 700; color: var(--text-sub); margin-bottom: 4px; letter-spacing: 0.04em; }
:focus-visible { outline: 4px solid #000; outline-offset: 2px; box-shadow: 0 0 0 2px var(--attention); }
a:focus-visible { background-color: var(--attention); color: var(--text); }
@media (max-width: 480px) { h1 { font-size: 1.5rem; } body { padding: 16px; } }

/* サイトのヘッダー・ゲームごとのメニュー */
.site-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding-bottom: 16px; margin-bottom: 24px; border-bottom: 1px solid var(--card-border); }
.logo, .logo:visited { font-size: 1.375rem; font-weight: 800; color: var(--text); text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 1rem; font-weight: 700; }
.site-nav a, .site-nav a:visited { display: inline-flex; flex-direction: column; line-height: 1.3; color: var(--primary); }
.site-nav a small { font-size: 0.875rem; font-weight: 600; color: var(--text-sub); }
.crumbs { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; font-size: 0.875rem; color: var(--text-sub); margin-bottom: 8px; }
.crumbs li + li::before { content: "/"; margin-right: 4px; }
.game-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.game-nav a, .game-nav a:visited { display: inline-block; border: 1px solid var(--control-border); border-radius: 4px; padding: 4px 8px; font-size: 1rem; font-weight: 700; background: #fff; color: var(--primary); text-decoration: none; }
.game-nav a:hover { border-color: var(--primary); }
.game-nav a[aria-current="page"] { color: var(--text); border-color: var(--keyword); }
.page-h1 { margin-bottom: 16px; }

/* カード・本文 */
.card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 8px; padding: 24px; margin-bottom: 24px; }
.prose h2 { display: flex; align-items: center; gap: 8px; }
.prose h2::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--text); flex: none; }
.prose li { margin-bottom: 4px; }
.prose-page p, .prose-page li { line-height: 1.75; }
.fig { margin: 16px 0; }
.fig svg { width: 100%; max-width: 600px; height: auto; display: block; border-radius: 8px; }
.fig figcaption { font-size: 0.875rem; color: var(--text-sub); margin-top: 8px; }
.tbl { border-collapse: collapse; font-size: 0.875rem; min-width: 240px; }
.tbl th, .tbl td { border-bottom: 1px solid var(--gray-100); padding: 8px 16px; text-align: left; }
.tbl thead th { background: var(--gray-50); font-weight: 700; }
.tbl.num td { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.sources { font-size: 0.875rem; }
@media (max-width: 480px) { .card { padding: 16px; } }

/* ボタン */
.btn, .btn:visited { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px; border-radius: 4px; border: 1px solid var(--primary); background: #fff; color: var(--primary); font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; text-decoration: none; touch-action: manipulation; }
.btn:hover:not(:disabled) { background: var(--primary-light); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary, .btn.primary:visited { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.big { min-height: 48px; padding: 8px 24px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.msg { padding: 8px 16px; border-radius: 8px; font-size: 1rem; margin: 8px 0; border: 1px solid var(--card-border); }
.msg.error { color: var(--danger); border-color: var(--danger); }

/* トップページ */
.hero { margin: 8px 0 24px; }
.hero h1 { font-size: 2rem; }
.hero-sub { font-size: 1.0625rem; color: var(--text); margin-top: 8px; }
.card.game-card { padding: 0; overflow: hidden; }
.game-card-art { display: block; background: var(--gray-50); padding: 16px; border-bottom: 1px solid var(--card-border); }
.game-card-art svg { width: 100%; height: auto; display: block; border-radius: 4px; }
.game-card-body { padding: 24px; }
.game-card h2 { font-size: 1.375rem; margin-bottom: 8px; }
.game-card h2 small { display: block; font-size: 1rem; font-weight: 600; color: var(--text-sub); }
.today-status { display: inline-block; font-family: var(--mono); font-size: 0.875rem; font-weight: 700; background: var(--gray-50); border: 1px solid var(--card-border); border-radius: 4px; padding: 4px 8px; }
.top-career { font-size: 1rem; color: var(--text); margin-top: 8px; }
.top-career strong { color: var(--keyword); }
.about-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.about-list li { padding-left: 24px; position: relative; }
.about-list li::before { content: ""; position: absolute; left: 4px; top: 0.7em; width: 8px; height: 8px; border-radius: 50%; background: var(--text); }
@media (max-width: 480px) { .game-card-body { padding: 16px; } .hero h1 { font-size: 1.5rem; } }

/* ---- プレイ画面（3つのゲームで共通） ---- */
.game { margin-bottom: 24px; }
.game-top { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 16px; }
.puzzle-title { margin: 0; font-size: 1.25rem; }
.puzzle-date { font-size: 0.875rem; color: var(--text-sub); margin: 0; }
.game-meta { display: flex; gap: 8px; align-items: stretch; }
.score { display: grid; grid-template-columns: repeat(3, auto); gap: 8px; margin: 0; }
.score div { background: var(--gray-50); border-radius: 8px; padding: 4px 16px; text-align: center; min-width: 72px; }
.score dt { font-size: 0.875rem; font-weight: 700; color: var(--text); }
.score dd { font-family: var(--mono); font-size: 1.5rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.sound-toggle { min-width: 48px; border-radius: 4px; border: 1px solid var(--control-border); background: #fff; font-size: 1.25rem; cursor: pointer; touch-action: manipulation; }
.sound-toggle:hover { background: var(--primary-light); border-color: var(--primary); }
.sound-toggle[aria-pressed="false"] { background: var(--gray-50); }
.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; background: var(--gray-100); padding: 4px; border-radius: 8px; margin-bottom: 16px; }
.level { border: 1px solid transparent; background: transparent; border-radius: 4px; padding: 4px; font: inherit; font-weight: 700; font-size: 1rem; color: var(--text); cursor: pointer; line-height: 1.35; }
.level small { display: block; font-size: 0.875rem; font-weight: 600; color: var(--text-sub); }
.level.active { background: #fff; color: var(--primary); border-color: var(--control-border); }
.intro { background: #fff; border: 1px solid var(--card-border); border-radius: 8px; padding: 24px; margin-bottom: 16px; }
.intro h2 { font-size: 1.25rem; }
.intro strong { color: var(--keyword); }
.order { position: relative; background: #fff; border: 1px solid var(--card-border); border-radius: 8px; padding: 16px 16px 16px 24px; margin-bottom: 16px; }
.order::before { content: ""; position: absolute; left: 8px; top: 16px; bottom: 16px; width: 4px; border-radius: 2px; background: var(--text); }
.order:empty { display: none; }
.order-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.order-tag { font-size: 0.875rem; font-weight: 700; color: #fff; background: var(--text); border-radius: 4px; padding: 0 8px; }
.order-head strong { font-family: var(--mono); font-size: 1rem; }
.order-meta { font-size: 0.875rem; color: var(--text-sub); }
.order-cargo { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.order-cargo li { display: inline-flex; align-items: center; gap: 4px; font-size: 0.875rem; font-weight: 700; background: #fff; border: 1px solid var(--card-border); border-radius: 4px; padding: 0 8px 0 4px; }
.order-cargo b { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 4px; background: var(--c); color: #fff; font-family: var(--mono); font-size: 0.875rem; }
.order-line { margin: 0; font-size: 1rem; }
.order-line span { font-size: 0.875rem; font-weight: 700; color: var(--text-sub); margin-right: 4px; }
.panel { background: #fff; border: 1px solid var(--card-border); border-radius: 8px; padding: 8px; }
.target-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 4px 8px 8px; }
.tag { font-size: 0.875rem; font-weight: 700; color: var(--text); background: var(--gray-50); border: 1px solid var(--card-border); border-radius: 4px; padding: 0 8px; }
.target-text { font-size: 0.875rem; }
.target-wrap { margin-left: auto; }
.target-wrap svg { height: 34px; width: auto; display: block; }
.status { display: flex; align-items: center; gap: 8px; font-size: 1rem; color: var(--text); padding: 8px 8px 4px; margin: 0; min-height: 2.2em; }
.status::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.status:empty::after { content: "操作を待っています"; color: var(--text-sub); font-size: 0.875rem; }
.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; font-size: 1rem; background: rgb(255 255 255 / 0.85); border-radius: 8px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--card-border); border-top-color: var(--text); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.console { background: #fff; border: 1px solid var(--card-border); border-radius: 8px; padding: 16px; margin-top: 16px; }
.console .note { margin: 8px 0 0; min-height: 1.5em; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.ctl { flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 8px 16px; border-radius: 4px; border: 1px solid var(--control-border); background: #fff; color: var(--text); font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; white-space: nowrap; touch-action: manipulation; }
.ctl:hover:not(:disabled) { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.ctl:disabled { opacity: 0.4; cursor: not-allowed; }
.ctl.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.ctl.primary:hover:not(:disabled) { background: var(--primary-hover); color: #fff; }
/* ヒントで示す場所（注目の黄色。フォーカス表示と同じ色） */
.hinted { background: var(--attention) !important; color: var(--text) !important; border-color: #000 !important; }
.result { margin-top: 24px; background: #fff; border: 1px solid var(--card-border); border-radius: 8px; padding: 24px; }
.result h2 { font-size: 1.375rem; }
.result-sub { color: var(--text-sub); font-size: 1rem; margin-top: -8px; }
.share-text { white-space: pre-wrap; font-family: var(--mono); background: var(--gray-50); border-radius: 8px; padding: 16px; font-size: 1rem; line-height: 1.6; margin: 8px 0; }
.stats { margin: 16px 0 8px; }
.stat-cells { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; text-align: center; margin-bottom: 16px; }
.stat-cells div { background: var(--gray-50); border-radius: 8px; padding: 8px 4px; }
.stat-cells strong { display: block; font-family: var(--mono); font-size: 1.25rem; line-height: 1.3; }
.stat-cells span { font-size: 0.875rem; }
.dist { list-style: none; padding: 0; font-size: 0.875rem; }
.dist li { display: grid; grid-template-columns: 5.5em minmax(0, 1fr) 2.5em; gap: 8px; align-items: center; margin: 4px 0; font-family: var(--mono); }
.dist .bar { height: 16px; min-width: 4px; background: var(--text-sub); border-radius: 4px; }
.countdown { font-family: var(--mono); font-weight: 700; font-size: 1rem; }
.result-links { display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 1rem; }
.career { background: var(--gray-50); border-radius: 8px; padding: 16px; margin: 16px 0; }
.career-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.career-rank { font-weight: 800; font-size: 1.125rem; }
.career-pts { font-family: var(--mono); font-size: 0.875rem; }
.career-bar { height: 8px; background: #fff; border: 1px solid var(--card-border); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.career-bar span { display: block; height: 100%; background: var(--text-sub); }
.career .note { margin: 0; color: var(--text); }
.promote { background: #fff; border: 2px solid var(--keyword); border-radius: 8px; padding: 8px 16px; margin-bottom: 8px; font-weight: 700; }
.promote strong { color: var(--keyword); }
@media (max-width: 560px) { .stat-cells { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 480px) { .result, .intro { padding: 16px; } }

/* ---- Daily Shunter ---- */
.board-wrap { position: relative; min-height: 140px; max-width: 620px; margin: 0 auto; }
.board { width: 100%; height: auto; display: block; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.board > :not(.hit):not(.wagon) { pointer-events: none; }
.board .wagon { cursor: pointer; transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1); }
.board .hit { fill: transparent; cursor: pointer; }
.board .hit:hover { fill: var(--primary-light); }
.board .hit.sel { fill: #fbeee0; stroke: var(--keyword); stroke-width: 2; }
.board .trk.sel { stroke: var(--keyword); stroke-width: 6; }
.board .lbl.sel { fill: var(--keyword); }
@media (prefers-reduced-motion: reduce) { .board .wagon { transition: none; } }
.sidings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.siding { display: flex; align-items: baseline; justify-content: center; gap: 8px; min-height: 52px; border-radius: 4px; border: 1px solid var(--control-border); background: #fff; color: var(--text); font: inherit; cursor: pointer; touch-action: manipulation; }
.siding b { font-family: var(--mono); font-size: 1.375rem; font-weight: 800; }
.siding small { font-size: 0.875rem; color: var(--text-sub); font-weight: 600; }
.siding:hover { background: var(--primary-light); border-color: var(--primary); }
.siding[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.siding[aria-pressed="true"] small { color: #fff; }
.ops { display: grid; gap: 8px; margin-top: 16px; }
.op { display: grid; grid-template-columns: 6.5em repeat(3, minmax(0, 1fr)); gap: 8px; align-items: center; }
.op-label { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 4px; }
.op-label i { font-style: normal; font-family: var(--mono); }
.key { min-height: 48px; border-radius: 4px; border: 1px solid var(--control-border); background: #fff; font-family: var(--mono); font-size: 1.125rem; font-weight: 800; color: var(--text); cursor: pointer; touch-action: manipulation; }
.key::after { content: "両"; font-size: 0.875rem; font-weight: 600; margin-left: 2px; }
.key:hover:not(:disabled) { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.key:disabled { opacity: 0.35; cursor: not-allowed; background: var(--gray-50); }
@media (max-width: 560px) { .op { grid-template-columns: 5.5em repeat(3, minmax(0, 1fr)); } }

/* ---- Daily Dispatch ---- */
.plan { margin-top: 16px; }
.plan-wrap { overflow-x: auto; margin: 8px 0; }
.plan-table { border-collapse: collapse; font-size: 0.875rem; width: 100%; min-width: 360px; margin: 0; }
.plan-table th { font-weight: 700; text-align: left; padding: 4px 8px; background: var(--gray-50); }
.plan-table td { padding: 4px 8px; border-bottom: 1px solid var(--gray-100); white-space: nowrap; }
.plan-table .num { font-family: var(--mono); text-align: right; }
.plan-table .late { color: var(--keyword); font-weight: 800; }
.tdot { display: inline-block; width: 12px; height: 12px; border-radius: 4px; background: var(--c); margin-right: 8px; vertical-align: -1px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.875rem; }
.legend .lg, .legend-static .lg { display: inline-flex; align-items: center; gap: 4px; }
.legend-static { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.875rem; background: var(--gray-50); border-radius: 8px; padding: 8px 16px; }
.diagram-wrap { position: relative; max-width: 780px; margin: 0 auto; }
/* 図は元の大きさで出し、入りきらないときだけ縮める（文字が画面上で14px以上になるように） */
.diagram { display: block; width: auto; max-width: 100%; height: auto; margin: 0 auto; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.fig-wide { display: block; } .fig-narrow { display: none; }
@media (max-width: 600px) { .fig-wide { display: none; } .fig-narrow { display: block; } }
.fig-diagram svg { max-width: 640px; }
.diagram .wait { cursor: pointer; }
.diagram .wait:hover .wait-bar { stroke-opacity: 0.6; }
.diagram .wait.hinted .wait-bar { stroke: var(--attention); stroke-opacity: 1; }
.game.stuck .panel { border: 2px solid var(--danger); }
.game.stuck .status::before { background: var(--danger); }
.console-h { font-size: 1rem; font-weight: 700; margin: 0 0 8px; }
.console-h small { font-size: 0.875rem; font-weight: 600; color: var(--text-sub); margin-left: 8px; }
.orders { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.orders li { display: grid; grid-template-columns: 8em minmax(0, 1fr); gap: 8px; align-items: center; }
.seg-name { font-size: 0.875rem; font-weight: 700; white-space: nowrap; }
.seg-name i { font-style: normal; margin: 0 2px; }
.orders .chips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0; }
.orders .arrow { color: var(--text-sub); font-size: 0.875rem; }
.tchip { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 4px 8px; border-radius: 4px; border: 1px solid var(--control-border); border-left: 6px solid var(--c); background: #fff; font: inherit; font-size: 0.875rem; font-weight: 700; color: var(--text); cursor: pointer; touch-action: manipulation; }
.tchip i { font-style: normal; color: var(--text-sub); }
.tchip:hover:not(:disabled) { background: var(--primary-light); border-color: var(--primary); border-left-color: var(--c); }
.tchip:disabled { cursor: default; background: var(--gray-50); }
@media (max-width: 560px) { .orders li { grid-template-columns: minmax(0, 1fr); gap: 4px; } }

/* ---- ぴた停 ---- */
.drive { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 8px; }
/* 運転席からの景色は絵なので、決まりの対象外（その上に重ねる計器も絵を見るための部品） */
.cab { position: relative; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #000; }
.cab canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; left: 8px; top: 8px; display: grid; gap: 4px; padding: 8px; border-radius: 4px; background: rgb(15 23 42 / 0.82); color: #fff; font-family: var(--mono); min-width: 150px; }
.hud .speed { font-size: 2rem; font-weight: 800; line-height: 1; }
.hud .speed small { font-size: 0.875rem; margin-left: 4px; }
.speedbar { position: relative; height: 8px; border-radius: 4px; background: rgb(255 255 255 / 0.25); }
.speedbar span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: #fff; }
.speedbar span.over { background: #f87171; }
.speedbar i { position: absolute; top: -4px; bottom: -4px; width: 2px; background: #f87171; }
.hud-row { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; }
.hud-row .muted b { font-weight: 800; }
.limit { display: inline-grid; place-items: center; min-width: 2.4em; height: 1.9em; border: 3px solid var(--danger); background: #fff; color: var(--text); border-radius: 50%; font-weight: 800; font-size: 0.875rem; }
.limit.line { border-color: #767676; }
.notch-big { position: absolute; right: 8px; top: 8px; font-family: var(--mono); font-size: 1.75rem; font-weight: 800; padding: 0 16px; border-radius: 4px; background: rgb(15 23 42 / 0.82); color: #fff; }
.cab-msg { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); max-width: 88%; background: #fff; border: 1px solid var(--card-border); border-radius: 8px; padding: 16px; text-align: center; color: var(--text); font-size: 1rem; }
.cab-msg b { display: block; font-size: 1.25rem; margin-bottom: 4px; }
.cab-msg small { font-size: 0.875rem; color: var(--text-sub); }
.lever { position: relative; border-radius: 8px; border: 1px solid var(--control-border); background: #fff; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.lever ol { list-style: none; position: absolute; inset: 4px; display: grid; grid-template-rows: repeat(13, 1fr); padding: 0; margin: 0; }
.lever li { display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; font-family: var(--mono); font-size: 0.875rem; font-weight: 700; color: var(--text); border-top: 1px solid var(--gray-100); }
.lever li.p { color: var(--ok); } .lever li.b { color: var(--keyword); } .lever li.eb { color: var(--danger); }
.handle { position: absolute; left: 4px; width: 56%; height: calc((100% - 8px) / 13); border-radius: 4px; background: var(--primary); display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--mono); font-weight: 800; font-size: 0.875rem; pointer-events: none; transition: top 0.06s, left 0.06s; }
.strip { position: relative; height: 24px; margin: 8px 0 0; border-radius: 4px; background: var(--gray-50); border: 1px solid var(--card-border); overflow: hidden; }
.strip i { position: absolute; top: 0; bottom: 0; }
.strip .g.up { background: rgb(220 38 38 / 0.12); } .strip .g.down { background: rgb(4 120 87 / 0.12); }
.strip .lim { top: 4px; bottom: auto; height: 8px; background: var(--danger); border-radius: 4px; }
.strip .lim b { display: none; }
.strip .plat { top: auto; bottom: 4px; height: 8px; background: #999999; border-radius: 4px; }
.strip .stopmark { width: 2px; background: var(--text); }
.strip .me { width: 8px; margin-left: -4px; border-radius: 4px; background: var(--keyword); }
.parts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 16px 0; }
.parts div { position: relative; background: var(--gray-50); border-radius: 8px; padding: 8px 8px 16px; overflow: hidden; }
.parts span { display: block; font-size: 0.875rem; }
.parts b { font-family: var(--mono); font-size: 1.25rem; }
.parts small { font-size: 0.875rem; color: var(--text-sub); }
.parts i { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--text-sub); }
.fig-cab svg { max-width: 640px; border-radius: 8px; }
@media (max-width: 560px) { .parts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 過去のお題 */
.archive { list-style: none; padding: 0; }
.archive li { display: grid; grid-template-columns: 4.5em 9.5em minmax(0, 1fr) auto; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--gray-100); font-size: 1rem; align-items: center; }
.archive li a { font-family: var(--mono); font-weight: 800; }
.archive li.empty { display: block; color: var(--text-sub); }
.archive .st { font-size: 0.875rem; font-family: var(--mono); }
.archive .st.done { color: var(--ok); font-weight: 700; }
.archive .st.doing { color: var(--keyword); }
@media (max-width: 480px) { .archive li { grid-template-columns: 4em minmax(0, 1fr) auto; } .archive li span:nth-child(3) { display: none; } }

/* フッター（サイト内） */
.site-footer { border-top: 1px solid var(--card-border); margin-top: 40px; padding-top: 24px; }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.site-footer h2 { font-size: 1rem; margin-bottom: 8px; }
.site-footer ul { list-style: none; padding: 0; font-size: 0.875rem; }

/* ---- 縦長の画面 ---- */
@media (max-width: 560px) {
  .panel { padding: 4px; margin: 0 -8px; }
  .target-row { padding: 4px 4px 8px; }
  .target-wrap { margin-left: 0; }
  .score div { min-width: 64px; padding: 4px 8px; }
  .score dd { font-size: 1.25rem; }
  .ctl { font-size: 0.875rem; padding: 8px; }
}
@media (orientation: portrait) {
  .drive { grid-template-columns: minmax(0, 1fr); }
  .cab { aspect-ratio: 4 / 3; margin: 0 -8px; }
  .lever { height: 80px; }
  .lever ol { grid-template-rows: none; grid-template-columns: repeat(13, 1fr); }
  .lever li { justify-content: center; align-items: flex-end; padding: 0 0 4px; border-top: 0; border-left: 1px solid var(--gray-100); font-size: 0.875rem; }
  .lever li:first-child { border-left: 0; }
  .handle { top: 4px; left: 4px; width: calc((100% - 8px) / 13); height: 44px; font-size: 0.875rem; }
  .hud { min-width: 0; padding: 4px 8px; }
  .hud .speed { font-size: 1.5rem; }
  .notch-big { font-size: 1.25rem; }
  .cab-msg { font-size: 0.875rem; padding: 8px; top: 58%; }
  .cab-msg b { font-size: 1.125rem; }
  .cab-msg small { display: none; }
}

/* ---- 横長で背の低い画面（スマホを横にしたとき） ---- */
@media (orientation: landscape) and (max-height: 540px) and (min-width: 600px) {
  body { padding: 8px 16px; }
  .container { max-width: none; }
  .game { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); grid-template-areas: "intro intro" "top top" "levels levels" "panel order" "panel console" "panel controls" "result result"; column-gap: 8px; align-items: start; }
  .intro { grid-area: intro; }
  .game-top { grid-area: top; margin-bottom: 4px; }
  .levels { grid-area: levels; margin-bottom: 8px; }
  .panel { grid-area: panel; padding: 4px; }
  .order { grid-area: order; padding: 8px 8px 8px 24px; margin-bottom: 8px; }
  .order-line, .order-meta { display: none; }
  .order-cargo { margin: 4px 0 0; }
  .order-cargo li > span { display: none; }
  .console { grid-area: console; margin-top: 0; padding: 8px; }
  .controls { grid-area: controls; margin-top: 8px; flex-wrap: nowrap; }
  .result { grid-area: result; }
  .puzzle-title { font-size: 1.125rem; }
  .score div { min-width: 56px; padding: 0 8px; }
  .score dd { font-size: 1.125rem; }
  .target-row { padding: 0 4px 4px; }
  .target-text { display: none; }
  .target-wrap { margin-left: 0; }
  .target-wrap svg { height: 28px; }
  .board-wrap { max-width: none; }
  .board { height: calc(100svh - 150px); max-height: 420px; width: 100%; }
  .status { padding-top: 4px; min-height: 1.6em; font-size: 0.875rem; }
  .siding { min-height: 44px; }
  .siding b { font-size: 1.125rem; }
  .ops { gap: 4px; margin-top: 8px; }
  .op { grid-template-columns: 4.8em repeat(3, minmax(0, 1fr)); gap: 4px; }
  .key { min-height: 40px; font-size: 1rem; }
  .console .note { font-size: 0.875rem; margin-top: 4px; }
  .ctl { min-height: 40px; font-size: 0.875rem; padding: 4px 8px; }
  .game.dispatch { grid-template-areas: "intro intro" "top top" "levels levels" "panel console" "panel controls" "plan plan" "result result"; }
  .game.dispatch .plan { grid-area: plan; margin-top: 8px; }
  .game.dispatch .plan .order-line, .game.dispatch .plan .order-meta { display: inline; }
  /* 横長で背の低い画面では縮めずに横へスクロールする（縮めると文字が14pxより小さくなる） */
  .game.dispatch .diagram-wrap { overflow-x: auto; }
  .game.dispatch .diagram { max-width: none; margin: 0; }
  .game.dispatch .orders li { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .game.dispatch .tchip { min-height: 32px; }
  .game.pitatei { display: block; }
  .game.pitatei .order { display: none; }
  .game.pitatei .game-top { margin-bottom: 4px; }
  .game.pitatei .puzzle-date, .game.pitatei .level small { display: none; }
  .game.pitatei .levels { margin-bottom: 8px; padding: 4px; }
  .game.pitatei .level { padding: 4px; }
  .game.pitatei .drive { grid-template-columns: auto 96px; justify-content: center; }
  .game.pitatei .cab { height: calc(100svh - 110px); aspect-ratio: 16 / 9; }
  .game.pitatei .lever { height: calc(100svh - 110px); }
  .game.pitatei[data-mode="daily"] .cab, .game.pitatei[data-mode="daily"] .lever { height: calc(100svh - 70px); }
}
