:root {
  --case: #4a5a32;
  --case-dark: #2f3a20;
  --case-light: #6b7d48;
  --phosphor: #39ff14;
  --phosphor-dim: #1a8f0a;
  --phosphor-glow: rgba(57,255,20,.45);
  --amber: #ffb000;
  --amber-dim: #c47800;
  --crt-bg: #031402;
  --ink: #0a1008;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  min-height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #12160e;
  color: var(--amber);
  font-family: "Press Start 2P", ui-monospace, monospace;
  image-rendering: pixelated;
  display: grid;
  place-items: center;
  padding: 10px 12px;
}
.page {
  width: min(920px, 100%);
  max-height: calc(100dvh - 20px);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.home-link {
  display: inline-block;
  font-size: 7px;
  color: #8a9a60;
  text-decoration: none;
  margin-bottom: 10px;
  letter-spacing: .04em;
}
.home-link:hover { color: var(--amber); }

.device {
  width: 100%;
  flex: 1;
  min-height: 0;
  max-height: 100%;
  background: linear-gradient(145deg, var(--case-light), var(--case) 40%, var(--case-dark));
  border: 6px solid #1a2010;
  border-radius: 28px 28px 36px 36px;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,.15),
    inset 0 -6px 0 rgba(0,0,0,.25),
    0 12px 0 #0c1008;
  padding: 16px 16px 12px;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  grid-template-rows: minmax(0, 1fr) auto auto auto;
  gap: 12px;
  touch-action: none;
  overflow: hidden;
}
.screen-col {
  min-width: 0;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.led {
  width: 10px; height: 10px; border-radius: 2px;
  background: var(--amber-dim);
  box-shadow: 0 0 4px var(--amber-dim);
  margin: 0 auto 10px;
  transition: background .2s, box-shadow .2s;
}
.led.on {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}
.led.err { background: #a33; box-shadow: 0 0 8px #a33; }

.screen-bezel {
  background: #0c1208;
  border: 6px solid #1a2010;
  border-radius: 50%;
  aspect-ratio: 1;
  padding: 14px;
  box-shadow: inset 0 0 0 4px #243018, inset 0 0 40px #000;
  width: min(100%, 100%);
  max-width: 100%;
  max-height: 100%;
  flex: 0 1 auto;
}
.crt {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--crt-bg);
  position: relative; overflow: hidden;
  box-shadow: inset 0 0 30px #000, 0 0 24px var(--phosphor-glow);
  touch-action: none;
}
.crt::after {
  content: ""; position: absolute; inset: 0; z-index: 7;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 2px,
    rgba(0,0,0,.18) 2px 3px
  );
  pointer-events: none; border-radius: 50%;
}
.map-underlay {
  position: absolute; inset: 0; z-index: 0;
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
}
.map-underlay .leaflet-container {
  width: 100%; height: 100%;
  background: #031402;
  border-radius: 50%;
  font: inherit;
}
.map-underlay .leaflet-tile-pane {
  /* 高德浅色路网 → 轻 CRT 绿洗；少层 filter 减手机合成开销 */
  filter: brightness(0.55) contrast(1.1) sepia(0.35) hue-rotate(70deg) saturate(1.2);
}
.map-underlay .leaflet-control-attribution {
  background: rgba(3,20,2,.55) !important;
  color: var(--amber-dim) !important;
  font-family: "Press Start 2P", ui-monospace, monospace !important;
  font-size: 5px !important;
  line-height: 1.4 !important;
  max-width: 46%;
  margin: 0 !important;
  padding: 2px 4px !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  right: 10%;
  bottom: 18%;
  left: auto !important;
}
.map-underlay .leaflet-control-attribution a {
  color: var(--amber-dim) !important;
  text-decoration: none !important;
}
.map-fade {
  position: absolute; inset: 0; z-index: 1;
  pointer-events: none; border-radius: 50%;
  background: radial-gradient(circle at 50% 45%,
    rgba(10,31,8,0.18) 0%,
    rgba(3,20,2,0.42) 48%,
    rgba(3,20,2,0.82) 100%);
}
.rings, .cross, .sweep, .blips, .trail-layer { position: absolute; inset: 0; }
.rings { z-index: 2; }
.cross { z-index: 3; }
.sweep { z-index: 4; }
.trail-layer { z-index: 5; width: 100%; height: 100%; pointer-events: none; }
.blips { z-index: 6; }

.rings::before, .rings::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  border: 2px solid var(--phosphor-dim); border-radius: 50%;
  transform: translate(-50%,-50%);
}
.rings::before { width: 46%; height: 46%; opacity: .85; }
.rings::after { width: 78%; height: 78%; opacity: .55; }
.ring-outer {
  position: absolute; left: 50%; top: 50%;
  width: 96%; height: 96%;
  border: 2px solid var(--phosphor-dim);
  border-radius: 50%; transform: translate(-50%,-50%); opacity: .35;
}
.cross::before, .cross::after {
  content: ""; position: absolute; background: var(--phosphor-dim); opacity: .5;
}
.cross::before { left: 50%; top: 8%; bottom: 8%; width: 2px; transform: translateX(-50%); }
.cross::after { top: 50%; left: 8%; right: 8%; height: 2px; transform: translateY(-50%); }
.sweep {
  background: conic-gradient(from 0deg, transparent 0 78%, rgba(57,255,20,.0) 78%, rgba(57,255,20,.35) 92%, transparent 100%);
  animation: spin 4s linear infinite;
  opacity: .9;
  pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.blip {
  position: absolute; width: 8px; height: 8px;
  margin-left: -4px; margin-top: -4px;
  background: var(--phosphor); border-radius: 1px;
  box-shadow: 0 0 8px var(--phosphor), 0 0 2px #fff;
  cursor: pointer; z-index: 6;
  transform: translate(0,0);
}
.blip.selected {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  z-index: 8;
}
.rim-hint {
  position: absolute; left: 50%; bottom: 10%;
  transform: translateX(-50%);
  font-size: 6px; color: var(--phosphor-dim);
  opacity: .7; z-index: 7; pointer-events: none;
  white-space: nowrap; letter-spacing: .02em;
}
.range-badge {
  position: absolute; top: 12%; left: 50%;
  transform: translateX(-50%);
  font-size: 8px; color: var(--phosphor);
  text-shadow: 0 0 6px var(--phosphor-glow);
  z-index: 7; pointer-events: none;
}
.empty-ping {
  position: absolute; inset: 0; z-index: 9;
  display: grid; place-items: center;
  font-size: 8px; color: var(--amber);
  text-align: center; line-height: 1.8;
  text-shadow: 0 0 8px rgba(255,176,0,.4);
  pointer-events: none;
  background: radial-gradient(circle, rgba(3,20,2,.55) 0%, transparent 70%);
}
.empty-ping[hidden] { display: none; }

.panel {
  background: #12180c;
  border: 4px solid #1a2010;
  box-shadow: inset 0 0 0 2px #2a3418;
  padding: 12px 12px 10px;
  display: flex; flex-direction: column; gap: 8px;
  min-width: 0;
  min-height: 0;
  height: var(--disc-h, 100%);
  max-height: var(--disc-h, 100%);
  overflow: hidden;
}
.title {
  font-size: 9px; line-height: 1.55; color: var(--phosphor);
  text-shadow: 0 0 6px var(--phosphor-glow);
  flex-shrink: 0;
  word-break: break-word;
}
.meta { font-size: 7px; color: var(--amber-dim); line-height: 1.8; flex-shrink: 0; }
.list {
  list-style: none;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  /* ~60–70% of disc: panel height synced to bezel via JS; title/detail fixed */
  max-height: min(100%, calc(var(--disc-h, 360px) * 0.68));
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: var(--phosphor-dim) #0c1208;
  touch-action: pan-y;
}
.list li {
  display: grid; grid-template-columns: 1fr auto;
  gap: 8px; padding: 8px 4px;
  border-bottom: 2px solid #1e2812;
  font-size: 8px; line-height: 1.5; cursor: pointer;
}
.list li:hover, .list li.on { background: #1a2810; color: var(--phosphor); }
.list .sub { display: block; color: var(--amber-dim); font-size: 7px; margin-top: 4px; }
.list .empty {
  display: block; cursor: default; color: var(--amber-dim);
  border-bottom: 0; padding: 12px 4px; line-height: 1.8;
}
.detail {
  font-size: 7px; color: var(--amber-dim); line-height: 1.7;
  border-top: 2px solid #1e2812; padding-top: 8px; min-height: 48px;
  max-height: 72px; overflow: auto; flex-shrink: 0;
}
.detail strong { display: block; color: var(--phosphor); font-size: 9px; margin-bottom: 4px; font-weight: 400; }

.controls {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  justify-content: space-between; padding-top: 4px;
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  font-family: inherit; font-size: 8px;
  background: linear-gradient(180deg, #ffc94a, var(--amber) 45%, var(--amber-dim));
  color: var(--ink); border: 3px solid #1a2010;
  border-radius: 999px; padding: 10px 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 3px 0 #1a2010;
  cursor: pointer;
}
.btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 0 #1a2010; }
.btn.ghost {
  background: #2a3418; color: var(--amber);
  box-shadow: inset 0 0 0 2px #3a4820, 0 3px 0 #1a2010;
}
.btn.ghost.on {
  background: linear-gradient(180deg, #ffc94a, var(--amber) 45%, var(--amber-dim));
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 3px 0 #1a2010;
}
.btn.warn:not(.on) { color: var(--amber-dim); }
.dpad { width: 104px; height: 104px; position: relative; flex-shrink: 0; }
.dpad button {
  position: absolute; width: 30px; height: 30px;
  font-family: inherit; font-size: 12px; line-height: 1;
  color: var(--ink);
  background: linear-gradient(180deg, #ffc94a, var(--amber) 45%, var(--amber-dim));
  border: 3px solid #1a2010; border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 3px 0 #1a2010;
  padding: 0; cursor: pointer;
  display: grid; place-items: center;
  appearance: none; -webkit-appearance: none;
}
.dpad .u { left: 37px; top: 4px; }
.dpad .d { left: 37px; bottom: 4px; }
.dpad .l { left: 4px; top: 37px; }
.dpad .r { right: 4px; top: 37px; }
.dpad button:active {
  transform: translateY(2px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 0 #1a2010;
}

.custom-row {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  font-size: 7px; color: var(--amber-dim);
}
.custom-row[hidden] { display: none; }
.custom-row input {
  width: 88px; font-family: inherit; font-size: 8px;
  background: #0c1208; color: var(--phosphor);
  border: 2px solid #1a2010; padding: 8px 6px;
}
.hint {
  grid-column: 1 / -1;
  font-size: 7px; color: #8a9a60; line-height: 1.8; padding-top: 4px;
}

@media (max-width: 720px) {
  body { overflow: auto; height: auto; min-height: 100dvh; }
  .page { max-height: none; }
  .device {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
    max-height: none;
    overflow: visible;
  }
  /* mobile visual order: radar → controls → custom → panel(list) → hint */
  .screen-col { order: 1; }
  .controls { order: 2; grid-column: 1; }
  .custom-row { order: 3; grid-column: 1; }
  .panel { order: 4; }
  .hint { order: 5; grid-column: 1; }
  .screen-bezel { max-width: min(320px, 72vw); margin: 0 auto; }
  .panel {
    height: auto;
    max-height: none;
    min-height: 0;
  }
  .list {
    max-height: min(28vh, calc(var(--disc-h, 280px) * 0.55));
    overscroll-behavior: contain;
  }
  .dpad { width: 84px; height: 84px; }
  .dpad button { width: 24px; height: 24px; font-size: 10px; border-width: 2px; border-radius: 5px; }
  .dpad .u { left: 30px; top: 3px; }
  .dpad .d { left: 30px; bottom: 3px; }
  .dpad .l { left: 3px; top: 30px; }
  .dpad .r { right: 3px; top: 30px; }
}

