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

:root {
  --accent: #ff3a5f;
  --accent-muted: #ff7b8f;
  --accent-alt: #5f8dff;
  --accent-alt2: #22c1c3;
  --text-main: #f4f4f4;
  --text-sub: #a5a5a5;
  --bg-panel: rgba(14, 14, 18, 0.96);
  --border: rgba(120, 120, 140, 0.45);
  --bg-body: #030309;
}

/* 전체 레이아웃 */
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.2rem 0.8rem 1.8rem;
}

/* 배경 턴테이블 */
.turntable {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 50% 50%, #181818 0%, #070707 55%, #000 100%),
    repeating-radial-gradient(circle at 50% 50%,
      #2b2b2b, #2b2b2b 9px, transparent 9px, transparent 18px
    ),
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.02),
      rgba(255, 255, 255, 0.02) 1px,
      transparent 1px,
      transparent 3px
    );
  background-size: cover, 220px 220px, 100% 100%;
  z-index: -1;
  pointer-events: none;
  filter: contrast(1.1) brightness(0.85);
}

/* 상단 헤더 */
.site-header {
  text-align: center;
  margin-bottom: 0.7rem;
}

.site-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.site-subtitle {
  font-size: 0.78rem;
  color: var(--text-sub);
  margin-top: 0.2rem;
}

/* 탭 네비게이션 */
.tool-tabs {
  display: inline-flex;
  gap: 0.3rem;
  padding: 0.3rem;
  border-radius: 999px;
  background: rgba(5, 5, 10, 0.9);
  border: 1px solid rgba(120, 120, 140, 0.7);
  margin-bottom: 1rem;
}

.tool-tab {
  padding: 0.45rem 0.9rem;
  font-size: 0.78rem;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tool-tab:hover {
  color: var(--text-main);
}

.tool-tab.active {
  background: linear-gradient(120deg, var(--accent), var(--accent-muted));
  color: #fff;
  box-shadow: 0 0 10px rgba(255, 58, 95, 0.5);
}

/* 툴 패널 컨테이너 */
.tool-container {
  width: 100%;
  max-width: 540px;
}

/* 개별 툴 패널 */
.tool-panel {
  display: none;
}

.tool-panel.active {
  display: block;
}

/* 공용 카드(panel) */
.panel {
  background: var(--bg-panel);
  border-radius: 18px;
  padding: 1.4rem 1.4rem 1.5rem;
  box-shadow:
    0 18px 45px rgba(0, 0, 0, 0.9),
    inset 0 0 0 1px rgba(160, 160, 200, 0.25);
  backdrop-filter: blur(18px);
  width: 100%;
}

/* 패널 헤더 */
.panel-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid rgba(130, 130, 170, 0.35);
  padding-bottom: 0.5rem;
}

.panel-icon {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #ff9cb0, var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(255, 58, 95, 0.8);
}

.panel-icon-alt {
  background: radial-gradient(circle at 30% 30%, #a7c0ff, var(--accent-alt));
  box-shadow: 0 0 12px rgba(95, 141, 255, 0.8);
}

.panel-icon-alt2 {
  background: radial-gradient(circle at 30% 30%, #7ef5ff, var(--accent-alt2));
  box-shadow: 0 0 12px rgba(34, 193, 195, 0.8);
}

.icon-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #fff;
}

.icon-bars {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 2px solid #fff;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.icon-grid {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  border: 2px solid #fff;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.panel-title-group h1 {
  font-size: 1.35rem;
  margin-bottom: 0.1rem;
}

.panel-subtitle {
  font-size: 0.78rem;
  color: var(--text-sub);
}

/* Vinyl UI */
.vinyl-wrapper {
  display: flex;
  justify-content: center;
  margin: 0.8rem 0 1rem;
}

.vinyl {
  width: 230px;
  height: 230px;
  border-radius: 50%;
  background:
    conic-gradient(from 0deg,
      #111 0%,
      #232323 25%,
      #343434 50%,
      #232323 75%,
      #111 100%
    ),
    radial-gradient(circle at center,
      #101010 0%,
      #202020 45%,
      #303030 100%
    );
  border: 10px solid #404040;
  box-shadow:
    0 0 26px rgba(0, 0, 0, 0.9),
    0 0 0 3px rgba(255, 255, 255, 0.06);
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.vinyl:hover {
  transform: translateY(-1px);
  box-shadow:
    0 0 30px rgba(0, 0, 0, 0.95),
    0 0 0 3px rgba(255, 255, 255, 0.08);
}

.vinyl.tapping {
  box-shadow:
    0 0 30px rgba(255, 58, 95, 0.7),
    0 0 0 4px rgba(255, 123, 143, 0.9) inset;
  border-color: var(--accent-muted);
}

.label {
  width: 76px;
  height: 76px;
  background: radial-gradient(circle at 30% 30%, #222 0%, #111 60%, #000 100%);
  border-radius: 50%;
  border: 1px solid #444;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 0.63rem;
  letter-spacing: 0.7px;
  color: #ccc;
  text-transform: uppercase;
}

.label span:first-child {
  font-weight: 600;
  color: var(--accent-muted);
  margin-bottom: 2px;
}

/* BPM 부분 */
.bpm-container {
  margin: 0.4rem 0 0.6rem;
  padding: 0.6rem 1rem 0.65rem;
  background: rgba(5, 5, 10, 0.9);
  border-radius: 10px;
  border: 1px solid rgba(120, 120, 150, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.bpm-main {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.bpm-current {
  font-size: 2.1rem;
  font-weight: 700;
  color: #fff;
  min-width: 3.2ch;
  text-align: right;
}

.bpm-unit {
  font-size: 0.85rem;
  color: var(--text-sub);
}

.bpm-meta {
  font-size: 0.75rem;
  color: var(--text-sub);
  display: flex;
  gap: 0.8rem;
}

.bpm-meta span strong {
  color: #ddd;
  font-weight: 600;
}

.bpm-hint {
  font-size: 0.78rem;
  color: var(--text-sub);
  margin-bottom: 0.35rem;
}

/* Tap 버튼 + Reset */
.tap-buttons-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.tap-main {
  flex: 1;
}

/* 버튼 공통 */
.tap-button {
  padding: 0.9rem 2rem;
  font-size: 0.98rem;
  font-weight: 500;
  background: linear-gradient(135deg, var(--accent), var(--accent-muted));
  color: #fff;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(255, 58, 95, 0.35);
  transition: all 0.15s ease;
  width: 100%;
}

.tap-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(255, 58, 95, 0.45);
}

.tap-button:active {
  transform: translateY(0);
  box-shadow: 0 3px 8px rgba(255, 58, 95, 0.4);
}

.tap-button:focus-visible {
  outline: 2px solid rgba(255, 58, 95, 0.9);
  outline-offset: 2px;
}

/* 고스트 버튼 */
.ghost-button {
  border-radius: 8px;
  border: 1px solid rgba(200, 200, 220, 0.6);
  background: transparent;
  color: #f0f0f0;
  padding: 0.45rem 0.7rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.ghost-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.07);
}

.ghost-button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* 도움말 카드 */
.help {
  margin-top: 0.9rem;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  background: rgba(3, 3, 8, 0.9);
  border: 1px dashed rgba(120, 120, 160, 0.8);
  font-size: 0.75rem;
  color: var(--text-sub);
  text-align: left;
}

.help-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #ddd;
  margin-bottom: 0.3rem;
}

.help-list {
  list-style: none;
  display: grid;
  gap: 0.18rem;
}

.help-list li code {
  font-family: "SF Mono", "Consolas", monospace;
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  color: #ddd;
}

/* 메트로놈 UI */
.metro-section-label,
.delay-section-label {
  font-size: 0.75rem;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0.3rem 0 0.25rem;
}

.metro-bpm-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
  font-size: 0.8rem;
}

.metro-bpm-row label {
  color: var(--text-sub);
}

#metroBpmInput {
  width: 70px;
  padding: 0.25rem 0.3rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.7);
  color: var(--text-main);
  font-size: 0.8rem;
}

.metro-slider {
  width: 100%;
  margin-bottom: 0.9rem;
}

/* range 기본 스타일 */
.metro-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
}
.metro-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6);
}
.metro-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

/* 메트로놈 비주얼 */
.metro-visual {
  margin: 0.5rem 0 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.metro-disc {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #2f3250, #161728);
  border: 2px solid rgba(200, 200, 230, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}

.metro-light {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 0 rgba(255, 58, 95, 0.0);
  transition: box-shadow 0.1s ease, background 0.1s ease, border-color 0.1s ease;
}

.metro-light.active {
  background: var(--accent);
  border-color: #fff;
  box-shadow: 0 0 18px rgba(255, 58, 95, 0.95);
}

.metro-beat-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.9rem;
}

.metro-beat-label #metroBeat {
  font-size: 1.6rem;
  font-weight: 700;
}

.metro-beat-sub {
  font-size: 0.7rem;
  color: var(--text-sub);
}

.metro-controls {
  margin-top: 0.6rem;
}

/* 메트로놈 Start/Stop 버튼 */
.metro-toggle {
  width: 60%;
  margin-inline: auto;
  display: block;
}

/* Delay Calculator */
.delay-bpm-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
  font-size: 0.8rem;
}

.delay-bpm-row label {
  color: var(--text-sub);
}

#delayBpmInput {
  width: 70px;
  padding: 0.25rem 0.3rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.7);
  color: var(--text-main);
  font-size: 0.8rem;
}

.delay-table-wrapper {
  margin-top: 0.4rem;
  overflow-x: auto;
}

.delay-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.delay-table th,
.delay-table td {
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}

.delay-table th {
  font-weight: 600;
  color: #e0e0ff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.delay-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* 하단 푸터 / 광고 */
.site-footer {
  width: 100%;
  max-width: 540px;
  margin-top: 1rem;
  text-align: center;
}

.ad-slot {
  border-radius: 10px;
  border: 1px dashed rgba(150, 150, 180, 0.8);
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.4rem;
  background: rgba(5, 5, 12, 0.95);
}

.ad-label {
  font-size: 0.72rem;
  color: var(--text-sub);
}

.footer-text {
  font-size: 0.75rem;
  color: var(--text-sub);
}

@media (max-width: 480px) {
  .panel {
    padding: 1.3rem 1.1rem 1.3rem;
  }

  .vinyl {
    width: 200px;
    height: 200px;
  }

  .bpm-current {
    font-size: 1.9rem;
  }

  .metro-toggle {
    width: 100%;
  }

  .tap-buttons-row {
    flex-direction: column;
  }
}