:root {
  --bg: #111013;
  --unit-bg: #1a1a1e;
  --unit-face: #202025;
  --chrome: linear-gradient(145deg, #4a4a52, #2a2a30, #3a3a42, #222228);
  --chrome-edge: linear-gradient(180deg, #555560 0%, #1a1a20 50%, #333340 100%);
  --display-bg: #0a0c08;
  --display-glow: #d4830a;
  --display-dim: #7a4a05;
  --display-dark: #1a0f02;
  --amber: #e8920a;
  --amber-bright: #ffb030;
  --amber-dim: #8a5008;
  --btn-bg: #252528;
  --btn-active: #1a1a1e;
  --btn-text: #888890;
  --btn-active-text: #e8920a;
  --knob-body: radial-gradient(circle at 35% 30%, #4a4a55, #1a1a22 60%, #0f0f14);
  --knob-ring: linear-gradient(135deg, #555560, #2a2a35, #444450);
  --screw: radial-gradient(circle at 40% 35%, #444450, #1a1a22);
  --red: #cc3322;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Courier New', monospace;
  overflow-x: hidden;
}

/* Dashboard surround */
.dashboard {
  width: 100vw;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 60%, #1e1a14 0%, #0d0b09 60%, #080706 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

/* Beat bounce animation */
@keyframes beat-bounce {
  0%   { transform: scale(var(--beat-scale, 1.08)); }
  55%  { transform: scale(var(--beat-undershoot, 0.984)); }
  100% { transform: scale(1.0); }
}

.radio-unit.beat {
  animation: beat-bounce 350ms ease-out forwards;
}

/* The radio unit */
.radio-unit {
  display: inline-flex;
  background: var(--chrome-edge);
  border-radius: 6px;
  padding: 4px;
  box-shadow:
    0 0 0 1px #555560,
    0 8px 40px rgba(0,0,0,0.9),
    0 2px 6px rgba(0,0,0,0.8),
    inset 0 1px 0 rgba(255,255,255,0.08);
}

.radio-face {
  background: var(--unit-face);
  border-radius: 4px;
  padding: 18px 20px;
  display: inline-flex;
  align-items: center;
  gap: 18px;
  position: relative;
}


/* Screws in corners */
.radio-face::before,
.radio-face::after {
  content: '✕';
  position: absolute;
  font-size: 7px;
  color: #333338;
  width: 10px;
  height: 10px;
  background: var(--screw);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.05);
}
.radio-face::before { top: 8px; left: 8px; }
.radio-face::after  { top: 8px; right: 8px; }

/* Center panel */
.radio-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* LCD Display */
.display {
  background: var(--display-bg);
  border-radius: 3px;
  padding: 10px 14px;
  border: 1px solid #1a1a10;
  box-shadow:
    inset 0 2px 8px rgba(0,0,0,0.9),
    inset 0 0 20px rgba(0,0,0,0.6),
    0 0 6px rgba(232,146,10,0.08);
  position: relative;
  overflow: hidden;
  min-height: 78px;
}

.display::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.12) 2px,
    rgba(0,0,0,0.12) 3px
  );
  pointer-events: none;
  z-index: 10;
}

.display-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.display-brand {
  font-size: 8px;
  letter-spacing: 3px;
  color: var(--amber-dim);
  text-transform: uppercase;
}

.display-indicators {
  display: flex;
  gap: 4px;
}

.indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--display-dark);
}
.indicator.on {
  background: var(--amber);
  box-shadow: 0 0 4px var(--amber), 0 0 8px rgba(232,146,10,0.4);
}
.indicator.red.on {
  background: var(--red);
  box-shadow: 0 0 4px var(--red), 0 0 8px rgba(204,51,34,0.4);
}

.display-station {
  font-size: 22px;
  font-weight: bold;
  color: var(--amber-bright);
  text-shadow: 0 0 8px var(--amber), 0 0 20px rgba(232,146,10,0.3);
  letter-spacing: 1px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.display-station.off {
  color: var(--display-dark);
  text-shadow: none;
}

.display-meta {
  font-size: 9px;
  color: var(--display-dim);
  letter-spacing: 1px;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
}

.display-meta.scrolling {
  animation: scroll-text 12s linear infinite;
}

@keyframes scroll-text {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(0); }
  80%  { transform: translateX(-60%); }
  100% { transform: translateX(0); }
}

/* Preset buttons row */
.presets {
  display: flex;
  gap: 5px;
}

.preset-btn {
  flex: 1;
  background: var(--btn-bg);
  border: 1px solid #2a2a30;
  border-radius: 2px;
  color: var(--btn-text);
  font-family: 'Courier New', monospace;
  font-size: 9px;
  padding: 5px 2px;
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.5px;
  transition: all 0.08s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.03);
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  position: relative;
}

.preset-btn:hover {
  color: var(--amber-dim);
  border-color: #3a3a42;
}

.preset-btn.active {
  background: #1a1a10;
  color: var(--btn-active-text);
  border-color: var(--amber-dim);
  box-shadow: 0 0 6px rgba(232,146,10,0.15), inset 0 2px 4px rgba(0,0,0,0.6);
  text-shadow: 0 0 6px rgba(232,146,10,0.5);
}

.preset-btn:active {
  box-shadow: 0 1px 2px rgba(0,0,0,0.8), inset 0 2px 6px rgba(0,0,0,0.8);
  transform: translateY(1px);
}

.preset-btn.inactive {
  opacity: 0.35;
  cursor: default;
}

.preset-num {
  display: block;
  font-size: 7px;
  color: #444448;
  margin-bottom: 2px;
}
.preset-btn.active .preset-num { color: var(--amber-dim); }

/* Knob component */
.knob-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.knob-label {
  font-size: 8px;
  letter-spacing: 2px;
  color: #444448;
  text-transform: uppercase;
}

.knob-outer {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--knob-ring);
  padding: 4px;
  box-shadow:
    0 4px 12px rgba(0,0,0,0.8),
    0 1px 0 rgba(255,255,255,0.06),
    inset 0 2px 4px rgba(0,0,0,0.6);
  cursor: grab;
  user-select: none;
  position: relative;
}

.knob-outer:active { cursor: grabbing; }

.knob-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--knob-body);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.7),
    inset 0 -1px 2px rgba(255,255,255,0.04);
  position: relative;
  transition: transform 0.05s ease-out;
}

/* Indicator line on knob */
.knob-inner::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 12px;
  background: linear-gradient(180deg, var(--amber) 0%, var(--amber-dim) 100%);
  border-radius: 1px;
  box-shadow: 0 0 4px var(--amber);
}

/* Knob tick marks */
.knob-ticks {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  pointer-events: none;
}

.knob-ticks span {
  position: absolute;
  width: 2px;
  height: 4px;
  background: #333338;
  border-radius: 1px;
  left: 50%;
  transform-origin: 0 32px;
  margin-left: -1px;
}

/* Volume knob value display */
.knob-value {
  font-size: 9px;
  color: var(--amber-dim);
  letter-spacing: 1px;
}

/* Power button */
.power-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #3a3a42, #1a1a22);
  border: 1px solid #333338;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.05);
  transition: all 0.1s;
  user-select: none;
  margin-top: 4px;
}

.power-btn:hover { border-color: #444448; }

.power-btn.on {
  box-shadow: 0 0 8px rgba(204,51,34,0.4), 0 3px 8px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.05);
  border-color: #884422;
}

.power-icon {
  width: 12px;
  height: 12px;
  border: 2px solid #444448;
  border-radius: 50%;
  border-top-color: transparent;
  position: relative;
}
.power-icon::after {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 6px;
  background: #444448;
}
.power-btn.on .power-icon,
.power-btn.on .power-icon::after { border-color: var(--red); background: var(--red); }
.power-btn.on .power-icon { background: transparent; }

/* Settings button (mirrors power button) */
.settings-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #3a3a42, #1a1a22);
  border: 1px solid #333338;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.05);
  transition: all 0.1s;
  user-select: none;
  margin-top: 4px;
}

.settings-btn:hover { border-color: #444448; }

.settings-btn.open {
  box-shadow: 0 0 8px rgba(232,146,10,0.3), 0 3px 8px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.05);
  border-color: var(--amber-dim);
}

.settings-btn {
  font-size: 21px;
  color: #444448;
  line-height: 1;
}

.settings-btn.open { color: var(--amber-dim); }

/* Settings overlay */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.settings-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.settings-panel {
  background: var(--unit-face);
  border-radius: 4px;
  padding: 4px;
  background: var(--chrome-edge);
  box-shadow:
    0 0 0 1px #555560,
    0 12px 50px rgba(0,0,0,0.95),
    inset 0 1px 0 rgba(255,255,255,0.08);
  min-width: 240px;
  transform: scale(0.95);
  transition: transform 0.15s;
}

.settings-overlay.open .settings-panel {
  transform: scale(1);
}

.settings-header {
  background: var(--display-bg);
  border-radius: 2px 2px 0 0;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #1a1a10;
}

.settings-title {
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--amber-dim);
}

.settings-close {
  background: none;
  border: none;
  color: #444448;
  font-size: 10px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.1s;
}
.settings-close:hover { color: var(--amber-dim); }

.settings-body {
  background: var(--unit-face);
  border-radius: 0 0 2px 2px;
  padding: 14px 16px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.setting-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: #666670;
}

/* Toggle button */
.toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  user-select: none;
}

.toggle-track {
  width: 32px;
  height: 16px;
  border-radius: 8px;
  background: #1a1a22;
  border: 1px solid #333338;
  position: relative;
  display: block;
  transition: all 0.15s;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #444448;
  transition: all 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.toggle-btn.on .toggle-track {
  background: #1a1208;
  border-color: var(--amber-dim);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4), 0 0 6px rgba(232,146,10,0.15);
}

.toggle-btn.on .toggle-thumb {
  left: 18px;
  background: var(--amber);
  box-shadow: 0 0 4px var(--amber), 0 1px 3px rgba(0,0,0,0.6);
}

.toggle-state {
  font-size: 9px;
  letter-spacing: 1px;
  color: #444448;
  width: 18px;
  transition: color 0.15s;
}

.toggle-btn.on .toggle-state { color: var(--amber-dim); }

/* Admin link */
.admin-link {
  position: fixed;
  bottom: 18px;
  right: 22px;
  font-size: 10px;
  color: #333338;
  text-decoration: none;
  letter-spacing: 1px;
  opacity: 0.4;
  transition: opacity 0.2s;
}
.admin-link:hover { opacity: 0.8; color: var(--amber-dim); }

/* Debug link (sits above admin link) */
.debug-link {
  bottom: 38px;
  background: none;
  border: none;
  font-family: 'Courier New', monospace;
  padding: 0;
  cursor: pointer;
}

/* Debug modal rows */
.debug-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 6px;
}
.debug-row:last-child { margin-bottom: 0; }

.debug-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: #666670;
}
.debug-val {
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--amber-bright);
  min-width: 44px;
  text-align: right;
}

/* Responsive — medium screens */
@media (max-width: 900px) {
  .knob-outer { width: 46px; height: 46px; }
  .preset-btn { font-size: 8px; padding: 4px 1px; }
  .display-station { font-size: 16px; }
}

/* Responsive — mobile: stack center on top, knobs in a row below */
@media (max-width: 768px) {
  .dashboard {
    padding: 16px 12px;
    align-items: flex-start;
  }

  .radio-unit {
    display: flex;
    width: 100%;
  }

  .radio-face {
    display: grid;
    grid-template-areas:
      "center center"
      "vol    tune";
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    width: 100%;
  }

  .radio-center { grid-area: center; }

  .radio-face > .knob-wrap:first-child { grid-area: vol; }
  .radio-face > .knob-wrap:last-child  { grid-area: tune; }

  /* Pull power button out of vol knob-wrap and center it in the bottom row */
  .power-btn {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(18px + 22px); /* padding-bottom + half knob-row height */
    margin-top: 0;
  }

  .knob-outer { width: 44px; height: 44px; }

  .presets { flex-wrap: wrap; }

  .preset-btn {
    flex: 0 0 calc(20% - 4px);
    font-size: 8px;
  }

  .display-station { font-size: 15px; }
}
