/* ==============================
   メトロノームアプリ スタイル
   ============================== */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ── ナビゲーション ── */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #141428;
  border-bottom: 1px solid #2a2a4a;
  z-index: 100;
}

.nav-inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 8px 8px;
  overflow-x: auto;
}

.nav-link {
  color: #777;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
  touch-action: manipulation;
}

.nav-link:hover {
  color: #ccc;
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: #ff8c00;
  background: rgba(255, 140, 0, 0.1);
}

/* ── レイアウト ── */

.container {
  width: 100%;
  max-width: 420px;
  padding: 32px 24px;
  padding-top: 68px;
}

.title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 36px;
  color: #fff;
  letter-spacing: 2px;
}

.section {
  margin-bottom: 28px;
}

.section-label {
  text-align: center;
  font-size: 0.8rem;
  color: #777;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 3px;
  font-weight: 500;
}

/* ── テンポ ── */

.tempo-display {
  text-align: center;
  margin-bottom: 16px;
  line-height: 1;
}

#tempo-display {
  font-size: 3.5rem;
  font-weight: 700;
  color: #ff8c00;
  font-variant-numeric: tabular-nums;
}

.tempo-unit {
  font-size: 1rem;
  color: #777;
  margin-left: 4px;
  vertical-align: baseline;
}

.tempo-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tempo-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #555;
  background: transparent;
  color: #eee;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
  touch-action: manipulation;
  line-height: 1;
}

.tempo-btn:hover {
  border-color: #ff8c00;
  color: #ff8c00;
}

.tempo-btn:active {
  background: rgba(255, 140, 0, 0.15);
}

/* ── スライダー ── */

.tempo-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: #333;
  outline: none;
  touch-action: manipulation;
}

.tempo-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ff8c00;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 6px rgba(255, 140, 0, 0.4);
}

.tempo-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ff8c00;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 6px rgba(255, 140, 0, 0.4);
}

/* ── ボタングループ（拍子・音符） ── */

.button-group {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.beat-btn,
.note-btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: 2px solid #444;
  background: transparent;
  color: #aaa;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  min-width: 48px;
  text-align: center;
  touch-action: manipulation;
}

.beat-btn:hover,
.note-btn:hover {
  border-color: #777;
  color: #ddd;
}

.beat-btn.active,
.note-btn.active {
  border-color: #ff8c00;
  color: #ff8c00;
  background: rgba(255, 140, 0, 0.1);
}

/* ── ビートインジケーター ── */

.beat-indicators {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  min-height: 64px;
}

.beat-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #333;
  border: 2px solid #444;
  transition: background 0.06s, box-shadow 0.06s, transform 0.06s;
}

.beat-dot.accent {
  width: 42px;
  height: 42px;
}

.beat-dot.active {
  background: #4488ff;
  border-color: #4488ff;
  box-shadow: 0 0 18px rgba(68, 136, 255, 0.5);
  transform: scale(1.1);
}

.beat-dot.accent.active {
  background: #ff4444;
  border-color: #ff4444;
  box-shadow: 0 0 22px rgba(255, 68, 68, 0.6);
  transform: scale(1.15);
}

/* ── 再生/停止ボタン ── */

.play-section {
  text-align: center;
  margin-top: 8px;
}

.play-btn {
  width: 200px;
  height: 56px;
  border-radius: 28px;
  border: none;
  background: #44cc44;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 3px;
  transition: background 0.15s, transform 0.1s;
  touch-action: manipulation;
}

.play-btn:hover {
  filter: brightness(1.1);
  transform: scale(1.03);
}

.play-btn:active {
  transform: scale(0.97);
}

.play-btn.playing {
  background: #cc4444;
}

/* ── レスポンシブ ── */

@media (max-width: 480px) {
  .container {
    padding: 24px 16px;
    padding-top: 60px;
  }

  .nav-link {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .title {
    font-size: 1.3rem;
    margin-bottom: 28px;
  }

  #tempo-display {
    font-size: 2.8rem;
  }

  .beat-btn,
  .note-btn {
    padding: 8px 14px;
    font-size: 0.85rem;
    min-width: 42px;
  }

  .beat-dot {
    width: 26px;
    height: 26px;
  }

  .beat-dot.accent {
    width: 36px;
    height: 36px;
  }

  .beat-indicators {
    gap: 14px;
  }

  .play-btn {
    width: 180px;
    height: 50px;
    font-size: 1.05rem;
  }
}

/* ── コンテンツページ（ガイド・コツ） ── */

.content-page {
  max-width: 640px;
}

.content-section {
  margin-bottom: 36px;
}

.content-section h2 {
  font-size: 1.2rem;
  color: #ff8c00;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #333;
}

.content-section h3 {
  font-size: 1rem;
  color: #ccc;
  margin-top: 20px;
  margin-bottom: 10px;
}

.content-section p {
  color: #bbb;
  line-height: 1.8;
  margin-bottom: 12px;
}

.content-section ul,
.content-section ol {
  color: #bbb;
  line-height: 1.8;
  padding-left: 24px;
  margin-bottom: 12px;
}

.content-section li {
  margin-bottom: 6px;
}

.callout {
  background: rgba(255, 140, 0, 0.08);
  border-left: 3px solid #ff8c00;
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 0 6px 6px 0;
  color: #ccc;
  font-size: 0.9rem;
  line-height: 1.7;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 16px;
  font-size: 0.88rem;
}

.info-table th {
  background: #252545;
  color: #ddd;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 2px solid #444;
}

.info-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #333;
  color: #bbb;
}

.info-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* ── リズムエディター ── */

.rhythm-page {
  max-width: 520px;
}

.staff-section {
  background: #12122a;
  border-radius: 10px;
  padding: 12px 8px;
  margin-bottom: 20px;
}

#staff {
  width: 100%;
  display: block;
}

.remaining-display {
  text-align: center;
  font-size: 0.85rem;
  color: #888;
  margin-top: 8px;
}

.remaining-display.complete {
  color: #44cc44;
}

.dotted-toggle {
  padding: 10px 28px;
  border-radius: 20px;
  border: 2px solid #555;
  background: transparent;
  color: #aaa;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  touch-action: manipulation;
  letter-spacing: 1px;
}

.dotted-toggle:hover {
  border-color: #888;
  color: #ddd;
}

.dotted-toggle.active {
  border-color: #ff8c00;
  color: #fff;
  background: rgba(255, 140, 0, 0.25);
}

.note-add-btn,
.rest-add-btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 2px solid #444;
  background: transparent;
  color: #aaa;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s, opacity 0.15s;
  min-width: 52px;
  text-align: center;
  touch-action: manipulation;
}

.note-add-btn:hover:not(:disabled),
.rest-add-btn:hover:not(:disabled) {
  border-color: #888;
  color: #ddd;
}

.note-add-btn:disabled,
.rest-add-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.action-btn {
  padding: 10px 24px;
  border-radius: 8px;
  border: 2px solid #555;
  background: transparent;
  color: #aaa;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  touch-action: manipulation;
}

.action-btn:hover:not(:disabled) {
  border-color: #888;
  color: #ddd;
}

.action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.delete-btn:hover:not(:disabled) {
  border-color: #cc4444;
  color: #cc4444;
}

.clear-btn:hover {
  border-color: #cc4444;
  color: #cc4444;
}

.preset-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 2px solid #3a3a5a;
  background: transparent;
  color: #99a;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  touch-action: manipulation;
}

.preset-btn:hover {
  border-color: #ff8c00;
  color: #ff8c00;
  background: rgba(255, 140, 0, 0.08);
}

.play-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  align-items: center;
}

.metronome-toggle {
  padding: 12px 18px;
  border-radius: 20px;
  border: 2px solid #444;
  background: transparent;
  color: #888;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  touch-action: manipulation;
}

.metronome-toggle.active {
  border-color: #44cc44;
  color: #44cc44;
}

.metronome-toggle:hover {
  border-color: #888;
  color: #ddd;
}

.play-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

@media (max-height: 600px) {
  .container {
    padding: 16px;
  }

  .title {
    margin-bottom: 16px;
  }

  .section {
    margin-bottom: 16px;
  }

  .tempo-display {
    margin-bottom: 10px;
  }

  #tempo-display {
    font-size: 2.4rem;
  }
}
