:root {
  --page-bg: #0a0a0c;
  --wood-1: #5a3a24;
  --wood-2: #3e2716;
  --wood-3: #6b4530;
  --panel: #1b1712;
  --panel-2: #241f18;
  --metal: #cfcac0;
  --metal-dark: #8a857a;
  --text: #f5efe6;
  --text-dim: #b9ada0;
  --accent: #f0b429;
  --accent-hover: #ffc94d;
  --error: #f87171;
  --live: #4ade80;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "Courier New", monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(70% 55% at 50% 0%, rgba(240, 180, 41, 0.1) 0%, transparent 60%),
    var(--page-bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  user-select: none;
}

.radio-shell { width: 100%; max-width: 400px; }

.brand {
  text-align: center;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  color: #f5efe6;
}
.brand .dot { color: var(--accent); }

/* ===== Wood-cabinet body ===== */
.radio-device {
  background:
    repeating-linear-gradient(100deg, rgba(0,0,0,0.08) 0 2px, transparent 2px 6px),
    linear-gradient(155deg, var(--wood-3), var(--wood-1) 45%, var(--wood-2));
  border: 1px solid rgba(0,0,0,0.5);
  border-radius: 20px;
  padding: 20px;
  box-shadow:
    0 30px 70px -30px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 0 40px rgba(0, 0, 0, 0.35);
}

/* ===== Frequency bar ===== */
.freq-panel {
  background: linear-gradient(180deg, #26211a, #191510);
  border: 1px solid rgba(0,0,0,0.6);
  border-radius: 12px;
  padding: 14px 14px 10px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.5);
  margin-bottom: 14px;
}

.freq-bar {
  position: relative;
  height: 54px;
  border-bottom: 2px solid rgba(240, 180, 41, 0.35);
  margin-bottom: 4px;
  overflow: hidden;
}

.freq-ticks {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 4px 6px;
}
.freq-ticks span {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--metal-dark);
  position: relative;
}
.freq-ticks span::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 1px;
  height: 8px;
  background: rgba(207, 202, 192, 0.35);
}

.freq-needle {
  position: absolute;
  bottom: 0;
  left: 2%;
  width: 2px;
  height: 100%;
  background: linear-gradient(to top, var(--accent), #ff5a5a);
  box-shadow: 0 0 8px rgba(240, 180, 41, 0.7);
  transition: left 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.freq-needle::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(240, 180, 41, 0.9);
}
.freq-needle.sweeping { transition: left 0.12s linear; }

.readout-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 8px;
}

.frequency-readout {
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(240, 180, 41, 0.5);
}

.status-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4b1f1f;
  box-shadow: inset 0 0 2px rgba(0,0,0,0.6);
}
.status-led.live { background: var(--live); box-shadow: 0 0 8px var(--live); }
.status-led.scanning { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: led-pulse 0.6s ease-in-out infinite; }
@keyframes led-pulse { 50% { opacity: 0.3; } }

.status-message {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
  min-height: 16px;
  margin: 6px 0 2px;
}
.status-message.live { color: var(--live); }
.status-message.dead { color: var(--error); }

/* ===== Knob + Volume row ===== */
.controls-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding: 18px 4px 8px;
  gap: 12px;
}

.control-col { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.control-label {
  font-size: 10.5px;
  color: var(--metal-dark);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0;
}

.tuner-knob {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #e8e2d6, var(--metal) 40%, var(--metal-dark) 100%);
  box-shadow:
    0 6px 14px rgba(0,0,0,0.5),
    inset 0 -3px 6px rgba(0,0,0,0.3),
    inset 0 2px 3px rgba(255,255,255,0.6);
  position: relative;
  cursor: grab;
  touch-action: none;
}
.tuner-knob:active { cursor: grabbing; }
.tuner-knob .knob-indicator {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 3px;
  height: 22px;
  margin-left: -1.5px;
  background: #3a352c;
  border-radius: 2px;
}
.tuner-knob::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
}

#volume-slider {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 24px;
  height: 74px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ===== Tune controls ===== */
.tune-controls { display: flex; gap: 8px; margin-top: 18px; }

#code-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid rgba(0,0,0,0.5);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 1px;
}
#code-input:focus { outline: none; border-color: var(--accent); }
#code-input::placeholder { color: #6b6255; }

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
}

#tune-btn {
  padding: 12px 20px;
  border-radius: 10px;
  background: var(--accent);
  color: #201808;
  font-weight: 700;
  font-size: 14px;
}
#tune-btn:hover:not(:disabled) { background: var(--accent-hover); }

#scan-btn {
  width: 100%;
  margin-top: 10px;
  padding: 13px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid rgba(240, 180, 41, 0.5);
  color: var(--accent);
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.03em;
}
#scan-btn:hover:not(:disabled) { background: rgba(240, 180, 41, 0.1); }

button:disabled { opacity: 0.5; cursor: not-allowed; }

.hint {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 16px;
}

@media (max-width: 380px) {
  .tuner-knob { width: 62px; height: 62px; }
  #volume-slider { height: 62px; }
}
