:root {
  --bg-1: #1d1410;
  --bg-2: #0a0604;
  --wood-light: #6a3f1e;
  --wood-mid: #4a2812;
  --wood-dark: #25130a;
  --headstock-1: #1c100a;
  --headstock-2: #0b0604;
  --bone: #f4ecd2;
  --bone-dim: #d6cca9;
  --metal-1: #f4f4f4;
  --metal-2: #b8b8b8;
  --metal-3: #6a6a6a;
  --metal-4: #2a2a2a;
  --string-bright: #e8e8e8;
  --string-mid: #9a9a9a;
  --string-wound-1: #d9b977;
  --string-wound-2: #8a6a3a;
  --green: #5fd97a;
  --green-deep: #1f8a3d;
  --red: #ff6b5e;
  --red-deep: #b2241a;
  --gold: #f1c75a;
  --text: #f3ead4;
  --text-dim: #8a7d68;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse at 30% 0%, #2c1f15 0%, transparent 60%),
    radial-gradient(ellipse at 70% 100%, #1a0f08 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px clamp(16px, 3vw, 40px);
  gap: 20px;
}

/* ===================== Top bar ===================== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
}

.target-wrap {
  display: flex;
  align-items: baseline;
  gap: 18px;
}

.target-label {
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--text-dim);
}

.target-note {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 76px;
  font-weight: 700;
  line-height: 1;
  color: var(--gold);
  text-shadow:
    0 0 28px rgba(241, 199, 90, 0.35),
    0 2px 4px rgba(0, 0, 0, 0.6);
  min-width: 80px;
}

.stats {
  display: flex;
  gap: 36px;
  align-items: center;
}

/* Sound toggle */
.sound-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(241, 199, 90, 0.2);
  background: rgba(20, 12, 6, 0.6);
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: 12px;
  transition: all 0.15s;
}
.sound-toggle:hover {
  border-color: rgba(241, 199, 90, 0.5);
  color: var(--gold);
}
.sound-toggle svg { width: 18px; height: 18px; }
.sound-toggle .icon-off { display: none; }
.sound-toggle.muted .icon-on { display: none; }
.sound-toggle.muted .icon-off { display: block; }
.sound-toggle.muted {
  color: var(--text-dim);
  opacity: 0.6;
}
.sound-toggle:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.stat { text-align: center; }

.stat-label {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 30px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ===================== Guitar stage ===================== */
.guitar-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.guitar {
  display: flex;
  width: 100%;
  max-width: 1500px;
  height: clamp(280px, 42vh, 360px);
  border-radius: 6px;
  overflow: visible;
  position: relative;
  filter: drop-shadow(0 25px 50px rgba(0, 0, 0, 0.8));
}

/* ===================== Headstock ===================== */
.headstock {
  width: 150px;
  flex-shrink: 0;
  position: relative;
  background:
    repeating-linear-gradient(180deg,
      transparent 0,
      rgba(255, 245, 220, 0.02) 1px,
      transparent 4px),
    repeating-linear-gradient(90deg,
      transparent 0,
      rgba(0, 0, 0, 0.15) 2px,
      transparent 6px),
    linear-gradient(135deg, var(--headstock-1) 0%, var(--headstock-2) 50%, #150c07 100%);
  border-radius: 12px 0 0 12px;
  box-shadow:
    inset 0 0 30px rgba(0, 0, 0, 0.8),
    inset -8px 0 16px rgba(0, 0, 0, 0.6);
  border: 2px solid #050302;
  border-right: none;
  z-index: 1;
}

.tuner {
  position: absolute;
  left: 14px;
  top: var(--y);
  width: 30px;
  height: 22px;
  transform: translateY(-50%);
  background: linear-gradient(135deg, #f6f6f6 0%, #c0c0c0 30%, #888 55%, #d0d0d0 80%, #6a6a6a 100%);
  border-radius: 3px;
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.8),
    inset 0 1px 2px rgba(255, 255, 255, 0.6),
    inset 0 -2px 3px rgba(0, 0, 0, 0.4);
}

.tuner::before {
  content: '';
  position: absolute;
  inset: 4px 6px;
  border-radius: 1px;
  background: linear-gradient(180deg, transparent 0, transparent 45%, rgba(0,0,0,0.4) 50%, transparent 55%);
}

.tuner::after {
  content: '';
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 5px;
  background: linear-gradient(180deg, #5a5a5a, #d8d8d8 50%, #5a5a5a);
  border-radius: 1px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.headstock-string {
  position: absolute;
  left: 56px;
  right: 0;
  top: calc(var(--y) - 1px);
  pointer-events: none;
  background: linear-gradient(180deg, #555, #d8d8d8 45%, #d8d8d8 55%, #555);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
}
.headstock-string.s-1 { height: 1px; }
.headstock-string.s-2 { height: 1.4px; }
.headstock-string.s-3 { height: 1.8px; }
.headstock-string.s-4 {
  height: 2.4px;
  background:
    repeating-linear-gradient(90deg,
      rgba(0,0,0,0.45) 0, transparent 1px, transparent 2px),
    linear-gradient(180deg, var(--string-wound-2), var(--string-wound-1) 50%, var(--string-wound-2));
}
.headstock-string.s-5 {
  height: 3px;
  background:
    repeating-linear-gradient(90deg,
      rgba(0,0,0,0.5) 0, transparent 1px, transparent 2.2px),
    linear-gradient(180deg, var(--string-wound-2), var(--string-wound-1) 50%, var(--string-wound-2));
}
.headstock-string.s-6 {
  height: 4px;
  background:
    repeating-linear-gradient(90deg,
      rgba(0,0,0,0.55) 0, transparent 1.2px, transparent 2.5px),
    linear-gradient(180deg, #5a4422, #b89252 50%, #5a4422);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.6);
}

/* ===================== Fretboard ===================== */
.fretboard {
  flex: 1;
  position: relative;
  background:
    /* fine horizontal grain */
    repeating-linear-gradient(180deg,
      transparent 0,
      rgba(0, 0, 0, 0.04) 1px,
      transparent 2px,
      transparent 4px),
    /* coarse vertical wood grain */
    repeating-linear-gradient(90deg,
      transparent 0,
      rgba(255, 220, 170, 0.025) 2px,
      transparent 4px,
      rgba(0, 0, 0, 0.08) 7px,
      transparent 9px,
      transparent 18px),
    /* base wood color */
    linear-gradient(180deg, #58311a 0%, #3d2010 45%, #2d150a 100%);
  border-radius: 0 8px 8px 0;
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.6),
    inset 0 -6px 12px rgba(0, 0, 0, 0.5),
    inset 0 6px 12px rgba(0, 0, 0, 0.4);
  border: 2px solid #1a0d05;
  border-left: none;
  overflow: hidden;
}

/* ===================== Nut ===================== */
.nut {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 10px;
  background:
    linear-gradient(90deg,
      rgba(0,0,0,0.4) 0%,
      rgba(255,255,255,0) 15%,
      transparent 85%,
      rgba(0,0,0,0.4) 100%),
    linear-gradient(180deg, var(--bone) 0%, var(--bone-dim) 45%, var(--bone) 55%, #a8a085 100%);
  box-shadow:
    inset -2px 0 4px rgba(0, 0, 0, 0.4),
    3px 0 6px rgba(0, 0, 0, 0.5);
  z-index: 6;
}

/* ===================== Fret wires ===================== */
.fret {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--x) - 2px);
  width: 4px;
  background:
    linear-gradient(180deg,
      #6a6a6a 0%,
      #d8d8d8 20%,
      #f5f5f5 50%,
      #c8c8c8 80%,
      #5a5a5a 100%);
  box-shadow:
    -1px 0 3px rgba(0, 0, 0, 0.6),
    1px 0 3px rgba(0, 0, 0, 0.6),
    inset 0 0 1px rgba(255, 255, 255, 0.6);
  z-index: 2;
  border-radius: 1px;
}

/* ===================== Inlays ===================== */
.inlay {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%,
      #fffef0 0%,
      #f0e8c8 30%,
      #c8bf95 70%,
      #908872 100%);
  box-shadow:
    inset -2px -2px 4px rgba(0, 0, 0, 0.25),
    inset 2px 2px 3px rgba(255, 255, 255, 0.4),
    0 0 2px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -50%);
  z-index: 1;
}

/* ===================== Strings ===================== */
.string {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--y) - 2px);
  pointer-events: none;
  z-index: 4;
  background: linear-gradient(180deg, #555, #f0f0f0 45%, #f0f0f0 55%, #555);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
}
.string.s-1 { height: 1px; }
.string.s-2 { height: 1.4px; }
.string.s-3 { height: 1.8px; }
.string.s-4 {
  height: 2.4px;
  background:
    repeating-linear-gradient(90deg,
      rgba(0, 0, 0, 0.5) 0, transparent 1px, transparent 2px),
    linear-gradient(180deg, var(--string-wound-2), var(--string-wound-1) 50%, var(--string-wound-2));
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.65);
}
.string.s-5 {
  height: 3.2px;
  background:
    repeating-linear-gradient(90deg,
      rgba(0, 0, 0, 0.55) 0, transparent 1.2px, transparent 2.4px),
    linear-gradient(180deg, var(--string-wound-2), var(--string-wound-1) 50%, var(--string-wound-2));
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
}
.string.s-6 {
  height: 4.2px;
  background:
    repeating-linear-gradient(90deg,
      rgba(0, 0, 0, 0.6) 0, transparent 1.5px, transparent 3px),
    linear-gradient(180deg, #4a3618, #b8924c 50%, #4a3618);
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.75);
}

/* ===================== Fret positions (click targets) ===================== */
.fret-position {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 38px;
  height: 34px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Georgia", serif;
  font-weight: 700;
  font-size: 14px;
  color: transparent;
  transition: transform 0.08s ease-out;
  /* button reset */
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  outline: none;
}
.fret-position:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
  z-index: 8;
}
.btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.mode-card:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

.note-label {
  display: inline-block;
  line-height: 1;
}

.fret-position::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%,
    rgba(255, 255, 255, 0.22),
    rgba(255, 255, 255, 0.04) 60%,
    transparent 75%);
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

.fret-position:hover::before { opacity: 1; }

.fret-position:active {
  transform: translate(-50%, -50%) scale(0.92);
}

.fret-position.found {
  background:
    radial-gradient(circle at 32% 28%,
      #c5ffd2 0%,
      var(--green) 35%,
      var(--green-deep) 90%);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  box-shadow:
    0 0 18px rgba(95, 217, 122, 0.55),
    0 3px 6px rgba(0, 0, 0, 0.5),
    inset 0 -3px 5px rgba(0, 0, 0, 0.25),
    inset 0 2px 3px rgba(255, 255, 255, 0.35);
  animation: popIn 0.32s cubic-bezier(0.4, 1.4, 0.6, 1);
}

.fret-position.found::before { display: none; }

.fret-position.wrong {
  background:
    radial-gradient(circle at 32% 28%,
      #ffd4cf 0%,
      var(--red) 40%,
      var(--red-deep) 95%);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  box-shadow:
    0 0 18px rgba(255, 107, 94, 0.6),
    0 3px 6px rgba(0, 0, 0, 0.5),
    inset 0 -3px 5px rgba(0, 0, 0, 0.25),
    inset 0 2px 3px rgba(255, 255, 255, 0.35);
  animation: shake 0.4s ease-in-out;
}

.fret-position.wrong::before { display: none; }

/* Open string targets sit on the headstock layer */
.fret-position.open-string {
  z-index: 7;
}
/* Dashed ring so users discover the open-string click area */
.fret-position.open-string:not(.found):not(.wrong)::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px dashed rgba(245, 230, 210, 0.4);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: border-color 0.15s, transform 0.15s;
}
.fret-position.open-string:not(.found):not(.wrong):hover::after {
  border-color: rgba(241, 199, 90, 0.7);
  transform: translate(-50%, -50%) scale(1.08);
}

@keyframes popIn {
  0% { transform: translate(-50%, -50%) scale(0); }
  55% { transform: translate(-50%, -50%) scale(1.22); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translate(-50%, -50%); }
  20% { transform: translate(calc(-50% - 4px), -50%); }
  40% { transform: translate(calc(-50% + 4px), -50%); }
  60% { transform: translate(calc(-50% - 3px), -50%); }
  80% { transform: translate(calc(-50% + 2px), -50%); }
}

/* ===================== Fret numbers under board ===================== */
.fret-numbers {
  width: 100%;
  max-width: 1500px;
  height: 18px;
  position: relative;
  padding-left: 150px;
}
.fret-num {
  position: absolute;
  left: calc(150px + (100% - 150px) * var(--frac));
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}

/* ===================== Mobile portrait (vertical fretboard) ===================== */
@media (max-width: 768px) and (orientation: portrait) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; gap: 14px; padding: 14px 10px; }

  /* Topbar - compact stack */
  .topbar { flex-direction: column; gap: 10px; padding: 0; }
  .target-wrap { flex-direction: column; align-items: center; gap: 2px; }
  .target-label { font-size: 14px; letter-spacing: 4px; }
  .target-note { font-size: 56px; min-width: auto; }
  .stats { gap: 28px; }
  .stat-label { font-size: 10px; letter-spacing: 2px; }
  .stat-value { font-size: 22px; }

  /* Guitar - column layout (headstock on top) */
  .guitar-stage { flex: none; }
  .guitar {
    flex-direction: column;
    width: 100%;
    max-width: 460px;
    height: 70vh;
    min-height: 460px;
    max-height: calc(100vh - 240px);
  }

  /* Headstock - horizontal bar at top */
  .headstock {
    width: 100%;
    height: 130px;
    flex-shrink: 0;
    border-radius: 12px 12px 0 0;
    border: 2px solid #050302;
    border-right: 2px solid #050302;
    border-bottom: none;
    background:
      repeating-linear-gradient(90deg,
        transparent 0,
        rgba(255, 245, 220, 0.02) 1px,
        transparent 4px),
      repeating-linear-gradient(180deg,
        transparent 0,
        rgba(0, 0, 0, 0.15) 2px,
        transparent 6px),
      linear-gradient(135deg, var(--headstock-1) 0%, var(--headstock-2) 50%, #150c07 100%);
    box-shadow:
      inset 0 0 30px rgba(0, 0, 0, 0.8),
      inset 0 -8px 16px rgba(0, 0, 0, 0.6);
  }

  /* Tuners - small pegs across the top */
  .tuner {
    left: var(--y);
    top: 14px;
    width: 22px;
    height: 30px;
    transform: translateX(-50%);
    border-radius: 3px;
    background: linear-gradient(180deg, #f6f6f6 0%, #c0c0c0 30%, #888 55%, #d0d0d0 80%, #6a6a6a 100%);
  }
  .tuner::before {
    inset: 6px 4px;
    background: linear-gradient(90deg, transparent 0, transparent 45%, rgba(0,0,0,0.4) 50%, transparent 55%);
  }
  .tuner::after {
    right: auto;
    top: auto;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 12px;
    background: linear-gradient(90deg, #5a5a5a, #d8d8d8 50%, #5a5a5a);
  }

  /* Headstock strings - vertical */
  .headstock-string {
    left: calc(var(--y) - 1px);
    right: auto;
    top: 62px;
    bottom: 0;
    width: 1.4px;
    height: auto;
    background: linear-gradient(90deg, #555, #d8d8d8 45%, #d8d8d8 55%, #555);
  }
  .headstock-string.s-1 { width: 1px; }
  .headstock-string.s-2 { width: 1.4px; }
  .headstock-string.s-3 { width: 1.8px; }
  .headstock-string.s-4 {
    width: 2.4px;
    background:
      repeating-linear-gradient(0deg, rgba(0,0,0,0.45) 0, transparent 1px, transparent 2px),
      linear-gradient(90deg, var(--string-wound-2), var(--string-wound-1) 50%, var(--string-wound-2));
  }
  .headstock-string.s-5 {
    width: 3px;
    background:
      repeating-linear-gradient(0deg, rgba(0,0,0,0.5) 0, transparent 1px, transparent 2.2px),
      linear-gradient(90deg, var(--string-wound-2), var(--string-wound-1) 50%, var(--string-wound-2));
  }
  .headstock-string.s-6 {
    width: 4px;
    background:
      repeating-linear-gradient(0deg, rgba(0,0,0,0.55) 0, transparent 1.2px, transparent 2.5px),
      linear-gradient(90deg, #5a4422, #b89252 50%, #5a4422);
  }

  /* Fretboard - vertical orientation, wood grain rotated */
  .fretboard {
    border-radius: 0 0 8px 8px;
    border: 2px solid #1a0d05;
    border-top: none;
    border-left: 2px solid #1a0d05;
    background:
      repeating-linear-gradient(90deg,
        transparent 0,
        rgba(0, 0, 0, 0.04) 1px,
        transparent 2px,
        transparent 4px),
      repeating-linear-gradient(180deg,
        transparent 0,
        rgba(255, 220, 170, 0.025) 2px,
        transparent 4px,
        rgba(0, 0, 0, 0.08) 7px,
        transparent 9px,
        transparent 18px),
      linear-gradient(90deg, #58311a 0%, #3d2010 45%, #2d150a 100%);
  }

  /* Nut - horizontal bar at top of fretboard */
  .nut {
    left: 0;
    right: 0;
    top: 0;
    bottom: auto;
    width: auto;
    height: 10px;
    background:
      linear-gradient(180deg,
        rgba(0,0,0,0.4) 0%,
        rgba(255,255,255,0) 15%,
        transparent 85%,
        rgba(0,0,0,0.4) 100%),
      linear-gradient(90deg, var(--bone) 0%, var(--bone-dim) 45%, var(--bone) 55%, #a8a085 100%);
    box-shadow:
      inset 0 -2px 4px rgba(0, 0, 0, 0.4),
      0 3px 6px rgba(0, 0, 0, 0.5);
  }

  /* Fret wires - horizontal */
  .fret {
    left: 0;
    right: 0;
    top: calc(var(--x) - 2px);
    bottom: auto;
    width: auto;
    height: 4px;
    background:
      linear-gradient(90deg,
        #6a6a6a 0%,
        #d8d8d8 20%,
        #f5f5f5 50%,
        #c8c8c8 80%,
        #5a5a5a 100%);
    box-shadow:
      0 -1px 3px rgba(0, 0, 0, 0.6),
      0 1px 3px rgba(0, 0, 0, 0.6),
      inset 0 0 1px rgba(255, 255, 255, 0.6);
  }

  /* Inlays - swap axes */
  .inlay {
    left: var(--y);
    top: var(--x);
  }

  /* Strings - vertical */
  .string {
    left: calc(var(--y) - 1px);
    right: auto;
    top: 0;
    bottom: 0;
    width: 1.4px;
    height: auto;
    background: linear-gradient(90deg, #555, #f0f0f0 45%, #f0f0f0 55%, #555);
  }
  .string.s-1 { width: 1px; height: auto; }
  .string.s-2 { width: 1.4px; height: auto; }
  .string.s-3 { width: 1.8px; height: auto; }
  .string.s-4 {
    width: 2.4px; height: auto;
    background:
      repeating-linear-gradient(0deg, rgba(0,0,0,0.5) 0, transparent 1px, transparent 2px),
      linear-gradient(90deg, var(--string-wound-2), var(--string-wound-1) 50%, var(--string-wound-2));
  }
  .string.s-5 {
    width: 3.2px; height: auto;
    background:
      repeating-linear-gradient(0deg, rgba(0,0,0,0.55) 0, transparent 1.2px, transparent 2.4px),
      linear-gradient(90deg, var(--string-wound-2), var(--string-wound-1) 50%, var(--string-wound-2));
  }
  .string.s-6 {
    width: 4.2px; height: auto;
    background:
      repeating-linear-gradient(0deg, rgba(0,0,0,0.6) 0, transparent 1.5px, transparent 3px),
      linear-gradient(90deg, #4a3618, #b8924c 50%, #4a3618);
  }

  /* Click targets - swap axes, larger for fingers */
  .fret-position {
    left: var(--y);
    top: var(--x);
    width: 44px;
    height: 38px;
  }
  /* Open string targets - now at bottom of headstock (near the nut) */
  .fret-position.open-string {
    left: var(--y);
    top: calc(100% - 22px);
  }

  /* Hide fret-numbers row on mobile */
  .fret-numbers { display: none; }

  /* Controls */
  .controls { flex-wrap: wrap; gap: 10px; padding: 4px 0 8px; }
  .btn { padding: 10px 18px; font-size: 14px; }
  .btn-ghost { padding: 8px 14px; font-size: 12px; }
}

/* ===================== Controls ===================== */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 8px 0 4px;
}

.btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 12px 24px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, #3a2818, #221408);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease-out;
  letter-spacing: 1px;
}

.btn:hover {
  background: linear-gradient(180deg, #4a3220, #2c1c10);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(180deg, #d4a548, #a07820);
  color: #1a0f04;
  font-weight: 600;
  border-color: rgba(255, 220, 120, 0.5);
  box-shadow: 0 4px 12px rgba(160, 120, 32, 0.4);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #e8b758, #b48830);
  box-shadow: 0 6px 16px rgba(160, 120, 32, 0.55);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-dim);
  font-size: 13px;
  padding: 10px 18px;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.btn-large {
  padding: 14px 32px;
  font-size: 16px;
}

/* Mode switch */
.mode-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 14px;
}
.mode-switch input { display: none; }
.switch-track {
  width: 44px;
  height: 24px;
  background: #2a1c10;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #c0b090, #807060);
  box-shadow: 0 1px 3px rgba(0,0,0,0.6);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.mode-switch input:checked + .switch-track {
  background: linear-gradient(180deg, #6a4a20, #4a3010);
  border-color: rgba(241, 199, 90, 0.4);
}
.mode-switch input:checked + .switch-track .switch-thumb {
  transform: translateX(20px);
  background: linear-gradient(180deg, var(--gold), #a07a30);
}
.mode-switch:hover .switch-label { color: var(--text); }

/* ===================== Overlay ===================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 6, 4, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.25s ease-out;
}
.overlay[hidden] { display: none; }

.overlay-card {
  background: linear-gradient(180deg, #2a1d10, #1a1008);
  border: 1px solid rgba(241, 199, 90, 0.3);
  border-radius: 16px;
  padding: 40px 56px;
  text-align: center;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.8),
    0 0 60px rgba(241, 199, 90, 0.1);
  animation: cardIn 0.35s cubic-bezier(0.4, 1.4, 0.6, 1);
}

.overlay-title {
  font-family: "Georgia", serif;
  font-size: 42px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 16px;
  text-shadow: 0 0 20px rgba(241, 199, 90, 0.4);
}

.overlay-message {
  font-size: 18px;
  color: var(--text);
  margin-bottom: 28px;
  line-height: 1.6;
}
.overlay-message strong {
  font-size: 28px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.record-prev {
  color: var(--text-dim);
  font-size: 14px;
}
.new-record {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 12px;
  background: linear-gradient(135deg, #f1c75a, #c89638);
  color: #1a0f04;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===================== Overlay buttons ===================== */
.overlay-buttons {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===================== Start screen ===================== */
.start-screen {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 0%, #2c1f15 0%, transparent 55%),
    radial-gradient(ellipse at 70% 100%, #1a0f08 0%, transparent 55%),
    linear-gradient(180deg, #0d0805 0%, #050302 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 200;
  padding: 60px 20px 40px;
  animation: fadeIn 0.3s ease-out;
  overflow-y: auto;
}
.start-screen[hidden] { display: none; }

.start-card {
  max-width: 880px;
  width: 100%;
  text-align: center;
  padding: 40px 20px;
  animation: cardIn 0.45s cubic-bezier(0.4, 1.4, 0.6, 1);
}

.start-eyebrow {
  font-size: 12px;
  letter-spacing: 8px;
  color: var(--gold);
  opacity: 0.75;
  margin-bottom: 16px;
}

.start-title {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 54px);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  letter-spacing: 4px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

.start-subtitle {
  font-size: 16px;
  color: var(--text-dim);
  margin-bottom: 46px;
  letter-spacing: 1px;
}

.start-instruction {
  font-size: 13px;
  letter-spacing: 6px;
  color: var(--text-dim);
  margin-bottom: 24px;
  text-transform: uppercase;
}

.mode-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  max-width: 780px;
  margin: 0 auto;
}

.mode-card {
  position: relative;
  background:
    repeating-linear-gradient(90deg,
      transparent 0,
      rgba(255, 220, 170, 0.025) 2px,
      transparent 4px,
      rgba(0, 0, 0, 0.08) 7px,
      transparent 9px,
      transparent 18px),
    linear-gradient(180deg, #3a2515 0%, #25160a 100%);
  border: 1px solid rgba(241, 199, 90, 0.14);
  border-radius: 14px;
  padding: 32px 24px 28px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: all 0.22s ease-out;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.55),
    inset 0 0 30px rgba(0, 0, 0, 0.45);
}

.mode-card:hover {
  transform: translateY(-4px);
  border-color: rgba(241, 199, 90, 0.55);
  box-shadow:
    0 18px 36px rgba(0, 0, 0, 0.65),
    inset 0 0 40px rgba(241, 199, 90, 0.06),
    0 0 30px rgba(241, 199, 90, 0.18);
}
.mode-card:hover .mode-card-title {
  text-shadow: 0 0 20px rgba(241, 199, 90, 0.4);
}

.mode-card:active { transform: translateY(-2px); }

.mode-card-tag {
  display: inline-block;
  padding: 4px 12px;
  font-size: 10px;
  letter-spacing: 4px;
  border-radius: 999px;
  background: rgba(95, 217, 122, 0.15);
  border: 1px solid rgba(95, 217, 122, 0.35);
  color: var(--green);
  margin-bottom: 18px;
}
.mode-card-tag-pro {
  background: rgba(241, 199, 90, 0.15);
  border-color: rgba(241, 199, 90, 0.45);
  color: var(--gold);
}

.mode-card-title {
  font-family: "Georgia", serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 14px;
  transition: text-shadow 0.22s;
}

.mode-card-notes {
  font-family: "Georgia", serif;
  font-size: 14px;
  color: var(--text);
  letter-spacing: 1px;
  margin-bottom: 14px;
  opacity: 0.92;
  line-height: 1.6;
}

.mode-card-desc {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 3px;
  text-transform: uppercase;
}

@media (max-width: 700px) {
  .mode-options { grid-template-columns: 1fr; }
  .start-title { letter-spacing: 2px; }
}

/* ===================== Mobile guard (basic) ===================== */
@media (max-width: 900px) {
  .target-note { font-size: 56px; }
  .stat-value { font-size: 22px; }
  .stats { gap: 22px; }
}
/* Narrow horizontal layout — only in landscape so it does not
   override the portrait full-width headstock above. */
@media (max-width: 900px) and (orientation: landscape) {
  .headstock { width: 110px; }
  .fret-numbers { padding-left: 110px; }
}

/* ===================== Tablet (768–1100) — keep horizontal ===================== */
@media (min-width: 769px) and (max-width: 1100px) {
  .guitar { height: clamp(240px, 40vh, 320px); }
  .target-note { font-size: 64px; }
  .stat-value { font-size: 26px; }
  .headstock { width: 130px; }
  .fret-numbers { padding-left: 130px; }
  .app { padding: 18px 24px; }
}

/* ===================== Mobile landscape / short height ===================== */
@media (max-height: 520px) and (orientation: landscape) {
  .app {
    gap: 8px;
    padding: 10px 16px;
  }
  .topbar { padding: 0; }
  .target-note { font-size: 42px; }
  .target-label { font-size: 13px; letter-spacing: 1px; }
  .stat-value { font-size: 18px; }
  .stat-label { font-size: 9px; letter-spacing: 2px; margin-bottom: 0; }
  .stats { gap: 18px; }
  .guitar { height: clamp(160px, 54vh, 260px); }
  .headstock { width: 90px; }
  .fret-numbers { padding-left: 90px; height: 14px; }
  .fret-num { font-size: 9px; }
  .controls { padding: 0; gap: 14px; }
  .btn { padding: 7px 14px; font-size: 12px; letter-spacing: 0.5px; }
  .btn-ghost { padding: 5px 10px; font-size: 11px; }
  .sound-toggle { width: 32px; height: 32px; margin-left: 8px; }
  .sound-toggle svg { width: 14px; height: 14px; }
  /* tighter fret-position circles so they don't clash on small height */
  .fret-position { width: 28px; height: 26px; font-size: 11px; }
  .fret-position.open-string:not(.found):not(.wrong)::after {
    width: 16px; height: 16px;
  }
}

/* ===================== Accessibility ===================== */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip-to-content link — visible only on keyboard focus */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--gold);
  color: #1a0f04;
  padding: 10px 16px;
  font-weight: 600;
  text-decoration: none;
  z-index: 1000;
  border-radius: 0 0 8px 0;
}
.skip-link:focus {
  left: 0;
  outline: none;
}

/* Honor users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .start-screen, .overlay, .cookie-banner {
    animation: none !important;
  }
}

/* ===================== Start screen scrollable ===================== */
.start-screen {
  overflow-y: auto;
}
.start-card {
  padding-bottom: 80px;
}

/* Language switcher inside start screen */
.start-lang {
  position: absolute;
  top: 20px;
  right: 24px;
  z-index: 2;
  max-width: calc(100% - 48px);
}
@media (max-width: 420px) {
  .start-lang { top: 12px; right: 14px; }
}
.lang-switcher {
  background: rgba(20, 12, 6, 0.7);
  border: 1px solid rgba(241, 199, 90, 0.25);
  color: var(--text);
  padding: 6px 28px 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%23a09080' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 8px;
  transition: border-color 0.2s;
}
.lang-switcher:hover {
  border-color: rgba(241, 199, 90, 0.55);
}
.lang-switcher option { background: #1a0f08; color: var(--text); }

/* ===================== Info sections (About / How / FAQ) ===================== */
.info-section {
  max-width: 720px;
  margin: 48px auto 0;
  text-align: left;
  padding: 0 8px;
}
.info-title {
  font-family: "Georgia", serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 14px;
  letter-spacing: 1px;
}
.info-text {
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
  opacity: 0.9;
}
.info-list {
  list-style: decimal inside;
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
  opacity: 0.92;
  padding-left: 4px;
}
.info-list li {
  margin-bottom: 8px;
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.note-pill {
  display: block;
  padding: 12px 10px;
  text-align: center;
  background: linear-gradient(180deg, #3a2515 0%, #25160a 100%);
  border: 1px solid rgba(241, 199, 90, 0.18);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-family: "Georgia", serif;
  font-size: 16px;
  transition: all 0.15s;
}
.note-pill:hover {
  border-color: rgba(241, 199, 90, 0.55);
  color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.4);
}

.faq-item {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 0;
}
.faq-item:last-child { border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.faq-item summary {
  cursor: pointer;
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.5px;
  list-style: none;
  padding-right: 24px;
  position: relative;
  transition: color 0.15s;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  font-size: 20px;
  font-weight: 300;
  transition: transform 0.2s;
}
.faq-item[open] summary::after {
  content: '−';
}
.faq-item summary:hover { color: var(--gold); }
.faq-item p {
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.7;
}

/* ===================== Site footer ===================== */
.site-footer {
  max-width: 720px;
  margin: 56px auto 0;
  padding: 24px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}
.site-footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  font-size: 13px;
  color: var(--text-dim);
}
.site-footer-row a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
}
.site-footer-row a:hover {
  color: var(--gold);
}
.site-footer-row-sub {
  margin-top: 10px;
  font-size: 11px;
  letter-spacing: 2px;
  opacity: 0.6;
}

/* ===================== Cookie banner ===================== */
.cookie-banner {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  max-width: 600px;
  margin: 0 auto;
  padding: 14px 18px;
  background: linear-gradient(180deg, #2a1d10, #1a1008);
  border: 1px solid rgba(241, 199, 90, 0.3);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 250;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  animation: slideUp 0.3s ease-out;
}
.cookie-banner[hidden] { display: none; }
.cookie-msg {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  opacity: 0.88;
  line-height: 1.5;
}
.cookie-banner .btn {
  padding: 8px 18px;
  font-size: 13px;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Mobile adjustments for info sections, footer, cookie */
@media (max-width: 768px) and (orientation: portrait) {
  .info-section { margin-top: 32px; padding: 0 4px; }
  .info-title { font-size: 19px; }
  .info-text, .info-list { font-size: 14px; }
  .site-footer { margin-top: 40px; }
  .site-footer-row { gap: 14px; font-size: 12px; }
  .cookie-banner {
    flex-direction: column;
    bottom: 8px; left: 8px; right: 8px;
    padding: 12px 14px;
    align-items: stretch;
  }
  .cookie-banner .btn { width: 100%; }
}
/* Push the bottom controls up so the cookie banner doesn't cover them (mobile) */
@media (max-width: 768px) {
  body:has(.cookie-banner:not([hidden])) .controls {
    padding-bottom: 96px;
  }
}
