:root {
  --bg: #04050a;
  --ink: #eef2ff;
  --dim: #9aa3bd;
  --accent: #3dd8ff;
  --pink: #ff3dbb;
  --line: rgba(255, 255, 255, 0.14);
  --glass: rgba(8, 10, 20, 0.62);
  --jp: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  --en: "Chakra Petch", "Arial Narrow", Arial, sans-serif;
  --logo: "Russo One", "Chakra Petch", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; font-family: var(--jp); -webkit-user-select: none; user-select: none; touch-action: none; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#scanlines { position: fixed; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0,0,0,0.08) 0 1px, transparent 1px 3px); mix-blend-mode: multiply; z-index: 5; }
button { font: inherit; color: inherit; cursor: pointer; }

.screen { position: fixed; inset: 0; display: none; z-index: 10; }
.screen.show { display: block; animation: fadein .35s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ロゴ */
/* ロゴ：銀のメッキ＋赤い線 */
.logo { display: flex; justify-content: center; }
.logo .mark { position: relative; display: inline-block; font-family: var(--logo); font-style: italic; font-size: clamp(54px, 10.5vw, 150px); line-height: 1; letter-spacing: .02em; padding: 0 .12em .06em .04em; transform: skewX(-10deg);
  background: linear-gradient(180deg, #ffffff 0%, #dfe6ef 38%, #7d8796 52%, #f2f5f9 70%, #aab3c0 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #2a0a10) drop-shadow(0 0 18px rgba(255,40,60,.35)); }
.logo .mark::after { content: ""; position: absolute; left: 4%; right: -2%; bottom: -.08em; height: max(4px, .06em); background: linear-gradient(90deg, transparent, #ff1e3c 20%, #ff1e3c 80%, transparent); box-shadow: 0 0 14px #ff1e3c; }
.logo.small .mark { font-size: 58px; }
#loading { display: none; place-items: center; text-align: center; background: radial-gradient(ellipse at 50% 60%, #121838, #04050a 70%); }
#loading.show { display: grid; }
.loadbar { width: min(420px, 80vw); height: 4px; background: var(--line); margin: 28px auto 12px; border-radius: 2px; overflow: hidden; }
.loadbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--pink)); box-shadow: 0 0 12px var(--accent); transition: width .2s; }
#load-msg { color: var(--dim); font-size: 14px; letter-spacing: .1em; }

/* タイトル */
#title { background: linear-gradient(180deg, rgba(4,5,10,.25), rgba(4,5,10,0) 30%, rgba(4,5,10,.0) 60%, rgba(4,5,10,.85)); }
.title-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 16px; }
.title-wrap .logo { margin-bottom: 56px; }
.hint { color: var(--dim); font-size: 12px; letter-spacing: .15em; }
.settings { position: absolute; right: 18px; bottom: 16px; display: flex; gap: 18px; font-size: 12px; color: var(--dim); }
.settings input { width: 90px; accent-color: var(--accent); vertical-align: middle; }

.btn { border: 1px solid rgba(255,255,255,.35); background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.02)); padding: 12px 26px; border-radius: 2px; font-family: var(--jp); font-weight: 700; letter-spacing: .12em; clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%); transition: background .15s, transform .1s; font-size: 15px; }
.btn:hover, .btn:focus-visible { background: linear-gradient(90deg, var(--accent), var(--pink)); color: #05060b; outline: none; }
.btn:active { transform: scale(.97); }
.btn.big { font-family: var(--en); font-size: 26px; padding: 14px 54px; letter-spacing: .3em; }
.btn.ghost { background: transparent; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 rgba(61,216,255,0); } 50% { box-shadow: 0 0 28px rgba(61,216,255,.55); } }

/* 上下の帯 */
.bar { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 16px; padding: 18px 28px; }
.bar.bottom { bottom: 0; justify-content: space-between; background: linear-gradient(0deg, rgba(4,5,10,.9), transparent); }
header.bar { top: 0; background: linear-gradient(180deg, rgba(4,5,10,.85), transparent); }
.bar h2 { margin: 0; font-family: var(--en); font-style: italic; font-size: clamp(24px, 3.4vw, 40px); letter-spacing: .08em; }
.bar h2 small { font-family: var(--jp); font-style: normal; font-size: 13px; color: var(--dim); letter-spacing: .2em; margin-left: 10px; }
.step { font-family: var(--en); font-weight: 700; font-size: 15px; color: #05060b; background: var(--accent); padding: 2px 10px; clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%); }

/* 車選び */
.car-panel { position: absolute; left: 28px; top: 50%; transform: translateY(-46%); width: min(380px, 42vw); background: var(--glass); border-left: 3px solid var(--accent); padding: 22px 24px; backdrop-filter: blur(6px); }
.car-name em { font-family: var(--en); font-style: normal; color: var(--dim); font-size: 14px; letter-spacing: .2em; }
.car-name h3 { margin: 2px 0 0; font-family: var(--en); font-style: italic; font-size: 46px; line-height: 1; letter-spacing: .04em; color: #fff; text-shadow: 0 0 18px var(--accent); }
.car-name p { margin: 4px 0 0; color: var(--dim); font-size: 13px; letter-spacing: .2em; }
.car-desc { font-size: 13.5px; line-height: 1.8; color: #d7dcef; margin: 14px 0 16px; }
.stats { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.stats li { display: grid; grid-template-columns: 92px 1fr; align-items: center; font-size: 12px; letter-spacing: .1em; color: var(--dim); }
.stats .meter { height: 8px; background: rgba(255,255,255,.08); position: relative; clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%); }
.stats .meter i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--accent), #fff); box-shadow: 0 0 10px var(--accent); transition: width .35s cubic-bezier(.2,.8,.2,1); }
.spec { margin-top: 14px; display: flex; gap: 16px; font-family: var(--en); font-size: 15px; color: #fff; flex-wrap: wrap; }
.spec span { color: var(--dim); font-size: 11px; display: block; letter-spacing: .15em; font-family: var(--jp); }
.arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 56px; height: 90px; font-size: 54px; line-height: 1; background: rgba(255,255,255,.05); border: 1px solid var(--line); color: #fff; }
.arrow:hover { background: var(--accent); color: #05060b; }
.arrow.left { left: calc(min(380px, 42vw) + 60px); } .arrow.right { right: 28px; }

/* ステージ選び */
.sel-car { margin-left: auto; font-family: var(--en); font-size: 18px; color: var(--dim); letter-spacing: .1em; }
.sel-car b { color: #fff; font-size: 22px; font-style: italic; }
.stage-grid { position: absolute; top: 96px; bottom: 88px; left: 0; right: 0; display: flex; justify-content: center; align-items: stretch; gap: 24px; padding: 0 36px; }
.stage { cursor: pointer; position: relative; flex: 1 1 0; max-width: 430px; min-width: 0; display: flex; flex-direction: column; background: rgba(6,8,16,.95); border: 1px solid var(--line); overflow: hidden; text-align: left;
  transition: transform .2s, border-color .2s, box-shadow .2s, opacity .2s; opacity: .72; backdrop-filter: blur(6px); }
.stage::after { content: ""; position: absolute; inset: auto 0 0 0; height: 4px; background: var(--c); box-shadow: 0 0 16px var(--c); opacity: .6; }
.stage.sel, .stage:hover, .stage:focus-visible { opacity: 1; transform: translateY(-6px) scale(1.02); border-color: var(--c); box-shadow: 0 0 40px -8px var(--c), 0 20px 50px -20px #000; outline: none; }
.stage.sel::after { opacity: 1; }
.stage .thumb { position: relative; flex: 0 0 34%; min-height: 120px; background-size: cover; background-position: center; }
.stage .thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(6,8,16,0) 40%, rgba(6,8,16,.95)); }
.stage .body { position: relative; flex: 1; display: flex; flex-direction: column; padding: 0 20px 18px; margin-top: -46px; min-height: 0; }
.stage .head { display: flex; align-items: center; justify-content: space-between; }
.stage .no { font-family: var(--logo); font-style: italic; font-size: 46px; line-height: 1; color: #fff; text-shadow: 0 0 18px var(--c); }
.stage .type { font-size: 12px; font-weight: 700; letter-spacing: .2em; padding: 4px 10px; border: 1px solid var(--c); color: var(--c); background: rgba(0,0,0,.5); }
.stage h4 { margin: 6px 0 0; font-size: 21px; font-weight: 900; letter-spacing: .04em; line-height: 1.3; }
.stage .en { font-family: var(--en); font-size: 12px; letter-spacing: .3em; color: var(--c); margin-bottom: 4px; }
.stage canvas.map { display: block; width: 100%; height: auto; aspect-ratio: 560 / 200; margin: 4px 0 6px; flex: 0 1 auto; min-height: 0; }
.stage .sub { font-size: 13px; color: #c9cfe2; line-height: 1.7; margin: 0 0 10px; }
.stage .facts { list-style: none; margin: 0; padding: 10px 0 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 10px; }
.stage .facts li { display: flex; flex-direction: column; }
.stage .facts span { font-size: 11px; color: var(--dim); letter-spacing: .1em; }
.stage .facts b { font-family: var(--en); font-size: 17px; font-weight: 600; color: #fff; }
.stage .rec { margin-top: auto; padding-top: 12px; font-family: var(--en); font-size: 16px; color: #ffe27a; letter-spacing: .05em; }
.stage .rec small { color: var(--dim); margin-left: 6px; }
.stage .rec.none { color: rgba(255,255,255,.45); }
.stage .go { margin-top: 10px; text-align: center; font-weight: 700; letter-spacing: .15em; font-size: 13px; padding: 9px 0; border: 1px solid var(--c); color: var(--c); opacity: 0; transition: opacity .2s; }
.stage.sel .go, .stage:hover .go { opacity: 1; background: color-mix(in srgb, var(--c) 18%, transparent); }
.keyhint { color: #c9cfe2 !important; font-size: 13px !important; letter-spacing: .15em; }
@media (max-width: 760px) {
  .stage-grid { flex-direction: column; justify-content: flex-start; overflow-y: auto; padding: 8px 16px 20px; top: 70px; gap: 16px; }
  .stage { flex: 0 0 auto; max-width: none; opacity: 1; }
  .stage.sel, .stage:hover, .stage:focus-visible { transform: none; }
  .stage .thumb { flex: 0 0 auto; height: 140px; }
  .stage .go { opacity: 1; }
}
@media (max-height: 560px) and (min-width: 761px) {
  .stage .sub, .stage .go { display: none; }
  .stage .thumb { flex-basis: 26%; min-height: 70px; }
  .stage .no { font-size: 34px; } .stage h4 { font-size: 17px; }
}

/* 走行中 */
.hud { pointer-events: none; }
.hud button { pointer-events: auto; }
.hud-top { position: absolute; top: 14px; left: 18px; right: 18px; display: flex; align-items: flex-start; gap: 16px; }
.h-stage { font-size: 14px; letter-spacing: .1em; background: var(--glass); padding: 8px 14px; border-left: 3px solid var(--accent); }
.h-stage b { font-family: var(--en); font-style: italic; font-size: 18px; margin-right: 8px; color: var(--accent); }
.h-stage span { margin-left: 10px; font-size: 11px; border: 1px solid var(--accent); color: var(--accent); padding: 1px 6px; }
.h-timebox { margin: 0 auto; text-align: center; }
.h-time { font-family: var(--en); font-weight: 700; font-size: clamp(34px, 5vw, 56px); line-height: 1; letter-spacing: .04em; text-shadow: 0 0 18px rgba(255,255,255,.35); font-variant-numeric: tabular-nums; }
.h-best { font-family: var(--en); font-size: 15px; color: #ffe27a; letter-spacing: .1em; }
#minimap { width: 150px; height: 150px; background: radial-gradient(circle, rgba(8,10,20,.7), rgba(8,10,20,.35)); border: 1px solid var(--line); border-radius: 50%; }
.h-prog { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); width: min(460px, 60vw); height: 4px; background: rgba(255,255,255,.12); }
.h-prog i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--accent), #fff); box-shadow: 0 0 10px var(--accent); }
.h-prog span { position: absolute; right: 0; top: 8px; font-family: var(--en); font-size: 13px; color: var(--dim); }
#h-msg { position: absolute; left: 0; right: 0; top: 34%; text-align: center; font-family: var(--en); font-weight: 700; font-style: italic; font-size: clamp(60px, 12vw, 150px); color: #fff; opacity: 0; transform: scale(1.4); transition: opacity .2s, transform .25s; text-shadow: 0 0 30px var(--accent), 0 0 60px var(--accent); }
#h-msg.show { opacity: 1; transform: scale(1); }
#h-msg.small { font-size: clamp(26px, 4vw, 44px); }
.gauges { position: absolute; right: 16px; bottom: 14px; display: flex; gap: 6px; }
.gauges canvas { width: clamp(150px, 17vw, 230px); height: clamp(150px, 17vw, 230px); filter: drop-shadow(0 8px 20px rgba(0,0,0,.6)); }
.keys-help { position: absolute; left: 18px; bottom: 14px; font-size: 11px; color: rgba(255,255,255,.45); letter-spacing: .08em; max-width: 46vw; line-height: 1.7; }
.pause-btn { position: absolute; right: 18px; top: 178px; width: 40px; height: 40px; background: var(--glass); border: 1px solid var(--line); font-size: 16px; }
.touch { display: none; }
@media (pointer: coarse) {
  .keys-help { display: none; }
  .touch { display: block; }
  .touch button { position: absolute; bottom: 18px; width: 74px; height: 74px; border-radius: 50%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.3); font-size: 22px; pointer-events: auto; font-family: var(--en); font-weight: 700; }
  .touch button.on { background: rgba(61,216,255,.45); }
  .touch [data-k=left] { left: 16px; } .touch [data-k=right] { left: 100px; }
  .touch .thr { right: 16px; bottom: 200px; width: 84px; height: 84px; } .touch .brk { right: 110px; bottom: 200px; font-size: 14px; } .touch .hb { right: 16px; bottom: 296px; width: 64px; height: 64px; font-size: 12px; }
  .touch .thr { font-size: 16px; }
  .gauges canvas { width: 120px; height: 120px; }
}

/* モーダル */
.modal { background: rgba(2,3,8,.6); backdrop-filter: blur(4px); }
.modal.show { display: grid; place-items: center; }
.card { background: linear-gradient(160deg, rgba(20,24,44,.95), rgba(8,9,18,.95)); border: 1px solid var(--line); padding: 28px 34px; min-width: min(420px, 92vw); display: flex; flex-direction: column; gap: 12px; text-align: center; box-shadow: 0 0 60px -10px var(--accent); }
.card h2 { margin: 0 0 8px; font-family: var(--en); font-style: italic; font-size: 44px; letter-spacing: .1em; }
.result .r-stage { margin: 0; color: var(--dim); letter-spacing: .15em; font-size: 13px; }
.result h2 { background: linear-gradient(90deg, var(--accent), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; font-size: 56px; }
.r-time { font-family: var(--en); font-weight: 700; font-size: 64px; line-height: 1; text-shadow: 0 0 20px rgba(255,255,255,.4); font-variant-numeric: tabular-nums; }
.r-new { font-family: var(--en); font-weight: 700; letter-spacing: .3em; color: #ffe27a; text-shadow: 0 0 14px #ffb800; animation: pulse 1s infinite; display: none; }
.r-new.on { display: block; }
.r-list { display: grid; grid-template-columns: 1fr auto; gap: 6px 24px; margin: 8px 0; text-align: left; font-size: 14px; }
.r-list dt { color: var(--dim); } .r-list dd { margin: 0; font-family: var(--en); font-size: 17px; text-align: right; }
.r-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

@media (max-width: 760px) {
  .car-panel { left: 16px; right: 16px; width: auto; top: auto; bottom: 86px; transform: none; padding: 14px 16px; }
  .car-desc { display: none; }
  .car-name h3 { font-size: 34px; }
  .arrow { top: 34%; } .arrow.left { left: 16px; } .arrow.right { right: 16px; }
  .bar { padding: 12px 16px; }
  .h-stage { display: none; }
  .settings { left: 16px; right: 16px; justify-content: center; }
}

/* 最初のクリック */
#splash { background: radial-gradient(ellipse at 50% 60%, #121838, #04050a 70%); }
.splash-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; text-align: center; padding: 16px; }

/* 順位とライバル */
.h-left { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.h-pos { display: flex; align-items: baseline; gap: 2px; font-family: var(--en); font-style: italic; font-weight: 700; color: #fff; text-shadow: 0 0 16px var(--accent); background: var(--glass); padding: 2px 14px 4px 12px; border-left: 3px solid var(--accent); }
.h-pos b { font-size: 48px; line-height: 1; }
.h-pos span { font-size: 20px; margin-right: 10px; }
.h-pos em { font-style: normal; font-size: 20px; color: #7dffb0; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.h-pos.lose { border-left-color: #ff2a50; text-shadow: 0 0 16px #ff2a50; }
.h-pos.lose em { color: #ff6f86; }
.h-prog b { position: absolute; top: -4px; width: 4px; height: 12px; margin-left: -2px; background: #ff2a50; box-shadow: 0 0 8px #ff2a50; }
.result h2.lose { background: linear-gradient(90deg, #ff2a50, #ff9a3d); -webkit-background-clip: text; background-clip: text; }
@media (max-width: 760px) { .h-stage { display: none; } .h-pos b { font-size: 34px; } }

/* 遊び方・ステージ・車 */
.btn.small { font-size: 13px; padding: 8px 18px; margin-top: 14px; letter-spacing: .08em; }
.about.show { display: grid; place-items: center; overflow-y: auto; padding: 24px 12px; }
.about-card { position: relative; text-align: left; max-width: 760px; width: 100%; max-height: calc(100vh - 48px); overflow-y: auto; gap: 0; padding: 28px 30px; -webkit-user-select: text; user-select: text; touch-action: pan-y; }
.about-card h1 { font-family: var(--logo); font-style: italic; font-size: 30px; margin: 0 0 10px; color: #fff; }
.about-card h2 { font-size: 17px; margin: 22px 0 8px; padding-left: 10px; border-left: 3px solid #ff1e3c; font-family: var(--jp); font-style: normal; letter-spacing: .05em; }
.about-card p, .about-card li, .about-card td, .about-card dd { font-size: 14px; line-height: 1.8; color: #d7dcef; }
.about-card .lead { margin: 0; }
.about-card ol, .about-card ul { margin: 0; padding-left: 1.4em; }
.about-card .list { list-style: none; padding: 0; }
.about-card .list li { padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.about-card b { color: #fff; }
.keys { border-collapse: collapse; width: 100%; }
.keys th { text-align: left; white-space: nowrap; vertical-align: top; padding: 6px 14px 6px 0; font-size: 13px; color: var(--dim); }
.keys td { padding: 6px 0; }
.faq dt { font-weight: 700; margin-top: 10px; color: #fff; font-size: 14px; }
.faq dd { margin: 2px 0 0; }
.about-close { position: absolute; right: 12px; top: 10px; width: 36px; height: 36px; background: none; border: 1px solid var(--line); font-size: 20px; color: #fff; }
.about-foot { margin-top: 20px !important; font-size: 13px !important; }
.about-foot a { color: #8fd8ff; }
.cam-btn { position: absolute; right: 66px; top: 178px; height: 40px; padding: 0 12px; background: var(--glass); border: 1px solid var(--line); font-size: 13px; }

/* ---------- スマホ・タブレット ---------- */
@media (max-width: 760px) {
  .btn.big { font-size: 18px; padding: 12px 30px; letter-spacing: .2em; white-space: nowrap; }
  .bar h2 { font-size: 22px; white-space: nowrap; }
  .bar h2 small { display: none; }
  .sel-car { font-size: 13px; white-space: nowrap; } .sel-car b { font-size: 16px; }
  .bar.bottom .hint { display: none; }
  .bar.bottom .btn { padding: 10px 16px; font-size: 13px; white-space: nowrap; }
  .about-card { padding: 22px 18px; }
  .about-card h1 { font-size: 24px; padding-right: 40px; }
  .keys th { display: block; padding-bottom: 0; } .keys td { display: block; }
}
@media (max-height: 500px) {
  header.bar { padding: 8px 16px; }
  .bar.bottom { padding: 8px 16px; }
  .car-panel { top: 52px; bottom: 58px; transform: none; padding: 10px 16px; overflow-y: auto; width: min(340px, 46vw); }
  .car-desc { display: none; }
  .car-name h3 { font-size: 28px; }
  .stats { gap: 5px; } .spec { margin-top: 8px; font-size: 13px; }
  .arrow { height: 64px; width: 44px; font-size: 40px; } .arrow.left { left: calc(min(340px, 46vw) + 28px); }
  .stage-grid { top: 56px; bottom: 58px; }
  .title-wrap .logo { margin-bottom: 24px; }
}
@media (pointer: coarse) {
  /* 走行中の配置：上＝順位・タイム・ミニマップ、下＝左にハンドル、右にアクセル類、まん中にメーター */
  .hud-top { top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; gap: 8px; }
  .h-stage { display: none; }
  .h-pos b { font-size: 30px; } .h-pos span { font-size: 15px; } .h-pos em { font-size: 15px; }
  .h-time { font-size: 30px; } .h-best { font-size: 12px; }
  #minimap { width: 92px; height: 92px; }
  .h-prog { top: 62px; width: 44vw; }
  .pause-btn { top: 112px; right: 10px; width: 40px; }
  .cam-btn { top: 112px; right: 56px; }
  .gauges { right: auto; left: 50%; transform: translateX(-50%); bottom: max(8px, env(safe-area-inset-bottom)); gap: 2px; }
  .gauges canvas { width: 96px; height: 96px; }
  .touch button { bottom: max(14px, env(safe-area-inset-bottom)); width: 70px; height: 70px; }
  .touch [data-k=left] { left: 12px; } .touch [data-k=right] { left: 92px; }
  .touch .thr { right: 12px; bottom: max(14px, env(safe-area-inset-bottom)); width: 82px; height: 82px; }
  .touch .brk { right: 102px; bottom: max(14px, env(safe-area-inset-bottom)); }
  .touch .hb { right: 12px; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 92px); width: 62px; height: 62px; }
  #h-msg { top: 28%; }
}
@media (pointer: coarse) and (max-aspect-ratio: 1/1) {
  /* 縦向き：メーターはボタンの上に */
  .gauges { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 84px); }
  .touch .hb { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 92px); }
}
@media (max-width: 440px) { .sel-car { display: none; } }

/* 数字を同じ幅に（字体の数字の幅がそろっていないため） */
i.d { font-style: inherit; display: inline-block; width: .62em; text-align: center; }
i.p { font-style: inherit; display: inline-block; width: .3em; text-align: center; }

.title-links { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
a.btn { text-decoration: none; display: inline-block; color: #eef2ff; }

/* NIGHTHAWK の印と、登場の知らせ */
.h-prog b.nh { position: absolute; top: -4px; width: 4px; height: 12px; margin-left: -2px; background: #b98cff; box-shadow: 0 0 8px #b98cff; }
#h-msg.warn { color: #e9dcff; font-size: clamp(44px, 8vw, 110px); text-shadow: 0 0 24px #8b4dff, 0 0 60px #8b4dff; letter-spacing: .08em; }

/* モード選び */

/* NIGHTHAWK 登場の文字：左からさっと入り、中央で止まり、右へさっと抜ける */
#h-nh { position: absolute; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none; overflow: hidden; visibility: hidden; }
#h-nh span { display: inline-block; font-family: var(--en); font-weight: 700; font-style: italic; font-size: clamp(30px, 6.5vw, 96px); letter-spacing: .06em; color: #f0e6ff; text-shadow: 0 0 22px #8b4dff, 0 0 56px #8b4dff; white-space: nowrap; }
#h-nh.run { visibility: visible; }
#h-nh.run span { animation: nh-pass 3200ms linear both; animation-duration: inherit; }
@keyframes nh-pass {
  0% { transform: translateX(-110vw) skewX(-14deg); animation-timing-function: cubic-bezier(.2, .9, .3, 1); }
  10% { transform: translateX(0) skewX(-8deg); animation-timing-function: linear; }
  86% { transform: translateX(0) skewX(-8deg); animation-timing-function: cubic-bezier(.7, 0, .9, .4); }
  100% { transform: translateX(110vw) skewX(-14deg); }
}

/* オープニング：夜の車の中。下に会話の枠 */
#opening { z-index: 40; background: #000; cursor: pointer; }
#opening .op-bg { position: absolute; inset: 0; background: url(assets/opening.jpg) center / cover no-repeat; animation: op-zoom 60s linear both; transition: opacity 2.6s ease; }
#opening.fade .op-bg { opacity: 0; }
@keyframes op-zoom { from { transform: scale(1.0); } to { transform: scale(1.08); } }
.op-skip { position: absolute; top: 16px; right: 16px; z-index: 2; font-family: var(--en); font-size: 14px; letter-spacing: .15em; color: #cfd6ea; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.25); border-radius: 6px; padding: 8px 14px; cursor: pointer; }
.op-box { position: absolute; left: 50%; bottom: 5vh; transform: translateX(-50%); width: min(960px, calc(100vw - 32px)); min-height: 130px; box-sizing: border-box; padding: 34px 28px 22px; background: linear-gradient(180deg, rgba(8,10,18,.82), rgba(4,5,10,.92)); border: 1px solid rgba(160,180,255,.22); border-radius: 10px; opacity: 0; transition: opacity .3s; }
.op-box.on { opacity: 1; }
.op-name { position: absolute; top: -14px; left: 22px; padding: 4px 16px; border-radius: 4px; font-size: 15px; font-weight: 700; letter-spacing: .15em; color: #fff; }
.op-name.me { background: #2b4dbb; }
.op-name.tel { background: #5a5f6e; }
.op-text { margin: 0; font-size: clamp(16px, 2.2vw, 22px); line-height: 1.7; color: #eef1fa; }
.op-next { position: absolute; right: 18px; bottom: 10px; font-style: normal; color: #9fb0ff; opacity: 0; }
#opening.wait .op-next { opacity: 1; animation: op-blink 1s infinite; }
@keyframes op-blink { 50% { opacity: .2; } }

/* タイトルの操作方法：PC はキーボード、スマホは画面のボタン */
.ctrl-help { margin: 14px auto 0; width: min(520px, calc(100vw - 32px)); text-align: left; background: rgba(6,8,18,.62); border: 1px solid rgba(160,180,255,.2); border-radius: 10px; padding: 12px 16px; box-sizing: border-box; }
.ctrl-ttl { margin: 0 0 8px; font-size: 13px; letter-spacing: .15em; color: #9fb0ff; }
.ctrl dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; align-items: center; }
.ctrl dt { white-space: nowrap; color: #fff; font-size: 13px; }
.ctrl dd { margin: 0; color: #d7dcef; font-size: 13px; }
.ctrl kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; margin: 0 1px; border: 1px solid rgba(255,255,255,.4); border-bottom-width: 2px; border-radius: 4px; font-family: var(--en); font-size: 12px; text-align: center; color: #fff; background: rgba(255,255,255,.06); }
.ctrl b { font-family: var(--en); color: #fff; }
.ctrl-note { margin: 8px 0 0; font-size: 12px; color: var(--dim); line-height: 1.6; }
.ctrl.sp { display: none; }
@media (pointer: coarse) { .ctrl.pc { display: none; } .ctrl.sp { display: block; } }

/* エンディングの前に画面をゆっくり暗くする */
#fader { position: fixed; inset: 0; z-index: 39; background: #000; opacity: 0; pointer-events: none; transition: opacity 2.5s ease; }
#fader.on { opacity: 1; }
