:root {
      --bg-primary: #121212;
      --bg-card: #1e1e1e;
      --bg-input: #27272a;
      --border-color: #333338;
      --accent-blue: #3b82f6;
      --accent-green: #22c55e;
      --accent-amber: #f59e0b;
      --accent-red: #ef4444;
      --text-main: #f4f4f5;
      --text-muted: #a1a1aa;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      -webkit-tap-highlight-color: transparent;
    }

    body {
      background-color: var(--bg-primary);
      color: var(--text-main);
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 20px 16px 40px;
    }

    /* Header Nav */
    .nav-header {
      width: 100%;
      max-width: 860px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 24px;
      padding-bottom: 14px;
      border-bottom: 1px solid var(--border-color);
      flex-wrap: wrap;
      gap: 12px;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .brand-icon {
      font-size: 26px;
    }

    .brand-title {
      font-size: 20px;
      font-weight: 700;
      letter-spacing: -0.5px;
      color: #fff;
    }

    .brand-subtitle {
      font-size: 11px;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    .nav-actions {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .nav-btn {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 8px 14px;
      background: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 8px;
      color: var(--text-main);
      font-size: 13px;
      font-weight: 600;
      text-decoration: none;
      transition: background 0.15s, border-color 0.15s;
    }

    .nav-btn:hover {
      background: #2a2a30;
      border-color: #4b4b54;
    }

    /* Main Container */
    .tuner-container {
      width: 100%;
      max-width: 860px;
      display: flex;
      flex-direction: column;
      gap: 20px;
    }

    /* Card Standard */
    .card {
      background: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 12px;
      padding: 20px;
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    }

    /* Digital Display Console */
    .display-card {
      background: radial-gradient(circle at 50% 20%, #1f2937 0%, #111827 80%);
      border: 1px solid #374151;
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
      padding: 28px 20px 22px;
      position: relative;
      overflow: hidden;
    }

    .top-status-row {
      display: flex;
      justify-content: space-between;
      width: 100%;
      margin-bottom: 12px;
      font-size: 12px;
      font-weight: 600;
      letter-spacing: 0.5px;
      text-transform: uppercase;
      color: var(--text-muted);
    }

    .status-badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 4px 10px;
      border-radius: 20px;
      font-size: 11px;
      font-weight: 700;
      background: rgba(0,0,0,0.4);
      border: 1px solid rgba(255,255,255,0.1);
    }

    .status-badge.live {
      color: #4ade80;
      border-color: rgba(74, 222, 128, 0.3);
    }

    .status-badge.live .dot {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: #4ade80;
      box-shadow: 0 0 8px #4ade80;
      animation: pulse 1.8s infinite;
    }

    .status-badge.tuning {
      color: #fbbf24;
      border-color: rgba(251, 191, 36, 0.3);
    }

    .status-badge.tuning .dot {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: #fbbf24;
    }

    @keyframes pulse {
      0% { opacity: 0.5; transform: scale(0.9); }
      50% { opacity: 1; transform: scale(1.1); }
      100% { opacity: 0.5; transform: scale(0.9); }
    }

    .freq-readout-wrap {
      display: flex;
      align-items: baseline;
      justify-content: center;
      gap: 8px;
      margin: 8px 0;
    }

    .freq-number {
      font-family: "Courier New", Courier, monospace, "Segoe UI";
      font-size: 64px;
      font-weight: 800;
      color: #60a5fa;
      letter-spacing: -2px;
      text-shadow: 0 0 20px rgba(96, 165, 250, 0.4);
      line-height: 1;
    }

    .freq-unit {
      font-size: 20px;
      font-weight: 700;
      color: #93c5fd;
      letter-spacing: 0.5px;
    }

    .station-name-banner {
      font-size: 16px;
      font-weight: 600;
      color: #e2e8f0;
      margin-top: 4px;
      min-height: 24px;
    }

    /* Audio Spectrum Visualizer Canvas */
    .visualizer-container {
      width: 100%;
      max-width: 500px;
      height: 48px;
      margin-top: 18px;
      background: rgba(0, 0, 0, 0.3);
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.05);
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    #visualizerCanvas {
      width: 100%;
      height: 100%;
      display: block;
    }

    /* Tuning Controls Card */
    .section-title {
      font-size: 13px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      color: var(--text-muted);
      margin-bottom: 14px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    /* FM Dial Slider */
    .dial-wrap {
      margin-bottom: 20px;
    }

    .dial-slider {
      -webkit-appearance: none;
      width: 100%;
      height: 10px;
      border-radius: 5px;
      background: #27272a;
      outline: none;
      transition: background 0.2s;
    }

    .dial-slider::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 24px;
      height: 24px;
      border-radius: 50%;
      background: #3b82f6;
      cursor: pointer;
      box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
      border: 2px solid #fff;
      transition: transform 0.1s;
    }

    .dial-slider::-webkit-slider-thumb:hover {
      transform: scale(1.15);
    }

    .dial-slider::-moz-range-thumb {
      width: 24px;
      height: 24px;
      border-radius: 50%;
      background: #3b82f6;
      cursor: pointer;
      box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
      border: 2px solid #fff;
    }

    .dial-ticks {
      display: flex;
      justify-content: space-between;
      margin-top: 8px;
      font-size: 11px;
      color: #71717a;
      font-family: monospace;
      padding: 0 2px;
    }

    /* Step buttons & Direct Tune Row */
    .tune-row {
      display: grid;
      grid-template-columns: 1fr auto 1fr;
      gap: 12px;
      align-items: center;
    }

    @media (max-width: 640px) {
      .tune-row {
        grid-template-columns: 1fr;
        gap: 14px;
      }
    }

    .step-btn-group {
      display: flex;
      gap: 6px;
    }

    .tune-step-btn {
      flex: 1;
      padding: 9px 8px;
      background: #27272a;
      border: 1px solid #3f3f46;
      border-radius: 6px;
      color: #f4f4f5;
      font-size: 12px;
      font-weight: 700;
      cursor: pointer;
      transition: background 0.15s, border-color 0.15s;
    }

    .tune-step-btn:hover {
      background: #3f3f46;
      border-color: #52525b;
    }

    .direct-tune-form {
      display: flex;
      gap: 6px;
      justify-content: center;
    }

    .direct-input {
      width: 90px;
      padding: 8px 10px;
      background: #141416;
      border: 1px solid #3f3f46;
      border-radius: 6px;
      color: #fff;
      font-size: 14px;
      font-weight: bold;
      text-align: center;
      outline: none;
    }

    .direct-input:focus {
      border-color: #3b82f6;
    }

    .btn-tune {
      padding: 8px 14px;
      background: #2563eb;
      border: none;
      border-radius: 6px;
      color: #fff;
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
      transition: background 0.15s;
    }

    .btn-tune:hover {
      background: #1d4ed8;
    }

    /* Player Controls Card */
    .player-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      flex-wrap: wrap;
    }

    .play-btn {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 12px 24px;
      background: #16a34a;
      border: none;
      border-radius: 8px;
      color: #fff;
      font-size: 15px;
      font-weight: 700;
      cursor: pointer;
      transition: background 0.15s, transform 0.1s;
    }

    .play-btn:hover {
      background: #15803d;
    }

    .play-btn.playing {
      background: #dc2626;
    }

    .play-btn.playing:hover {
      background: #b91c1c;
    }

    .volume-group {
      display: flex;
      align-items: center;
      gap: 10px;
      background: #27272a;
      padding: 8px 14px;
      border-radius: 8px;
      border: 1px solid #3f3f46;
    }

    .vol-btn {
      background: none;
      border: none;
      color: #fff;
      cursor: pointer;
      font-size: 16px;
      display: flex;
      align-items: center;
    }

    .vol-slider {
      width: 110px;
      accent-color: #3b82f6;
      cursor: pointer;
    }

    .live-sync-btn {
      padding: 8px 14px;
      background: #27272a;
      border: 1px solid #3f3f46;
      border-radius: 8px;
      color: #a1a1aa;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.15s, color 0.15s;
    }

    .live-sync-btn:hover {
      background: #3f3f46;
      color: #fff;
    }

    /* Preset Stations Grid */
    .preset-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
      gap: 10px;
    }

    .preset-card {
      background: #27272a;
      border: 1px solid #3f3f46;
      border-radius: 8px;
      padding: 12px 10px;
      text-align: center;
      cursor: pointer;
      transition: all 0.15s ease;
      position: relative;
    }

    .preset-card:hover {
      background: #323238;
      border-color: #52525b;
      transform: translateY(-2px);
    }

    .preset-card.active {
      background: rgba(59, 130, 246, 0.15);
      border-color: #3b82f6;
      box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
    }

    .preset-freq {
      font-size: 17px;
      font-weight: 800;
      color: #60a5fa;
      font-family: monospace;
    }

    .preset-label {
      font-size: 11px;
      color: #d4d4d8;
      margin-top: 3px;
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .preset-genre {
      font-size: 10px;
      color: #71717a;
      margin-top: 2px;
    }

    .preset-del-btn {
      position: absolute;
      top: 4px;
      right: 4px;
      background: none;
      border: none;
      color: #71717a;
      font-size: 12px;
      cursor: pointer;
      padding: 2px 4px;
      border-radius: 4px;
      display: none;
    }

    .preset-card:hover .preset-del-btn {
      display: block;
    }

    .preset-del-btn:hover {
      color: #ef4444;
    }

    .custom-preset-btn {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      border: 1px dashed #3f3f46;
      background: transparent;
      color: #a1a1aa;
      font-size: 12px;
      font-weight: 600;
      border-radius: 8px;
      padding: 12px 10px;
      cursor: pointer;
      transition: all 0.15s;
    }

    .custom-preset-btn:hover {
      border-color: #3b82f6;
      color: #3b82f6;
      background: rgba(59, 130, 246, 0.05);
    }

    /* Game Mode Lockout Modal / Overlay */
    .lockout-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      background: rgba(10, 10, 12, 0.92);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 9999;
      padding: 20px;
    }

    .lockout-card {
      background: #18181b;
      border: 1px solid #3f3f46;
      border-radius: 16px;
      padding: 40px 32px;
      max-width: 480px;
      text-align: center;
      box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
    }

    .lockout-icon {
      font-size: 64px;
      margin-bottom: 14px;
      animation: bounce 2s infinite ease-in-out;
    }

    @keyframes bounce {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-8px); }
    }

    .lockout-badge {
      display: inline-block;
      background: rgba(245, 158, 11, 0.15);
      border: 1px solid rgba(245, 158, 11, 0.3);
      color: #f59e0b;
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      padding: 5px 12px;
      border-radius: 20px;
      margin-bottom: 16px;
    }

    .lockout-title {
      font-size: 24px;
      font-weight: 800;
      color: #fff;
      margin-bottom: 12px;
    }

    .lockout-desc {
      font-size: 14px;
      line-height: 1.6;
      color: #a1a1aa;
      margin-bottom: 28px;
    }

    .lockout-btn {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      background: #2563eb;
      color: #fff;
      text-decoration: none;
      padding: 12px 28px;
      border-radius: 8px;
      font-size: 15px;
      font-weight: 700;
      transition: background 0.15s, transform 0.1s;
    }

    .lockout-btn:hover {
      background: #1d4ed8;
      transform: translateY(-1px);
    }

    /* Modal for Custom Preset */
    .modal-backdrop {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      background: rgba(0, 0, 0, 0.75);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 1000;
      padding: 20px;
    }

    .modal-box {
      background: #1f1f23;
      border: 1px solid #3f3f46;
      border-radius: 12px;
      padding: 24px;
      width: 100%;
      max-width: 360px;
    }

    .modal-box h3 {
      font-size: 18px;
      margin-bottom: 16px;
      color: #fff;
    }

    .form-group {
      margin-bottom: 14px;
      text-align: left;
    }

    .form-group label {
      display: block;
      font-size: 12px;
      color: #a1a1aa;
      margin-bottom: 6px;
    }

    .form-group input {
      width: 100%;
      padding: 9px 12px;
      background: #141416;
      border: 1px solid #3f3f46;
      border-radius: 6px;
      color: #fff;
      font-size: 14px;
      outline: none;
    }

    .form-group input:focus {
      border-color: #3b82f6;
    }

    .modal-actions {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      margin-top: 20px;
    }

    .btn-secondary {
      background: #27272a;
      border: 1px solid #3f3f46;
      color: #fff;
      padding: 8px 14px;
      border-radius: 6px;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
    }

    /* Toast Notification */
    .toast {
      position: fixed;
      bottom: 24px;
      background: #27272a;
      border: 1px solid #3f3f46;
      color: #fff;
      padding: 10px 18px;
      border-radius: 8px;
      font-size: 13px;
      font-weight: 600;
      box-shadow: 0 6px 20px rgba(0,0,0,0.5);
      z-index: 5000;
      opacity: 0;
      transform: translateY(20px);
      transition: all 0.25s ease;
      pointer-events: none;
    }

    .toast.show {
      opacity: 1;
      transform: translateY(0);
    }
