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

body {
  background: #121212;
  color: #fff;
  font-family: system-ui, -apple-system, sans-serif;
  padding: 20px 15px 0;
  height: 100dvh; 
  display: flex;
  flex-direction: column;
}

.container {
  margin: 0 auto;
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  gap: 15px;
}

/* ====================== メインエリア ====================== */
.main-panel {
  width: 100%;
  flex-shrink: 0;
}

/* 周波数エリア */
.freq-area {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  padding: 0 8px;
  width: 100%;
}

.freq-wrapper {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

#freq {
  font-size: 2.55rem; 
  font-weight: bold;
  letter-spacing: 1px;
  line-height: 1;
  min-width: 152px;
  text-align: right;
}

.freq-area .unit {
  font-size: 1.35rem;
  font-weight: 600;
  color: #ccc;
  margin-top: 6px;
  white-space: nowrap;
}

/* ====================== 緑の信号ボックス ====================== */
.signal-box {
  background: #0a1f0a;
  border: 3px solid #00ff88;
  border-radius: 12px;
  padding: 9px 14px;
  box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
  width: 195px;
  min-width: 195px;
  max-width: 195px;
  flex-shrink: 0;
}

.signal-table {
  width: 100%;
  table-layout: fixed;
}

.signal-table td {
  padding: 4px 0;
}

.signal-table .label {
  font-size: 0.82rem;
  color: #aaa;
  text-align: left;
  width: 38%;
}

.signal-table .value {
  font-size: 1.05rem;
  font-weight: 600;
  color: #00ff88;
  text-align: right;
  font-family: monospace;
  width: 62%;
}

/* 古いpillスタイル排除 */
#rssi-level,
.signal-table .value {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* LED表示灯 */
.led-container {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-right: 8px !important;
}

.led {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  transition: all 0.2s ease;
  box-shadow: 0 0 0 rgba(255, 0, 0, 0);
}

.led.on {
  background: #ff3333;
  box-shadow: 0 0 10px rgba(255, 51, 51, 0.8), inset 0 0 4px rgba(255, 100, 100, 0.4);
}

.led.off {
  background: #330000;
  box-shadow: 0 0 0 rgba(255, 0, 0, 0);
  opacity: 0.5;
}

/* ====================== コントロール ====================== */
.controls {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 10px;
}

.step-btn {
  width: 60px;
  height: 60px;
  font-size: 2rem;
  border: none;
  border-radius: 50%;
  background: #333;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.freq-input-group {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
}

.freq-input-group input {
  width: 130px;
  padding: 14px;
  font-size: 1.4rem;
  text-align: center;
  border: none;
  border-radius: 12px;
  background: #222;
  color: #fff;
}

.freq-input-group button {
  padding: 0 24px;
  font-size: 1.1rem;
  font-weight: bold;
  border: none;
  border-radius: 12px;
  background: #0066ff;
  color: white;
}

/* オーディオ再生 */
details#audioPanel {
  margin-bottom: 15px;
}

details#audioPanel summary {
  font-size: 1.1rem;
  cursor: pointer;
}

audio {
  width: 100%;
  margin-top: 8px;
}

/* ====================== プリセット ====================== */
#presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  padding-bottom: 20px;
}

#presets button {
  padding: 14px 10px;
  font-size: 1.05rem;
  text-align: center;
  white-space: normal;
  background: #1f1f1f;
  border: none;
  border-radius: 12px;
  color: #ddd;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

button:active {
  transform: scale(0.95);
  background: #444;
}

/* ====================== 横画面（landscape） ====================== */
@media (orientation: landscape) {
  .container {
    flex-direction: row;
    gap: 20px;
    padding: 15px 15px 0;
    align-items: stretch;
    max-width: none;
    margin: 0;
  }

  .main-panel {
    flex: 0 0 420px;
    max-width: 420px;
    display: flex;
    flex-direction: column;
  }

  #presets {
    flex: 1;
    min-width: 0;
    grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
    gap: 14px;
    overflow-y: auto;
    padding: 0 8px 20px 0;
  }

  #freq {
    font-size: 2.4rem;
    min-width: 138px;
  }

  .signal-box {
    width: 185px;
    min-width: 185px;
    max-width: 185px;
  }
}

/* ====================== スマホ縦画面微調整 ====================== */
@media (orientation: portrait) and (max-width: 480px) {
  .signal-box {
    width: 175px !important;
    min-width: 175px !important;
    max-width: 175px !important;
  }

  #freq {
    font-size: 2.35rem;
    min-width: 138px;
  }
}

/* ====================== スマホ縦画面微調整（緑枠欠け完全防止） ====================== */
@media (max-width: 480px) {
  .freq-area {
    gap: 8px;                 /* 左側と信号ボックスの間隔をさらに狭く */
    padding: 0 4px;           /* 左右の余白も最小限に */
  }

  .freq-wrapper {
    gap: 5px;
  }

  #freq {
    font-size: 2.3rem;        /* 少し小さくして余裕を作る */
    min-width: 130px;
  }

  .freq-area .unit {
    font-size: 1.18rem;
    margin-top: 4px;
  }

  /* 信号ボックスを縦画面でさらに小さく固定（これで欠けなくなります） */
  .signal-box {
    width: 168px !important;
    min-width: 168px !important;
    max-width: 168px !important;
    padding: 8px 10px;
    border: 3px solid #00ff88;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
  }

  /* テーブルも少し小さく */
  .signal-table .label {
    font-size: 0.78rem;
  }
  .signal-table .value {
    font-size: 0.98rem;
  }
}