* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background: #0d0f12; color: #eef2f5;
  font-family: -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
}
canvas#game { position: fixed; left: 0; top: 0; display: block; touch-action: none; cursor: none; }
#safeProbe {
  position: fixed; visibility: hidden; pointer-events: none; left: 0; top: 0; width: 0; height: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.hidden { display: none !important; }
button { touch-action: manipulation; font: inherit; }

/* ---------- HUD（全在上方） ---------- */
#hud {
  position: fixed; left: 0; right: 0; top: 0; pointer-events: none; z-index: 5;
  padding: max(4px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
}
.hud-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.hud-left, .hud-right { flex: 1 1 0; min-width: 0; }
.hud-right { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.hud-center { text-align: center; flex: 0 0 auto; }
/* streetfix Z10：血條加高加寬（28px 以上、寬 250px；窄畫面仍不超過左欄） */
.hp { position: relative; width: min(250px, 100%); height: 30px; background: rgba(0,0,0,.55); border: 2px solid #fff; border-radius: 5px; overflow: hidden; }
#hpFill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: #33d17a; transition: width .1s; }
#hpText { position: absolute; left: 0; right: 0; top: 0; bottom: 0; text-align: center; font-size: 16px; font-weight: 800; line-height: 26px; }
/* streetfix Z3：次要文字 12px → 15px */
.sub { font-size: 15px; font-weight: 700; margin-top: 2px; line-height: 1.2; }
#phaseText { font-size: 15px; font-weight: 800; color: #ffd36b; line-height: 1.2; }
#timeText { font-size: 24px; font-weight: 800; letter-spacing: 1px; line-height: 1.05; font-variant-numeric: tabular-nums; }
#timeText.warn { color: #ff6b5a; }
#gearText { font-size: 18px; font-weight: 800; color: #ffb347; background: rgba(0,0,0,.45); padding: 2px 8px; border-radius: 6px; }
#gearText.done { color: #5dff9b; }
/* streetfix Z3：暫停鈕點擊區 44×44 */
#btnPause {
  pointer-events: auto; width: 44px; height: 44px; border-radius: 9px; border: 2px solid rgba(255,255,255,.8);
  background: rgba(0,0,0,.5); color: #fff; font-size: 15px; font-weight: 800; padding: 0; flex: 0 0 auto;
}
.xpbar { height: 4px; margin-top: 3px; background: rgba(0,0,0,.5); border-radius: 2px; overflow: hidden; }
#xpFill { height: 100%; width: 0; background: #7fb8ff; }
#modeTag { position: absolute; left: 50%; transform: translateX(-50%); top: calc(max(4px, env(safe-area-inset-top)) + 52px); font-size: 11px; background: #b3261e; color: #fff; padding: 1px 8px; border-radius: 4px; white-space: nowrap; }

/* streetfix Z4：top 由 ui.js 依實際 HUD 底部＋8px 設定（這裡是備用值），不壓倒數 */
#toast {
  position: fixed; left: 50%; top: calc(max(4px, env(safe-area-inset-top)) + 76px); transform: translateX(-50%); z-index: 6;
  background: rgba(0,0,0,.72); border: 1px solid rgba(255,255,255,.35); padding: 6px 14px; border-radius: 8px;
  font-size: 15px; font-weight: 700; pointer-events: none; white-space: nowrap; text-align: center;
}
@media (max-width: 699px) { #toast { white-space: normal; max-width: 86vw; width: max-content; } }

/* ---------- 疊加畫面 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  background: rgba(8,10,14,.78);
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.overlay.see-through { background: rgba(8,10,14,.35); }
/* streetfix Z5：直拿提示完全蓋住下層（暫停面板看不到、點不到） */
#rotate { z-index: 20; background: #0d0f12; }
.panel {
  background: #1b2028; border: 2px solid #3b4556; border-radius: 14px; padding: 14px 18px; max-width: 520px; width: 100%;
  max-height: 100%; overflow: hidden; text-align: center;
}
.panel.wide { max-width: 860px; display: flex; gap: 18px; text-align: left; align-items: center; }
.panel .col { flex: 1 1 0; min-width: 0; }
h1 { margin: 0 0 6px; font-size: clamp(24px, 6vh, 38px); color: #3ff0ff; }
h1 small { font-size: 14px; color: #9aa6b5; font-weight: 400; }
h2 { margin: 0 0 8px; font-size: clamp(18px, 5vh, 26px); }
p { margin: 4px 0; }
.lead { font-size: 15px; }
.help p { font-size: 15px; line-height: 1.4; color: #cfd6df; margin: 6px 0; }
.note { font-size: 13px; color: #aab4c0; }
.mode { font-size: 12px; color: #9fe0a8; margin-top: 8px; }
.mode.fast { color: #ff9b8f; font-weight: 700; }
.c-gear { color: #ff9d1a; font-weight: 700; } .c-slow { color: #8fb33a; font-weight: 700; }
.c-fast { color: #ff4fd8; font-weight: 700; } .c-runner { color: #b9c9b0; font-weight: 700; } .c-barrel { color: #ff5a4a; font-weight: 700; }
.btns { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.btns.row { flex-direction: row; justify-content: center; }
.btns button, .cards button {
  min-height: 42px; border-radius: 10px; border: 2px solid #56637a; background: #2a3240; color: #fff; font-size: 16px; font-weight: 700; padding: 6px 14px;
}
.btns button.primary { background: #1a8f9c; border-color: #3ff0ff; }
.btns button:active, .cards button:active { transform: scale(.97); }

.cards-panel { max-width: 860px; }
.cards { display: flex; gap: 10px; justify-content: center; }
.cards button {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px;
  padding: 10px 8px; min-height: clamp(120px, 45vh, 210px); background: #232b38; text-align: center;
}
.cards button[disabled] { opacity: .55; }
.cards .cat { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: #44506a; }
.cards .cat.生存 { background: #2f7a4b; } .cards .cat.移動 { background: #2c5f9e; } .cards .cat.火力 { background: #9e5a2c; }
.cards .cat.武器 { background: #7a3a9e; } .cards .cat.後路 { background: #a07a10; } .cards .cat.特殊 { background: #9e2c3a; }
.cards .name { font-size: clamp(16px, 5vh, 20px); }
.cards .desc { font-size: clamp(12px, 3.6vh, 14px); font-weight: 400; color: #d5dce6; line-height: 1.4; }

.settings-panel { max-width: 420px; text-align: left; }
.settings-panel label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0; font-size: 14px; }
.settings-panel input[type=range] { flex: 1; touch-action: none; }
.settings-panel .chk { justify-content: flex-start; }

#debugPanel {
  position: fixed; right: max(6px, env(safe-area-inset-right)); top: 70px; z-index: 7; display: flex; flex-direction: column; gap: 4px;
  background: rgba(80,0,0,.55); padding: 4px; border-radius: 6px;
}
#debugPanel button { font-size: 11px; padding: 3px 6px; background: #400; color: #fff; border: 1px solid #f66; border-radius: 4px; }
