{
  "id": 35,
  "slug": "shortwave-phosphor-tuner",
  "name": "Shortwave Phosphor Tuner",
  "kind": "style",
  "family": "Y2K & Skeuomorphic",
  "sourceSite": {
    "name": "Radio Garden",
    "url": "https://radio.garden/",
    "verifiedStatus": 200
  },
  "tagline": "Deep phosphor-black CRT radar reticle, emerald scanlines, analog frequency dial, and live world-station signal lock.",
  "whyUnique": "Merges shortwave radio nostalgia with precision radar telemetry, letting visitors tune frequencies across cities with animated reticle lock and phosphor waveforms.",
  "theme": "dark",
  "mobileStrength": "native-first",
  "tags": [
    "crt-phosphor",
    "shortwave-radio",
    "radar-tuner",
    "analog-dial",
    "emerald-terminal"
  ],
  "bestFor": [
    "Global audio & radio explorers",
    "Telemetry & satellite dashboards",
    "Ambient soundscape apps",
    "Retro sci-fi interfaces"
  ],
  "palette": [
    {
      "role": "canvas",
      "hex": "#050A07",
      "name": "CRT Tube Black"
    },
    {
      "role": "surface",
      "hex": "#0B1610",
      "name": "Phosphor Housing"
    },
    {
      "role": "ink",
      "hex": "#D9FFE6",
      "name": "Bright Phosphor"
    },
    {
      "role": "accent",
      "hex": "#2BFF88",
      "name": "Signal Lock Green"
    },
    {
      "role": "muted",
      "hex": "#4E8264",
      "name": "Reticle Dim Green"
    }
  ],
  "typography": {
    "display": "Share Tech Mono",
    "body": "JetBrains Mono",
    "mono": "Share Tech Mono",
    "googleFontsUrl": "https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=JetBrains+Mono:wght@400;600&display=swap",
    "scaleNotes": "Monospaced frequency readouts (kHz/MHz) in glowing phosphor green with tabular latitude/longitude coordinates and signal dB meters."
  },
  "layoutNotes": "Centered circular azimuth radar reticle with subtle CRT scanline overlay, flanked by a precision frequency tuning slider, live signal-strength waveform, and city station presets.",
  "interactionNotes": "Interactive frequency slider and global station presets (Reykjavik, Tokyo, Buenos Aires, Cairo, Zurich) that sweep the radar coordinates, animate signal lock strength, and modulate the live phosphor waveform.",
  "mobileNotes": "Stacks the circular radar scope above a full-width thumb-friendly tuning slider and >=44px station preset buttons on 390px viewports.",
  "agentGuardrails": {
    "do": [
      "Layer subtle low-opacity horizontal CRT scanlines over deep green-black phosphor surfaces.",
      "Use crisp vector concentric rings, crosshairs, and coordinate telemetry.",
      "Provide immediate visual signal-lock feedback as the user tunes across frequencies."
    ],
    "dont": [
      "Never make scanlines or glow effects so heavy that frequency labels lose readability.",
      "Avoid generic purple/blue sci-fi tropes; keep the palette authentically emerald phosphor."
    ]
  },
  "demoFile": "demos/shortwave-phosphor-tuner.html",
  "thumbDesktop": "thumbs/shortwave-phosphor-tuner-desktop.webp",
  "thumbMobile": "thumbs/shortwave-phosphor-tuner-mobile.webp",
  "urls": {
    "page": "https://templates.michaelpitts.net/t/shortwave-phosphor-tuner",
    "markdown": "https://templates.michaelpitts.net/t/shortwave-phosphor-tuner.md",
    "api": "https://templates.michaelpitts.net/api/templates/shortwave-phosphor-tuner",
    "demo": "https://templates.michaelpitts.net/demos/shortwave-phosphor-tuner.html",
    "thumbDesktop": "https://templates.michaelpitts.net/thumbs/shortwave-phosphor-tuner-desktop.webp",
    "thumbMobile": "https://templates.michaelpitts.net/thumbs/shortwave-phosphor-tuner-mobile.webp"
  },
  "agentPrompt": "Design & build using template #035 \"Shortwave Phosphor Tuner\" (style / Y2K & Skeuomorphic, dark theme).\nFull AI blueprint & standalone starter code: https://templates.michaelpitts.net/t/shortwave-phosphor-tuner.md\nLive demo: https://templates.michaelpitts.net/demos/shortwave-phosphor-tuner.html\nReal-world inspiration: Radio Garden (https://radio.garden/)\n\nCore aesthetic: Merges shortwave radio nostalgia with precision radar telemetry, letting visitors tune frequencies across cities with animated reticle lock and phosphor waveforms.\nPalette: canvas: #050A07 (CRT Tube Black), surface: #0B1610 (Phosphor Housing), ink: #D9FFE6 (Bright Phosphor), accent: #2BFF88 (Signal Lock Green), muted: #4E8264 (Reticle Dim Green)\nTypography: Display=\"Share Tech Mono\", Body=\"JetBrains Mono\", Mono=\"Share Tech Mono\"\nLayout: Centered circular azimuth radar reticle with subtle CRT scanline overlay, flanked by a precision frequency tuning slider, live signal-strength waveform, and city station presets.\nInteractions: Interactive frequency slider and global station presets (Reykjavik, Tokyo, Buenos Aires, Cairo, Zurich) that sweep the radar coordinates, animate signal lock strength, and modulate the live phosphor waveform.\nMobile: Stacks the circular radar scope above a full-width thumb-friendly tuning slider and >=44px station preset buttons on 390px viewports.\n\nGuardrails:\n- DO: Layer subtle low-opacity horizontal CRT scanlines over deep green-black phosphor surfaces.\n- DO: Use crisp vector concentric rings, crosshairs, and coordinate telemetry.\n- DO: Provide immediate visual signal-lock feedback as the user tunes across frequencies.\n- DON'T: Never make scanlines or glow effects so heavy that frequency labels lose readability.\n- DON'T: Avoid generic purple/blue sci-fi tropes; keep the palette authentically emerald phosphor.",
  "sourceCode": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n  <title>SW-8800 — Shortwave Phosphor Radar Tuner</title>\n  <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n  <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n  <link href=\"https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&family=Orbitron:wght@500;700&display=swap\" rel=\"stylesheet\">\n  <style>\n    :root {\n      --bg: #040806;\n      --panel: #08120c;\n      --panel-hi: #0d1d14;\n      --phosphor: #46ff96;\n      --phosphor-dim: #1b663d;\n      --amber: #ffba49;\n      --alert: #ff5d52;\n      --border: #1e4d33;\n      --mono: 'JetBrains Mono', 'Courier New', monospace;\n      --display: 'Orbitron', 'Courier New', monospace;\n    }\n\n    * {\n      box-sizing: border-box;\n      margin: 0;\n      padding: 0;\n    }\n\n    html, body {\n      min-height: 100%;\n      width: 100%;\n      overflow-x: hidden;\n      background: radial-gradient(circle at 50% 15%, #0c1d13 0%, #040806 72%);\n      color: var(--phosphor);\n      font-family: var(--mono);\n    }\n\n    /* Subtle CRT scanline overlay */\n    body::after {\n      content: \"\";\n      position: fixed;\n      inset: 0;\n      pointer-events: none;\n      z-index: 900;\n      background: repeating-linear-gradient(\n        to bottom,\n        rgba(0, 0, 0, 0) 0px,\n        rgba(0, 0, 0, 0) 2px,\n        rgba(0, 0, 0, 0.22) 3px,\n        rgba(0, 0, 0, 0.22) 4px\n      );\n    }\n\n    .shell {\n      width: 100%;\n      max-width: 1080px;\n      margin: 0 auto;\n      padding: 14px 10px 36px;\n      display: flex;\n      flex-direction: column;\n      gap: 14px;\n    }\n\n    /* Top Telemetry Header */\n    .topbar {\n      display: flex;\n      flex-wrap: wrap;\n      align-items: center;\n      justify-content: space-between;\n      gap: 8px;\n      padding: 10px 12px;\n      background: var(--panel);\n      border: 1.5px solid var(--border);\n      box-shadow: 0 0 22px rgba(70, 255, 150, 0.08);\n    }\n\n    .brand {\n      display: flex;\n      align-items: center;\n      gap: 10px;\n    }\n\n    .pulse-led {\n      width: 10px;\n      height: 10px;\n      border-radius: 50%;\n      background: var(--phosphor);\n      box-shadow: 0 0 10px var(--phosphor);\n      animation: blink 2s ease-in-out infinite;\n    }\n\n    @keyframes blink {\n      0%, 100% { opacity: 1; }\n      50% { opacity: 0.4; }\n    }\n\n    .brand h1 {\n      font-family: var(--display);\n      font-size: 14px;\n      letter-spacing: 0.12em;\n      text-shadow: 0 0 10px rgba(70, 255, 150, 0.45);\n    }\n\n    .utc-readout {\n      font-size: 12px;\n      color: var(--amber);\n      letter-spacing: 0.08em;\n    }\n\n    /* Main Grid */\n    .console-grid {\n      display: grid;\n      grid-template-columns: 1fr;\n      gap: 14px;\n    }\n\n    .crt-card {\n      background: var(--panel);\n      border: 1.5px solid var(--border);\n      padding: 12px;\n      display: flex;\n      flex-direction: column;\n      gap: 12px;\n      box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.85), 0 0 18px rgba(70, 255, 150, 0.06);\n    }\n\n    .card-head {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      gap: 8px;\n      font-size: 11px;\n      letter-spacing: 0.12em;\n      text-transform: uppercase;\n      color: #87cfa6;\n      border-bottom: 1px solid var(--border);\n      padding-bottom: 8px;\n    }\n\n    /* Radar Reticle */\n    .radar-stage {\n      position: relative;\n      width: 100%;\n      max-width: 380px;\n      margin: 0 auto;\n      aspect-ratio: 1 / 1;\n    }\n\n    #radar-canvas {\n      display: block;\n      width: 100%;\n      height: 100%;\n      border-radius: 50%;\n      border: 2px solid var(--border);\n      background: radial-gradient(circle, #0b1c12 0%, #040a06 78%);\n      box-shadow: 0 0 28px rgba(70, 255, 150, 0.14), inset 0 0 24px rgba(0, 0, 0, 0.9);\n      cursor: crosshair;\n      touch-action: manipulation;\n    }\n\n    .coord-strip {\n      display: grid;\n      grid-template-columns: repeat(3, 1fr);\n      gap: 6px;\n      text-align: center;\n    }\n\n    .coord-cell {\n      padding: 7px 6px;\n      background: #050c08;\n      border: 1px solid var(--border);\n    }\n\n    .coord-cell span {\n      display: block;\n      font-size: 10px;\n      color: #74b28f;\n      margin-bottom: 2px;\n    }\n\n    .coord-cell strong {\n      font-size: 12px;\n      color: var(--phosphor);\n    }\n\n    /* Frequency Display */\n    .freq-box {\n      background: #040906;\n      border: 1.5px solid var(--border);\n      padding: 12px;\n      display: flex;\n      flex-direction: column;\n      gap: 8px;\n    }\n\n    .freq-top {\n      display: flex;\n      justify-content: space-between;\n      align-items: baseline;\n      gap: 8px;\n      flex-wrap: wrap;\n    }\n\n    .freq-digits {\n      font-family: var(--display);\n      font-size: 32px;\n      letter-spacing: 0.06em;\n      color: var(--phosphor);\n      text-shadow: 0 0 14px rgba(70, 255, 150, 0.65);\n      line-height: 1.1;\n    }\n\n    .freq-unit {\n      font-size: 14px;\n      color: var(--amber);\n      margin-left: 4px;\n    }\n\n    .lock-badge {\n      padding: 4px 8px;\n      border: 1px solid var(--phosphor);\n      font-size: 11px;\n      letter-spacing: 0.1em;\n      color: var(--phosphor);\n      background: rgba(70, 255, 150, 0.1);\n    }\n\n    .lock-badge.searching {\n      border-color: var(--amber);\n      color: var(--amber);\n      background: rgba(255, 186, 73, 0.08);\n    }\n\n    .station-meta {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      gap: 8px;\n      flex-wrap: wrap;\n      font-size: 12px;\n      color: #b7f5d2;\n    }\n\n    /* Tuning Controls */\n    .tuner-slider-wrap {\n      display: flex;\n      flex-direction: column;\n      gap: 8px;\n    }\n\n    .freq-range {\n      width: 100%;\n      -webkit-appearance: none;\n      appearance: none;\n      height: 14px;\n      background: #06120b;\n      border: 1px solid var(--border);\n      border-radius: 2px;\n      outline: none;\n      cursor: pointer;\n    }\n\n    .freq-range::-webkit-slider-thumb {\n      -webkit-appearance: none;\n      appearance: none;\n      width: 24px;\n      height: 28px;\n      background: var(--phosphor);\n      border: 2px solid #040806;\n      box-shadow: 0 0 12px rgba(70, 255, 150, 0.7);\n      cursor: pointer;\n    }\n\n    .scale-ticks {\n      display: flex;\n      justify-content: space-between;\n      font-size: 10px;\n      color: #6ca886;\n    }\n\n    .fine-controls {\n      display: grid;\n      grid-template-columns: repeat(4, 1fr);\n      gap: 6px;\n    }\n\n    .crt-btn {\n      min-height: 44px;\n      padding: 8px 6px;\n      background: var(--panel-hi);\n      border: 1.5px solid var(--border);\n      color: var(--phosphor);\n      font-family: var(--mono);\n      font-size: 12px;\n      font-weight: 600;\n      cursor: pointer;\n      transition: background 0.12s ease, border-color 0.12s ease;\n    }\n\n    .crt-btn:hover, .crt-btn:focus-visible {\n      border-color: var(--phosphor);\n      background: rgba(70, 255, 150, 0.14);\n      outline: none;\n    }\n\n    .crt-btn.active {\n      background: var(--phosphor);\n      color: #040806;\n      border-color: var(--phosphor);\n      box-shadow: 0 0 12px rgba(70, 255, 150, 0.45);\n    }\n\n    /* Signal Strength Meter */\n    .meter-wrap {\n      display: flex;\n      flex-direction: column;\n      gap: 6px;\n    }\n\n    .meter-head {\n      display: flex;\n      justify-content: space-between;\n      font-size: 11px;\n      color: #87cfa6;\n    }\n\n    .s-meter {\n      display: grid;\n      grid-template-columns: repeat(12, 1fr);\n      gap: 4px;\n    }\n\n    .s-seg {\n      height: 16px;\n      background: #0a1b11;\n      border: 1px solid #183d28;\n      transition: background 0.12s ease, box-shadow 0.12s ease;\n    }\n\n    .s-seg.on {\n      background: var(--phosphor);\n      box-shadow: 0 0 8px rgba(70, 255, 150, 0.65);\n    }\n\n    .s-seg.on.amber {\n      background: var(--amber);\n      box-shadow: 0 0 8px rgba(255, 186, 73, 0.65);\n    }\n\n    .s-seg.on.hot {\n      background: var(--alert);\n      box-shadow: 0 0 8px rgba(255, 93, 82, 0.65);\n    }\n\n    /* Phosphor Waveform */\n    .scope-frame {\n      background: #030805;\n      border: 1.5px solid var(--border);\n      padding: 4px;\n    }\n\n    #wave-canvas {\n      display: block;\n      width: 100%;\n      height: 92px;\n    }\n\n    /* Station Presets */\n    .preset-grid {\n      display: grid;\n      grid-template-columns: 1fr;\n      gap: 8px;\n    }\n\n    .preset-card {\n      min-height: 52px;\n      padding: 9px 10px;\n      background: #06100a;\n      border: 1.5px solid var(--border);\n      color: var(--phosphor);\n      font-family: var(--mono);\n      cursor: pointer;\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      gap: 10px;\n      text-align: left;\n    }\n\n    .preset-card:hover {\n      border-color: var(--phosphor);\n      background: #0c2115;\n    }\n\n    .preset-card.locked {\n      background: rgba(70, 255, 150, 0.14);\n      border-color: var(--phosphor);\n      box-shadow: inset 3px 0 0 var(--phosphor);\n    }\n\n    .preset-city {\n      font-weight: 700;\n      font-size: 13px;\n      display: block;\n    }\n\n    .preset-call {\n      font-size: 11px;\n      color: #87cfa6;\n    }\n\n    .preset-freq {\n      font-family: var(--display);\n      font-size: 13px;\n      color: var(--amber);\n      flex-shrink: 0;\n    }\n\n    @media (min-width: 820px) {\n      .shell {\n        padding: 20px 20px 44px;\n      }\n\n      .console-grid {\n        grid-template-columns: 1fr 1.15fr;\n        align-items: start;\n      }\n\n      .preset-grid {\n        grid-template-columns: repeat(2, 1fr);\n      }\n    }\n  </style>\n</head>\n<body>\n  <main class=\"shell\">\n    <header class=\"topbar\">\n      <div class=\"brand\">\n        <span class=\"pulse-led\" aria-hidden=\"true\"></span>\n        <h1>SW-8800 // PHOSPHOR RADAR TUNER</h1>\n      </div>\n      <div class=\"utc-readout\" id=\"utc-clock\">UTC 00:00:00 Z</div>\n    </header>\n\n    <section class=\"console-grid\">\n      <!-- LEFT: AZIMUTH RADAR RETICLE -->\n      <article class=\"crt-card\" aria-label=\"Azimuth Shortwave Globe Radar\">\n        <div class=\"card-head\">\n          <span>Azimuth Bearing Reticle</span>\n          <span id=\"radar-hint\">Tap blip to lock</span>\n        </div>\n\n        <div class=\"radar-stage\">\n          <canvas id=\"radar-canvas\" width=\"380\" height=\"380\"></canvas>\n        </div>\n\n        <div class=\"coord-strip\">\n          <div class=\"coord-cell\">\n            <span>LATITUDE</span>\n            <strong id=\"coord-lat\">64.15° N</strong>\n          </div>\n          <div class=\"coord-cell\">\n            <span>LONGITUDE</span>\n            <strong id=\"coord-lon\">21.94° W</strong>\n          </div>\n          <div class=\"coord-cell\">\n            <span>AZIMUTH</span>\n            <strong id=\"coord-az\">342° NNW</strong>\n          </div>\n        </div>\n      </article>\n\n      <!-- RIGHT: FREQUENCY TUNER, S-METER, WAVEFORM, PRESETS -->\n      <article class=\"crt-card\" aria-label=\"Frequency Controls and Station Presets\">\n        <div class=\"card-head\">\n          <span>HF Shortwave Receiver</span>\n          <span id=\"prop-band\">IONOSPHERE: F2 LAYER</span>\n        </div>\n\n        <div class=\"freq-box\">\n          <div class=\"freq-top\">\n            <div>\n              <span class=\"freq-digits\" id=\"freq-display\">06.185</span>\n              <span class=\"freq-unit\">MHz</span>\n            </div>\n            <span class=\"lock-badge\" id=\"lock-badge\">CARRIER LOCKED</span>\n          </div>\n          <div class=\"station-meta\">\n            <strong id=\"station-name\">Reykjavik — RUV North Atlantic</strong>\n            <span id=\"station-prog\">Weather &amp; Maritime Bulletin</span>\n          </div>\n        </div>\n\n        <div class=\"tuner-slider-wrap\">\n          <input class=\"freq-range\" type=\"range\" id=\"freq-slider\" min=\"3.00\" max=\"22.00\" step=\"0.005\" value=\"6.185\" aria-label=\"Shortwave frequency in megahertz\">\n          <div class=\"scale-ticks\">\n            <span>3.0 MHz</span><span>7.5</span><span>12.0</span><span>17.0</span><span>22.0 MHz</span>\n          </div>\n          <div class=\"fine-controls\">\n            <button class=\"crt-btn\" id=\"btn-down-coarse\">-0.25</button>\n            <button class=\"crt-btn\" id=\"btn-down-fine\">-0.01</button>\n            <button class=\"crt-btn\" id=\"btn-up-fine\">+0.01</button>\n            <button class=\"crt-btn active\" id=\"btn-squelch\">SQL: ON</button>\n          </div>\n        </div>\n\n        <div class=\"meter-wrap\">\n          <div class=\"meter-head\">\n            <span>SIGNAL STRENGTH (S-METER)</span>\n            <span id=\"snr-readout\">S9 +20 dB</span>\n          </div>\n          <div class=\"s-meter\" id=\"s-meter\" aria-hidden=\"true\"></div>\n        </div>\n\n        <div class=\"scope-frame\">\n          <canvas id=\"wave-canvas\" width=\"460\" height=\"92\"></canvas>\n        </div>\n\n        <div>\n          <div class=\"card-head\" style=\"margin-bottom:8px;\">\n            <span>Global Shortwave Presets</span>\n            <span>5 Beacons</span>\n          </div>\n          <div class=\"preset-grid\" id=\"preset-grid\"></div>\n        </div>\n      </article>\n    </section>\n  </main>\n\n  <script>\n    const STATIONS = [\n      {\n        id: 'reykjavik',\n        city: 'Reykjavik',\n        call: 'RUV North Atlantic',\n        prog: 'Arctic Maritime & Glacial Relay',\n        freq: 6.185,\n        lat: '64.15° N',\n        lon: '21.94° W',\n        az: '342° NNW',\n        // Polar coords on radar (angle in deg, radius 0..0.82)\n        angle: 332,\n        dist: 0.44,\n        harmonics: [1.0, 2.2, 3.6]\n      },\n      {\n        id: 'tokyo',\n        city: 'Tokyo',\n        call: 'NHK World Radio Japan',\n        prog: 'Pacific Midnight Telemetry',\n        freq: 11.815,\n        lat: '35.68° N',\n        lon: '139.65° E',\n        az: '044° NE',\n        angle: 42,\n        dist: 0.74,\n        harmonics: [1.4, 2.8, 4.1]\n      },\n      {\n        id: 'buenos-aires',\n        city: 'Buenos Aires',\n        call: 'RAE Argentina al Mundo',\n        prog: 'South Atlantic Tango Broadcast',\n        freq: 15.345,\n        lat: '34.60° S',\n        lon: '58.38° W',\n        az: '198° SSW',\n        angle: 204,\n        dist: 0.68,\n        harmonics: [0.85, 1.9, 3.1]\n      },\n      {\n        id: 'cairo',\n        city: 'Cairo',\n        call: 'ERTU Radio Cairo',\n        prog: 'Nile Delta Shortwave Service',\n        freq: 9.720,\n        lat: '30.04° N',\n        lon: '31.23° E',\n        az: '112° ESE',\n        angle: 118,\n        dist: 0.56,\n        harmonics: [1.2, 2.5, 3.9]\n      },\n      {\n        id: 'zurich',\n        city: 'Zurich',\n        call: 'SRF Alpine Time Beacon',\n        prog: 'Atomic Clock & Alpine Weather',\n        freq: 17.640,\n        lat: '47.37° N',\n        lon: '8.54° E',\n        az: '078° ENE',\n        angle: 78,\n        dist: 0.34,\n        harmonics: [1.6, 3.2, 4.8]\n      }\n    ];\n\n    const state = {\n      freq: 6.185,\n      squelch: true,\n      targetX: 0,\n      targetY: 0,\n      reticleX: 190,\n      reticleY: 190,\n      sweepAngle: 0,\n      wavePhase: 0\n    };\n\n    const els = {\n      freqDisplay: document.getElementById('freq-display'),\n      freqSlider: document.getElementById('freq-slider'),\n      lockBadge: document.getElementById('lock-badge'),\n      stationName: document.getElementById('station-name'),\n      stationProg: document.getElementById('station-prog'),\n      coordLat: document.getElementById('coord-lat'),\n      coordLon: document.getElementById('coord-lon'),\n      coordAz: document.getElementById('coord-az'),\n      snrReadout: document.getElementById('snr-readout'),\n      sMeter: document.getElementById('s-meter'),\n      presetGrid: document.getElementById('preset-grid'),\n      btnSquelch: document.getElementById('btn-squelch'),\n      utcClock: document.getElementById('utc-clock')\n    };\n\n    // Build 12-segment S-Meter\n    const meterSegs = [];\n    for (let i = 0; i < 12; i++) {\n      const seg = document.createElement('div');\n      seg.className = 's-seg';\n      els.sMeter.appendChild(seg);\n      meterSegs.push(seg);\n    }\n\n    // Build Station Preset Cards\n    els.presetGrid.innerHTML = STATIONS.map(st => `\n      <button class=\"preset-card\" data-station=\"${st.id}\">\n        <span>\n          <span class=\"preset-city\">${st.city}</span>\n          <span class=\"preset-call\">${st.call}</span>\n        </span>\n        <span class=\"preset-freq\">${st.freq.toFixed(3)}</span>\n      </button>\n    `).join('');\n\n    function getNearestStation(freq) {\n      let best = STATIONS[0];\n      let minDiff = Infinity;\n      STATIONS.forEach(st => {\n        const d = Math.abs(st.freq - freq);\n        if (d < minDiff) {\n          minDiff = d;\n          best = st;\n        }\n      });\n      // Signal strength 0..1 based on proximity to carrier\n      const lockStrength = Math.max(0, 1 - minDiff / 0.45);\n      return { station: best, diff: minDiff, strength: lockStrength };\n    }\n\n    function stationRadarPos(st, cx, cy, maxR) {\n      const rad = (st.angle - 90) * (Math.PI / 180);\n      return {\n        x: cx + Math.cos(rad) * maxR * st.dist,\n        y: cy + Math.sin(rad) * maxR * st.dist\n      };\n    }\n\n    function setFrequency(val) {\n      state.freq = Math.max(3.0, Math.min(22.0, Number(val)));\n      els.freqSlider.value = state.freq.toFixed(3);\n      els.freqDisplay.textContent = state.freq.toFixed(3).padStart(6, '0');\n\n      const { station, diff, strength } = getNearestStation(state.freq);\n      const isLocked = diff <= 0.08;\n\n      if (isLocked) {\n        els.lockBadge.textContent = 'CARRIER LOCKED';\n        els.lockBadge.classList.remove('searching');\n        els.stationName.textContent = `${station.city} — ${station.call}`;\n        els.stationProg.textContent = station.prog;\n        els.coordLat.textContent = station.lat;\n        els.coordLon.textContent = station.lon;\n        els.coordAz.textContent = station.az;\n      } else if (strength > 0.2) {\n        els.lockBadge.textContent = 'WEAK SIGNAL';\n        els.lockBadge.classList.add('searching');\n        els.stationName.textContent = `Drift near ${station.city} (${station.freq.toFixed(3)} MHz)`;\n        els.stationProg.textContent = 'Fine-tune carrier for clear lock';\n      } else {\n        els.lockBadge.textContent = 'ATMOSPHERIC NOISE';\n        els.lockBadge.classList.add('searching');\n        els.stationName.textContent = 'Open HF Band — Ionospheric Static';\n        els.stationProg.textContent = 'Select a preset or sweep dial';\n        els.coordLat.textContent = '--.--°';\n        els.coordLon.textContent = '--.--°';\n        els.coordAz.textContent = 'SCANNING';\n      }\n\n      document.querySelectorAll('.preset-card').forEach(card => {\n        card.classList.toggle('locked', isLocked && card.dataset.station === station.id);\n      });\n\n      const pos = stationRadarPos(station, 190, 190, 165);\n      if (strength > 0.25) {\n        state.targetX = pos.x;\n        state.targetY = pos.y;\n      } else {\n        const driftAngle = (state.freq * 42) * (Math.PI / 180);\n        state.targetX = 190 + Math.cos(driftAngle) * 70;\n        state.targetY = 190 + Math.sin(driftAngle) * 70;\n      }\n    }\n\n    // Event Wiring\n    els.presetGrid.addEventListener('click', (e) => {\n      const btn = e.target.closest('.preset-card');\n      if (!btn) return;\n      const st = STATIONS.find(s => s.id === btn.dataset.station);\n      if (st) setFrequency(st.freq);\n    });\n\n    els.freqSlider.addEventListener('input', () => setFrequency(els.freqSlider.value));\n    document.getElementById('btn-down-coarse').addEventListener('click', () => setFrequency(state.freq - 0.25));\n    document.getElementById('btn-down-fine').addEventListener('click', () => setFrequency(state.freq - 0.01));\n    document.getElementById('btn-up-fine').addEventListener('click', () => setFrequency(state.freq + 0.01));\n\n    els.btnSquelch.addEventListener('click', () => {\n      state.squelch = !state.squelch;\n      els.btnSquelch.classList.toggle('active', state.squelch);\n      els.btnSquelch.textContent = state.squelch ? 'SQL: ON' : 'SQL: OFF';\n    });\n\n    // Radar Canvas\n    const radarCanvas = document.getElementById('radar-canvas');\n    const rCtx = radarCanvas.getContext('2d');\n\n    radarCanvas.addEventListener('click', (e) => {\n      const rect = radarCanvas.getBoundingClientRect();\n      const x = ((e.clientX - rect.left) / rect.width) * radarCanvas.width;\n      const y = ((e.clientY - rect.top) / rect.height) * radarCanvas.height;\n      let chosen = null;\n      let bestDist = 36;\n      STATIONS.forEach(st => {\n        const p = stationRadarPos(st, 190, 190, 165);\n        const d = Math.hypot(p.x - x, p.y - y);\n        if (d < bestDist) {\n          bestDist = d;\n          chosen = st;\n        }\n      });\n      if (chosen) setFrequency(chosen.freq);\n    });\n\n    function drawRadar() {\n      const w = radarCanvas.width;\n      const h = radarCanvas.height;\n      const cx = w / 2;\n      const cy = h / 2;\n      const maxR = 165;\n\n      rCtx.clearRect(0, 0, w, h);\n\n      // Concentric azimuth rings\n      rCtx.strokeStyle = 'rgba(70, 255, 150, 0.22)';\n      rCtx.lineWidth = 1;\n      [0.25, 0.5, 0.75, 1].forEach(frac => {\n        rCtx.beginPath();\n        rCtx.arc(cx, cy, maxR * frac, 0, Math.PI * 2);\n        rCtx.stroke();\n      });\n\n      // Globe meridian arcs\n      rCtx.strokeStyle = 'rgba(70, 255, 150, 0.14)';\n      rCtx.beginPath();\n      rCtx.ellipse(cx, cy, maxR * 0.52, maxR, 0, 0, Math.PI * 2);\n      rCtx.stroke();\n      rCtx.beginPath();\n      rCtx.ellipse(cx, cy, maxR, maxR * 0.45, 0, 0, Math.PI * 2);\n      rCtx.stroke();\n\n      // Crosshairs\n      rCtx.strokeStyle = 'rgba(70, 255, 150, 0.22)';\n      rCtx.beginPath();\n      rCtx.moveTo(cx - maxR, cy); rCtx.lineTo(cx + maxR, cy);\n      rCtx.moveTo(cx, cy - maxR); rCtx.lineTo(cx, cy + maxR);\n      rCtx.stroke();\n\n      // Compass labels\n      rCtx.fillStyle = '#74b28f';\n      rCtx.font = 'bold 11px JetBrains Mono, monospace';\n      rCtx.textAlign = 'center';\n      rCtx.fillText('N', cx, cy - maxR - 6);\n      rCtx.fillText('S', cx, cy + maxR + 14);\n      rCtx.fillText('W', cx - maxR - 12, cy + 4);\n      rCtx.fillText('E', cx + maxR + 12, cy + 4);\n\n      // Sweeping phosphor beam\n      state.sweepAngle = (state.sweepAngle + 0.018) % (Math.PI * 2);\n      const grad = rCtx.createConicGradient(state.sweepAngle - 0.55, cx, cy);\n      grad.addColorStop(0, 'rgba(70, 255, 150, 0)');\n      grad.addColorStop(0.08, 'rgba(70, 255, 150, 0.24)');\n      grad.addColorStop(0.09, 'rgba(70, 255, 150, 0)');\n      rCtx.fillStyle = grad;\n      rCtx.beginPath();\n      rCtx.arc(cx, cy, maxR, 0, Math.PI * 2);\n      rCtx.fill();\n\n      // Station blips\n      const { station: activeSt, diff } = getNearestStation(state.freq);\n      STATIONS.forEach(st => {\n        const p = stationRadarPos(st, cx, cy, maxR);\n        const locked = diff <= 0.08 && st.id === activeSt.id;\n        rCtx.beginPath();\n        rCtx.arc(p.x, p.y, locked ? 6 : 4, 0, Math.PI * 2);\n        rCtx.fillStyle = locked ? '#ffba49' : '#46ff96';\n        rCtx.shadowColor = locked ? '#ffba49' : '#46ff96';\n        rCtx.shadowBlur = locked ? 12 : 6;\n        rCtx.fill();\n        rCtx.shadowBlur = 0;\n\n        rCtx.fillStyle = locked ? '#ffba49' : '#9ee8be';\n        rCtx.font = '10px JetBrains Mono, monospace';\n        rCtx.textAlign = 'left';\n        rCtx.fillText(st.city.toUpperCase(), p.x + 9, p.y + 3);\n      });\n\n      // Smoothly animate target lock reticle\n      state.reticleX += (state.targetX - state.reticleX) * 0.1;\n      state.reticleY += (state.targetY - state.reticleY) * 0.1;\n\n      rCtx.strokeStyle = '#ffba49';\n      rCtx.lineWidth = 1.5;\n      rCtx.beginPath();\n      rCtx.arc(state.reticleX, state.reticleY, 15, 0, Math.PI * 2);\n      rCtx.stroke();\n      rCtx.beginPath();\n      rCtx.moveTo(state.reticleX - 21, state.reticleY); rCtx.lineTo(state.reticleX - 10, state.reticleY);\n      rCtx.moveTo(state.reticleX + 10, state.reticleY); rCtx.lineTo(state.reticleX + 21, state.reticleY);\n      rCtx.moveTo(state.reticleX, state.reticleY - 21); rCtx.lineTo(state.reticleX, state.reticleY - 10);\n      rCtx.moveTo(state.reticleX, state.reticleY + 10); rCtx.lineTo(state.reticleX, state.reticleY + 21);\n      rCtx.stroke();\n    }\n\n    // Phosphor Waveform & S-Meter Animation\n    const waveCanvas = document.getElementById('wave-canvas');\n    const wCtx = waveCanvas.getContext('2d');\n\n    function drawWaveform() {\n      const w = waveCanvas.width;\n      const h = waveCanvas.height;\n      wCtx.fillStyle = '#030805';\n      wCtx.fillRect(0, 0, w, h);\n\n      // Centerline & grid\n      wCtx.strokeStyle = 'rgba(70, 255, 150, 0.16)';\n      wCtx.lineWidth = 1;\n      wCtx.beginPath();\n      wCtx.moveTo(0, h / 2); wCtx.lineTo(w, h / 2);\n      for (let x = 46; x < w; x += 46) {\n        wCtx.moveTo(x, 0); wCtx.lineTo(x, h);\n      }\n      wCtx.stroke();\n\n      const { station, strength } = getNearestStation(state.freq);\n      state.wavePhase += 0.12;\n\n      // Update S-Meter dynamically with subtle ionospheric fading\n      const fade = Math.sin(state.wavePhase * 0.35) * 0.08;\n      const effectiveStrength = Math.max(0.05, Math.min(1, strength + fade));\n      const litCount = Math.round(effectiveStrength * 12);\n\n      meterSegs.forEach((seg, idx) => {\n        const on = idx < litCount;\n        seg.className = 's-seg' + (on ? (idx >= 10 ? ' on hot' : idx >= 7 ? ' on amber' : ' on') : '');\n      });\n\n      const dbText = strength > 0.8 ? `S9 +${Math.round(effectiveStrength * 30)} dB` : `S${Math.max(1, Math.round(effectiveStrength * 9))} (${Math.round(effectiveStrength * 100)}%)`;\n      els.snrReadout.textContent = dbText;\n\n      // Draw live phosphor trace\n      wCtx.strokeStyle = strength > 0.7 ? '#46ff96' : '#ffba49';\n      wCtx.shadowColor = wCtx.strokeStyle;\n      wCtx.shadowBlur = 8;\n      wCtx.lineWidth = 2;\n      wCtx.beginPath();\n\n      const noiseAmp = state.squelch && strength < 0.25 ? 2.5 : (1 - strength) * 24;\n      const sigAmp = strength * 28;\n      const [h1, h2, h3] = station.harmonics;\n\n      for (let x = 0; x < w; x += 3) {\n        const t = (x / w) * Math.PI * 8;\n        const carrier =\n          Math.sin(t * h1 + state.wavePhase) * sigAmp * 0.6 +\n          Math.sin(t * h2 - state.wavePhase * 1.4) * sigAmp * 0.28 +\n          Math.cos(t * h3 + state.wavePhase * 0.7) * sigAmp * 0.16;\n        const staticNoise = (Math.random() - 0.5) * noiseAmp;\n        const y = h / 2 + carrier + staticNoise;\n        if (x === 0) wCtx.moveTo(x, y);\n        else wCtx.lineTo(x, y);\n      }\n      wCtx.stroke();\n      wCtx.shadowBlur = 0;\n    }\n\n    function updateUTC() {\n      const now = new Date();\n      const iso = now.toISOString().slice(11, 19);\n      els.utcClock.textContent = `UTC ${iso} Z`;\n    }\n\n    function frame() {\n      drawRadar();\n      drawWaveform();\n      requestAnimationFrame(frame);\n    }\n\n    setFrequency(6.185);\n    updateUTC();\n    setInterval(updateUTC, 1000);\n    requestAnimationFrame(frame);\n  </script>\n</body>\n</html>\n"
}
