* { box-sizing: border-box; }
html, body { margin: 0; background: #fff; color: #2a2328; font-family: -apple-system,BlinkMacSystemFont,"Hiragino Sans","Noto Sans JP",sans-serif; }
button { font: inherit; font-weight: 700; min-height: 44px; border: 0; border-radius: 8px; background: #f3f4f6; color: #2a2328; padding: 8px 12px; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
main { height: calc(100dvh - var(--nav-height,44px)); padding: 0 8px max(4px,env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 4px; }
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; border-radius: 8px; display: flex; flex-direction: column; }
.hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 4px 6px; min-height: 54px; background: #fff; }
.hud small { display: block; font-size: 11px; line-height: 1.4; color: #6e626a; }
.hud strong { font-size: 18px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.hud .points { min-width: 90px; text-align: center; }
.hud .points strong { font-size: 16px; }
.timer { margin-left: auto; text-align: center; white-space: nowrap; }
.timer strong { font-size: 21px; }
.timer small { display: inline; margin-left: 2px; }
.hud button { width: 44px; padding: 8px; font-size: 19px; }
.hud button:disabled { opacity: .4; }
#field { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #49655b; touch-action: none; }
#world { position: absolute; width: 360px; height: 560px; transform-origin: top left; background: #49655b; }
.block { position: absolute; width: 132px; height: 232px; background: #547064; border-radius: 4px; }
.nw { left: 0; top: 0; }
.ne { right: 0; top: 0; }
.sw { left: 0; bottom: 0; }
.se { right: 0; bottom: 0; }
.road { position: absolute; background: #293c47; }
.horizontal { left: 0; top: 235px; width: 360px; height: 90px; border-block: 1px solid #a4b2a4; }
.vertical { top: 0; left: 135px; width: 90px; height: 560px; border-inline: 1px solid #a4b2a4; }
.crossing { position: absolute; left: 136px; top: 236px; width: 88px; height: 88px; border: 2px solid #dfbc75; background: #354854; }
.stop-line { position: absolute; background: #e9e4d4; }
.east-line { left: 110px; top: 246px; width: 4px; height: 68px; }
.south-line { top: 210px; left: 146px; height: 4px; width: 68px; }
.flow { position: absolute; color: #b3c0c6; font-size: 30px; line-height: 1; }
.east-flow { left: 22px; top: 264px; }
.south-flow { left: 169px; top: 76px; }
.car { position: absolute; width: var(--hit,52px); height: var(--hit,52px); padding: 0; min-height: var(--hit,52px); transform: translate(-50%,-50%); background: transparent; border-radius: 8px; z-index: 2; touch-action: none; }
.car .body { display: block; position: absolute; width: 38px; height: 25px; left: calc(50% - 19px); top: calc(50% - 12px); border: 2px solid #fff0bc; border-radius: 6px; background: #dcb45e; pointer-events: none; }
.car .body:before { content: ''; position: absolute; left: 14px; top: 3px; width: 12px; height: 15px; background: #254452; border-radius: 2px; }
.car .body:after { content: ''; position: absolute; right: -2px; top: 2px; width: 3px; height: 5px; background: #fff8d6; box-shadow: 0 12px #fff8d6; }
.car.south .body { transform: rotate(90deg); background: #65c6d1; border-color: #d5ffff; }
.car .sprite { position: absolute; width: 38px; height: 25px; left: calc(50% - 19px); top: calc(50% - 12px); object-fit: contain; visibility: hidden; pointer-events: none; }
.car .sprite.ready { visibility: visible; }
.car.south .sprite { transform: rotate(90deg); }
.car:has(.sprite.ready) .body { visibility: hidden; }
.car:not(.stopped):not(.committed):after { content: ''; position: absolute; top: calc(50% - 25px); left: calc(50% - 5px); width: 10px; height: 10px; border-inline: 3px solid #edf3f5; pointer-events: none; }
.car.stopped .body { border-color: #ff9b9f; }
.car.stopped:after { content: '停止'; position: absolute; top: -6px; left: calc(50% - 16px); color: #fff; background: #a33d4d; border-radius: 3px; font-size: 10px; min-width: 32px; line-height: 18px; }
.car.committed .body { border-color: #a1afb6; }
.chain { color: #6e626a; }
.chain.hot { color: #835d16; }
.hint { position: absolute; bottom: 0; width: 100%; padding: 7px 2px; background: #293c47; color: #f2f4f5; text-align: center; font-size: 12px; pointer-events: none; }
#impact { position: absolute; left: 180px; top: 280px; transform: translate(-50%,-50%); font-size: 40px; font-weight: 900; color: #fff; background: #aa3d42; border-radius: 50%; width: 60px; height: 60px; line-height: 60px; text-align: center; z-index: 3; }
.buddy { display: flex; align-items: center; gap: 8px; min-height: 56px; flex-shrink: 0; }
.buddy img { width: 52px; height: 52px; object-fit: contain; }
.buddy small { font-size: 11px; color: #6e626a; }
.buddy p { font-size: 13px; line-height: 1.4; margin: 2px 0; }
main:has(#overlay:not([hidden])) .buddy { display: none; }
#overlay { position: absolute; inset: 0; background: #152b35b8; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 5; }
.panel { max-width: 320px; width: 100%; padding: 20px 16px 16px; background: #fff; color: #2a2328; text-align: center; border-radius: 12px; }
.panel > img { width: 80px; height: 80px; object-fit: contain; }
.panel > small { display: block; font-size: 11px; color: #6e626a; }
.panel h2 { font-size: 20px; margin: 8px 0; }
.panel p { font-size: 13px; line-height: 1.65; margin: 12px 0; }
.panel #best { font-size: 12px; color: #6e626a; }
.panel button { width: 100%; margin-top: 4px; min-height: 48px; }
.panel #storage { font-size: 11px; color: #884139; margin: 8px 0 0; }
.panel #storage:empty { display: none; }
@media (max-height: 650px) {
 .panel { padding: 12px 16px; }
 .panel > img { width: 64px; height: 64px; }
 .panel p { margin: 8px 0; }
 .hud { min-height: 50px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
