:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f7f7f8;
  background: #070708;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html, body, #root {
  width: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 10%, rgba(108, 92, 231, 0.18), transparent 34%),
    radial-gradient(circle at 85% 90%, rgba(0, 210, 160, 0.13), transparent 34%),
    #070708;
}

button { font: inherit; }

.app-shell {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vh, 20px) clamp(12px, 3vw, 20px);
}

.tuner-card {
  width: min(100%, 760px);
  max-height: calc(100vh - clamp(20px, 4vh, 40px));
  max-height: calc(100svh - clamp(20px, 4vh, 40px));
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: clamp(20px, 3vw, 32px);
  background: rgba(18,18,21,0.88);
  box-shadow: 0 30px 90px rgba(0,0,0,0.48);
  backdrop-filter: blur(20px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: clamp(10px, 1.6vh, 18px);
  overflow: hidden;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: #9b8cff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.3rem);
  line-height: 1;
  letter-spacing: -0.055em;
}

.subtitle {
  margin: 8px 0 0;
  color: #a4a4ad;
  font-size: clamp(0.82rem, 1.9vw, 0.95rem);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  color: #a4a4ad;
  background: rgba(255,255,255,0.04);
  font-size: 0.78rem;
  font-weight: 700;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #666670;
}

.live-badge.active { color: #6ef0c5; }
.live-badge.active .live-dot {
  background: #22d3a2;
  box-shadow: 0 0 0 5px rgba(34,211,162,0.12);
}

.string-list {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(6px, 1vw, 9px);
  margin-bottom: 0;
}

.string-chip {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  padding: clamp(8px, 1.4vw, 12px) 6px;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  background: rgba(255,255,255,0.035);
  transition: 180ms ease;
}

.string-chip strong { font-size: clamp(0.95rem, 2vw, 1.1rem); }
.string-chip span { margin-top: 2px; color: #a4a4ad; font-size: clamp(0.65rem, 1.4vw, 0.72rem); }
.string-chip small { margin-top: 4px; color: #696972; font-size: clamp(0.56rem, 1.2vw, 0.62rem); }

.string-chip.active {
  border-color: rgba(155,140,255,0.6);
  background: rgba(155,140,255,0.13);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(80,60,180,0.14);
}

.display-panel {
  min-height: 0;
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.018));
  text-align: center;
  display: grid;
  align-content: center;
}

.current-label {
  margin: 0;
  color: #7f7f89;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.note {
  margin-top: 4px;
  font-size: clamp(3.8rem, 14vw, 7rem);
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.08em;
  text-shadow: 0 0 50px rgba(255,255,255,0.08);
}

.note.perfect { color: #5be6b8; }
.note.flat, .note.sharp { color: #ffd16a; }

.frequency {
  min-height: 24px;
  margin: 4px 0 clamp(12px, 2vh, 20px);
  color: #aaaab3;
  font-size: clamp(0.88rem, 1.8vw, 1rem);
  font-variant-numeric: tabular-nums;
}

.meter { width: 100%; }
.meter-labels, .meter-scale {
  display: flex;
  justify-content: space-between;
  color: #6f6f78;
  font-size: 0.68rem;
}

.meter-track {
  position: relative;
  height: 14px;
  margin: 8px 3px 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f1b45d 0%, #6ae0b9 50%, #f1b45d 100%);
  box-shadow: inset 0 0 0 4px rgba(0,0,0,0.3);
  overflow: hidden;
}

.meter-sweet-spot {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 50%;
  width: 14%;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(255,255,255,0.15);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset;
  transition: background 140ms ease, box-shadow 140ms ease;
}

.meter-sweet-spot.active {
  background: rgba(91,230,184,0.28);
  box-shadow: 0 0 12px rgba(91,230,184,0.25);
}

.meter-center {
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.55);
}

.needle {
  position: absolute;
  top: 50%;
  width: 24px;
  height: 24px;
  border: 4px solid #151518;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #a0a0aa;
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
  will-change: left;
  transition: background 140ms ease;
}

.needle.perfect { background: #5be6b8; }
.needle.flat, .needle.sharp { background: #ffd16a; }

.status-message {
  margin-top: clamp(14px, 2vh, 20px);
  padding: 10px 13px;
  border-radius: 13px;
  color: #a2a2ab;
  background: rgba(255,255,255,0.045);
  font-size: clamp(0.82rem, 1.8vw, 0.9rem);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.status-message.perfect { color: #69e7bd; background: rgba(34,211,162,0.1); }
.status-message.flat, .status-message.sharp { color: #ffd16a; background: rgba(255,209,106,0.09); }

.guidance-text {
  min-height: 20px;
  margin: 10px 0 0;
  color: #c7c7ce;
  font-size: clamp(0.78rem, 1.6vw, 0.86rem);
  font-weight: 600;
}

.error-message {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(255,100,100,0.2);
  border-radius: 13px;
  color: #ff9b9b;
  background: rgba(255,80,80,0.07);
  text-align: center;
  font-size: 0.86rem;
}

.primary-button {
  width: 100%;
  min-height: clamp(46px, 6vh, 54px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 0;
  border: 0;
  border-radius: 16px;
  color: #0b0b0d;
  background: #f5f5f7;
  font-weight: 850;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease;
}

.primary-button:hover { transform: translateY(-2px); }
.primary-button:active { transform: translateY(0); }
.primary-button.stop { color: #fff; background: #dd4d57; }
.button-icon { font-size: 0.8rem; }

.tip {
  margin: 0;
  color: #6f6f78;
  text-align: center;
  font-size: clamp(0.68rem, 1.5vw, 0.76rem);
  line-height: 1.45;
}

@media (max-width: 720px) {
  .tuner-card {
    width: min(100%, 560px);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  }

  .header {
    gap: 10px;
  }

  .live-badge {
    padding: 7px 10px;
    font-size: 0.72rem;
  }

  .string-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 520px), (max-height: 760px) {
  .app-shell {
    padding: 8px;
  }

  .tuner-card {
    max-height: calc(100vh - 16px);
    max-height: calc(100svh - 16px);
    padding: 14px;
    gap: 10px;
  }

  .header {
    align-items: flex-start;
  }

  h1 {
    font-size: clamp(1.7rem, 9vw, 2.4rem);
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 0.64rem;
  }

  .subtitle {
    margin-top: 6px;
    font-size: 0.78rem;
  }

  .display-panel {
    padding: 14px;
  }

  .note {
    font-size: clamp(3.2rem, 18vw, 4.8rem);
  }

  .meter-track {
    height: 12px;
  }

  .needle {
    width: 20px;
    height: 20px;
    border-width: 3px;
  }

  .status-message,
  .error-message {
    border-radius: 12px;
    font-size: 0.8rem;
  }

  .guidance-text {
    margin-top: 8px;
    font-size: 0.76rem;
  }

  .primary-button {
    min-height: 44px;
    border-radius: 14px;
    font-size: 0.92rem;
  }
}

@media (max-width: 390px), (max-height: 680px) {
  .string-chip {
    padding: 7px 4px;
  }

  .string-chip small {
    display: none;
  }

  .display-panel {
    padding: 12px;
  }

  .frequency {
    margin-bottom: 10px;
    min-height: 20px;
    font-size: 0.82rem;
  }

  .meter-labels,
  .meter-scale,
  .tip {
    font-size: 0.64rem;
  }
}

@media (max-width: 620px) {
  .app-shell { padding: 0; }
  .tuner-card { min-height: 100vh; border: 0; border-radius: 0; padding: 24px 16px; }
  .header { flex-direction: column; }
  .live-badge { align-self: flex-start; }
  .string-list { grid-template-columns: repeat(3, 1fr); }
  .display-panel { padding-inline: 16px; }
}
