:root {
  --bg: #14121a;
  --fg: #f2f4ff;
  --accent: #ffcc33;
  --muted: #a9a6b8;
  --card: rgba(255, 255, 255, 0.06);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--fg);
  font: 14px/1.5 -apple-system, "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.hidden { display: none !important; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#touch { position: fixed; inset: 0; touch-action: none; }

/* ゲーム中の表示 */
.hud { position: fixed; pointer-events: none; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .85); display: none; }
body.playing .hud { display: block; }
#mission { top: 10px; left: 10px; max-width: 52vw; background: rgba(0, 0, 0, .55); padding: 8px 12px; border-radius: 8px; line-height: 1.45; }
#mission .t { color: var(--accent); font-weight: 700; font-size: 12px; }
#mission .d { color: #cfe0f2; font-size: 12px; }
#topright { top: 10px; right: 10px; text-align: right; }
#money { font-size: 20px; font-weight: 700; color: #7fe08a; }
#stars { font-size: 20px; letter-spacing: 1px; }
#clock { font-size: 13px; font-weight: 700; color: #e8eef8; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); } /* いまの時間(昼・夕方・夜) */
#street { font-size: 12px; font-weight: 700; color: #cfe8d8; text-shadow: 0 1px 3px rgba(0, 0, 0, .9); min-height: 1em; } /* いまいる通りの名前(v=23) */
#scores { font-size: 14px; font-weight: 700; background: rgba(0, 0, 0, .5); border-radius: 8px; padding: 4px 10px; }
#scores:empty { display: none; }
#scores .me { text-decoration: underline; }
#timer { font-size: 18px; color: #ffb3b3; font-weight: 700; }
#speed { font-size: 16px; font-weight: 700; margin-top: 2px; }
#mm { position: fixed; left: 14px; bottom: 168px; width: 112px; height: 112px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .9); pointer-events: none; display: none; }
body.playing #mm { display: block; }
#toast { top: 26%; left: 0; right: 0; text-align: center; font-size: 22px; font-weight: 800; opacity: 0; transition: opacity .3s; }
#warn { top: 40%; left: 0; right: 0; text-align: center; font-size: 18px; font-weight: 700; color: #ff8080; }
#quitBtn { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); display: none; padding: 4px 12px; font-size: 12px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .6); background: rgba(0, 0, 0, .45); color: #fff; }
body.playing:not(.solo) #quitBtn { display: block; } /* やめるボタンは配達競争だけ。ひとり用は ⚙ の中(v=23) */
#btns { position: fixed; right: 14px; bottom: 16px; display: none; flex-direction: column; gap: 12px; align-items: flex-end; }
body.playing #btns { display: flex; }
.btn { width: 78px; height: 78px; border-radius: 50%; background: rgba(255, 255, 255, .18); border: 2px solid rgba(255, 255, 255, .75); color: #fff; font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; touch-action: none; text-shadow: 0 1px 2px #000; }
.btn.on { background: rgba(255, 210, 63, .5); }
#enterBtn.near { background: rgba(255, 210, 63, .6); border-color: #ffd23f; }
#joyBase, #joyKnob { position: fixed; border-radius: 50%; pointer-events: none; display: none; }
body.playing #joyBase, body.playing #joyKnob { display: block; }
#joyBase { left: 80px; bottom: 80px; width: 120px; height: 120px; margin: 0 0 -60px -60px; background: rgba(255, 255, 255, .12); border: 2px solid rgba(255, 255, 255, .5); }
#joyKnob { left: 80px; bottom: 80px; width: 52px; height: 52px; margin: 0 0 -26px -26px; background: rgba(255, 255, 255, .55); }

/* 画面(スタート・ロビー・結果) */
.overlay { position: fixed; inset: 0; background: rgba(10, 8, 14, .78); display: flex; align-items: center; justify-content: center; z-index: 10; }
.panel { max-width: 440px; width: 88vw; max-height: 90vh; overflow: auto; touch-action: pan-y; background: rgba(20, 18, 28, .96); border: 1px solid rgba(255, 255, 255, .18); border-radius: 14px; padding: 16px 20px; }
.panel h1 { margin: 0 0 2px; font-size: 22px; color: var(--accent); letter-spacing: 1px; }
.panel h2 { margin: 12px 0 2px; font-size: 15px; color: #9fd0ff; }
.panel p { margin: 4px 0; }
.sub { color: var(--muted); font-size: 13px; }
.btn-big { display: block; width: 100%; margin-top: 10px; padding: 11px; font-size: 17px; font-weight: 700; border: 0; border-radius: 10px; background: var(--accent); color: #222; }
.btn-big.online { background: #ff6b5b; color: #fff; }
.btn-big.ghost { background: transparent; color: var(--fg); border: 1px solid rgba(255, 255, 255, .35); }
.btn-big:disabled { opacity: .45; }
.links { margin-top: 12px !important; font-size: 12px; text-align: center; }
.links a { color: var(--muted); }
.field { display: block; margin-top: 8px; font-size: 13px; color: var(--muted); }
.field input, .join input { display: block; width: 100%; margin-top: 4px; padding: 10px; font-size: 17px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .08); color: var(--fg); user-select: text; -webkit-user-select: text; }
.join { display: flex; gap: 8px; align-items: center; }
.join input { flex: 1; margin-top: 10px; }
.join .btn-big { width: auto; padding: 11px 18px; }
.msg { color: #ff9f8f; min-height: 1.5em; font-size: 13px; }
.code { font-size: 40px; font-weight: 800; letter-spacing: 8px; text-align: center; color: var(--accent); }
.players { background: var(--card); border-radius: 10px; padding: 8px 12px; margin-top: 6px; }
.players-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.players ol, #resList { margin: 4px 0; padding-left: 22px; }
.players li.off { opacity: .45; }
/* 待合室の時間えらび(v=20)。ホスト以外は押せない(えらばれているのは見える) */
.times { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.times .tl { color: var(--muted); font-size: 13px; margin-right: 2px; }
.times button { flex: 1; padding: 8px 4px; font-size: 15px; font-weight: 700; border-radius: 9px; border: 1px solid rgba(255, 255, 255, .35); background: transparent; color: var(--fg); }
.times button.on { background: var(--accent); color: #222; border-color: var(--accent); }
.times button:disabled { opacity: .55; }
.times button.on:disabled { opacity: .85; }
.times.rules { flex-wrap: wrap; }
.times.rules button { font-size: 14px; flex: 1 0 22%; } /* ルールが5つになったので2段に(v=28) */
.ruleNote { margin: 4px 0 0; font-size: 12px; min-height: 1.2em; }
#lbTeamNote:empty { display: none; }
.players small, #resList small { color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
#err { position: fixed; bottom: 0; left: 0; right: 0; color: #fff; background: #a00; font-size: 12px; padding: 4px; display: none; z-index: 20; }

/* 横向きのお知らせ(スタート画面) */
.landNote { display: inline-block; margin: 6px 0 4px !important; padding: 3px 12px; border-radius: 999px; background: rgba(255, 210, 63, .14); border: 1px solid rgba(255, 210, 63, .55); color: #ffd23f; font-size: 13px; }
/* 縦に持ったときの警告(スマホ・タブレットだけ) */
#rotate { position: fixed; inset: 0; z-index: 30; background: #0b0a12; display: none; align-items: center; justify-content: center; text-align: center; color: #fff; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }
.rotBox .phone { width: 56px; height: 96px; margin: 0 auto 26px; border: 4px solid #fff; border-radius: 12px; position: relative; animation: scRot 2.4s ease-in-out infinite; }
.rotBox .phone::after { content: ""; position: absolute; left: 50%; bottom: 6px; width: 14px; height: 4px; margin-left: -7px; border-radius: 2px; background: #fff; }
@keyframes scRot { 0%, 20% { transform: rotate(0); } 50%, 80% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
.rotT { font-size: 18px; font-weight: bold; color: #ffd23f; margin: 0 0 8px; }
.rotS { font-size: 15px; color: #ddd; margin: 0; }

/* 体力・こうげき(ひとり用だけ) */
#hpBar { top: 10px; right: 10px; width: 170px; height: 14px; background: rgba(0, 0, 0, .6); border: 1px solid rgba(255, 255, 255, .7); border-radius: 7px; overflow: hidden; }
#hpFill { height: 100%; width: 100%; background: linear-gradient(#6fe68a, #2fa84a); transition: width .15s; }
#hpText { position: absolute; inset: 0; font-size: 10px; line-height: 13px; text-align: center; font-weight: 700; }
body:not(.solo):not(.shoot) #hpBar { display: none !important; }
#hurt { position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 90px 30px rgba(255, 0, 0, .85); opacity: 0; z-index: 5; }
#atkBox { position: fixed; right: 14px; bottom: 16px; display: none; flex-direction: column; gap: 10px; align-items: center; }
body.playing.solo #atkBox, body.playing.shoot #atkBox { display: flex; }
body.shoot #btns { right: 122px; }
body.shoot #topright { top: 38px; } /* 撃ち合い(v=28): 体力バーの下へ */
#blindFx { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 5; background: radial-gradient(circle at 50% 45%, rgba(242, 166, 166, .55) 0, rgba(224, 123, 132, .97) 55%); } /* 豚の頭をかぶって前が見えない(撃ち合い) */
body.solo #btns { right: 122px; }
#atkBtn { width: 94px; height: 94px; background: rgba(230, 60, 50, .45); border-color: #ffb0a8; font-size: 16px; }
#wpnBtn { width: 100px; height: 40px; border-radius: 20px; font-size: 11px; white-space: nowrap; overflow: hidden; }
#atkBtn { transition: transform .06s; } /* ピストル・マシンガン: 倒した方へ少し動く(ねらっているしるし) */

/* 防弾チョッキ・回復(ひとり用だけ) */
#armorBar { top: 26px; right: 10px; width: 170px; height: 7px; background: rgba(0, 0, 0, .6); border: 1px solid rgba(255, 255, 255, .6); border-radius: 4px; overflow: hidden; }
#armorFill { height: 100%; width: 100%; background: linear-gradient(#8fc4ff, #3a7fe0); }
body:not(.solo):not(.shoot) #armorBar { display: none !important; }
#healBtn { width: 92px; height: 36px; border-radius: 18px; font-size: 12px; background: rgba(60, 200, 90, .4); border-color: #b6ffbe; display: none; }

/* 車に乗っているとき: アクセル・ブレーキ・バック(こうげき・ダッシュは消える) */
#carBox { position: fixed; right: 14px; bottom: 16px; width: 190px; height: 170px; display: none; pointer-events: none; }
body.playing.incar #carBox { display: block; }
#carBox .btn { position: absolute; pointer-events: auto; }
#carHp { position: absolute; right: 0; bottom: 104px; width: 96px; height: 9px; background: rgba(0, 0, 0, .6); border: 1px solid rgba(255, 255, 255, .7); border-radius: 5px; } /* 車の体力(v=42) */
#carHp::before { content: '🚗'; position: absolute; left: -22px; top: -6px; font-size: 14px; }
#carHpFill { height: 100%; width: 100%; background: #5fd47a; border-radius: 4px; }
#accBtn { right: 0; bottom: 0; width: 96px; height: 96px; background: rgba(70, 200, 90, .4); border-color: #b6ffbe; }
#brkBtn { right: 106px; bottom: 0; width: 80px; height: 80px; background: rgba(230, 60, 50, .4); border-color: #ffb0a8; }
#revBtn { right: 112px; bottom: 92px; width: 66px; height: 66px; font-size: 13px; }
#accBtn.on { background: rgba(70, 220, 90, .75); }
#brkBtn.on { background: rgba(240, 70, 60, .75); }
body.incar #atkBox, body.incar #dashBtn { display: none !important; }
body.riding #dashBtn { display: none !important; } /* 助手席(v=43): 走れない。こうげきは出す */
body.playing.incar #btns { right: 22px; bottom: 124px; }

/* 店の画面 */
#shopList { margin-top: 6px; }
.shopItem { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; width: 100%; margin-top: 8px; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .08); color: var(--fg); font-size: 15px; text-align: left; }
.shopItem b { color: #7fe08a; font-size: 16px; }
.shopItem small { flex-basis: 100%; color: var(--muted); font-size: 12px; }
.shopItem:disabled { opacity: .45; }
.shopItem:not(:disabled):active { background: rgba(255, 210, 63, .3); }

/* 街の人との会話(ひとり用だけ): 「話す」ボタン・頭の上のふきだし・Q&A のこたえ */
#talkBtn { width: 78px; height: 42px; border-radius: 21px; background: rgba(255, 210, 63, .6); border-color: #ffd23f; display: none; }
#bubble { position: fixed; display: none; transform: translate(-50%, -100%); max-width: 240px; padding: 7px 12px; border-radius: 12px; background: rgba(255, 255, 255, .95); color: #1c1a22; font-size: 14px; font-weight: 700; line-height: 1.35; text-align: center; pointer-events: none; box-shadow: 0 2px 8px rgba(0, 0, 0, .5); z-index: 4; }
#bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-top-color: rgba(255, 255, 255, .95); border-bottom: 0; }
#qa { position: fixed; left: 156px; right: 214px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 6; }
.qaBtn { width: 100%; padding: 10px 12px; font-size: 15px; font-weight: 700; line-height: 1.3; border-radius: 12px; border: 2px solid #ffd23f; background: rgba(20, 18, 28, .88); color: #fff; touch-action: none; }
.qaBtn:active { background: rgba(255, 210, 63, .35); }

/* つづきから(スタート画面)・ミッションを受けるか(v=14) */
#goCont small { display: block; font-size: 12px; font-weight: 400; opacity: .8; }
#offerReward { color: #7fe08a; font-size: 18px; font-weight: 700; }
#offer .panel { border-color: #b06bff; }
#offer .panel h1 { color: #d4b0ff; }

/* v=15: お話の場面・ひとこと(字幕)・ねる */
#story { position: fixed; inset: 0; z-index: 12; touch-action: none; }
#storyLines { position: absolute; left: 9%; right: 9%; bottom: 20%; }
#storyLines p { margin: 7px 0; font-size: 19px; font-weight: 700; line-height: 1.5; color: #fff; text-shadow: 0 0 4px #000, 0 1px 3px #000, 0 0 12px rgba(0, 0, 0, .9); }
#storyLines p.q { color: #ffe9a8; } /* セリフは少し黄色 */
#storyLines p.old { opacity: .45; font-size: 16px; } /* 前の行は、うすく残る */
#storySkip { position: absolute; top: 12px; right: 14px; padding: 6px 16px; font-size: 13px; border-radius: 16px; border: 1px solid rgba(255, 255, 255, .7); background: rgba(0, 0, 0, .4); color: #fff; }
#storyTap { position: absolute; right: 9%; bottom: 9%; font-size: 13px; color: #fff; text-shadow: 0 1px 3px #000; opacity: .85; animation: scTap 1.2s ease-in-out infinite; }
@keyframes scTap { 50% { opacity: .3; } }
body.story .hud, body.story #mm, body.story #btns, body.story #atkBox, body.story #carBox, body.story #joyBase, body.story #joyKnob, body.story #quitBtn, body.story #bubble, body.story #qa { display: none !important; }
#sub { left: 156px; right: 214px; bottom: 14px; text-align: center; font-size: 15px; font-weight: 700; line-height: 1.4; opacity: 0; transition: opacity .3s; text-shadow: 0 0 4px #000, 0 1px 3px #000, 0 0 10px rgba(0, 0, 0, .9); }
#subName { display: block; font-size: 12px; color: #ffd23f; }
#sleepBtn { width: 78px; height: 42px; border-radius: 21px; background: rgba(74, 168, 255, .55); border-color: #9fd0ff; display: none; }
#clearPanel h2 { color: var(--fg); }
#clearPanel { text-align: center; }

/* v=23: 体力バーは右上(お金の上)。右上の文字は1段下げる。左上は ⚙(一時停止) */
body.solo #topright { top: 38px; }
body.solo #mission { top: 10px; left: 54px; max-width: 46vw; }
#optBtn { position: fixed; top: 10px; left: 10px; width: 36px; height: 36px; display: none; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .7); background: rgba(0, 0, 0, .5); color: #fff; font-size: 20px; line-height: 32px; padding: 0; text-align: center; }
body.playing.solo #optBtn { display: block; }
body.story #optBtn { display: none !important; }
#pause { z-index: 30; }
#goSusp small { display: block; font-size: 12px; font-weight: 400; opacity: .8; }
/* ライフルのスコープ(v=29): まん中の丸だけ見えて、まわりは黒。こうげきボタンだけ上に出す */
#scopeFx { position: fixed; inset: 0; pointer-events: none; z-index: 5; display: none; background: radial-gradient(circle at 50% 50%, transparent 0, transparent 160px, rgba(0, 0, 0, .35) 162px, #000 166px); }
body.scoped #scopeFx { display: block; }
body.scoped #atkBox { z-index: 6; }
#scopeX { position: fixed; right: 18px; top: 18px; width: 56px; height: 56px; z-index: 6; display: none; font-size: 26px; background: rgba(0, 0, 0, .55); } /* スコープを閉じる(v=40) */
body.scoped #scopeX { display: flex; }
body.scoped .hud, body.scoped #mm, body.scoped #optBtn, body.scoped #mission { visibility: hidden; }
#scopeFx .ring { position: absolute; left: 50%; top: 50%; width: 332px; height: 332px; margin: -166px 0 0 -166px; border-radius: 50%; box-shadow: inset 0 0 40px rgba(0, 0, 0, .7); }
#scopeFx .h { position: absolute; left: calc(50% - 150px); top: 50%; width: 300px; height: 1.5px; background: rgba(0, 0, 0, .85); }
#scopeFx .v { position: absolute; top: calc(50% - 150px); left: 50%; height: 300px; width: 1.5px; background: rgba(0, 0, 0, .85); }
#scopeFx .dot { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: #ff3a3a; }
#scopeInfo { position: absolute; left: 50%; top: 34px; transform: translateX(-50%); color: #fff; font: bold 14px sans-serif; white-space: nowrap; text-shadow: 0 1px 3px #000; } /* 画面のいちばん上(✕ と同じ高さ)。下だと縦が短いスマホで見えない(v=41) */
/* 言語の切りかえ(スタート画面) */
.langSw { display: flex; justify-content: center; gap: 6px; margin: 6px 0 8px; }
.langSw button { padding: 4px 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .06); color: var(--muted); font-size: 12px; font-family: inherit; }
.langSw button.on { background: #ffd23f; border-color: #ffd23f; color: #1a1408; font-weight: 700; }
