:root {
  --concrete: #E8D2A8; --shade: #B9B2A6; --asphalt: #3A3A3C; --yellow: #F2C230; --sky: #A9C3BE; --red: #E0262B; --jet: #F4F6F7;
  --steel: #C9CDD0; --ink: #141414; --paper: #F3F3EE;
  --mono: "Azeret Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --goth: "Zen Kaku Gothic Antique", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-user-drag: none; touch-action: none; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #111; color: #fff; font-family: var(--mono); overscroll-behavior: none; }
input[type=text] { user-select: text; -webkit-user-select: text; }
#app { position: fixed; inset: 0; overflow: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#fx { position: absolute; inset: 0; pointer-events: none; }
#touch { position: absolute; inset: 0; }
.hidden { display: none !important; }
svg.ic { width: 1.15em; height: 1.15em; display: block; flex: 0 0 auto; }

/* 計器の帯（プレイ中） */
.burn { position: absolute; left: 0; right: 0; top: 0; height: var(--bh, 24px); background: linear-gradient(180deg, rgba(0,0,0,.72), rgba(0,0,0,.45)); display: flex; align-items: center; gap: 1.3em; padding: 0 max(12px, env(safe-area-inset-left)); font: 600 var(--bf, 13px)/1 var(--mono); color: #f2f2f2; white-space: nowrap; overflow: hidden; pointer-events: none; z-index: 5; }
body.nohud .burn { display: none; }
.rd { display: flex; align-items: baseline; gap: .35em; }
.rd i { font-style: normal; font-size: .72em; color: #b9b9b9; letter-spacing: .06em; }
.rd b { font-weight: 800; font-size: 1.15em; }
.rd em { font-style: normal; font-size: .72em; color: #ccc; }
.rd .ic { align-self: center; }
#bState { font-weight: 800; letter-spacing: .06em; }
#bState:empty { display: none; }
.burn .warn { color: #ff5b4f; }
.burn .hov { color: #fff7c9; }
.burn .ok { color: var(--yellow); }
.faint { margin-left: auto; opacity: .38; font-size: .78em; }
#bWind:empty { display: none; }

/* プレイ中 HUD */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
#airMeter { position: absolute; left: 0; top: 0; width: 84px; height: 9px; transform: translate(-50%, -100%); padding: 1px; background: rgba(10,10,10,.75); outline: 1px solid rgba(255,255,255,.35); }
#airSegs { display: flex; gap: 2px; width: 100%; height: 100%; }
#airSegs i { display: block; height: 100%; background: #3a3a3a; position: relative; overflow: hidden; }
#airSegs i b { position: absolute; left: 0; top: 0; bottom: 0; background: #f4f6f7; }
#airMeter.hover #airSegs i b { background: #fffbe0; box-shadow: 0 0 6px #fff; }
#airMeter.low #airSegs i b { background: #ff5b4f; }
#hint { position: absolute; left: 0; top: 0; transform: translate(-50%, 0); display: flex; align-items: center; gap: 6px; font: 800 13px/1 var(--mono); letter-spacing: .05em; color: #fff; background: rgba(0,0,0,.62); padding: 4px 8px; white-space: nowrap; opacity: 0; transition: opacity .18s; }
#hint .ic { width: 16px; height: 16px; }
#hint.on { opacity: 1; }
#hint:not(.on) { visibility: hidden; }
#pop { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); font: 800 18px/1 var(--mono); letter-spacing: .06em; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.6); white-space: nowrap; opacity: 0; }
#pop.on { opacity: 1; }
#pop:not(.on) { visibility: hidden; }
#arrow { position: absolute; inset: 0; overflow: visible; }
#arrowLine { stroke: rgba(255,255,255,.9); stroke-width: 2; }
#arrowDot { fill: none; stroke: rgba(255,255,255,.85); stroke-width: 1.5; }
#arrowHead { fill: rgba(255,255,255,.95); }
#btnPause { position: absolute; right: max(8px, env(safe-area-inset-right)); top: calc(var(--bh, 24px) + 6px); width: 40px; height: 34px; pointer-events: auto; }
.gauge { position: absolute; bottom: max(8px, env(safe-area-inset-bottom)); width: var(--gs, 58px); height: var(--gs, 58px); }
#gaugeG { left: max(8px, env(safe-area-inset-left)); }
#gaugeA { right: max(8px, env(safe-area-inset-right)); }
.gauge svg { width: 100%; height: 100%; }
.g-ring { fill: rgba(12,12,12,.78); stroke: #d9d9d9; stroke-width: 2.5; }
.g-red { fill: none; stroke: var(--red); stroke-width: 6; }
#gTicks line, #aTicks line { stroke: #e9e9e9; stroke-width: 2; }
#gNeedle, #aNeedle { stroke: var(--yellow); stroke-width: 3.2; stroke-linecap: square; }
.g-hub { fill: #ddd; }
.g-lab { position: absolute; left: 0; right: 0; top: 60%; text-align: center; font: 600 8px/1 var(--mono); color: #bbb; }
.g-val { position: absolute; left: 0; right: 0; top: 72%; text-align: center; font: 800 10px/1 var(--mono); color: #fff; }
.gauge.redzone .g-val { color: #ff5b4f; }
#countdown { position: absolute; left: 50%; top: calc(var(--bh, 24px) + 10px); transform: translateX(-50%); display: flex; gap: 8px; padding: 6px 9px; background: rgba(10,10,10,.82); opacity: 0; transition: opacity .2s; }
#countdown.on { opacity: 1; }
#countdown i { width: 16px; height: 16px; border-radius: 50%; background: #3b2020; border: 2px solid #555; }
#countdown i.lit { background: #ff3b30; box-shadow: 0 0 10px #ff3b30; }
#countdown i.go.lit { background: #f4f6f7; box-shadow: 0 0 12px #fff; }

/* 金属プレートのボタン（黄黒の斜め縞の縁、角は小さく面取り） */
.plate { position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 800 14px/1 var(--mono); letter-spacing: .06em; color: #111; border: none; cursor: pointer; padding: 0 12px; height: 34px; white-space: nowrap; overflow: hidden;
  clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
  background: repeating-linear-gradient(-45deg, var(--yellow) 0 6px, #161616 6px 12px); background-size: 17px 17px; }
.plate::before { content: ""; position: absolute; inset: 4px; clip-path: polygon(3px 0, calc(100% - 3px) 0, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 0 calc(100% - 3px), 0 3px);
  background: linear-gradient(180deg, #e9ebec 0%, #c6cacd 55%, #b2b7ba 100%); z-index: -1; }
.plate.pressed, .plate:active { animation: stripes .35s linear infinite; }
@keyframes stripes { to { background-position: 17px 0; } }
.plate.sel::before { background: linear-gradient(180deg, #fff6cf 0%, #f2d36a 100%); }
.plate.red::before { background: linear-gradient(180deg, #ef4b3f 0%, #c9271f 60%, #a81f19 100%); }
.plate.red { color: #fff; }
.plate.icon { padding: 0; }
.plate .ic { width: 18px; height: 18px; }
.plate.small { height: 30px; font-size: 12px; padding: 0 10px; }
.plate.icon.small { width: 38px; padding: 0; }
.plate.big { height: 48px; font-size: 22px; padding: 0 26px; letter-spacing: .14em; }
.plate.big .ic { width: 20px; height: 20px; }
.plate:focus { outline: none; }

/* 画面（固定の設計サイズを縮尺） */
.screen { position: absolute; inset: 0; z-index: 6; }
.stage { position: absolute; left: 50%; top: 50%; transform-origin: 0 0; }
.land .stage { width: 667px; height: 375px; }
.port .stage { width: 375px; height: 667px; }

/* タイトル */
#title .logo { position: absolute; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.35); }
#title .logo .l1 { font: 800 46px/1 var(--mono); letter-spacing: -.01em; white-space: nowrap; }
#title .logo .l2 { font: 600 12px/1.4 var(--mono); letter-spacing: .12em; margin-top: 4px; white-space: nowrap; display: flex; gap: 10px; align-items: baseline; }
#title .logo .ja { font: 700 11px/1 var(--goth); letter-spacing: .05em; opacity: .85; }
.land #title .logo { left: 18px; top: 16px; }
.port #title .logo { left: 16px; top: 22px; }
.port #title .logo .l1 { font-size: 38px; }
.topBtns { position: absolute; display: flex; gap: 6px; }
.topBtns .plate { width: 40px; height: 36px; }
.land .topBtns { right: 14px; top: 14px; }
.port .topBtns { right: 12px; top: 84px; }
.card { position: absolute; background: var(--paper); padding: 6px 8px; color: #111; }
.land .card { left: 18px; top: 96px; width: 182px; }
.port .card { left: 12px; top: 338px; width: 351px; }
.cardName { font: 800 15px/1.1 var(--mono); white-space: nowrap; overflow: hidden; }
.bars { display: grid; grid-template-columns: 16px 1fr; gap: 3px 6px; margin: 5px 0 4px; align-items: center; }
.port .bars { grid-template-columns: 16px 1fr 16px 1fr; }
.bars span { color: #333; width: 16px; height: 16px; }
.bars span .ic { width: 16px; height: 16px; }
.bars i { display: block; height: 6px; background: #ddd; position: relative; }
.bars i b { position: absolute; left: 0; top: 0; bottom: 0; background: #2a2a2a; }
.bars i b.y { background: #c79a10; }
.cardBest { display: flex; align-items: center; gap: 5px; font: 700 11px/1 var(--mono); color: #333; }
.cardBest .ic { width: 14px; height: 14px; }
.shelf { position: absolute; }
.land .shelf { left: 16px; top: 234px; width: 635px; }
.port .shelf { left: 12px; top: 420px; width: 351px; }
.shelfGrid { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.port .shelfGrid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tag { position: relative; overflow: hidden; min-width: 0; background: rgba(243,243,238,.92); height: 62px; padding: 3px 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 2px solid transparent; }
.tag img { width: 100%; height: 40px; object-fit: contain; }
.tag .tn { font: 600 7.5px/1 var(--mono); color: #444; white-space: nowrap; transform-origin: center; }
.tag.sel { border-color: var(--red); background: #fff; }
.textRow { position: absolute; display: flex; gap: 5px; align-items: center; background: rgba(14,14,14,.6); padding: 4px 4px 4px 8px; }
.land .textRow { left: 16px; top: 314px; width: 280px; }
.port .textRow { left: 12px; top: 562px; width: 351px; }
.tIc { color: #fff; }
#textIn { flex: 1; min-width: 0; height: 30px; font: 700 16px/1 var(--mono), var(--goth); padding: 0 6px; border: 2px solid #222; background: #fff; color: #111; border-radius: 0; outline: none; touch-action: manipulation; letter-spacing: .04em; }
#textIn::placeholder { color: #999; font-size: 13px; }
.textMsg { position: absolute; font: 700 11px/1.3 var(--mono); color: #fff; background: rgba(0,0,0,.7); padding: 2px 6px; white-space: nowrap; overflow: hidden; }
.land .textMsg { left: 16px; top: 354px; max-width: 420px; }
.port .textMsg { left: 12px; top: 602px; max-width: 351px; }
.textMsg:empty { display: none; }
#btnStart { position: absolute; }
.land #btnStart { left: 451px; top: 310px; width: 200px; }
.port #btnStart { left: 12px; top: 608px; width: 351px; }

/* 設定 */
#settings { position: absolute; inset: 0; background: rgba(0,0,0,.45); z-index: 2; }
.setPanel { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, 92vw); background: #1a1a1a; border: 2px solid #555; padding: 10px 12px 6px; }
.setHead { display: flex; justify-content: space-between; align-items: center; font: 800 14px/1 var(--mono); letter-spacing: .1em; margin-bottom: 10px; }
.optRow { display: flex; align-items: center; gap: 8px; }
.optLab { width: 24px; height: 24px; color: #ddd; flex: 0 0 auto; }
.optLab .ic { width: 22px; height: 22px; }
.seg { display: flex; gap: 4px; flex: 1; min-width: 0; }
.seg .plate { height: 32px; font-size: 11px; padding: 0 4px; flex: 1; min-width: 0; letter-spacing: .02em; }
.optDesc { font: 400 11px/1.35 var(--mono); color: #ddd; margin: 4px 0 10px 32px; min-height: 15px; white-space: nowrap; overflow: hidden; }

/* 遊び方 */
#howto { background: rgba(0,0,0,.35); }
.howSheet { position: absolute; background: var(--paper); color: #111; padding: 14px 18px; background-image: linear-gradient(rgba(0,0,0,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,.05) 1px, transparent 1px); background-size: 12px 12px; }
.land .howSheet { left: 83px; top: 40px; width: 500px; height: 295px; }
.port .howSheet { left: 20px; top: 120px; width: 335px; height: 430px; }
.howHead { font: 800 18px/1 var(--mono); letter-spacing: .12em; border-bottom: 3px solid #111; padding-bottom: 6px; margin-bottom: 12px; }
.steps { display: flex; gap: 12px; }
.port .steps { flex-direction: column; gap: 10px; }
.step { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.port .step { flex-direction: row; text-align: left; align-items: center; }
.step .pic { width: 64px; height: 64px; background: #111; color: var(--yellow); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.step .pic .ic { width: 40px; height: 40px; }
.step b { font: 800 15px/1 var(--mono); letter-spacing: .08em; }
.port .step b { width: 92px; flex: 0 0 auto; }
.step span { font: 400 12px/1.4 var(--mono); color: #333; }
.howFoot { font: 700 13px/1.4 var(--mono); color: #333; margin-top: 12px; }
.howKeys { font: 400 11px/1.4 var(--mono); color: #555; margin-top: 4px; }
#btnHowOk { position: absolute; right: 18px; bottom: 14px; }
body.touchdev .pc-only { display: none; }

/* 一時停止 */
#pause { background: rgba(0,0,0,.45); }
.pausePanel { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: #1a1a1a; border: 2px solid #555; padding: 12px 14px; width: min(300px, 86vw); }
.pHead { font: 800 14px/1 var(--mono); letter-spacing: .12em; color: #fff; margin-bottom: 10px; }
.vol { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; color: #ddd; }
.vol span .ic { width: 20px; height: 20px; }
.vol input { flex: 1; accent-color: var(--yellow); height: 24px; }
.pBtns { display: flex; gap: 6px; }
.pBtns .plate.red { flex: 1; font-size: 13px; }
.pBtns .plate.icon { width: 42px; }

/* 結果 */
#result { background: rgba(0,0,0,.25); }
.photo { position: absolute; background: #0d0d0d; padding: 3px; }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.land .photo { left: 16px; top: 12px; width: 635px; height: 214px; }
.port .photo { left: 10px; top: 28px; width: 355px; height: 200px; }
.bigDist { position: absolute; display: flex; align-items: baseline; gap: 6px; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,.5); white-space: nowrap; }
.land .bigDist { left: 20px; top: 232px; }
.port .bigDist { left: 14px; top: 236px; }
.bigDist b { font: 800 54px/1 var(--mono); letter-spacing: -.02em; }
.bigDist em { font: 700 20px/1 var(--mono); font-style: normal; }
#rOk { font: 800 12px/1 var(--mono); letter-spacing: .1em; padding: 4px 6px; margin-left: 6px; background: #111; color: #fff; align-self: center; }
#rOk.ng { background: #b51d18; }
.newRec { display: inline-flex; align-items: center; gap: 4px; font: 800 12px/1 var(--mono); letter-spacing: .08em; color: #111; background: var(--yellow); padding: 4px 6px; align-self: center; }
.newRec .ic { width: 14px; height: 14px; }
.sheet { position: absolute; background: rgba(243,243,238,.95); color: #111; padding: 6px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px 14px; }
.land .sheet { left: 20px; top: 300px; width: 370px; }
.port .sheet { left: 14px; top: 300px; width: 347px; }
.rl { display: flex; justify-content: space-between; gap: 8px; font: 400 10px/1.5 var(--mono); color: #555; white-space: nowrap; overflow: hidden; }
.rl b { font: 800 12px/1.3 var(--mono); color: #111; overflow: hidden; text-overflow: ellipsis; }
.resBtns { position: absolute; display: grid; gap: 6px; grid-template-columns: 1fr 38px 38px; }
.land .resBtns { left: 406px; top: 238px; width: 245px; }
.port .resBtns { left: 14px; top: 372px; width: 347px; }
.resBtns #btnAgain { grid-column: 1 / 4; height: 48px; font-size: 20px; letter-spacing: .14em; }
.resBtns #btnChange { height: 38px; font-size: 15px; }
.resBtns .plate.icon.small { height: 38px; width: 38px; }
.resMsg { position: absolute; font: 700 11px/1.3 var(--mono); color: #fff; background: rgba(0,0,0,.6); padding: 2px 6px; white-space: nowrap; overflow: hidden; }
.land .resMsg { left: 406px; top: 336px; max-width: 245px; }
.port .resMsg { left: 14px; top: 470px; max-width: 347px; }
.resMsg:empty { display: none; }
@media (max-width: 400px) { .burn { gap: 0.9em; } }
.port .bigDist { width: 347px; flex-wrap: wrap; row-gap: 6px; }
.port .bigDist b { font-size: 46px; }
.port .sheet { top: 316px; }
.port .resBtns { top: 392px; }
.port .resMsg { top: 490px; }
/* 横持ちの結果：距離の右に「STOOD UP」と「NEW RECORD」を縦に積む（長い距離でもボタンに重ならない） */
.land .bigDist { display: grid; grid-template-columns: auto auto auto; grid-template-rows: auto auto; column-gap: 6px; row-gap: 5px; align-items: center; max-width: 386px; }
.land .bigDist b { grid-row: 1 / 3; }
.land .bigDist em { grid-row: 1 / 3; align-self: end; margin-bottom: 6px; }
.land .bigDist #rOk { grid-column: 3; grid-row: 1; justify-self: start; }
.land .bigDist #rNew { grid-column: 3; grid-row: 2; justify-self: start; }
/* 隠し演出 */
#unlock { position: absolute; inset: 0; z-index: 9; pointer-events: none; display: flex; align-items: center; justify-content: center; }
#unlock.go { animation: ulFlash 1.4s ease-out forwards; }
#unlock .ulIn { text-align: center; color: #fff; text-shadow: 0 0 18px rgba(255,40,40,.9), 0 2px 6px rgba(0,0,0,.6); }
#unlock .u1 { font: 800 clamp(14px, 3.4vmin, 26px)/1 var(--mono); letter-spacing: .3em; }
#unlock .u2 { font: 800 clamp(30px, 9vmin, 72px)/1.1 var(--mono); letter-spacing: .08em; color: #ff4a3f; margin-top: 6px; }
@keyframes ulFlash { 0% { background: rgba(224,38,43,.55); opacity: 1; } 12% { background: rgba(224,38,43,.08); } 22% { background: rgba(224,38,43,.42); } 40% { background: rgba(224,38,43,0); opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; background: rgba(0,0,0,0); } }
.card.mars .cardName { color: #d21f1f; letter-spacing: .06em; }
.card.mars { box-shadow: 0 0 0 2px #d21f1f, 0 0 14px rgba(224,38,43,.5); }
#btnStart.pulse { animation: stPulse 1.1s ease-in-out infinite; }
@keyframes stPulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35) drop-shadow(0 0 10px rgba(255,40,40,.9)); } }
#pop.big { font-size: 30px; color: #ff4a3f; letter-spacing: .1em; }
#result.marsres .bigDist em { display: none; }
#rOk.mars { background: #b51d18; }
#congrats { position: absolute; left: 4%; right: 4%; top: 20%; text-align: center; color: #fff; animation: cgIn .5s ease-out both; }
#congrats .c1 { font: 800 clamp(20px, 5.4vmin, 46px)/1.15 var(--mono); letter-spacing: .04em; text-shadow: 0 0 14px rgba(255,50,40,.95), 0 0 30px rgba(224,38,43,.6), 0 2px 4px rgba(0,0,0,.6); }
#congrats .c2 { font: 600 clamp(12px, 2.6vmin, 22px)/1.4 var(--mono); letter-spacing: .14em; margin-top: 10px; color: #ffe9e6; text-shadow: 0 0 10px rgba(255,50,40,.8); }
@keyframes cgIn { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
