body { font-family: Inter, sans-serif; }

.tool-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 3px 12px rgba(0,0,0,.04);
}

/* ── Mode buttons ── */
.mode-btn {
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #6b7280;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.mode-btn.active {
  background: #fff;
  color: #92400e;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}

/* ── Reverb toggle ── */
.reverb-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 1px;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 3px;
}
.reverb-btn {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #6b7280;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.reverb-btn.active {
  background: #fff;
  color: #92400e;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}

/* ── Scale selects ── */
.scale-select {
  font-size: 0.72rem;
  font-weight: 600;
  color: #374151;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.scale-select:focus { border-color: #d97706; }

/* ── Tuba body wrapper — polished brass ── */
.tuba-body {
  position: relative;
  background: linear-gradient(160deg, #7a5a14 0%, #3d2c06 45%, #1e1503 100%);
  border-radius: 1rem;
  padding: 14px 16px 18px;
  box-shadow:
    inset 0 2px 10px rgba(255, 210, 90, 0.14),
    inset 0 -4px 22px rgba(0,0,0,0.5),
    0 8px 32px rgba(0,0,0,0.24);
}
.tuba-body::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(255, 220, 120, 0.12) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 100%, rgba(255, 180, 40, 0.06) 0%, transparent 50%);
  pointer-events: none;
  border-radius: 1rem;
}

/* ── Instrument view (default) ── */
#instrumentView,
#keyboardView {
  position: relative;
  z-index: 1;
}
[hidden] { display: none !important; }

.tuba-svg-wrap {
  position: relative;
  width: 100%;
  max-width: clamp(240px, 48vw, 420px);
  margin: 0 auto 4px;
  display: block;
}
.tuba-art {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}
.bell-flash {
  position: absolute;
  left: 0;
  top: 4%;
  width: 24%;
  height: 78%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255,248,192,0.95), rgba(255,248,192,0) 72%);
  opacity: 0;
  transition: opacity 0.18s ease-out;
  pointer-events: none;
}
.bell-flash.on {
  opacity: 0.5;
  transition: opacity 0.04s ease-out;
}
.bell-puff {
  position: absolute;
  left: 9%;
  top: 37%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 1.5px solid #d4a030;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
.bell-puff.go {
  animation: tubaPuff 0.5s ease-out forwards;
}
@keyframes tubaPuff {
  0% { opacity: 0.7; transform: scale(0.35); }
  100% { opacity: 0; transform: scale(3.4); }
}

.tuba-note-display {
  text-align: center;
  padding: 4px 0 2px;
  position: relative;
  z-index: 1;
}
.tuba-note-name {
  font-size: 1.4rem;
  font-weight: 700;
  color: #e8c040;
  line-height: 1;
  letter-spacing: 0.04em;
  min-height: 1.4rem;
  transition: color 0.08s;
  text-shadow: 0 2px 8px rgba(0,0,0,0.45);
}
.tuba-note-name.playing { color: #fde68a; }
.tuba-note-meta {
  font-size: 0.66rem;
  color: #c8a860;
  margin-top: 3px;
  min-height: 1rem;
  letter-spacing: 0.06em;
}

/* ── Note grid: all 35 notes G1–F4 (responsive) ── */
.tuba-keys {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(3px, 0.8vw, 6px);
  width: 100%;
  max-width: 560px;
  margin: 10px auto 0;
  position: relative;
  z-index: 1;
}
.tuba-key {
  aspect-ratio: 1;
  width: 100%;
  border: 1.5px solid #8a7030;
  border-radius: 7px;
  background: linear-gradient(160deg, #f7efd8 0%, #e6d8b0 100%);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: background 0.07s, border-color 0.07s, transform 0.07s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  padding: 2px;
  box-sizing: border-box;
}
.tuba-key:hover {
  border-color: #f2da78;
  background: linear-gradient(160deg, #fdf3d8 0%, #f3e2b0 100%);
}
.tuba-key.active {
  background: linear-gradient(160deg, #f8d870 0%, #d8a020 100%);
  border-color: #f2da78;
  transform: scale(0.93);
}
.tuba-key.active .key-note-lbl { color: #78350f; }
.tuba-key.active .key-char-lbl { color: #92400e; }

/* Accidentals: dark brass buttons */
.tuba-key.accidental {
  background: linear-gradient(160deg, #4a3a10 0%, #171004 100%);
  border-color: #0a0700;
}
.tuba-key.accidental:hover {
  background: linear-gradient(160deg, #6a5018 0%, #241a06 100%);
}
.tuba-key.accidental.active {
  background: linear-gradient(160deg, #c89828 0%, #7a5810 100%);
}
.tuba-key.accidental .key-note-lbl { color: rgba(255,225,150,0.92); }
.tuba-key.accidental .key-char-lbl { color: rgba(255,255,255,0.28); }
.tuba-key.accidental.active .key-note-lbl { color: #fffbeb; }
.tuba-key.accidental.active .key-char-lbl { color: rgba(255,255,255,0.6); }

.tuba-key.dimmed { opacity: 0.28; }

.key-char-lbl {
  font-size: 7px;
  color: #a89060;
  font-weight: 500;
  line-height: 1;
  min-height: 7px;
}
.key-note-lbl {
  font-size: 10px;
  font-weight: 700;
  color: #44403c;
  line-height: 1;
}

/* ── Bell flash overlay ── */
#bell-flash {
  pointer-events: none;
  mix-blend-mode: screen;
}

/* ── Fullscreen button ── */
.fullscreen-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  background: #f9fafb;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  margin-left: auto;
}
.fullscreen-btn:hover {
  background: #fff;
  color: #92400e;
  border-color: #fcd34d;
}
.fullscreen-btn svg {
  width: 15px;
  height: 15px;
  pointer-events: none;
}
.tool-card.is-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  border-radius: 0 !important;
  max-width: 100vw !important;
  width: 100vw !important;
  height: 100dvh !important;
  overflow-y: auto !important;
  margin: 0 !important;
  padding: 1.5rem !important;
  box-sizing: border-box !important;
}

/* ── Mobile ── */
@media (max-width: 639px) {
  .tuba-svg-wrap { max-width: clamp(220px, 78vw, 340px); }
  .tuba-keys { grid-template-columns: repeat(5, 1fr); gap: clamp(3px, 1.2vw, 5px); max-width: 100%; }
  .key-note-lbl { font-size: clamp(8px, 2.4vw, 11px); }
  .key-char-lbl { font-size: clamp(6px, 1.8vw, 8px); min-height: 6px; }
  .tuba-note-name { font-size: clamp(1.1rem, 4vw, 1.4rem); min-height: 1.4rem; }
}

/* ── Piano keyboard scroll wrapper ── */
.piano-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,220,120,0.25) transparent;
  padding-bottom: 4px;
  position: relative;
  z-index: 1;
}
.piano-scroll::-webkit-scrollbar { height: 4px; }
.piano-scroll::-webkit-scrollbar-track { background: transparent; }
.piano-scroll::-webkit-scrollbar-thumb { background: rgba(255,220,120,0.25); border-radius: 2px; }

.piano-keys {
  position: relative;
  display: flex;
  align-items: stretch;
  width: max-content;
}

/* ── White keys ── */
.key-white {
  position: relative;
  flex-shrink: 0;
  background: linear-gradient(180deg, #f3ead2 0%, #d4c49a 100%);
  border-left: 1px solid #a89060;
  border-bottom: 1px solid #a89060;
  border-right: none;
  border-top: none;
  border-radius: 0 0 5px 5px;
  box-shadow: inset -1px 0 0 rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.35);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.06s, transform 0.06s;
  box-sizing: border-box;
  z-index: 1;
}
.key-white:last-child { border-right: 1px solid #a89060; }
.key-white:active,
.key-white.struck {
  background: linear-gradient(180deg, #f8d870 0%, #d8a020 100%);
  transform: scaleY(0.985) translateY(1px);
}
.key-white.dimmed { opacity: 0.28; }

/* ── Black keys ── */
.key-black {
  position: absolute;
  top: 0;
  background: linear-gradient(180deg, #4a3a10 0%, #171004 100%);
  border: 1px solid #0a0700;
  border-top: none;
  border-radius: 0 0 4px 4px;
  box-shadow: 2px 5px 8px rgba(0,0,0,0.75), inset 1px 0 1px rgba(255,230,140,0.10);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.06s, transform 0.06s;
  z-index: 2;
  box-sizing: border-box;
}
.key-black:active,
.key-black.struck {
  background: linear-gradient(180deg, #c89828 0%, #7a5810 100%);
  transform: scaleY(0.97) translateY(1px);
}
.key-black.dimmed { opacity: 0.28; }

/* ── Key labels ── */
.key-lbl {
  position: absolute;
  bottom: 5px;
  left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  gap: 1px;
}
.lbl-note { font-size: 6px;  font-weight: 700; line-height: 1.1; }
.lbl-kb   { font-size: 5px;  font-family: monospace; line-height: 1.1; }

.key-white .lbl-note { color: rgba(60,40,5,0.82); }
.key-white .lbl-kb   { color: rgba(90,60,10,0.32); }
.key-black .lbl-note { color: rgba(255,225,150,0.90); }
.key-black .lbl-kb   { color: rgba(255,255,255,0.24); }

/* ── Loading bar ── */
.loading-bar {
  background: #f3f4f6;
  border-radius: 6px;
  height: 6px;
  overflow: hidden;
}
.loading-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, #d97706, #f59e0b);
  border-radius: 6px;
  width: 0%;
  transition: width 0.3s ease;
}
.loading-bar.done { display: none; }

/* ── Ripple ── */
.key-ripple {
  position: fixed;
  border-radius: 4px;
  pointer-events: none;
  z-index: 50;
  animation: keyRip 0.35s ease-out forwards;
}
/* In-key ripple: absolute within the piano key (no layout thrash from fixed+body) */
.key-ripple.in-key {
  position: absolute;
  z-index: 5;
}
@keyframes keyRip {
  from { opacity: 0.5; transform: scale(1); }
  to   { opacity: 0;   transform: scale(1.6); }
}

tbody tr:nth-child(even) { background: #f9fafb; }
