html {
  height: 100%;
  height: 100dvh;
  /* デザイン基準：レーダー／アナログ用（地図にはかけない） */
  --design-width-base: 390px;
  --design-width-max: 420px;
  /* 取っ手：レーダー／地図で同じ実寸（つまみやすさ優先でやや厚め） */
  --design-handle-h: 2.7rem;
  --design-handle-knob-w: 5.5rem;
  /* スマホ幅に合わせて UI 全体を同じ比率で縮尺（基準幅 390px = 16px） */
  font-size: 16px;
}

@media (max-width: 430px) {
  html {
    /* 下限を上げる（TWA／狭い端末でボタン文字が潰れるのを防ぐ） */
    font-size: clamp(14px, calc(100vw * 16 / 390), 16px);
  }
}

/* Play／ホーム画面起動：ブラウザより根の文字が小さく見える端末向け */
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  html {
    font-size: 16px;
  }
}

@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  @media (max-width: 430px) {
    html {
      font-size: clamp(15px, calc(100vw * 16.5 / 390), 17px);
    }
  }
}

/* Custom Tab でも display-mode が browser のままなので、タッチ端末は standalone 相当の根文字にする */
@media (pointer: coarse) {
  html {
    font-size: 16px;
  }
}
@media (pointer: coarse) and (max-width: 430px) {
  html {
    font-size: clamp(15px, calc(100vw * 16.5 / 390), 17px);
  }
}

body {
  font-family: "Share Tech Mono", monospace;
  background-color: #030a05;
  color: #00ff66;
  /* スマホブラウザのアドレスバーで下ボタンが切れるのを防ぐ */
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
}

/* TWA／スマホは余白控えめ。広いPCだけ広げない（sm: が誤爆して細い柱になるのを防ぐ） */
body.app-shell {
  padding: 0.5rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) and (pointer: fine) {
  body.app-shell {
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  }
}

body.h-screen {
  height: 100dvh !important;
  max-height: 100dvh !important;
  min-height: 100dvh;
}

.font-orbitron {
  font-family: "Orbitron", sans-serif;
}

.crt-container {
  position: relative;
  background: radial-gradient(circle, rgba(6, 32, 15, 0.95) 0%, rgba(2, 10, 4, 1) 90%);
  box-shadow: inset 0 0 80px rgba(0, 255, 102, 0.15);
}

.crt-overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  background-size: 100% 3px, 6px 100%;
  pointer-events: none;
  z-index: 20;
}

.crt-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  z-index: 21;
  border: 2px solid rgba(0, 255, 102, 0.3);
  border-radius: 1rem;
}

.text-glow {
  text-shadow: 0 0 8px rgba(0, 255, 102, 0.7), 0 0 15px rgba(0, 255, 102, 0.4);
}

.retro-btn {
  background-color: rgba(0, 30, 12, 0.8);
  border: 1px solid #00ff66;
  color: #00ff66;
  transition: all 0.15s ease;
  box-shadow: 0 0 5px rgba(0, 255, 102, 0.2);
}

.retro-btn:hover,
.retro-btn:active,
.retro-btn.active {
  background-color: #00ff66;
  color: #030a05;
  box-shadow: 0 0 15px rgba(0, 255, 102, 0.8);
}

.retro-btn-alert {
  background-color: rgba(40, 10, 10, 0.8);
  border: 1px solid #ff3333;
  color: #ff3333;
}

.retro-btn-alert:hover,
.retro-btn-alert:active {
  background-color: #ff3333;
  color: #030a05;
  box-shadow: 0 0 15px rgba(255, 51, 51, 0.8);
}

.post-fab {
  width: 4.5rem;
  min-width: 4.5rem;
  height: 2.55rem;
  min-height: 40px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #ff3333;
  background: #ff3333;
  color: #1a0505;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 0 12px rgba(255, 51, 51, 0.45);
  cursor: pointer;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.post-fab:hover,
.post-fab:active {
  background: #ff5555;
  box-shadow: 0 0 16px rgba(255, 51, 51, 0.7);
}

.radar-draft-fab {
  position: relative;
  flex-shrink: 0;
  width: 4.5rem;
  min-width: 4.5rem;
}

#radarChromeHeader.radar-chrome {
  padding-bottom: 0.35rem;
  gap: 0.35rem;
  min-width: 0;
}

#radarChromeHeader .radar-brand {
  flex: 0 1 5.5rem;
  min-width: 3.2rem;
  max-width: 30%;
}

#radarChromeHeader .radar-brand-title {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* RADAR ZONE は2段（RADAR / ZONE）。幅は従来の RADAR-X と同じ枠に収める */
#radarChromeHeader .radar-brand-title > span {
  display: block;
}

#radarChromeHeader .radar-brand-title {
  font-size: 0.84rem;
  line-height: 1.1;
  overflow: visible; /* 2段の短い語。グロー・下端を切らない */
}

#radarChromeHeader .radar-mode-group {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  justify-content: center;
}

#radarChromeHeader > .radar-mode-group,
#radarChromeHeader > .flex.border {
  padding: 0.12rem;
  gap: 0.15rem;
}

#radarChromeHeader .btn-view-radar,
#radarChromeHeader .btn-view-map,
#radarChromeHeader .btn-view-experience {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  max-width: 4.8rem;
  min-height: 2.15rem;
  max-height: 2.15rem;
  height: 2.15rem;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  padding-left: 0.25rem !important;
  padding-right: 0.25rem !important;
  aspect-ratio: auto;
  flex-direction: row;
  justify-content: center;
  box-sizing: border-box;
  flex-shrink: 1;
  font-size: 0.68rem;
  line-height: 1;
  overflow: hidden;
}

#radarChromeHeader .btn-view-experience {
  max-width: 3.6rem;
}

#radarChromeHeader .radar-mode-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#radarChromeHeader .radar-draft-fab,
#radarChromeHeader .draft-fab {
  flex: 0 0 auto;
  width: 3.8rem !important;
  min-width: 3.8rem !important;
  max-width: 3.8rem !important;
  height: 2.15rem !important;
  min-height: 2.15rem !important;
  font-size: 10px !important;
}

@media (max-width: 360px) {
  #radarChromeHeader .radar-mode-ico {
    display: none;
  }
}

/* 舞台（main）基準の共通変数 */
body:not(.map-layout) main.crt-container,
body.map-layout main.crt-container {
  container-type: size;
  container-name: radar-stage;
  --stage-fab-band: 12%;
  --stage-handle-band: var(--design-handle-h, 2.7rem);
}

/* レーダー：スマホは画面幅いっぱい。広い画面だけ 420 で中央（PCで巨大化防止）。地図はフルのまま */
body:not(.map-layout) main.crt-container,
body:not(.map-layout) #radarChromeHeader,
body:not(.map-layout) #radarChromeFooter {
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  max-width: none;
}

/* マウスの広い画面だけ上限。タッチ端末は幅誤判定でも全幅（TWAで細い柱になるのを防ぐ） */
@media (min-width: 480px) and (hover: hover) and (pointer: fine) {
  body:not(.map-layout) main.crt-container,
  body:not(.map-layout) #radarChromeHeader,
  body:not(.map-layout) #radarChromeFooter {
    max-width: var(--design-width-max, 420px);
  }
}

body:not(.map-layout) main.crt-container {
  margin-top: 0.25rem !important;
  margin-bottom: 0 !important;
  overflow: hidden;
}

/* 地図：フルブリードで舞台が縦に長い（幅上限なし） */
body.map-layout main.crt-container {
  overflow: hidden;
  max-width: none;
  width: 100%;
}

body:not(.map-layout) #radarChromeFooter {
  padding-top: 0.15rem;
}

body:not(.map-layout) #radarChromeFooter > p {
  margin-top: 0.2rem;
  margin-bottom: 0;
}

body:not(.map-layout) #radarChromeFooter > p:first-child {
  margin-top: 0;
}

body:not(.map-layout) #radarChromeFooter .radar-tool-grid {
  margin-top: 0.35rem;
}

.radar-tool-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.22rem;
}

.radar-tool-btn {
  min-width: 0;
  width: 100%;
  min-height: 1.9rem;
  height: 1.9rem;
  padding: 0.02rem 0.04rem;
  border-radius: 0.5rem;
  background-color: rgba(0, 30, 12, 0.8);
  border: 1px solid #00ff66;
  color: #00ff66;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  box-shadow: 0 0 5px rgba(0, 255, 102, 0.2);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s ease;
  line-height: 1.05;
}

.radar-tool-kicker {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #34d399;
  line-height: 1;
}

/* スマホはタップ後に :hover が残って緑のままになる → マウス環境だけホバー */
@media (hover: hover) and (pointer: fine) {
  .radar-tool-btn:hover {
    background-color: #00ff66;
    color: #030a05;
    box-shadow: 0 0 15px rgba(0, 255, 102, 0.8);
  }

  .radar-tool-btn:hover .radar-tool-kicker {
    color: #030a05;
  }
}

/* 押している瞬間だけ（離したら戻る）。.active は意図した点灯用 */
.radar-tool-btn:active:not(.active) {
  background-color: rgba(0, 255, 102, 0.35);
  color: #b7ffd0;
  box-shadow: 0 0 8px rgba(0, 255, 102, 0.35);
}

.radar-tool-btn:active:not(.active) .radar-tool-kicker {
  color: #b7ffd0;
}

.radar-tool-btn.active {
  background-color: #00ff66;
  color: #030a05;
  box-shadow: 0 0 15px rgba(0, 255, 102, 0.8);
}

.radar-tool-btn.active .radar-tool-kicker {
  color: #030a05;
}

.radar-virtual-btn,
.virtual-demo-btn.map-chip {
  border-color: rgba(0, 210, 255, 0.4);
  color: #7defff;
  background: rgba(0, 12, 18, 0.88);
  box-shadow: none;
}

.virtual-demo-btn.map-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.08rem;
  line-height: 1.05;
}

.virtual-demo-btn.map-chip .virtual-chip-name {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.virtual-demo-btn.map-chip .virtualDemoLabel {
  font-size: 12px;
  font-weight: 800;
}

.radar-virtual-btn .radar-tool-kicker {
  color: #67e8f9;
}

/* スマホは :hover が残りやすいので、マウス環境だけホバー点灯 */
@media (hover: hover) and (pointer: fine) {
  .radar-virtual-btn:hover,
  .virtual-demo-btn.map-chip:hover {
    background: rgba(0, 210, 255, 0.35);
    color: #e6fbff;
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.35);
  }

  .radar-virtual-btn:hover .radar-tool-kicker {
    color: #e6fbff;
  }
}

.radar-virtual-btn.active,
.virtual-demo-btn.map-chip.active,
.virtual-demo-btn.active {
  background: rgba(0, 210, 255, 0.92);
  color: #031018;
  border-color: #7defff;
  box-shadow: 0 0 14px rgba(0, 210, 255, 0.65);
}

.radar-virtual-btn.active .radar-tool-kicker {
  color: #031018;
}

/* 通常チップの緑 :active が仮想ボタンに乗らないように */
.virtual-demo-btn.map-chip:active:not(.active) {
  background: rgba(0, 12, 18, 0.88);
  color: #7defff;
  box-shadow: none;
}

body.experience-active .virtual-demo-btn {
  display: none !important;
}

.virtual-demo-banner {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  border-radius: 0.4rem;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #031018;
  background: rgba(0, 210, 255, 0.88);
  border: 1px solid rgba(120, 240, 255, 0.9);
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.35);
  width: fit-content;
  max-width: min(90vw, 22rem);
  pointer-events: none;
  white-space: nowrap;
  /* 不透明度だけ点滅（背景は濃いめのまま文字を読ませる） */
  animation: virtual-demo-banner-pulse 1.35s ease-in-out infinite;
}

@keyframes virtual-demo-banner-pulse {
  0%,
  100% {
    opacity: 0.28;
  }
  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .virtual-demo-banner {
    animation: none;
    opacity: 1;
  }
}

.virtual-demo-banner.hidden {
  display: none;
}

body.map-layout .virtual-demo-banner {
  top: 3.4rem;
}

.radar-action-dock {
  position: absolute;
  left: 0;
  right: 0;
  /* main 高さの下端からの %（機種で変えず、舞台比率で固定） */
  bottom: 2.5%;
  z-index: 46;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.radar-sweep-style-btn {
  position: absolute;
  /* 隅すぎず仮記録と被りすぎない、余白のバランス位置 */
  right: 9%;
  bottom: 5%;
  z-index: 47;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 3.25rem;
  height: 3.25rem;
  min-width: 3.25rem;
  min-height: 3.25rem;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 255, 102, 0.65);
  background: rgba(0, 30, 12, 0.9);
  color: #86efac;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.28);
}

.radar-sweep-style-btn:active {
  background: #00ff66;
  color: #030a05;
}

body.map-layout .radar-sweep-style-btn {
  display: none !important;
}

.radar-action-dock > * {
  pointer-events: auto;
}

.radar-record-fab {
  position: relative;
}

body.map-layout .radar-action-dock {
  display: none !important;
}

/* Map mode: full-bleed map, chrome overlays on top */
body.map-layout {
  padding: 0 !important;
  justify-content: stretch;
}

body.map-layout .radar-chrome {
  display: none !important;
}

body.map-layout main.crt-container {
  margin: 0 !important;
  border-radius: 0 !important;
  flex: 1 1 auto;
  min-height: 100%;
}

body.map-layout .crt-vignette {
  border-radius: 0;
}

/* 地図モード：スキャンラインがポップアップ文字に乗らないようオフ */
body.map-layout .crt-overlay {
  display: none;
}

/* Map: keep status text visible (no black panels) */
body.map-layout .status-hud-right {
  right: 3.2rem;
  font-size: 13px;
}

/* 地図モード左上HUD：レーダーより少し大きく（明るい地図でチラ見しやすく） */
body.map-layout .status-hud:not(.status-hud-right) {
  font-size: 13px;
}

body.map-layout .status-hud:not(.status-hud-right) .hud-text {
  font-size: 13px !important;
}

body.map-layout .status-hud:not(.status-hud-right) #targetCountText {
  font-size: 14px !important;
}

body.map-layout .status-hud:not(.status-hud-right) .situational-status {
  font-size: 13px !important;
  max-width: 18rem;
}

body.map-layout .status-hud:not(.status-hud-right) .hud-label {
  font-size: 9px !important;
}

body.map-layout .status-hud:not(.status-hud-right) .nearest-hud-inline-name {
  font-size: 13px !important;
}

body.map-layout .status-hud:not(.status-hud-right) .nearest-hud-inline-brg .hud-text,
body.map-layout .status-hud:not(.status-hud-right) .nearest-hud-inline-dist .hud-text {
  font-size: 14px !important;
}

body.map-layout .status-hud:not(.status-hud-right) .nearest-hud-inline-dist .hud-text {
  font-size: 15px !important;
}

/* 地図モード右上 SPEED / GPS も左上と同レベル */
body.map-layout .status-hud-right > .hud-text:first-child {
  font-size: 12px !important;
}

body.map-layout .status-hud-right #speedHud {
  font-size: 1.2rem !important;
}

/* レーダー右上 SPEED / GPS・速度：大きく。速度だけ最初の強いグロー */
body:not(.map-layout) .status-hud-right > .hud-text:first-child {
  font-size: 12px !important;
}

body:not(.map-layout) .status-hud-right #speedHud {
  font-size: 1.2rem !important;
  /* 弱め前の .hud-text グロー＋.text-glow */
  text-shadow:
    0 0 3px rgba(255, 255, 255, 0.95),
    0 0 6px rgba(255, 255, 255, 0.75),
    0 1px 2px rgba(0, 0, 0, 0.55),
    0 0 8px rgba(0, 255, 102, 0.7),
    0 0 15px rgba(0, 255, 102, 0.4);
}

.hud-text {
  /* レーダー用グロー（弱め）。戻すなら旧:
     0 0 3px rgba(255,255,255,0.95), 0 0 6px rgba(255,255,255,0.75), 0 1px 2px rgba(0,0,0,0.55) */
  text-shadow:
    0 0 1.5px rgba(255, 255, 255, 0.45),
    0 0 3px rgba(255, 255, 255, 0.28),
    0 1px 2px rgba(0, 0, 0, 0.55);
}

.hud-label {
  display: block;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7dffb0;
  line-height: 1;
  /* レーダー用グロー（弱め）。戻すなら旧: 0 0 3px rgba(255,255,255,0.9), 0 1px 2px rgba(0,0,0,0.5) */
  text-shadow:
    0 0 1.5px rgba(255, 255, 255, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.5);
}

/* 地図・夜：暗い背景なので影・縁取りなし（文字色だけで足りる） */
body.map-layout:has(#mapView.map-theme-night) .status-hud .hud-text,
body.map-layout:has(#mapView.map-theme-night) .status-hud .hud-label {
  text-shadow: none;
  -webkit-text-stroke: 0;
}

/* 地図・昼：実況以外は黒＋細い縁。実況は緑（!important にすると明滅の濃淡が負ける） */
body.map-layout:has(#mapView.map-theme-day) .status-hud .hud-text:not(.situational-status),
body.map-layout:has(#mapView.map-theme-day) .status-hud .hud-label {
  color: #031006 !important;
  text-shadow: none !important;
  -webkit-text-stroke: 0.6px rgba(255, 255, 255, 0.55);
  paint-order: stroke fill;
}

body.map-layout:has(#mapView.map-theme-day) .status-hud .hud-text.situational-status {
  /* 明るい地図では薄い緑も透明度の明滅も白く溶ける。不透明な緑のまま */
  color: #059669;
  opacity: 1;
  font-weight: 700; /* 昼の地図だけ太字（明るい背景で細い緑が読みにくいため） */
  -webkit-text-stroke: 0;
  text-shadow: none;
}

body.map-layout:has(#mapView.map-theme-day) .status-hud .situational-status.is-clear {
  animation: situational-pulse-day 2.8s ease-in-out infinite;
}

body.map-layout:has(#mapView.map-theme-day) .status-hud .situational-status.is-alert {
  color: #b45309 !important;
}

body.map-layout:has(#mapView.map-theme-day) .status-hud .text-glow {
  text-shadow: none !important;
}

.situational-status {
  font-size: 11px;
  line-height: 1.25;
  color: rgba(110, 231, 183, 0.88);
  letter-spacing: 0.01em;
  max-width: 15rem;
}

.situational-status.is-clear {
  animation: situational-pulse 2.8s ease-in-out infinite;
}

.situational-status.is-alert {
  color: #fbbf24;
  animation: none;
}

.nearest-hud-inline {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(16, 185, 129, 0.55);
  max-width: 15rem;
}

.nearest-hud-inline .nearest-hud-kicker {
  margin-bottom: 0.12rem;
}

.nearest-hud-inline-name {
  font-size: 11px;
  font-weight: 700;
  color: #a7f3d0;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nearest-hud-inline-metrics {
  display: flex;
  align-items: flex-end;
  gap: 0.85rem;
  margin-top: 0.25rem;
}

.nearest-hud-inline-brg .hud-text,
.nearest-hud-inline-dist .hud-text {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #ecfdf5;
  line-height: 1.1;
  margin-top: 0.08rem;
}

.nearest-hud-inline-dist .hud-text {
  color: #6ee7b7;
  font-size: 13px;
}

@keyframes situational-pulse {
  0%,
  100% {
    opacity: 0.62;
  }
  50% {
    opacity: 1;
  }
}

/* 昼の地図は背景が明るい。透明度を下げると緑が消えるので、濃淡で明滅する */
@keyframes situational-pulse-day {
  0%,
  100% {
    color: #065f46;
    opacity: 1;
  }
  50% {
    color: #059669;
    opacity: 1;
  }
}

body.map-layout:has(#mapView.map-theme-day) .drive-sheet-title,
body.map-layout:has(#mapView.map-theme-day) .drive-sheet-ref,
body.map-layout:has(#mapView.map-theme-day) .drive-sheet .hud-label,
body.map-layout:has(#mapView.map-theme-day) .drive-speed-label,
body.map-layout:has(#mapView.map-theme-day) .drive-alert-metric-label,
body.map-layout:has(#mapView.map-theme-day) .drive-alert-metric-value,
body.map-layout:has(#mapView.map-theme-day) .drive-alert-detail-text,
body.map-layout:has(#mapView.map-theme-day) .drive-sheet-summary-text {
  /* 昼でもアナログ中央デジタルと同じミント系（白縁取りは使わない） */
  color: #a7f3d0;
  text-shadow: 0 0 6px rgba(0, 255, 102, 0.35);
}

body.map-layout:has(#mapView.map-theme-day) .drive-sheet-ref,
body.map-layout:has(#mapView.map-theme-day) .drive-speed-label,
body.map-layout:has(#mapView.map-theme-day) .drive-alert-metric-label,
body.map-layout:has(#mapView.map-theme-day) .drive-sheet-summary-text.is-clear {
  color: rgba(110, 231, 183, 0.85);
  text-shadow: none;
}

body.map-layout:has(#mapView.map-theme-day) .drive-sheet-summary-text.is-alert {
  color: #b45309;
  text-shadow: 0 0 6px rgba(255, 180, 80, 0.3);
}

body.map-layout:has(#mapView.map-theme-day) .drive-alert-row.is-alert .drive-alert-metric-value,
body.map-layout:has(#mapView.map-theme-day) .drive-alert-row.is-alert .drive-alert-detail-text {
  color: #fecaca;
  text-shadow: 0 0 6px rgba(255, 80, 80, 0.35);
}

body.map-layout:has(#mapView.map-theme-day) .drive-alert-row.is-alert .drive-alert-metric-label {
  color: rgba(254, 202, 202, 0.8);
  text-shadow: none;
}

body.map-layout:has(#mapView.map-theme-day) .drive-alert-row.is-alert.is-cyan .drive-alert-metric-value,
body.map-layout:has(#mapView.map-theme-day) .drive-alert-row.is-alert.is-cyan .drive-alert-detail-text {
  color: #a5f3fc;
  text-shadow: 0 0 6px rgba(0, 210, 255, 0.35);
}

body.map-layout:has(#mapView.map-theme-day) .drive-alert-row.is-alert.is-cyan .drive-alert-metric-label {
  color: rgba(165, 243, 252, 0.8);
  text-shadow: none;
}

.map-chrome {
  position: absolute;
  inset: 0;
  z-index: 35;
  pointer-events: none;
}

.map-chrome > * {
  pointer-events: auto;
}

/* 上左HUDの下：モード切替は左縦（カーテン展開時のデジタル下を定位置） */
.map-chrome-left {
  position: absolute;
  top: 16.2rem;
  left: max(0.45rem, env(safe-area-inset-left, 0px));
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.map-view-toggle {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  padding: 0.18rem;
  border-radius: 0.65rem;
  background: rgba(3, 12, 6, 0.42);
  border: 1px solid rgba(0, 255, 102, 0.35);
  box-sizing: border-box;
  /* 外枠幅＝右チップ幅。中のボタンは縦長のまま */
  width: 2.75rem;
}

/* 地図モード左トグル：幅だけ右チップに合わせる（正方形にはしない） */
.map-chrome-left .map-view-btn {
  padding: 0.2rem 0.05rem;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: auto;
  aspect-ratio: 1 / 1.12;
  border-radius: 0.4rem;
  font-size: 9px;
  font-weight: 700;
  color: #7dffb0;
  background: transparent;
  border: none;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.08rem;
  box-sizing: border-box;
  flex-shrink: 0;
  line-height: 1.05;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.map-chrome-left .map-view-btn > span:first-child {
  font-size: 1rem;
  line-height: 1;
}

.map-chrome-left .map-view-btn.btn-view-radar,
.map-chrome-left .map-view-btn.btn-view-map,
.map-chrome-left .map-view-btn.btn-view-experience {
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: auto;
}

.map-chrome-left .map-view-btn-active,
.map-chrome-left .btn-view-map.map-view-btn-active,
.map-chrome-left .btn-view-radar.map-view-btn-active {
  background: rgba(0, 255, 102, 0.92);
  color: #031006;
}

.map-chrome-left .btn-view-experience.map-view-btn {
  color: #7defff;
}

.map-chrome-left .btn-view-experience.experience-btn-active,
.map-chrome-left .btn-view-experience.map-view-btn.experience-btn-active {
  background: rgba(0, 210, 255, 0.92);
  color: #031018;
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.55);
}

/* 体験ガイド：地図・レーダー共通（上端バナー＋▼で体験説明） */
#experienceGuide.experience-sheet,
.experience-sheet {
  position: absolute;
  top: calc(0.35rem + 3.1rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: min(78vw, 18.5rem);
  border-radius: 0.75rem;
  background: rgba(0, 210, 255, 0.94);
  border: 1px solid rgba(140, 240, 255, 0.95);
  box-shadow: 0 0 16px rgba(0, 210, 255, 0.4);
  color: #031018;
  overflow: hidden;
  transition: width 0.3s ease;
  pointer-events: auto;
}

body.map-layout #experienceGuide.experience-sheet {
  top: calc(3.1rem + 1.0rem);
}

/* 開いたとき：前面＋幅いっぱい（閉じれば通常操作に戻る） */
body:has(#experienceGuide.is-open) #mapChrome {
  z-index: 70;
}

body:has(#experienceGuide.is-open) .drive-sheet,
body:has(#experienceGuide.is-open) .status-hud {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
}

#experienceGuide.experience-sheet.is-open,
.experience-sheet.is-open {
  width: calc(100% - 0.7rem);
  max-width: none;
  z-index: 73;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.45), 0 0 20px rgba(0, 210, 255, 0.45);
}

#experienceGuide.experience-sheet.hidden,
.experience-sheet.hidden {
  display: none !important;
}

.experience-sheet-handle-bar {
  display: flex;
  align-items: stretch;
  width: 100%;
  background: rgba(0, 210, 255, 0.94);
}

.experience-sheet-handle {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: #031018;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.experience-sheet-handle-label {
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #031018;
}

.experience-sheet-chevron {
  font-size: 11px;
  font-weight: 800;
  color: #031018;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#experienceGuide.is-open .experience-sheet-chevron,
.experience-sheet.is-open .experience-sheet-chevron {
  transform: rotate(180deg);
}

.experience-sheet-panel {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  background: rgba(0, 210, 255, 0.94);
  transition:
    max-height 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.25s ease;
}

#experienceGuide.is-open .experience-sheet-panel,
.experience-sheet.is-open .experience-sheet-panel {
  max-height: min(48vh, 18rem);
  opacity: 1;
}

.experience-sheet-panel-inner {
  padding: 0.55rem 0.85rem 0.85rem;
  text-align: left;
  line-height: 1.4;
  color: #031018;
  max-height: min(48vh, 18rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

.experience-guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.1rem 0 0.45rem;
}

.experience-guide-title {
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin: 0;
  color: #031018;
}

.experience-sheet-panel-inner p {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: #031018;
}

.experience-sheet-panel-inner p + p {
  margin-top: 0.2rem;
}

@media (max-width: 900px), (pointer: coarse) {
  #experienceGuide.experience-sheet,
  .experience-sheet {
    width: min(72vw, 17rem);
  }

  #experienceGuide.experience-sheet.is-open,
  .experience-sheet.is-open {
    width: calc(100% - 0.5rem);
  }

  .experience-sheet-handle-label {
    font-size: 13px;
  }

  .experience-sheet-panel-inner {
    padding-top: 0.7rem;
  }

  .experience-sheet-panel-inner p {
    font-size: 13px;
  }

  #experienceGuide.is-open .experience-sheet-panel,
  .experience-sheet.is-open .experience-sheet-panel,
  .experience-sheet-panel-inner {
    max-height: min(44vh, 16rem);
  }
}

.app-manual {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(1, 8, 4, 0.92);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0.75rem;
}

.app-manual.hidden {
  display: none;
}

.app-manual-panel {
  width: min(100%, 34rem);
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 1rem;
  overflow: hidden;
  background: #04150b;
  border: 1px solid rgba(0, 255, 102, 0.35);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.55);
}

.app-manual-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem 0.7rem;
  border-bottom: 1px solid rgba(0, 255, 102, 0.22);
  flex-shrink: 0;
}

.app-manual-kicker {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: #5fd98f;
}

.app-manual-title {
  margin: 0.1rem 0 0;
  font-family: "Orbitron", sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  color: #d8ffe8;
}

.app-manual-close {
  border: 1px solid rgba(0, 255, 102, 0.45);
  background: rgba(0, 40, 18, 0.85);
  color: #7dffb0;
  font-size: 14px;
  font-weight: 800;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  min-height: 44px;
  cursor: pointer;
}

.app-manual-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem 1.05rem 1.35rem;
}

.app-manual-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid rgba(0, 255, 102, 0.12);
}

.app-manual-section-last {
  border-bottom: none;
  margin-bottom: 0.25rem;
  padding-bottom: 0;
}

.app-manual-section h3 {
  margin: 0 0 0.55rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: #7dffb0;
  letter-spacing: 0.02em;
}

.app-manual-section .app-manual-subhead {
  margin: 1.05rem 0 0.45rem;
  font-size: 0.98rem;
  font-weight: 800;
  color: #9dffc0;
  letter-spacing: 0.02em;
}

.app-manual-section .app-manual-subhead:first-of-type {
  margin-top: 0.65rem;
}

.app-manual-section p,
.app-manual-section li {
  margin: 0;
  font-size: 16px;
  line-height: 1.65;
  color: #b7f0cc;
}

.app-manual-section p + p {
  margin-top: 0.55rem;
}

.app-manual-section ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}

.app-manual-section li + li {
  margin-top: 0.4rem;
}

.app-manual-section strong {
  color: #eafff0;
  font-weight: 800;
}

.app-manual-section a {
  color: #7defff;
  text-decoration: underline;
}

.app-manual-footer {
  flex-shrink: 0;
  padding: 0.75rem 0.95rem 0.95rem;
  border-top: 1px solid rgba(0, 255, 102, 0.22);
}

.app-manual-footer-btn {
  width: 100%;
  border: 1px solid rgba(0, 255, 102, 0.55);
  background: rgba(0, 255, 102, 0.12);
  color: #9dffc0;
  font-size: 16px;
  font-weight: 800;
  border-radius: 0.7rem;
  padding: 0.85rem 0.9rem;
  min-height: 48px;
  cursor: pointer;
}

@media (max-width: 900px), (pointer: coarse) {
  .app-manual {
    padding: 0.45rem;
  }

  .app-manual-title {
    font-size: 1.35rem;
  }

  .app-manual-section h3 {
    font-size: 1.12rem;
  }

  .app-manual-section .app-manual-subhead {
    font-size: 1.05rem;
  }

  .app-manual-section p,
  .app-manual-section li {
    font-size: 17px;
    line-height: 1.7;
  }
}

body.experience-active.map-layout .status-hud {
  opacity: 0;
  pointer-events: none;
}

.map-chrome-right {
  position: absolute;
  top: 3.2rem;
  right: 0.55rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.28rem;
  z-index: 40;
}

/* 仮想オンオフだけ、他チップより広めに離す（スマホ含む・末尾でも効くよう強めに） */
.map-chrome-right .map-virtual-gap {
  flex: 0 0 auto;
  width: 100%;
  height: 0.7rem;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.map-chrome-right .virtual-demo-btn {
  margin-top: 0 !important;
}

.map-audio-unlock.needs-unlock {
  border-color: rgba(0, 255, 102, 0.95);
  color: #031006;
  background: rgba(0, 255, 102, 0.92);
  box-shadow: 0 0 12px rgba(0, 255, 102, 0.55);
  animation: audio-unlock-pulse 1.2s ease-in-out infinite;
}

.map-audio-unlock:not(.needs-unlock) {
  display: none;
}

@keyframes audio-unlock-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.06);
    opacity: 0.85;
  }
}

body.map-layout #audioUnlockBanner {
  top: auto;
  bottom: 6.2rem;
  z-index: 55;
}

.map-chrome-zoom {
  position: absolute;
  left: 0.55rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  z-index: 40;
}

.map-chrome-zoom .map-zoom-stack-btn {
  flex-shrink: 0;
}

/* 音量の下の ± ◎ だけ間隔を空ける */
.map-chrome-zoom .map-volume-btn + .map-zoom-btn {
  margin-top: 0.36rem;
}

.js-alert-volume-btn {
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.map-locate-btn {
  margin-top: 0.35rem;
  font-size: 0.95rem;
  letter-spacing: -0.05em;
}

.map-locate-btn:disabled {
  opacity: 0.45;
}

.map-action-dock {
  position: absolute;
  right: 0.75rem;
  bottom: 5.1rem;
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  z-index: 37;
}

.map-post-fab {
  position: absolute;
  right: 0.75rem;
  bottom: 1.85rem;
  width: 4.5rem;
  min-width: 4.5rem;
  height: 2.55rem;
  min-height: 40px;
  padding: 0;
  font-size: 12px;
  border-radius: 999px;
  z-index: 37;
}

/* 投稿と同じ高さの正円。投稿の左・少し離す（仮記録には近づけない） */
.watch-fab,
.map-watch-fab {
  width: 2.55rem;
  min-width: 2.55rem;
  height: 2.55rem;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #ff4db8;
  background: #ff4db8;
  color: #2a0618;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.05;
  box-shadow: 0 0 12px rgba(255, 77, 184, 0.45);
  cursor: pointer;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.map-watch-fab {
  position: absolute;
  /* 投稿の左。すぐ横でくっついて見えないよう余裕を取る */
  right: calc(0.75rem + 4.5rem + 1.25rem);
  bottom: 1.85rem;
  z-index: 37;
}

@media (hover: hover) and (pointer: fine) {
  .watch-fab:hover,
  .map-watch-fab:hover {
    background: #ff6ec8;
    box-shadow: 0 0 16px rgba(255, 77, 184, 0.7);
  }
}

.watch-fab:active,
.map-watch-fab:active {
  background: #ff6ec8;
}

.pin-place-sheet {
  position: absolute;
  left: 50%;
  bottom: 0.75rem;
  transform: translateX(-50%);
  width: min(92vw, 22rem);
  z-index: 45;
  padding: 0.75rem 0.85rem 0.85rem;
  border-radius: 0.85rem;
  background: rgba(3, 18, 10, 0.92);
  border: 1px solid rgba(0, 255, 102, 0.45);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

.pin-place-sheet.hidden {
  display: none;
}

.pin-place-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.pin-place-sheet-title {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #7dffb0;
  letter-spacing: 0.04em;
}

.pin-place-sheet-close {
  border: none;
  background: transparent;
  color: #5a9a72;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.pin-place-sheet-hint {
  margin: 0 0 0.55rem;
  font-size: 11px;
  color: #8fe0b0;
  line-height: 1.35;
}

.pin-place-sheet-label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 10px;
  color: #5fd98f;
}

.pin-place-sheet-select {
  width: 100%;
  margin-bottom: 0.65rem;
  padding: 0.45rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(0, 255, 102, 0.35);
  background: #000;
  color: #9dffc0;
  font-size: 11px;
}

.pin-dir-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.pin-dir-head .pin-place-sheet-label {
  margin-bottom: 0;
}

.pin-dir-toggle {
  flex-shrink: 0;
  border: 1px solid rgba(0, 210, 255, 0.55);
  background: rgba(0, 210, 255, 0.18);
  color: #9ef0ff;
  font-size: 10px;
  font-weight: 800;
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  cursor: pointer;
}

.pin-dir-toggle.is-off {
  border-color: rgba(140, 160, 170, 0.45);
  background: rgba(40, 50, 55, 0.55);
  color: #9aa8b0;
}

.pin-dir-panel.is-off {
  opacity: 0.38;
  pointer-events: none;
}

.pin-dir-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.pin-dir-slider {
  flex: 1;
  min-width: 0;
  accent-color: #00d2ff;
}

.pin-dir-nudge {
  flex-shrink: 0;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(0, 210, 255, 0.55);
  background: rgba(0, 40, 55, 0.65);
  color: #9ef0ff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.pin-dir-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  font-size: 11px;
  font-weight: 700;
  color: #7defff;
}

.pin-place-fields.hidden {
  display: none;
}

.pin-place-sheet-actions {
  display: flex;
  gap: 0.45rem;
}

.pin-place-btn {
  flex: 1;
  padding: 0.55rem 0.4rem;
  border-radius: 0.55rem;
  font-size: 11px;
  font-weight: 700;
}

.pin-place-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

body.pin-place-active .map-record-fab,
body.pin-place-active .map-post-fab,
body.pin-place-active .map-watch-fab,
body.pin-place-active .map-action-dock,
body.pin-place-active .map-gsi-credit {
  opacity: 0.25;
  pointer-events: none;
}

/* 速度計展開中は上半分を優先。下のFAB・地理院はそのまま */
body.drive-sheet-open .status-hud,
body.drive-sheet-open #experienceGuide,
body.drive-sheet-open .virtual-demo-banner {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.experience-active .map-watch-fab {
  display: none !important;
}

body.pin-place-active #mapView {
  cursor: crosshair;
}

.pin-marker-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: visible;
}

/* #mapView .custom-target-icon の position:relative より強くする（積み上がりで下ズレ防止） */
#mapView .pin-marker-layer .custom-target-icon,
#mapView .pin-marker-layer .custom-target-icon.has-recheck {
  position: absolute;
  left: 0;
  top: 0;
  /* 扇の大きな枠は通過させ、点だけ受け取る（ポップアップ操作の阻害防止） */
  pointer-events: none;
  will-change: transform;
}

#mapView .pin-marker-layer .custom-target-icon .target-dot {
  pointer-events: auto;
  cursor: pointer;
}

.pin-place-overlay {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 20;
  pointer-events: none;
  will-change: transform;
}

.pin-place-overlay.is-draggable {
  pointer-events: auto;
  cursor: grab;
}

.pin-place-overlay.is-dragging {
  cursor: grabbing;
}

.pin-place-temp-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #00ff66;
  border: 2px solid #fff;
  box-shadow: 0 0 12px rgba(0, 255, 102, 0.85);
}

.pin-place-temp-root {
  position: relative;
  width: 104px;
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.pin-place-temp-root .pin-place-temp-marker {
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

.pin-place-temp-root .target-dir-fan {
  width: 104px;
  height: 104px;
}

.pin-place-temp-marker--draft {
  width: 22px;
  height: 22px;
  background: #ffb020;
  border: 2px solid #ffe099;
  box-shadow:
    0 0 0 3px rgba(255, 176, 32, 0.35),
    0 0 14px rgba(255, 176, 32, 0.9);
  color: #3a2200;
  font-size: 12px;
  font-weight: 900;
  line-height: 18px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
}

.pin-place-temp-marker--draft:active {
  cursor: grabbing;
}

.pin-place-sheet.draft-adjust-mode {
  border-color: rgba(255, 176, 32, 0.55);
  background: rgba(24, 16, 4, 0.94);
}

.pin-place-sheet.draft-adjust-mode .pin-place-sheet-title {
  color: #ffc857;
}

.pin-place-sheet.draft-adjust-mode .pin-place-sheet-hint {
  color: #ffd98a;
}

.pin-place-sheet.draft-adjust-mode .pin-place-sheet-close {
  color: #c9a050;
}

.record-fab {
  min-width: 10.5rem;
  width: 10.5rem;
  height: 2.65rem;
  min-height: 44px;
  padding: 0 1rem;
  border-radius: 999px;
  border: 1px solid #ffb020;
  background: #ffb020;
  color: #1a1200;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1em;
  box-shadow: 0 0 14px rgba(255, 176, 32, 0.5);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.record-fab:active {
  background: #ffc44d;
  box-shadow: 0 0 18px rgba(255, 176, 32, 0.7);
}

.map-record-fab {
  position: absolute;
  /* ◎列〜要注意のあいだで中央（左右の隙間を揃える） */
  --map-rec-left-clear: calc(0.55rem + 2.6rem);
  --map-rec-right-clear: calc(0.75rem + 4.5rem + 1.25rem + 2.55rem);
  left: calc(
    var(--map-rec-left-clear) + (100% - var(--map-rec-left-clear) - var(--map-rec-right-clear)) / 2
  );
  right: auto;
  bottom: 1.1rem;
  transform: translateX(-50%);
  width: min(9.5rem, 46vw);
  min-width: 0;
  z-index: 37;
}

/* スマホ：下切れ防止＋タッチサイズ。幅だけでなくタッチ端末でも当てる */
@media (max-width: 900px), (pointer: coarse) {
  #radarChromeFooter > p {
    display: none;
  }

  #radarChromeFooter {
    padding-bottom: max(0.35rem, env(safe-area-inset-bottom, 0px));
  }

  main.crt-container {
    margin-top: 0.35rem !important;
    margin-bottom: 0.35rem !important;
    min-height: 0;
  }

  body:not(.map-layout) main.crt-container {
    margin-top: 0.2rem !important;
    margin-bottom: 0 !important;
  }

  .radar-action-dock {
    bottom: 2.5%;
  }

  .drive-sheet {
    top: 0;
    bottom: auto;
    left: 0;
    right: 0;
  }

  .drive-alert-lamp {
    width: 1.55rem;
    height: 1.55rem;
    min-width: 26px;
    min-height: 26px;
  }

  .map-chip-sq,
  .map-zoom-btn {
    width: 3rem;
    height: 3rem;
    min-width: 3rem;
    min-height: 3rem;
    box-sizing: border-box;
    font-size: 17px;
  }

  .map-chrome-zoom .map-volume-btn {
    font-size: 18px;
  }

  .map-chrome-right .map-manual-btn {
    font-size: 18px;
  }

  .map-chrome-zoom .map-zoom-btn {
    font-size: 1.35rem;
  }

  .map-chrome-right {
    top: 3.5rem;
    right: max(0.4rem, env(safe-area-inset-right, 0px));
    gap: 0.36rem;
  }

  .map-chrome-right .map-virtual-gap {
    height: 0.95rem;
  }

  .map-chrome-right .virtual-demo-btn {
    margin-top: 0 !important;
  }

  .map-chrome-left .map-view-btn,
  .map-chrome-left .map-view-btn.btn-view-radar,
  .map-chrome-left .map-view-btn.btn-view-map,
  .map-chrome-left .map-view-btn.btn-view-experience {
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: auto;
    font-size: 10px;
  }

  .map-chrome-left .map-view-btn > span:first-child {
    font-size: 1.1rem;
  }

  .map-view-toggle {
    width: 3rem;
    gap: 0.36rem;
    padding: 0.22rem;
  }

  .record-fab {
    min-width: 10.25rem;
    width: min(10.25rem, 68vw);
    height: 2.85rem;
    min-height: 48px;
    padding: 0 0.9rem;
    font-size: 14px;
    letter-spacing: 0.09em;
  }

  /* レーダー仮記録のみ：BRG被り緩和で今の9割幅 */
  .radar-record-fab {
    min-width: 0;
    width: min(9.225rem, 61.2vw);
  }

  /* 地理院は右下固定。ボタン下端はその直上で揃える */
  body.map-layout .map-gsi-credit {
    left: auto;
    right: max(0.7rem, env(safe-area-inset-right, 0px));
    bottom: max(0.45rem, env(safe-area-inset-bottom, 0px));
    font-size: 10px;
  }

  .map-record-fab,
  .map-post-fab,
  .map-watch-fab,
  .map-chrome-zoom {
    bottom: calc(max(0.45rem, env(safe-area-inset-bottom, 0px)) + 1.15rem);
  }

  .map-record-fab {
    height: 3rem;
    min-height: 48px;
    --map-rec-left-clear: calc(max(0.45rem, env(safe-area-inset-left, 0px)) + 2.85rem);
    --map-rec-right-clear: calc(
      max(0.7rem, env(safe-area-inset-right, 0px)) + 5rem + 1.35rem + 3rem
    );
    left: calc(
      var(--map-rec-left-clear) + (100% - var(--map-rec-left-clear) - var(--map-rec-right-clear)) / 2
    );
    transform: translateX(-50%);
    width: min(8.75rem, 44vw);
    min-width: 0;
  }

  .map-post-fab {
    width: 5rem;
    min-width: 5rem;
    height: 3rem;
    min-height: 48px;
    font-size: 13px;
  }

  .map-watch-fab,
  .watch-fab {
    width: 3rem;
    min-width: 3rem;
    height: 3rem;
    min-height: 48px;
    font-size: 12px;
  }

  .map-watch-fab {
    right: calc(max(0.7rem, env(safe-area-inset-right, 0px)) + 5rem + 1.35rem);
  }

  .map-action-dock {
    bottom: calc(max(0.45rem, env(safe-area-inset-bottom, 0px)) + 1.15rem + 3rem + 0.45rem);
  }

  .map-chrome-zoom {
    left: max(0.45rem, env(safe-area-inset-left, 0px));
  }

  .draft-fab,
  .post-fab,
  .radar-draft-fab {
    width: 5rem;
    min-width: 5rem;
    height: 3rem;
    min-height: 48px;
    font-size: 13px;
  }

  /* ヘッダー内は拡大しない（ロゴを潰さない） */
  #radarChromeHeader .radar-draft-fab,
  #radarChromeHeader .draft-fab {
    width: 3.8rem !important;
    min-width: 3.8rem !important;
    max-width: 3.8rem !important;
    height: 2.15rem !important;
    min-height: 2.15rem !important;
    font-size: 10px !important;
  }

  .radar-tool-btn {
    min-height: 2.15rem;
    height: 2.15rem;
    font-size: 12px;
  }

  .radar-tool-kicker {
    font-size: 8.5px;
  }

  .radar-tool-grid {
    gap: 0.28rem;
  }

  #radarChromeHeader .btn-view-radar,
  #radarChromeHeader .btn-view-map,
  #radarChromeHeader .btn-view-experience {
    width: auto;
    min-height: 2.15rem;
    height: 2.15rem;
    max-height: 2.15rem;
    font-size: 0.68rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
    padding-top: 0;
    padding-bottom: 0;
  }

  #radarChromeHeader .btn-view-experience {
    max-width: 3.6rem;
  }

  body.map-layout {
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
  }
}

.draft-fab {
  position: relative;
  width: 4.5rem;
  min-width: 4.5rem;
  height: 2.55rem;
  min-height: 40px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 176, 32, 0.7);
  background: rgba(40, 28, 0, 0.55);
  color: #ffd27a;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.draft-fab.has-drafts {
  border-color: #ffb020;
  color: #ffe099;
  box-shadow: 0 0 10px rgba(255, 176, 32, 0.3);
}

.draft-fab.draft-pulse {
  animation: draft-pulse 0.9s ease-out;
}

@keyframes draft-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(255, 176, 32, 0);
  }
  35% {
    transform: scale(1.12);
    border-color: #ffb020;
    color: #fff3c4;
    box-shadow: 0 0 18px rgba(255, 176, 32, 0.85);
  }
  100% {
    transform: scale(1);
  }
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%) translateY(0.4rem);
  z-index: 60;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: rgba(40, 28, 0, 0.92);
  border: 1px solid rgba(255, 176, 32, 0.75);
  color: #ffe099;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.app-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

body.map-layout .app-toast {
  bottom: 4.2rem;
}

/* 共有（サーバー）が使えないときの案内。警報の動作は止まっていないことを伝える */
.sync-notice {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%);
  z-index: 59;
  max-width: calc(100vw - 1rem);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: rgba(40, 28, 0, 0.9);
  border: 1px solid rgba(255, 176, 32, 0.7);
  color: #ffe099;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease;
}

.sync-notice.show {
  opacity: 1;
  visibility: visible;
}

body.map-layout .sync-notice {
  bottom: 4.2rem;
}

/* 一時的なトーストが出ている間は、同じ場所のトーストを優先する */
.app-toast.show + .sync-notice {
  opacity: 0;
}

/* 縦画面専用：スマホ等のタッチ端末を横にしたときだけ、案内で全面を覆う。
   PC（マウス）や高さのある端末（タブレット等）は対象外＝地図は従来どおり全面 */
#orientationGuard {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1rem;
  text-align: center;
  background: #020a05;
  color: #00ff66;
  font-family: "Orbitron", "Share Tech Mono", sans-serif;
  text-shadow: 0 0 8px rgba(0, 255, 102, 0.55);
}

#orientationGuard .orientation-guard-ico {
  font-size: 2.4rem;
  line-height: 1;
}

#orientationGuard .orientation-guard-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

#orientationGuard .orientation-guard-sub {
  font-size: 0.8rem;
  opacity: 0.8;
}

@media (orientation: landscape) and (pointer: coarse) and (max-height: 560px) {
  #orientationGuard {
    display: flex;
  }
}

/* 他の人の投稿を読み上げたあと、地図で確認しに行くチップ（タップ可） */
.post-jump-chip {
  position: fixed;
  left: 50%;
  bottom: 8.2rem;
  transform: translateX(-50%) translateY(0.4rem);
  z-index: 61;
  max-width: calc(100vw - 1.5rem);
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  background: rgba(0, 28, 10, 0.94);
  border: 1px solid rgba(0, 255, 102, 0.8);
  box-shadow: 0 0 12px rgba(0, 255, 102, 0.35);
  color: #9dffc4;
  font-family: "Share Tech Mono", "Orbitron", monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.post-jump-chip.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

body.map-layout .post-jump-chip {
  bottom: 6.8rem;
}

.map-draft-fab {
  position: static;
}

/* 未編集・投稿は常に同サイズ（後勝ち cascade でずれないよう末尾で固定） */
.draft-fab,
.post-fab,
.map-draft-fab,
.map-post-fab,
.radar-draft-fab {
  width: 4.5rem;
  min-width: 4.5rem;
  height: 2.55rem;
  min-height: 40px;
  font-size: 12px;
  box-sizing: border-box;
}

@media (max-width: 900px), (pointer: coarse) {
  .draft-fab,
  .post-fab,
  .map-draft-fab,
  .map-post-fab,
  .radar-draft-fab {
    width: 5rem;
    min-width: 5rem;
    height: 3rem;
    min-height: 48px;
    font-size: 13px;
  }
}

.draftCountBadge {
  position: absolute;
  top: -0.45rem;
  right: -0.4rem;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: #ff3333;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35rem;
  text-align: center;
}

.map-chip {
  background: rgba(3, 16, 8, 0.32);
  border: 1px solid rgba(0, 255, 102, 0.55);
  color: #00ff66;
  font-size: 10px;
  font-weight: 700;
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 0 6px rgba(0, 255, 102, 0.12);
  white-space: nowrap;
  text-align: center;
  backdrop-filter: blur(2px);
}

.map-chip-sq {
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  border-radius: 0.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.map-chrome-zoom .map-volume-btn {
  font-size: 17px;
  font-weight: 800;
}

.map-chrome-right .map-chip-sq:not(.virtual-demo-btn):not(.map-glow-btn):not(.keep-awake-btn) {
  font-size: 16px;
  font-weight: 800;
}

.map-chrome-right .map-manual-btn {
  font-size: 17px;
  font-weight: 800;
}

.map-glow-btn {
  letter-spacing: -0.02em;
  gap: 0;
}

.map-chip:active:not(.active) {
  background: rgba(0, 255, 102, 0.28);
  color: #b7ffd0;
}

.map-chip.active {
  background: #00ff66;
  color: #030a05;
}

.map-zoom-btn {
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  box-sizing: border-box;
  background: rgba(3, 16, 8, 0.32);
  border: 1px solid rgba(0, 255, 102, 0.55);
  color: #00ff66;
  font-family: "Orbitron", sans-serif;
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 0.45rem;
  box-shadow: 0 0 6px rgba(0, 255, 102, 0.12);
  backdrop-filter: blur(2px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* 左列：±◎も音量と同じ角丸連結スタイルに合わせる */
.map-chrome-zoom .map-zoom-btn.rounded-t-lg {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-width: 0;
}

.map-chrome-zoom .map-zoom-btn.rounded-b-lg {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.map-zoom-btn:active {
  background: #00ff66;
  color: #030a05;
}

.drive-sheet {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: auto;
  z-index: 38;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  pointer-events: none;
  /* 閉じ時：取っ手帯のみ（レーダー／地図で同じ実寸） */
  height: var(--design-handle-h, 2.7rem);
  max-height: var(--design-handle-h, 2.7rem);
  transition: height 0.24s ease, max-height 0.24s ease;
}

.drive-sheet.is-open {
  height: auto;
  max-height: calc(100% - var(--stage-fab-band, 12%));
  z-index: 42;
  pointer-events: none;
}

/*
 * 速度計シート（デジタル／アナログ共通）：上限幅で中央揃え。
 * 地図は全画面のまま、シートだけスマホ幅に収める。
 */
body:not(.map-layout) .drive-sheet.is-open,
body.map-layout .drive-sheet.is-open {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: auto;
  width: 100%;
  max-width: var(--design-width-max, 420px);
  margin-left: auto;
  margin-right: auto;
  z-index: 50;
}

/*
 * アナログカーテン：円は幅基準。カーテンは中身の高さ。
 */
body:not(.map-layout) .drive-sheet.is-open:has(.drive-mode-analog),
body.map-layout .drive-sheet.is-open:has(.drive-mode-analog) {
  height: auto;
  max-height: 88%;
  overflow: hidden;
}

body:not(.map-layout) .drive-sheet.is-open:has(.drive-mode-analog) .drive-sheet-body,
body.map-layout .drive-sheet.is-open:has(.drive-mode-analog) .drive-sheet-body {
  flex: 0 1 auto;
  min-height: 0;
  height: auto;
  overflow: hidden;
  margin-bottom: 0;
  justify-content: flex-start;
  padding-bottom: 0.5%;
}

body:not(.map-layout) .drive-sheet.is-open:has(.drive-mode-analog) .drive-speed-analog,
body.map-layout .drive-sheet.is-open:has(.drive-mode-analog) .drive-speed-analog {
  /* 円はカーテン幅いっぱい（≤420）。縦だけ円に合わせて余白を削る */
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1.06;
  max-height: none;
  min-height: 0;
}

.drive-sheet.is-blocked {
  display: none !important;
}

.drive-sheet-handle {
  position: relative;
  order: 2;
  width: 100%;
  height: var(--design-handle-h, 2.7rem);
  flex: 0 0 var(--design-handle-h, 2.7rem);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.drive-sheet.is-open .drive-sheet-handle {
  height: var(--design-handle-h, 2.7rem);
  flex: 0 0 var(--design-handle-h, 2.7rem);
  max-height: none;
  min-height: 0;
}

.drive-sheet-handle:active {
  cursor: grabbing;
}

.drive-sheet-rail {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 50%;
  height: 2px;
  min-height: 2px;
  max-height: 2px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: rgba(0, 255, 102, 0.45);
  box-shadow: 0 0 6px rgba(0, 255, 102, 0.28);
}

.drive-sheet-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  /* つまみ幅もレーダー／地図で同じ実寸（舞台 cqw だと地図で太くなる） */
  width: var(--design-handle-knob-w, 4.5rem);
  max-width: 28%;
  height: 36%;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: rgba(0, 255, 102, 0.92);
  border: none;
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.35);
}

.drive-sheet-body {
  display: none;
  order: 1;
  flex-direction: column;
  align-items: stretch;
  gap: 1.2%;
  margin: 1% 2.5% 0;
  padding: 2% 3.5% 2%;
  border-radius: 0.75rem 0.75rem 0.9rem 0.9rem;
  background: rgba(3, 12, 6, 0.94);
  border: 1px solid rgba(0, 255, 102, 0.38);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  overflow: visible;
  min-height: 0;
  flex: 1 1 auto;
}

.drive-sheet.is-open .drive-sheet-body {
  display: flex;
}

.drive-sheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
}

.drive-sheet-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #a7f3d0;
}

.drive-sheet-ref {
  font-size: 9px;
  font-weight: 700;
  color: rgba(110, 231, 183, 0.75);
  letter-spacing: 0;
}

.drive-alert-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.55rem;
  flex-shrink: 0;
  min-width: 0;
}

.drive-alert-lamp-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  flex-shrink: 0;
  width: auto;
  min-width: 5.5rem;
}

.drive-alert-lamp {
  width: 1.35rem;
  height: 1.35rem;
  min-width: 22px;
  min-height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  box-sizing: border-box;
  background: rgba(70, 95, 78, 0.95);
  border: 2px solid rgba(0, 255, 102, 0.45);
  box-shadow:
    inset 0 0 5px rgba(0, 0, 0, 0.45),
    0 0 4px rgba(0, 255, 102, 0.2);
  z-index: 3;
  pointer-events: none;
  margin-left: 0.15rem;
}

.drive-alert-metrics {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 0.55rem;
}

.drive-alert-metric {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
}

.drive-alert-metric-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(110, 231, 183, 0.65);
  line-height: 1;
}

.drive-alert-metric-value {
  font-family: "Orbitron", sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(167, 243, 208, 0.92);
  line-height: 1;
  white-space: nowrap;
}

.drive-alert-detail {
  min-width: 0;
  flex: 1 1 auto;
  padding-top: 0.12rem;
}

.drive-alert-detail-text {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #a7f3d0;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-alert-row.is-alert .drive-alert-metric-value {
  color: #fecaca;
}

.drive-alert-row.is-alert .drive-alert-metric-label {
  color: rgba(254, 202, 202, 0.75);
}

.drive-alert-row.is-alert .drive-alert-detail-text {
  color: #fecaca;
}

.drive-alert-row.is-alert.is-cyan .drive-alert-metric-value,
.drive-alert-row.is-alert.is-cyan .drive-alert-detail-text {
  color: #a5f3fc;
}

.drive-alert-row.is-alert.is-cyan .drive-alert-metric-label {
  color: rgba(165, 243, 252, 0.75);
}

/* デジタル：GPS速度タイトルの直下・やや右 */
.drive-sheet-body.drive-mode-digital .drive-alert-row {
  align-self: stretch;
  margin: 0 0 0.05rem 0.55rem;
}

/* アナログ：タイトル直下を詰めてメーターを上げる（ゲージ寸法は変えない） */
.drive-sheet-body.drive-mode-analog .drive-alert-row {
  align-self: stretch;
  margin: 0.1rem 0 0.1rem 0.55rem;
}

.drive-sheet-body.drive-mode-analog .drive-speed-analog {
  margin-top: 1%;
  margin-bottom: 1%;
}

.drive-alert-lamp.is-on {
  background: #ff3333;
  border-color: rgba(255, 180, 180, 0.95);
  box-shadow:
    0 0 10px rgba(255, 51, 51, 0.95),
    0 0 20px rgba(255, 51, 51, 0.55),
    inset 0 0 4px rgba(255, 255, 255, 0.45);
  animation: drive-alert-lamp-pulse 0.8s ease-in-out infinite;
}

.drive-alert-lamp.is-on.is-cyan {
  background: #00d2ff;
  border-color: rgba(180, 245, 255, 0.95);
  box-shadow:
    0 0 10px rgba(0, 210, 255, 0.95),
    0 0 20px rgba(0, 210, 255, 0.55),
    inset 0 0 4px rgba(255, 255, 255, 0.45);
  animation-name: drive-alert-lamp-pulse-cyan;
}

.drive-alert-lamp.is-on.alert-glow-weak {
  animation-duration: 0.9s;
  opacity: 0.85;
}

.drive-alert-lamp.is-on.alert-glow-mid {
  animation-duration: 0.8s;
}

.drive-alert-lamp.is-on.alert-glow-strong {
  animation-duration: 0.7s;
}

@keyframes drive-alert-lamp-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
    box-shadow:
      0 0 12px rgba(255, 51, 51, 1),
      0 0 22px rgba(255, 51, 51, 0.65),
      inset 0 0 4px rgba(255, 255, 255, 0.5);
  }
  50% {
    opacity: 0.28;
    transform: scale(0.92);
    box-shadow:
      0 0 2px rgba(255, 51, 51, 0.25),
      inset 0 0 2px rgba(0, 0, 0, 0.35);
  }
}

@keyframes drive-alert-lamp-pulse-cyan {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
    box-shadow:
      0 0 12px rgba(0, 210, 255, 1),
      0 0 22px rgba(0, 210, 255, 0.65),
      inset 0 0 4px rgba(255, 255, 255, 0.5);
  }
  50% {
    opacity: 0.28;
    transform: scale(0.92);
    box-shadow:
      0 0 2px rgba(0, 210, 255, 0.25),
      inset 0 0 2px rgba(0, 0, 0, 0.35);
  }
}

.drive-sheet-modes {
  display: inline-flex;
  gap: 0.25rem;
}

.drive-speed-mode-btn {
  min-height: 1.7rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 255, 102, 0.35);
  background: rgba(0, 30, 12, 0.55);
  color: #86efac;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.drive-speed-mode-btn.active {
  background: #00ff66;
  color: #030a05;
  border-color: #00ff66;
}

.drive-speed-digital {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.15rem 0.5rem 0.2rem;
  min-height: 5.4rem;
  text-align: center;
}

.drive-speed-digital.hidden {
  display: none !important;
}

.drive-speed-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(110, 231, 183, 0.8);
  line-height: 1;
}

.drive-speed-value {
  font-family: "Orbitron", sans-serif;
  /* 3桁 + " KM/H"（元サイズと1.5倍の中間 ≈1.25倍） */
  font-size: clamp(2.3125rem, 10.625vw, 3.3125rem);
  font-weight: 700;
  line-height: 1.05;
  /* 中＝白 / 縁＝アナログ針と同じ蛍光緑（昼夜共通） */
  color: #ffffff;
  -webkit-text-stroke: 1.55px #00ff66;
  paint-order: stroke fill;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  min-width: 11ch;
  text-align: center;
  text-shadow:
    0 0 8px rgba(0, 255, 102, 0.95),
    0 0 18px rgba(0, 255, 102, 0.45),
    0 0 2px rgba(0, 255, 102, 0.9);
  transition: color 0.2s ease, text-shadow 0.2s ease, -webkit-text-stroke-color 0.2s ease;
}

/* HUD昼夜ルールに巻き込まれないようデジタル数字は明示上書き */
body.map-layout:has(#mapView.map-theme-day) .drive-speed-value,
body.map-layout:has(#mapView.map-theme-night) .drive-speed-value {
  color: #ffffff !important;
  -webkit-text-stroke: 1.55px #00ff66;
  paint-order: stroke fill;
  text-shadow:
    0 0 8px rgba(0, 255, 102, 0.95),
    0 0 18px rgba(0, 255, 102, 0.45),
    0 0 2px rgba(0, 255, 102, 0.9) !important;
}

.drive-speed-value.is-over {
  /* 100km/h超：中の色をアナログ針の警戒色へ */
  color: #ff8c00;
  -webkit-text-stroke: 1.55px #ffe08a;
  text-shadow:
    0 0 10px rgba(255, 100, 0, 1),
    0 0 24px rgba(255, 120, 0, 0.65),
    0 0 2px rgba(255, 200, 80, 0.95);
}

body.map-layout:has(#mapView.map-theme-day) .drive-speed-value.is-over,
body.map-layout:has(#mapView.map-theme-night) .drive-speed-value.is-over {
  color: #ff8c00 !important;
  -webkit-text-stroke: 1.55px #ffe08a;
  text-shadow:
    0 0 10px rgba(255, 100, 0, 1),
    0 0 24px rgba(255, 120, 0, 0.65),
    0 0 2px rgba(255, 200, 80, 0.95) !important;
}

.drive-speed-analog {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: auto;
  overflow: hidden;
}

.drive-speed-analog.hidden {
  display: none !important;
}

.drive-speed-analog canvas {
  width: auto;
  height: auto;
  max-width: 96%;
  max-height: 100%;
  aspect-ratio: auto;
}

.drive-sheet-summary {
  margin-top: 1%;
  padding-top: 1.5%;
  border-top: 1px solid rgba(16, 185, 129, 0.22);
  flex-shrink: 0;
  min-width: 0;
}

.drive-sheet-body.drive-mode-analog .drive-sheet-summary {
  margin-top: 1.2%;
}

.drive-sheet-summary-text {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: rgba(167, 243, 208, 0.9);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-sheet-summary-text.is-clear {
  color: rgba(110, 231, 183, 0.72);
}

.drive-sheet-summary-text.is-alert {
  color: #fde68a;
}

/* 上端取っ手分だけHUDを少し下げる */
.status-hud,
.status-hud-right {
  top: calc(0.75rem + 1.45rem) !important;
}

body.map-layout .map-chrome-left {
  top: 16.2rem;
}

body.map-layout .map-chrome-right {
  top: calc(3.2rem + 1.45rem);
}

body.map-layout .drive-sheet {
  left: 0;
  right: 0;
  top: 0;
  bottom: auto;
}

.map-gsi-credit {
  display: none;
  position: absolute;
  right: 0.7rem;
  bottom: 0.55rem;
  left: auto;
  z-index: 36;
  font-size: 10px;
  line-height: 1.2;
  color: #06321c;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-shadow:
    0 0 3px rgba(255, 255, 255, 0.95),
    0 0 6px rgba(255, 255, 255, 0.9),
    0 1px 2px rgba(255, 255, 255, 1);
  background: transparent;
  border: none;
  padding: 0;
  pointer-events: auto;
}

body.map-layout .map-gsi-credit {
  display: block;
}

body.map-layout:has(#mapView.map-theme-night) .map-gsi-credit {
  color: #d2ffe6;
  text-shadow:
    0 0 4px rgba(0, 0, 0, 0.95),
    0 1px 3px rgba(0, 0, 0, 0.9);
}

@keyframes alert-glow {
  0%,
  100% {
    border-color: rgba(255, 51, 51, 0.9);
    border-width: var(--alert-border-w, 5px);
    box-shadow:
      inset 0 0 calc(var(--alert-border-w, 5px) * 12) rgba(255, 51, 51, 0.45),
      inset 0 0 calc(var(--alert-border-w, 5px) * 24) rgba(255, 51, 51, 0.25);
  }
  50% {
    border-color: rgba(255, 51, 51, 0.25);
    border-width: var(--alert-border-w, 5px);
    box-shadow:
      inset 0 0 calc(var(--alert-border-w, 5px) * 2) rgba(255, 51, 51, 0.08),
      inset 0 0 calc(var(--alert-border-w, 5px) * 8) rgba(255, 51, 51, 0.05);
  }
}

@keyframes alert-glow-cyan {
  0%,
  100% {
    border-color: rgba(0, 210, 255, 0.95);
    border-width: var(--alert-border-w, 5px);
    box-shadow:
      inset 0 0 calc(var(--alert-border-w, 5px) * 12) rgba(0, 210, 255, 0.45),
      inset 0 0 calc(var(--alert-border-w, 5px) * 24) rgba(0, 210, 255, 0.28);
  }
  50% {
    border-color: rgba(0, 210, 255, 0.25);
    border-width: var(--alert-border-w, 5px);
    box-shadow:
      inset 0 0 calc(var(--alert-border-w, 5px) * 2) rgba(0, 210, 255, 0.1),
      inset 0 0 calc(var(--alert-border-w, 5px) * 8) rgba(0, 210, 255, 0.06);
  }
}

.alert-active {
  animation: alert-glow 0.8s infinite;
}

.alert-active-cyan {
  animation: alert-glow-cyan 0.8s infinite;
}

.alert-active.alert-glow-weak,
.alert-active-cyan.alert-glow-weak {
  --alert-border-w: 2px;
  animation-duration: 0.9s;
  opacity: 1;
  filter: none;
}

.alert-active.alert-glow-mid,
.alert-active-cyan.alert-glow-mid {
  --alert-border-w: 5px;
  animation-duration: 0.8s;
  opacity: 1;
  filter: none;
}

.alert-active.alert-glow-strong,
.alert-active-cyan.alert-glow-strong {
  --alert-border-w: 11px;
  animation-duration: 0.7s;
  opacity: 1;
  filter: none;
}

.maplibregl-map {
  font-family: "Share Tech Mono", monospace !important;
}

#mapView {
  width: 100%;
  height: 100%;
}

#mapView.map-theme-day .maplibregl-canvas {
  filter: none;
}

#mapView.map-theme-night .maplibregl-canvas {
  filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(1.05) saturate(0.7);
}

#mapView .maplibregl-canvas-container.maplibregl-interactive,
#mapView .maplibregl-ctrl-logo {
  outline: none;
}

#mapView .maplibregl-popup {
  z-index: 30;
  max-width: 280px;
}

#mapView .maplibregl-popup-content {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fffef8;
  color: #111;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  font-size: 12px;
  line-height: 1.35;
  pointer-events: auto;
}

#mapView .maplibregl-popup-close-button {
  font-size: 18px;
  color: #444;
  padding: 2px 8px;
}

#mapView .maplibregl-popup-tip {
  border-top-color: #fffef8;
}

#mapView .custom-user-icon {
  background: transparent !important;
  border: none !important;
}

#mapView .user-car-marker {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#mapView .user-car-triangle {
  width: 100%;
  height: 100%;
  clip-path: polygon(50% 0%, 8% 100%, 92% 100%);
  border: none;
  transform-origin: 50% 62%;
}

#mapView .user-car-red .user-car-triangle {
  background: #ff2a2a;
  box-shadow: 0 0 10px rgba(255, 42, 42, 0.95);
  filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 6px #ff2a2a);
}

#mapView .user-car-blue .user-car-triangle {
  background: #2a7dff;
  box-shadow: 0 0 10px rgba(42, 125, 255, 0.95);
  filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 6px #2a7dff);
}

#mapView .user-car-yellow .user-car-triangle {
  background: #f5c400;
  box-shadow: 0 0 10px rgba(245, 196, 0, 0.95);
  filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 6px #f5c400);
}

#mapView .user-car-green .user-car-triangle {
  background: #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.95);
  filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 6px #22c55e);
}

#mapView .user-car-pink .user-car-triangle {
  background: #ff4db8;
  box-shadow: 0 0 10px rgba(255, 77, 184, 0.95);
  filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 6px #ff4db8);
}

#mapView .user-car-sm {
  width: 18px;
  height: 18px;
}

#mapView .user-car-md {
  width: 28px;
  height: 28px;
}

#mapView .user-car-lg {
  width: 40px;
  height: 40px;
}

#mapView .pin-marker-layer .pin-cluster-marker {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  z-index: 4;
}

#mapView .pin-cluster-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  background: radial-gradient(
    circle at 35% 30%,
    rgba(255, 90, 90, 0.98) 0%,
    rgba(200, 30, 30, 0.96) 55%,
    rgba(150, 15, 15, 0.95) 100%
  );
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow:
    0 0 0 1px rgba(120, 20, 20, 0.35),
    0 2px 10px rgba(0, 0, 0, 0.35);
}

#mapView .pin-marker-layer .pin-trace-marker {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none !important;
  z-index: 1;
}

#mapView .pin-trace-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(230, 55, 55, 0.5) 0%,
    rgba(210, 45, 45, 0.28) 48%,
    rgba(180, 35, 35, 0.1) 70%,
    transparent 80%
  );
  box-shadow:
    inset 0 0 0 2.5px rgba(220, 50, 50, 0.7),
    0 0 16px rgba(200, 40, 40, 0.35);
}

#mapView .pin-marker-layer .pin-watch-marker {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none !important;
  z-index: 1;
}

#mapView .pin-marker-layer .pin-watch-marker.is-own {
  pointer-events: auto !important;
  cursor: pointer;
}

#mapView .pin-watch-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(255, 77, 184, 0.5) 0%,
    rgba(230, 50, 160, 0.28) 48%,
    rgba(200, 40, 140, 0.1) 70%,
    transparent 80%
  );
  box-shadow:
    inset 0 0 0 2.5px rgba(255, 90, 190, 0.7),
    0 0 16px rgba(255, 77, 184, 0.35);
}

.pin-place-watch-circle {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  box-sizing: border-box;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(255, 77, 184, 0.5) 0%,
    rgba(230, 50, 160, 0.28) 48%,
    rgba(200, 40, 140, 0.1) 70%,
    transparent 80%
  );
  box-shadow:
    inset 0 0 0 2.5px rgba(255, 90, 190, 0.7),
    0 0 16px rgba(255, 77, 184, 0.35);
}

.pin-place-overlay.is-dragging .pin-place-watch-circle {
  cursor: grabbing;
}

#mapView .custom-target-icon {
  pointer-events: auto;
  position: relative;
  z-index: 2;
}

#mapView .target-marker-root {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#mapView .target-dir-fan,
.target-dir-fan {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 104px;
  height: 104px;
  transform: translate(-50%, -50%) rotate(var(--fan-screen-rot, var(--fan-rot, 0deg)));
  border-radius: 50%;
  background: conic-gradient(
    from calc(0deg - (var(--fan-spread, 90deg) / 2)),
    rgba(255, 64, 64, 0.5) 0deg,
    rgba(255, 120, 80, 0.42) var(--fan-spread, 90deg),
    transparent var(--fan-spread, 90deg)
  );
  box-shadow: inset 0 0 0 1px rgba(255, 180, 140, 0.35);
  pointer-events: none;
  z-index: 0;
}

#mapView .pin-marker-layer .target-dir-fan {
  width: 104px;
  height: 104px;
}

#mapView .target-dot {
  box-sizing: border-box;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

#mapView .target-glyph {
  position: relative;
  z-index: 1;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  text-shadow:
    0 0 2px rgba(0, 0, 0, 0.95),
    0 1px 2px rgba(0, 0, 0, 0.85),
    0 0 6px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  font-family: "Share Tech Mono", "Yu Gothic UI", sans-serif;
}

#mapView .target-dot.shape-circle {
  border-radius: 50%;
}

#mapView .target-dot.shape-square {
  border-radius: 4px;
}

#mapView .target-dot.shape-diamond {
  border-radius: 3px;
  transform: rotate(45deg);
  transform-origin: center center;
}

#mapView .target-dot.shape-diamond .target-glyph {
  transform: rotate(-45deg);
}

#mapView .target-dot.shape-triangle {
  border-radius: 0;
  clip-path: polygon(50% 4%, 4% 96%, 96% 96%);
  border: none !important;
  box-shadow: 0 0 14px rgba(192, 132, 252, 0.85);
  padding-top: 6px;
}

#mapView .target-dot.shape-octagon {
  border-radius: 0;
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
}

#mapView .target-dot.shape-pill {
  border-radius: 999px;
}

#mapView .target-dot.shape-hexagon {
  border-radius: 0;
  clip-path: polygon(25% 4%, 75% 4%, 100% 50%, 75% 96%, 25% 96%, 0% 50%);
}

#mapView .target-dot.shape-pentagon {
  border-radius: 0;
  clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
}

#mapView .draft-target-dot {
  border-radius: 50% !important;
  clip-path: none !important;
  width: 100% !important;
  margin-left: 0 !important;
  background: #ffb020 !important;
  box-shadow:
    0 0 0 3px rgba(255, 176, 32, 0.4),
    0 0 16px rgba(255, 176, 32, 0.95);
  animation: draft-marker-blink 0.85s ease-in-out infinite;
  transform-origin: center center;
}

#mapView .draft-target-dot .target-glyph {
  color: #1a1200;
  font-size: 15px;
  text-shadow: none;
}

@keyframes draft-marker-blink {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
    box-shadow:
      0 0 0 3px rgba(255, 176, 32, 0.4),
      0 0 16px rgba(255, 176, 32, 0.95);
  }
  50% {
    opacity: 0.45;
    transform: scale(1.22);
    box-shadow:
      0 0 0 6px rgba(255, 176, 32, 0.25),
      0 0 28px rgba(255, 224, 153, 0.9);
  }
}

#mapView .virtual-target-dot {
  border-radius: 50% !important;
  clip-path: none !important;
  width: 100% !important;
  margin-left: 0 !important;
  box-shadow:
    0 0 0 3px rgba(0, 210, 255, 0.4),
    0 0 16px rgba(0, 210, 255, 0.95);
}

#mapView .custom-target-icon.has-recheck {
  position: relative;
}

#mapView .recheck-target-dot {
  box-shadow:
    0 0 0 2px rgba(255, 176, 32, 0.55),
    0 0 14px rgba(255, 176, 32, 0.75) !important;
  animation: recheck-marker-pulse 1.4s ease-in-out infinite;
  transform-origin: center center;
}

#mapView .recheck-badge {
  position: absolute;
  top: -0.35rem;
  right: -0.4rem;
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  background: #ffb020;
  border: 1.5px solid #fff3c4;
  color: #3a2200;
  font-size: 10px;
  font-weight: 900;
  line-height: 1rem;
  text-align: center;
  box-shadow: 0 0 8px rgba(255, 176, 32, 0.8);
  pointer-events: none;
  z-index: 2;
}

#mapView .highway-badge,
.highway-badge {
  position: absolute;
  bottom: -6px;
  left: -6px;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.14rem;
  border-radius: 0.28rem;
  background: #1d4ed8;
  border: 1.5px solid #bfdbfe;
  color: #eff6ff;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.15rem;
  text-align: center;
  letter-spacing: -0.02em;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.85);
  pointer-events: none;
  z-index: 2;
}

#mapView .highway-target-dot {
  box-shadow:
    0 0 0 2px rgba(96, 165, 250, 0.55),
    0 0 14px rgba(37, 99, 235, 0.65),
    0 0 12px rgba(0, 0, 0, 0.35);
}

#mapView .custom-target-icon.has-road-ring .target-dot {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.35),
    0 0 12px rgba(0, 0, 0, 0.4);
}

.pin-place-temp-root .highway-badge {
  bottom: -5px;
  left: -5px;
}

@keyframes recheck-marker-pulse {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.18);
  }
}

.crt-container.map-day-mode .crt-overlay {
  opacity: 0.25;
}

.crt-container.map-day-mode .crt-vignette {
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.25);
  border-color: rgba(0, 120, 80, 0.25);
}
