:root {
  --primary-color: #ff6b35;
  --glow-color: rgba(255, 107, 53, 0.6);
  --glow-border: rgba(255, 107, 53, 0.12);
  --deep-obsidian: #1a1a1a;
  --surface-dark: #2d2d2d;
  --text-light: #fafbfc;
  /* key size variables */
  --white-key-width: 58px;
  --white-key-height: 220px;
  --black-key-width: 38px;
  --black-key-height: 132px;
}

/* THEME VARIANTS */
body[data-theme="purple"] {
  --primary-color: #9b59b6;
  --glow-color: rgba(155, 89, 182, 0.6);
  --glow-border: rgba(155, 89, 182, 0.12);
}

body[data-theme="red"] {
  --primary-color: #e74c3c;
  --glow-color: rgba(231, 76, 60, 0.6);
  --glow-border: rgba(231, 76, 60, 0.12);
}

body[data-theme="black"] {
  --primary-color: #ffffff;
  --glow-color: rgba(255, 255, 255, 0.4);
  --glow-border: rgba(255, 255, 255, 0.09);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Inter", sans-serif;
  user-select: none;
}

body {
  background-color: var(--deep-obsidian);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-light);
}

/* ========================================
   MANDATORY LANDSCAPE ROTATE OVERLAY
   ======================================== */
.rotate-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 40px 24px;
  text-align: center;
}

.rotate-overlay .msg {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-light);
  max-width: 320px;
  line-height: 1.6;
}

.rotate-overlay::before {
  content: "";
  width: 80px;
  height: 120px;
  border: 4px solid var(--primary-color);
  border-radius: 12px;
  position: relative;
  animation: rotatePhone 2s ease-in-out infinite;
}

.rotate-overlay::after {
  content: "↻";
  font-size: 2.5rem;
  color: var(--primary-color);
  animation: rotateArrow 2s ease-in-out infinite;
  margin-top: -16px;
}

@keyframes rotatePhone {
  0%,
  100% {
    transform: rotate(0deg);
  }

  25%,
  75% {
    transform: rotate(-90deg);
  }
}

@keyframes rotateArrow {
  0%,
  100% {
    opacity: 1;
    transform: rotate(0deg);
  }

  50% {
    opacity: 0.5;
    transform: rotate(180deg);
  }
}

/* Show overlay ONLY on mobile portrait */
@media screen and (max-width: 900px) and (orientation: portrait) {
  .rotate-overlay {
    display: flex !important;
  }

  .app-container {
    filter: blur(8px);
    pointer-events: none;
  }
}

/* Hide overlay in landscape or on desktop */
@media screen and (orientation: landscape), screen and (min-width: 901px) {
  .rotate-overlay {
    display: none !important;
  }
}

.app-container {
  background: var(--surface-dark);
  padding: 20px 18px;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  border: 1px solid #404040;
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 8px;
  max-height: calc(100vh - 24px);
  /* keep the entire app inside the viewport */
}

.synth-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid #404040;
  padding-bottom: 15px;
}

.brand-name {
  font-size: 1.5rem;
  font-weight: 700;
}

.brand-name .accent {
  color: var(--primary-color);
}

/* SHARE BUTTON */
.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.share-btn {
  background: transparent;
  border: 1.5px solid var(--primary-color);
  color: var(--primary-color);
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 0.85;
}

.share-btn:hover {
  background: var(--primary-color);
  color: #fff;
  opacity: 1;
  transform: scale(1.05);
  box-shadow: 0 4px 15px var(--glow-color);
}

.share-btn:active {
  transform: scale(0.95);
}

.share-btn svg {
  display: block;
}

/* THEME DOTS */
.theme-selector {
  display: flex;
  gap: 10px;
}

.dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s;
}

.dot:hover {
  transform: scale(1.2);
}

.dot.active {
  border-color: white;
  box-shadow: 0 0 8px var(--primary-color);
}

.dot.orange {
  background: #ff6b35;
}

.dot.purple {
  background: #9b59b6;
}

.dot.red {
  background: #ffaba1;
}

.dot.black {
  background: #eee;
}

/* VISUALIZER */
.viz-container {
  margin-bottom: 20px;
  background: #000;
  border-radius: 8px;
  border: 1px solid #333;
  overflow: hidden;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* VISUAL DASHBOARD: Left (key display), Center (visualizer), Right (recording) */
.visual-dashboard {
  display: flex;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 8px;
  min-height: 10vh;
  max-height: 26vh;
  border-radius: 10px;
  border: 2px solid var(--glow-border);
  padding: 12px 10px;
}

.visual-dashboard .viz-left,
.visual-dashboard .viz-right {
  flex: 2 1 0;
  min-width: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 10px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(0, 0, 0, 0.03)
  );
  border-radius: 8px;
  border: 1px solid var(--glow-border);
}

.visual-dashboard .viz-center {
  flex: 6 1 0;
  min-width: 220px;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
  position: relative;
  /* allow absolute overlay inside */
}

/* Make the central visualizer fill the full height like the side panels, with a subtle theme border */
.visual-dashboard .viz-center.viz-container {
  border: 1.6px solid var(--glow-border);
  padding: 0;
  background: #000;
  display: flex;
  align-items: stretch;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
}

.visual-dashboard .viz-center.viz-container canvas {
  width: 100% !important;
  height: 100% !important;
}

.visual-dashboard > .viz-left,
.visual-dashboard > .viz-center,
.visual-dashboard > .viz-right {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.visual-dashboard > .viz-left {
  border-right: 1px solid var(--glow-border);
}

.visual-dashboard > .viz-right {
  border-left: 1px solid var(--glow-border);
}

.visual-dashboard .viz-left,
.visual-dashboard .viz-right,
.visual-dashboard .viz-center {
  transition: border-color 0.18s, box-shadow 0.18s;
}

.visual-dashboard .viz-left:hover,
.visual-dashboard .viz-center:hover,
.visual-dashboard .viz-right:hover {
  box-shadow: 0 10px 25px -18px var(--glow-color);
  border-color: var(--glow-color);
}

.pressed-key-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ddd;
  gap: 6px;
}

.viz-overlay {
  position: absolute;
  /* overlay on top of canvas */
  inset: 0;
  /* top/right/bottom/left: 0 */
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  /* don't block canvas input */
  opacity: 0;
  transition: opacity 220ms ease, transform 220ms ease;
  transform: translateY(8px);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.2));
  backdrop-filter: blur(2px);
  border-radius: 6px;
}

.viz-overlay.visible {
  opacity: 1;
  transform: translateY(0);
}

.viz-overlay span:first-child {
  font-size: 1rem;
  color: #ccc;
}

.viz-overlay span:last-child {
  font-size: 1.35rem;
  color: var(--primary-color);
  letter-spacing: 1px;
}

.pressed-key-letter {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--primary-color);
}

.pressed-key-letter.active {
  transform: scale(1.05);
  text-shadow: 0 6px 20px var(--glow-color);
}

.pressed-key-note {
  font-size: 0.9rem;
  color: #999;
}

.record-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #ddd;
}

#record-status {
  font-weight: 700;
  text-transform: none;
}

#record-status.recording {
  color: #ff4444;
}

#record-timer {
  font-size: 0.9rem;
  color: #aaa;
}

/* DASHBOARD */
.dashboard {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 25px;
  background: #222;
  padding: 15px;
  border-radius: 12px;
  align-items: flex-end;
  justify-content: space-between;
  width: 100%;
}

.control-group {
  flex: 1 1 auto;
  min-width: fit-content;
}

.control-group label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 6px;
  font-weight: 600;
}

input[type="range"] {
  accent-color: var(--primary-color);
  cursor: pointer;
}

.toggle-switch {
  display: flex;
  background: #111;
  border-radius: 6px;
  padding: 2px;
}

.tone-btn {
  background: transparent;
  border: none;
  color: #888;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 4px;
}

.tone-btn.active {
  background: var(--surface-dark);
  color: var(--primary-color);
  font-weight: 600;
}

.tone-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.45);
}

.octave-controls {
  display: flex;
  align-items: center;
  background: #111;
  padding: 4px;
  border-radius: 5px;
}

.octave-btn {
  background: #333;
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  cursor: pointer;
  border-radius: 4px;
}

.octave-btn:hover {
  background: var(--primary-color);
}

.octave-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.45);
}

#octave-display {
  width: 35px;
  text-align: center;
  font-size: 0.8rem;
}

/* ========================================
   PROFESSIONAL RECORD/STOP BUTTONS
   ======================================== */
.record-controls-pro {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Record Button - Circular Red */
.record-btn-pro {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #444;
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.05);
}

.record-btn-pro:hover:not(:disabled) {
  border-color: #ff4444;
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(255, 68, 68, 0.3);
}

.record-btn-pro:active:not(:disabled) {
  transform: scale(0.95);
}

/* The red circle icon inside */
.record-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ff4444, #cc0000);
  box-shadow: 0 2px 8px rgba(255, 68, 68, 0.5);
  transition: all 0.2s ease;
}

.record-btn-pro:hover:not(:disabled) .record-icon {
  background: linear-gradient(145deg, #ff6666, #ff4444);
  box-shadow: 0 2px 12px rgba(255, 68, 68, 0.7);
}

/* Pulsing ring when recording */
.record-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #ff4444;
  opacity: 0;
  transition: all 0.3s ease;
}

/* Recording state */
.record-btn-pro.recording {
  border-color: #ff4444;
  box-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
}

.record-btn-pro.recording .record-ring {
  opacity: 1;
  animation: pulse-ring 1.5s ease-in-out infinite;
}

.record-btn-pro.recording .record-icon {
  animation: pulse-glow 1s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.15);
    opacity: 0.3;
  }
}

@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.5);
  }

  50% {
    box-shadow: 0 2px 20px rgba(255, 68, 68, 0.9);
  }
}

/* Stop Button - Square Icon */
.stop-btn-pro {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid #444;
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.stop-btn-pro:hover:not(:disabled) {
  border-color: #888;
  background: linear-gradient(145deg, #333, #222);
  transform: scale(1.05);
}

.stop-btn-pro:active:not(:disabled) {
  transform: scale(0.95);
}

/* The square stop icon */
.stop-icon {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: #888;
  transition: all 0.2s ease;
}

.stop-btn-pro:hover:not(:disabled) .stop-icon {
  background: #fff;
}

/* Disabled states */
.record-btn-pro:disabled,
.stop-btn-pro:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.record-btn-pro:disabled .record-icon {
  background: linear-gradient(145deg, #666, #444);
  box-shadow: none;
}

/* Legacy support for old button classes */
.rec-controls,
.record-controls {
  display: flex;
  gap: 10px;
}

.rec-btn,
.record-btn {
  border: none;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: white;
  transition: all 0.2s;
}

.rec-btn.record,
.record-btn.record {
  background: #2a2a2a;
  border: 1px solid #cc0000;
  color: #ff4444;
}

.rec-btn.record:hover,
.record-btn.record:hover {
  background: #cc0000;
  color: white;
}

.rec-btn.record.recording,
.record-btn.record.recording {
  background: #cc0000;
  color: white;
  animation: pulse 1.5s infinite;
}

.record-btn[disabled],
.stop-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.rec-btn.stop,
.stop-btn {
  background: #333;
  color: #888;
}

.rec-btn.stop:not(:disabled):hover,
.stop-btn:not(:disabled):hover {
  background: #444;
  color: white;
}

@keyframes pulse {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }

  100% {
    opacity: 1;
  }
}

/* PIANO KEYS */
.piano-wrapper {
  display: flex;
  justify-content: center;
  background: #111;
  padding: 10px 4px;
  border-radius: 8px;
  box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  /* No scrolling - all keys must fit in viewport */
  height: 100%;
  /* fill the grid row height */
  width: 100%;
  /* ensure full width utilization */
}

.piano-keys-list {
  display: flex;
  list-style: none;
  position: relative;
  justify-content: center;
  width: 100%;
  /* Keys will fill available space */
}

/* Mobile: Keys fit to viewport - NO SCROLLING */
@media (max-width: 900px) {
  .piano-wrapper {
    justify-content: center;
    overflow: hidden;
    min-height: calc(var(--white-key-height) + 16px);
    padding: 6px 2px;
  }

  .piano-keys-list {
    width: 100%;
    justify-content: center;
    gap: 0;
  }

  /* Dynamic key sizing: 15 white keys must fit in available width */
  /* Available width = 100vw - safe margins (16px total) */
  .key.white {
    width: calc((100vw - 16px) / 15);
    max-width: 50px;
    min-width: 20px;
    flex-shrink: 0;
  }

  .key.black {
    width: calc(((100vw - 16px) / 15) * 0.6);
    max-width: 32px;
    min-width: 12px;
    margin: 0 calc(((100vw - 16px) / 15) * -0.3);
    flex-shrink: 0;
  }

  /* Make key text labels visible on mobile */
  .key.white span {
    font-size: clamp(0.45rem, calc((100vw - 16px) / 15 * 0.22), 0.7rem);
    padding-bottom: 4px;
    color: #333;
    font-weight: 700;
    text-shadow: none;
  }

  .key.black span {
    font-size: clamp(0.35rem, calc((100vw - 16px) / 15 * 0.18), 0.55rem);
    padding-bottom: 3px;
    color: #999;
    font-weight: 600;
  }
}


.key {
  position: relative;
  cursor: pointer;
  border-radius: 0 0 5px 5px;
  transition: all 0.05s ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.key {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.key.white {
  width: var(--white-key-width);
  height: var(--white-key-height);
  background: linear-gradient(#fafafa, #e2e2e2);
  border: 1px solid #ccc;
  z-index: 1;
  color: #999;
  font-size: 0.8rem;
  padding-bottom: 10px;
  box-shadow: inset 0 -8px 16px rgba(0, 0, 0, 0.04);
}

.key.white:active,
.key.white.active {
  height: 195px;
  border-bottom: 4px solid var(--primary-color);
  background: #d1d1d1;
}

.key.black {
  width: var(--black-key-width);
  height: var(--black-key-height);
  background: linear-gradient(#333, #000);
  z-index: 2;
  margin: 0 calc(var(--black-key-width) * -0.45);
  border-radius: 0 0 3px 3px;
  color: #555;
  font-size: 0.7rem;
  padding-bottom: 8px;
}

.key.black:active,
.key.black.active {
  border-bottom: 3px solid var(--primary-color);
  background: #222;
}

.key.disabled {
  opacity: 0.5;
  pointer-events: none;
}

button[disabled],
input[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.piano-wrapper.disabled {
  opacity: 0.6;
  filter: grayscale(0.25);
}

/* ========================================
   MOBILE RESPONSIVENESS & BREAKPOINTS
   ======================================== */

/* Tablet Landscape (max-width: 900px) */
@media (max-width: 900px) {
  :root {
    --white-key-width: 55px;
    --white-key-height: 200px;
    --black-key-width: 36px;
    --black-key-height: 120px;
  }

  .app-container {
    max-width: 760px;
    padding: 18px;
    margin: 8px;
    max-height: calc(100vh - 16px);
  }

  .synth-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
  }

  .brand-name {
    font-size: 1.3rem;
  }
}

/* Tablet Portrait / Large Phones (max-width: 768px) */
@media (max-width: 768px) {
  :root {
    --white-key-width: 52px;
    --white-key-height: 185px;
    --black-key-width: 34px;
    --black-key-height: 110px;
  }

  .app-container {
    padding: 14px;
    gap: 6px;
    border-radius: 16px;
  }

  .synth-header {
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
  }

  .brand-name {
    font-size: 1.2rem;
  }

  .theme-selector {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .theme-selector label {
    font-size: 0.7rem;
  }

  .dot {
    width: 24px;
    height: 24px;
  }

  .dashboard {
    gap: 14px;
    padding: 12px;
  }

  .visual-dashboard {
    min-height: 80px;
    max-height: 20vh;
    padding: 10px 8px;
  }

  .pressed-key-letter {
    font-size: 2rem;
  }

  .viz-overlay span:last-child {
    font-size: 1.1rem;
  }
}

/* Small Tablets / Phones Landscape (max-width: 600px) */
@media (max-width: 600px) {
  :root {
    --white-key-width: 48px;
    --white-key-height: 165px;
    --black-key-width: 32px;
    --black-key-height: 100px;
  }

  .app-container {
    padding: 10px;
    margin: 4px;
    border-radius: 14px;
    max-height: calc(100vh - 8px);
  }

  .synth-header {
    margin-bottom: 10px;
    padding-bottom: 10px;
  }

  .brand-name {
    font-size: 1.1rem;
  }

  .visual-dashboard {
    flex-direction: column;
    gap: 8px;
    min-height: 70px;
    max-height: 18vh;
    padding: 8px;
  }

  .visual-dashboard .viz-left,
  .visual-dashboard .viz-right {
    flex: 1;
    min-width: auto;
    padding: 8px;
    min-height: 40px;
  }

  .visual-dashboard .viz-center {
    flex: 2;
    min-width: auto;
    min-height: 50px;
  }

  .pressed-key-letter {
    font-size: 1.6rem;
  }

  .pressed-key-note {
    font-size: 0.75rem;
  }

  #record-status {
    font-size: 0.75rem;
  }

  #record-timer {
    font-size: 0.7rem;
  }

  .dashboard {
    gap: 10px;
    padding: 10px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .control-group {
    flex: 1 1 auto;
    min-width: 80px;
  }

  .control-group label {
    font-size: 0.65rem;
    margin-bottom: 4px;
  }

  .tone-btn {
    padding: 5px 8px;
    font-size: 0.7rem;
  }

  .octave-btn {
    width: 32px;
    height: 32px;
  }

  #octave-display {
    font-size: 0.75rem;
  }

  .record-btn,
  .stop-btn {
    padding: 6px 10px;
    font-size: 0.7rem;
  }

  .power-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .piano-wrapper {
    padding: 8px 4px;
    border-radius: 6px;
  }
}

/* Mobile Phones (max-width: 480px) */
@media (max-width: 480px) {
  :root {
    --white-key-width: 44px;
    --white-key-height: 152px;
    --black-key-width: 29px;
    --black-key-height: 90px;
  }

  body {
    align-items: flex-start;
    padding-top: 4px;
  }

  .app-container {
    padding: 8px;
    margin: 2px;
    border-radius: 12px;
    max-height: calc(100vh - 4px);
    gap: 4px;
  }

  .synth-header {
    margin-bottom: 8px;
    padding-bottom: 8px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .brand-name {
    font-size: 1rem;
  }

  .theme-selector {
    width: 100%;
    justify-content: flex-start;
  }

  .dot {
    width: 22px;
    height: 22px;
  }

  .visual-dashboard {
    min-height: 60px;
    max-height: 15vh;
    padding: 6px;
    gap: 6px;
  }

  .visual-dashboard .viz-left,
  .visual-dashboard .viz-right {
    padding: 6px;
  }

  .pressed-key-letter {
    font-size: 1.4rem;
  }

  .viz-overlay span:first-child {
    font-size: 0.75rem;
  }

  .viz-overlay span:last-child {
    font-size: 0.9rem;
  }

  .dashboard {
    gap: 8px;
    padding: 8px;
    border-radius: 10px;
  }

  .control-group {
    min-width: 70px;
  }

  .control-group label {
    font-size: 0.6rem;
  }

  .toggle-switch {
    flex-wrap: wrap;
    gap: 2px;
  }

  .tone-btn {
    padding: 5px 6px;
    font-size: 0.65rem;
  }

  .octave-btn {
    width: 28px;
    height: 28px;
  }

  .record-controls {
    gap: 6px;
  }

  .record-btn,
  .stop-btn {
    padding: 6px 8px;
    font-size: 0.65rem;
  }

  .piano-wrapper {
    padding: 8px 4px;
    min-height: calc(var(--white-key-height) + 24px);
  }

  .key.white span,
  .key.black span {
    font-size: 0.62rem;
    padding-bottom: 6px;
  }
}

/* Small Phones (max-width: 375px) - iPhone SE, Galaxy S8 */
@media (max-width: 375px) {
  :root {
    --white-key-width: 40px;
    --white-key-height: 140px;
    --black-key-width: 26px;
    --black-key-height: 84px;
  }

  .app-container {
    padding: 6px;
    margin: 2px;
    gap: 3px;
  }

  .synth-header {
    margin-bottom: 6px;
    padding-bottom: 6px;
  }

  .brand-name {
    font-size: 0.95rem;
  }

  .dot {
    width: 20px;
    height: 20px;
  }

  .visual-dashboard {
    min-height: 55px;
    max-height: 14vh;
    padding: 5px;
    gap: 5px;
    border-radius: 8px;
  }

  .pressed-key-letter {
    font-size: 1.2rem;
  }

  .pressed-key-note {
    font-size: 0.65rem;
  }

  #record-status {
    font-size: 0.65rem;
  }

  #record-timer {
    font-size: 0.6rem;
  }

  .dashboard {
    gap: 6px;
    padding: 6px;
    border-radius: 8px;
    margin-bottom: 6px;
  }

  .control-group {
    min-width: 65px;
  }

  .control-group label {
    font-size: 0.55rem;
    margin-bottom: 3px;
  }

  .toggle-switch {
    padding: 1px;
    border-radius: 4px;
  }

  .tone-btn {
    padding: 4px 5px;
    font-size: 0.6rem;
    border-radius: 3px;
  }

  .octave-btn {
    width: 26px;
    height: 26px;
    font-size: 0.8rem;
  }

  #octave-display {
    width: 28px;
    font-size: 0.7rem;
  }

  .record-btn,
  .stop-btn {
    padding: 5px 7px;
    font-size: 0.6rem;
  }

  .power-btn {
    padding: 5px 8px;
    font-size: 0.65rem;
  }

  .power-indicator {
    width: 8px;
    height: 8px;
  }

  .piano-wrapper {
    padding: 7px 3px;
    border-radius: 5px;
    min-height: calc(var(--white-key-height) + 22px);
  }

  .key.white span,
  .key.black span {
    font-size: 0.58rem;
    padding-bottom: 5px;
  }
}

/* Very Small Phones (max-width: 320px) - iPhone 5/SE old */
@media (max-width: 320px) {
  :root {
    --white-key-width: 36px;
    --white-key-height: 126px;
    --black-key-width: 24px;
    --black-key-height: 76px;
  }

  .app-container {
    padding: 4px;
    margin: 1px;
    gap: 2px;
    border-radius: 10px;
  }

  .synth-header {
    margin-bottom: 4px;
    padding-bottom: 4px;
  }

  .brand-name {
    font-size: 0.85rem;
  }

  .theme-selector label {
    font-size: 0.6rem;
  }

  .dot {
    width: 18px;
    height: 18px;
  }

  .visual-dashboard {
    min-height: 50px;
    max-height: 12vh;
    padding: 4px;
    gap: 4px;
  }

  .visual-dashboard .viz-left,
  .visual-dashboard .viz-right {
    padding: 4px;
  }

  .pressed-key-letter {
    font-size: 1rem;
  }

  .viz-overlay span:first-child {
    font-size: 0.65rem;
  }

  .viz-overlay span:last-child {
    font-size: 0.75rem;
  }

  .dashboard {
    gap: 5px;
    padding: 5px;
    margin-bottom: 4px;
  }

  .control-group {
    min-width: 55px;
  }

  .control-group label {
    font-size: 0.5rem;
  }

  .tone-btn {
    padding: 3px 4px;
    font-size: 0.55rem;
  }

  .octave-btn {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }

  #octave-display {
    width: 24px;
    font-size: 0.65rem;
  }

  .record-btn,
  .stop-btn {
    padding: 4px 6px;
    font-size: 0.55rem;
  }

  .power-btn {
    padding: 4px 6px;
    font-size: 0.6rem;
  }

  .piano-wrapper {
    padding: 6px 2px;
    min-height: calc(var(--white-key-height) + 18px);
  }

  .key.white span,
  .key.black span {
    font-size: 0.54rem;
    padding-bottom: 4px;
  }
}

/* Portrait Orientation Handling - Rotate overlay will block this, but ensure no scrolling as backup */
@media (orientation: portrait) and (max-width: 700px) {
  :root {
    --white-key-height: 160px;
    --black-key-height: 96px;
  }

  .piano-wrapper {
    overflow: hidden;
  }
}

@media (orientation: portrait) and (max-width: 480px) {
  :root {
    --white-key-width: 42px;
    --white-key-height: 145px;
    --black-key-width: 28px;
    --black-key-height: 87px;
  }
}

@media (orientation: portrait) and (max-width: 375px) {
  :root {
    --white-key-width: 38px;
    --white-key-height: 130px;
    --black-key-width: 25px;
    --black-key-height: 78px;
  }
}

/* ========================================
   MOBILE LANDSCAPE - COMPACT CONTROLS & MAXIMIZE KEYS
   ======================================== */
@media (orientation: landscape) and (max-height: 600px) {
  .app-container {
    padding: 4px 8px;
    gap: 3px;
    max-height: 100vh;
  }

  .synth-header {
    margin-bottom: 2px;
    padding-bottom: 2px;
  }

  .brand-name {
    font-size: 0.9rem;
  }

  .dot {
    width: 18px;
    height: 18px;
  }

  /* Compact visual dashboard */
  .visual-dashboard {
    min-height: 36px;
    max-height: 15vh;
    padding: 4px 6px;
    gap: 6px;
  }

  .visual-dashboard .viz-left,
  .visual-dashboard .viz-right {
    padding: 4px 6px;
    min-width: 50px;
  }

  .pressed-key-letter {
    font-size: 1.2rem;
  }

  .pressed-key-note {
    font-size: 0.6rem;
  }

  #record-status {
    font-size: 0.55rem;
  }

  #record-timer {
    font-size: 0.5rem;
  }

  /* COMPACT DASHBOARD - All controls distributed evenly */
  .dashboard {
    padding: 4px 8px;
    gap: 8px;
    margin-bottom: 2px;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
  }

  .control-group {
    flex: 0 1 auto;
    min-width: auto;
  }

  .control-group label {
    font-size: 0.5rem;
    margin-bottom: 2px;
  }

  /* Compact tone buttons */
  .toggle-switch {
    padding: 1px;
    gap: 1px;
  }

  .tone-btn {
    padding: 3px 5px;
    font-size: 0.55rem;
    min-height: 24px;
  }

  /* Compact octave controls */
  .octave-btn {
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
  }

  #octave-display {
    width: 26px;
    font-size: 0.6rem;
  }

  /* Compact power controls */
  .power-btn {
    padding: 3px 8px;
    font-size: 0.55rem;
    min-height: 22px;
    min-width: 32px;
  }

  .power-indicator {
    width: 7px;
    height: 7px;
  }

  /* Compact record controls */
  .record-btn-pro {
    width: 32px;
    height: 32px;
  }

  .record-icon {
    width: 14px;
    height: 14px;
  }

  .stop-btn-pro {
    width: 28px;
    height: 28px;
  }

  .stop-icon {
    width: 10px;
    height: 10px;
  }

  /* Compact mic controls */
  .mic-btn {
    padding: 3px 6px;
    font-size: 0.5rem;
    min-height: 22px;
  }

  .mic-indicator {
    width: 6px;
    height: 6px;
  }

  /* Compact speed control */
  .speed-control {
    min-width: 60px;
  }

  .speed-controls {
    gap: 4px;
  }

  #speed-slider {
    width: 50px;
    height: 4px;
  }

  #speed-display {
    font-size: 0.5rem;
  }

  /* Volume slider compact */
  #volume-slider {
    width: 60px;
    height: 4px;
  }

  /* Piano wrapper - maximize height */
  .piano-wrapper {
    padding: 6px 2px;
    flex-grow: 1;
    min-height: 0;
  }

  /* Key heights for landscape */
  :root {
    --white-key-height: calc(100vh - 160px);
    --black-key-height: calc((100vh - 160px) * 0.6);
  }
}

/* Even smaller heights - hide visual dashboard entirely */
@media (orientation: landscape) and (max-height: 450px) {
  .visual-dashboard {
    display: none;
  }

  .synth-header {
    margin-bottom: 1px;
    padding-bottom: 1px;
  }

  .dashboard {
    margin-bottom: 1px;
    padding: 3px 6px;
  }

  :root {
    --white-key-height: calc(100vh - 100px);
    --black-key-height: calc((100vh - 100px) * 0.6);
  }
}

/* ========================================
   TOUCH & INTERACTION OPTIMIZATIONS
   ======================================== */

/* Ensure minimum touch targets (44px WCAG guideline) */
@media (pointer: coarse) {
  .dot {
    min-width: 44px;
    min-height: 44px;
  }

  .tone-btn {
    min-height: 40px;
  }

  .octave-btn {
    min-width: 40px;
    min-height: 40px;
  }

  .record-btn,
  .stop-btn,
  .power-btn {
    min-height: 40px;
    min-width: 44px;
  }
}

/* Prevent zoom on double tap for iOS */
@media (hover: none) {
  .key {
    touch-action: manipulation;
  }
}

/* ========================================
   ROTATE OVERLAY
   ======================================== */

.rotate-overlay {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 10, 0.85);
  z-index: 9999;
  color: var(--text-light);
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-direction: column;
  gap: 8px;
}

.rotate-overlay .msg {
  background: rgba(0, 0, 0, 0.45);
  padding: 12px 18px;
  border-radius: 8px;
  border: 1px solid #333;
  text-align: center;
  max-width: 90%;
}

@media (max-width: 480px) {
  .rotate-overlay {
    font-size: 0.9rem;
  }

  .rotate-overlay .msg {
    padding: 10px 14px;
  }
}

/* Subtle gap between keys for better touch targets */
.piano-keys-list {
  gap: 2px;
}

.landscape-locked .rotate-overlay {
  display: none !important;
}

/* ========================================
   POWER CONTROL
   ======================================== */

.power-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.power-btn {
  border: none;
  background: #333;
  color: #888;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.15s ease;
}

.power-btn:hover {
  transform: scale(1.02);
}

.power-btn:active {
  transform: scale(0.98);
}

.power-btn.on {
  background: var(--primary-color);
  color: white;
}

.power-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #777;
  display: inline-block;
  border: 2px solid rgba(255, 255, 255, 0.06);
  transition: background 0.2s ease;
}

.power-indicator.on {
  background: #4ecd6b;
}

.power-btn.off {
  background: #1a1a1a;
  color: #bfbfbf;
  border: 1px solid rgba(255, 0, 0, 0.14);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.5);
}

.power-indicator.off {
  background: #b30000;
  border-color: rgba(255, 255, 255, 0.06);
}

/* ========================================
   KEY LABELS
   ======================================== */

.key.white span {
  display: block;
  padding-bottom: 8px;
  color: #222;
  transition: opacity 0.15s ease;
}

.key.black span {
  display: block;
  padding-bottom: 8px;
  color: #fff;
  transition: opacity 0.15s ease;
}

/* Hide key labels on very small screens to save space */
@media (max-width: 375px) {
  .key.white span,
  .key.black span {
    opacity: 0.7;
  }
}

@media (max-width: 320px) {
  .key.white span,
  .key.black span {
    display: none;
  }
}

/* ========================================
   FIRST-TIME USER ONBOARDING TOUR
   ======================================== */

.onboarding-tour {
  position: fixed;
  inset: 0;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.onboarding-tour.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.tour-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.tour-spotlight {
  position: absolute;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75);
  background: transparent;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.tour-pointer {
  position: absolute;
  width: 48px;
  height: 48px;
  color: var(--primary-color);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
  animation: pointerBounce 0.8s ease-in-out infinite;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10001;
}

.tour-pointer svg {
  width: 100%;
  height: 100%;
  transform: rotate(180deg);
}

@keyframes pointerBounce {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-12px);
  }
}

.tour-tooltip {
  position: absolute;
  background: linear-gradient(
    135deg,
    rgba(40, 40, 40, 0.98),
    rgba(28, 28, 28, 0.98)
  );
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 10px 12px;
  max-width: 240px;
  width: calc(100vw - 32px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10002;
}

.tour-tooltip-content {
  margin-bottom: 8px;
}

.tour-tooltip-content h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary-color);
  margin: 0 0 2px 0;
}

.tour-tooltip-content p {
  font-size: 0.75rem;
  color: #ccc;
  margin: 0;
  line-height: 1.3;
}

.tour-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.tour-btn-skip {
  flex: 1;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #888;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tour-btn-skip:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ccc;
}

.tour-btn-next {
  flex: 1;
  padding: 8px 10px;
  background: linear-gradient(135deg, var(--primary-color), #ff8f5a);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 3px 10px rgba(255, 107, 53, 0.3);
}

.tour-btn-next:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(255, 107, 53, 0.45);
}

.tour-progress {
  text-align: center;
  font-size: 0.6rem;
  color: #666;
  font-weight: 500;
}

/* Mobile responsive tour - extra compact */
@media (max-width: 600px) {
  .tour-pointer {
    width: 36px;
    height: 36px;
  }

  .tour-tooltip {
    padding: 12px 14px;
    max-width: 260px;
    border-radius: 12px;
  }

  .tour-tooltip-content {
    margin-bottom: 10px;
  }

  .tour-tooltip-content h4 {
    font-size: 0.95rem;
  }

  .tour-tooltip-content p {
    font-size: 0.8rem;
    line-height: 1.35;
  }

  .tour-actions {
    gap: 8px;
    margin-bottom: 6px;
  }

  .tour-btn-skip,
  .tour-btn-next {
    padding: 9px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
  }

  .tour-progress {
    font-size: 0.65rem;
  }
}

/* Landscape mobile - even more compact */
@media (max-height: 500px) {
  .tour-tooltip {
    padding: 10px 12px;
    max-width: 240px;
  }

  .tour-tooltip-content {
    margin-bottom: 8px;
  }

  .tour-tooltip-content h4 {
    font-size: 0.9rem;
    margin-bottom: 2px;
  }

  .tour-tooltip-content p {
    font-size: 0.75rem;
    line-height: 1.3;
  }

  .tour-actions {
    margin-bottom: 4px;
  }

  .tour-btn-skip,
  .tour-btn-next {
    padding: 8px;
    font-size: 0.7rem;
  }

  .tour-progress {
    font-size: 0.6rem;
  }
}

/* Theme support for tour */
body[data-theme="purple"] .tour-pointer {
  color: #9b59b6;
  filter: drop-shadow(0 4px 12px rgba(155, 89, 182, 0.5));
}

body[data-theme="purple"] .tour-btn-next {
  background: linear-gradient(135deg, #9b59b6, #b07cc6);
  box-shadow: 0 4px 15px rgba(155, 89, 182, 0.35);
}

body[data-theme="red"] .tour-pointer {
  color: #e74c3c;
  filter: drop-shadow(0 4px 12px rgba(231, 76, 60, 0.5));
}

body[data-theme="red"] .tour-btn-next {
  background: linear-gradient(135deg, #e74c3c, #ec7063);
  box-shadow: 0 4px 15px rgba(231, 76, 60, 0.35);
}

body[data-theme="black"] .tour-pointer {
  color: #fff;
  filter: drop-shadow(0 4px 12px rgba(255, 255, 255, 0.3));
}

body[data-theme="black"] .tour-btn-next {
  background: linear-gradient(135deg, #fff, #e0e0e0);
  color: #1a1a1a;
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
}

/* ========================================
   ENHANCED INSTALL CARD (Premium PWA CTA)
   ======================================== */

.install-card {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  pointer-events: none;
}

.install-card.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.install-card-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.install-card-content {
  position: relative;
  background: linear-gradient(
    135deg,
    rgba(45, 45, 45, 0.95),
    rgba(30, 30, 30, 0.98)
  );
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 32px;
  max-width: 380px;
  width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(255, 107, 53, 0.15);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.install-card.visible .install-card-content {
  transform: scale(1) translateY(0);
}

.install-card-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #888;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.install-card-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  transform: rotate(90deg);
}

/* States */
.install-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.install-state.hidden {
  display: none;
}

/* Icon */
.install-card-icon {
  position: relative;
  width: 80px;
  height: 80px;
}

.install-card-icon img {
  width: 100%;
  height: 100%;
  border-radius: 20px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.install-icon-glow {
  position: absolute;
  inset: -8px;
  background: radial-gradient(circle, var(--glow-color) 0%, transparent 70%);
  opacity: 0.5;
  animation: iconPulse 2s ease-in-out infinite;
  z-index: -1;
  border-radius: 24px;
}

@keyframes iconPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.5;
  }

  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

/* Header */
.install-card-header h3 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-light);
  margin: 0;
}

.install-card-header p {
  font-size: 0.9rem;
  color: #aaa;
  margin: 6px 0 0 0;
}

/* Features List */
.install-features {
  list-style: none;
  padding: 0;
  margin: 0;
  text-align: left;
  width: 100%;
}

.install-features li {
  padding: 8px 0;
  font-size: 0.9rem;
  color: #ccc;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.install-features li:last-child {
  border-bottom: none;
}

/* Primary Button */
.install-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--primary-color), #ff8f5a);
  border: none;
  border-radius: 14px;
  color: white;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 8px 25px rgba(255, 107, 53, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.install-btn-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 35px rgba(255, 107, 53, 0.5);
}

.install-btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.install-btn-primary.success {
  background: linear-gradient(135deg, #27ae60, #2ecc71);
  box-shadow: 0 8px 25px rgba(46, 204, 113, 0.4);
}

.install-btn-primary.success:hover {
  box-shadow: 0 12px 35px rgba(46, 204, 113, 0.5);
}

.install-btn-icon {
  font-size: 1.2rem;
}

/* Progress State */
.install-progress-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 20px 0;
}

.install-progress-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.install-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.install-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), #ff8f5a);
  border-radius: 3px;
  animation: progressIndeterminate 1.5s ease-in-out infinite;
}

@keyframes progressIndeterminate {
  0% {
    width: 0%;
    margin-left: 0;
  }

  50% {
    width: 60%;
    margin-left: 20%;
  }

  100% {
    width: 0%;
    margin-left: 100%;
  }
}

/* Success State */
.install-success-icon {
  width: 80px;
  height: 80px;
}

.checkmark {
  width: 80px;
  height: 80px;
}

.checkmark-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 2;
  stroke-miterlimit: 10;
  stroke: #27ae60;
  animation: strokeCircle 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  stroke: #27ae60;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: strokeCheck 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.4s forwards;
}

@keyframes strokeCircle {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes strokeCheck {
  to {
    stroke-dashoffset: 0;
  }
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .install-card-content {
    padding: 24px 20px;
    border-radius: 20px;
  }

  .install-card-icon {
    width: 64px;
    height: 64px;
  }

  .install-card-header h3 {
    font-size: 1.2rem;
  }

  .install-card-header p {
    font-size: 0.85rem;
  }

  .install-features li {
    font-size: 0.85rem;
  }

  .install-btn-primary {
    padding: 14px 20px;
    font-size: 0.95rem;
  }
}

/* Theme Support */
body[data-theme="purple"] .install-card-content {
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(155, 89, 182, 0.15);
}

body[data-theme="purple"] .install-btn-primary {
  background: linear-gradient(135deg, #9b59b6, #b07cc6);
  box-shadow: 0 8px 25px rgba(155, 89, 182, 0.4);
}

body[data-theme="red"] .install-card-content {
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(231, 76, 60, 0.15);
}

body[data-theme="red"] .install-btn-primary {
  background: linear-gradient(135deg, #e74c3c, #ec7063);
  box-shadow: 0 8px 25px rgba(231, 76, 60, 0.4);
}

body[data-theme="black"] .install-card-content {
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(255, 255, 255, 0.1);
}

body[data-theme="black"] .install-btn-primary {
  background: linear-gradient(135deg, #fff, #e0e0e0);
  color: #1a1a1a;
  box-shadow: 0 8px 25px rgba(255, 255, 255, 0.2);
}

/* Hide install card in landscape on very short screens */
@media (orientation: landscape) and (max-height: 450px) {
  .install-card {
    display: none;
  }
}

/* ========================================
   SHARE MODAL (Fallback for browsers without Web Share API)
   ======================================== */
.share-modal {
  position: fixed;
  inset: 0;
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.share-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.share-modal-content {
  position: relative;
  background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
  border: 1px solid #404040;
  border-radius: 16px;
  padding: 24px;
  max-width: 340px;
  width: calc(100% - 40px);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease;
}

.share-modal-content h3 {
  margin: 0 0 20px 0;
  font-size: 1.2rem;
  text-align: center;
  color: var(--text-light);
}

.share-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.share-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  color: white;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.share-option:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.share-option:active {
  transform: scale(0.97);
}

.share-option.whatsapp {
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
}

.share-option.twitter {
  background: linear-gradient(135deg, #1da1f2 0%, #0d8ddb 100%);
}

.share-option.facebook {
  background: linear-gradient(135deg, #4267b2 0%, #2d4a8a 100%);
}

.share-option.linkedin {
  background: linear-gradient(135deg, #0077b5 0%, #005885 100%);
}

.share-modal-close {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1.5px solid #555;
  color: #aaa;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.share-modal-close:hover {
  background: #333;
  border-color: #777;
  color: white;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ========================================
   EXIT SHARE PROMPT - Mobile First
   ======================================== */
.exit-share-prompt {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.exit-share-prompt.visible {
  opacity: 1;
  visibility: visible;
}

.exit-share-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.exit-share-card {
  position: relative;
  background: linear-gradient(145deg, #2d2d2d 0%, #1a1a1a 100%);
  border: 1px solid #404040;
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

.exit-share-prompt.visible .exit-share-card {
  transform: translateY(0);
}

/* Handle bar indicator (mobile sheet style) */
.exit-share-card::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  background: #555;
  border-radius: 2px;
}

.exit-share-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  line-height: 1;
  pointer-events: auto;
}

.exit-share-close:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  transform: scale(1.1);
}

.exit-share-emoji {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 12px;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

.exit-share-title {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-light);
  margin: 0 0 8px 0;
}

.exit-share-subtitle {
  font-size: 0.95rem;
  text-align: center;
  color: #999;
  margin: 0 0 20px 0;
  line-height: 1.5;
}

/* Session Stats */
.exit-share-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 24px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary-color);
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #777;
}

/* Buttons */
.exit-share-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.exit-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.exit-share-btn.primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, #e55a2b 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.exit-share-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
}

.exit-share-btn.primary:active {
  transform: scale(0.98);
}

.exit-share-btn.secondary {
  background: transparent;
  border: 1.5px solid #444;
  color: #888;
}

.exit-share-btn.secondary:hover {
  border-color: #666;
  color: #ccc;
  background: rgba(255, 255, 255, 0.03);
}

/* Social Icons */
.exit-share-social {
  text-align: center;
}

.exit-share-social > p {
  font-size: 0.8rem;
  color: #666;
  margin: 0 0 12px 0;
}

.exit-share-social-icons {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.social-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: all 0.2s ease;
  text-decoration: none;
}

.social-icon svg {
  width: 22px;
  height: 22px;
}

.social-icon:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.social-icon:active {
  transform: scale(0.95);
}

.social-icon.whatsapp {
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
}

.social-icon.twitter {
  background: linear-gradient(135deg, #1da1f2 0%, #0d8ddb 100%);
}

.social-icon.facebook {
  background: linear-gradient(135deg, #4267b2 0%, #2d4a8a 100%);
}

.social-icon.copy {
  background: linear-gradient(135deg, #666 0%, #444 100%);
}

/* Desktop styles */
@media (min-width: 600px) {
  .exit-share-prompt {
    align-items: center;
  }

  .exit-share-card {
    border-radius: 20px;
    border: 1px solid #404040;
    max-width: 400px;
    padding: 32px 28px;
    transform: translateY(30px) scale(0.95);
  }

  .exit-share-prompt.visible .exit-share-card {
    transform: translateY(0) scale(1);
  }

  .exit-share-card::before {
    display: none;
  }

  .exit-share-buttons {
    flex-direction: row;
  }

  .exit-share-btn {
    flex: 1;
  }
}

/* Hide exit prompt in very short landscape (keyboard visible, etc) */
@media (orientation: landscape) and (max-height: 400px) {
  .exit-share-prompt {
    display: none;
  }
}

/* ========================================
   PWA INSTALL CARD - Multi-State Design
   ======================================== */
.install-card {
  position: fixed;
  inset: 0;
  z-index: 99997;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.install-card.visible {
  opacity: 1;
  visibility: visible;
}

.install-card-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.install-card-content {
  position: relative;
  background: linear-gradient(145deg, #2d2d2d 0%, #1a1a1a 100%);
  border: 1px solid #404040;
  border-radius: 24px;
  padding: 32px 28px;
  max-width: 380px;
  width: calc(100% - 40px);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.install-card.visible .install-card-content {
  transform: translateY(0) scale(1);
}

.install-card-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #888;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.install-card-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  transform: scale(1.1);
}

/* Install State Container */
.install-state {
  text-align: center;
}

.install-state.hidden {
  display: none;
}

/* App Icon with Glow */
.install-card-icon {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
}

.install-card-icon img {
  width: 100%;
  height: 100%;
  border-radius: 18px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.install-icon-glow {
  position: absolute;
  inset: -10px;
  background: radial-gradient(circle, var(--primary-color) 0%, transparent 70%);
  opacity: 0.3;
  border-radius: 28px;
  animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(1.05);
  }
}

/* Header */
.install-card-header h3 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-light);
  margin: 0 0 8px 0;
}

.install-card-header p {
  font-size: 0.95rem;
  color: #999;
  margin: 0;
  line-height: 1.5;
}

/* Feature List */
.install-features {
  list-style: none;
  padding: 0;
  margin: 20px 0;
  text-align: left;
}

.install-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  color: #ccc;
  font-size: 0.9rem;
}

/* Primary Install Button */
.install-btn-primary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 28px;
  background: linear-gradient(135deg, var(--primary-color) 0%, #e55a2b 100%);
  border: none;
  border-radius: 14px;
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 6px 20px rgba(255, 107, 53, 0.35);
}

.install-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(255, 107, 53, 0.45);
}

.install-btn-primary:active {
  transform: scale(0.98);
}

.install-btn-primary.success {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  box-shadow: 0 6px 20px rgba(34, 197, 94, 0.35);
}

.install-btn-icon {
  font-size: 1.3rem;
}

/* Installing State */
.install-progress-container {
  margin: 20px 0;
}

.install-progress-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid #333;
  border-top-color: var(--primary-color);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.install-progress-bar {
  height: 6px;
  background: #333;
  border-radius: 3px;
  overflow: hidden;
}

.install-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary-color), #ff9f6b);
  border-radius: 3px;
  animation: progressFill 2s ease-out forwards;
}

@keyframes progressFill {
  to {
    width: 100%;
  }
}

/* Success State */
.install-success-icon {
  width: 70px;
  height: 70px;
  margin: 0 auto 20px;
}

.checkmark {
  width: 100%;
  height: 100%;
}

.checkmark-circle {
  stroke: #22c55e;
  stroke-width: 3;
  animation: checkCircle 0.6s ease-out forwards;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
}

.checkmark-check {
  stroke: #22c55e;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: checkMark 0.4s 0.5s ease-out forwards;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
}

@keyframes checkCircle {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes checkMark {
  to {
    stroke-dashoffset: 0;
  }
}

/* Slide In Animation */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Hide on very small landscape screens */
@media (orientation: landscape) and (max-height: 450px) {
  .install-card {
    display: none;
  }
}

/* ========================================
   MICROPHONE CONTROLS
   ======================================== */
.mic-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mic-btn {
  border: none;
  background: #333;
  color: #888;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.mic-btn:hover:not(:disabled) {
  transform: scale(1.02);
}

.mic-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.mic-btn.on {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
  animation: micPulse 1.5s ease-in-out infinite;
}

.mic-btn.off {
  background: #1a1a1a;
  color: #bfbfbf;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.mic-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mic-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #777;
  display: inline-block;
  border: 2px solid rgba(255, 255, 255, 0.06);
  transition: background 0.2s ease;
}

.mic-indicator.on {
  background: #e74c3c;
  animation: micIndicatorPulse 0.8s ease-in-out infinite;
}

.mic-indicator.off {
  background: #555;
}

@keyframes micPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(231, 76, 60, 0);
  }
}

@keyframes micIndicatorPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}

/* ========================================
   SPEED CONTROL STYLING
   ======================================== */
.speed-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.speed-controls input[type="range"] {
  width: 70px;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(to right, var(--primary-color) 50%, #333 50%);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.speed-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.speed-controls input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 12px var(--glow-color);
}

.speed-controls input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

#speed-display {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-color);
  min-width: 32px;
  text-align: center;
}

/* Mobile: Mic and Speed on same row at extreme ends */
@media (max-width: 600px) {
  .dashboard {
    flex-wrap: wrap;
  }

  .control-group.speed-control {
    margin-left: auto;
  }

  .speed-controls input[type="range"] {
    width: 55px;
  }

  #speed-display {
    font-size: 0.65rem;
    min-width: 28px;
  }
}

@media (max-width: 480px) {
  .speed-controls input[type="range"] {
    width: 50px;
  }

  .speed-controls input[type="range"]::-webkit-slider-thumb {
    width: 14px;
    height: 14px;
  }

  #speed-display {
    font-size: 0.6rem;
  }
}

@media (max-width: 375px) {
  .speed-controls {
    gap: 4px;
  }

  .speed-controls input[type="range"] {
    width: 45px;
  }

  #speed-display {
    font-size: 0.55rem;
    min-width: 24px;
  }
}

/* ========================================
   ENHANCED PIANO STYLING - Distinct from background
   ======================================== */
.piano-wrapper {
  background: linear-gradient(
    180deg,
    #1e1e1e 0%,
    #0a0a0a 50%,
    #151515 100%
  ) !important;
  border: 2px solid rgba(255, 107, 53, 0.15);
  box-shadow: inset 0 5px 15px rgba(0, 0, 0, 0.8),
    inset 0 -3px 10px rgba(255, 255, 255, 0.02), 0 8px 32px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(255, 107, 53, 0.08);
  border-radius: 12px;
  position: relative;
}

/* Piano wood grain effect overlay */
.piano-wrapper::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 3px,
    rgba(139, 90, 43, 0.02) 3px,
    rgba(139, 90, 43, 0.02) 6px
  );
  pointer-events: none;
  border-radius: 12px;
}

/* Subtle top reflection */
.piano-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  pointer-events: none;
}

/* Theme variants for piano */
body[data-theme="purple"] .piano-wrapper {
  border-color: rgba(155, 89, 182, 0.15);
  box-shadow: inset 0 5px 15px rgba(0, 0, 0, 0.8), 0 8px 32px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(155, 89, 182, 0.08);
}

body[data-theme="red"] .piano-wrapper {
  border-color: rgba(231, 76, 60, 0.15);
  box-shadow: inset 0 5px 15px rgba(0, 0, 0, 0.8), 0 8px 32px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(231, 76, 60, 0.08);
}

body[data-theme="black"] .piano-wrapper {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 5px 15px rgba(0, 0, 0, 0.9), 0 8px 32px rgba(0, 0, 0, 0.7),
    0 0 40px rgba(255, 255, 255, 0.03);
}

/* ========================================
   BEAUTIFUL KEYBOARD FEATURE - Key Glow Effect
   ======================================== */
.key.white {
  position: relative;
  overflow: hidden;
}

.key.white::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  background: radial-gradient(
    ellipse at center,
    var(--primary-color),
    transparent
  );
  opacity: 0;
  transition: all 0.15s ease;
  pointer-events: none;
}

.key.white:active::after,
.key.white.active::after {
  width: 100%;
  height: 80%;
  opacity: 0.4;
}

.key.black::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  background: radial-gradient(
    ellipse at center,
    var(--primary-color),
    transparent
  );
  opacity: 0;
  transition: all 0.15s ease;
  pointer-events: none;
}

.key.black:active::after,
.key.black.active::after {
  width: 120%;
  height: 60%;
  opacity: 0.5;
}

/* Ripple effect on key press */
@keyframes keyRipple {
  0% {
    transform: translateX(-50%) scale(0);
    opacity: 0.6;
  }
  100% {
    transform: translateX(-50%) scale(2);
    opacity: 0;
  }
}

.key.ripple::before {
  content: "";
  position: absolute;
  bottom: 20%;
  left: 50%;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-color);
  animation: keyRipple 0.4s ease-out forwards;
  pointer-events: none;
}

/* ========================================
   LANDSCAPE INSTALL BANNER - Non-blocking
   ======================================== */
.landscape-install-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99998;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  pointer-events: none;
}

.landscape-install-banner.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.landscape-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(
    135deg,
    rgba(26, 26, 26, 0.97) 0%,
    rgba(35, 35, 35, 0.97) 100%
  );
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 107, 53, 0.2);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4), 0 0 40px rgba(255, 107, 53, 0.08);
}

.landscape-banner-icon {
  flex-shrink: 0;
}

.landscape-banner-icon img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.landscape-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.landscape-banner-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.landscape-banner-subtitle {
  font-size: 0.75rem;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.landscape-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.landscape-install-btn {
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--primary-color), #e55a2b);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 10px rgba(255, 107, 53, 0.3);
  white-space: nowrap;
}

.landscape-install-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
}

.landscape-install-btn:active {
  transform: scale(0.98);
}

.landscape-dismiss-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #888;
  border-radius: 50%;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.landscape-dismiss-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Only show in landscape on mobile */
@media (orientation: portrait) {
  .landscape-install-banner {
    display: none !important;
  }
}

/* Desktop - hide the landscape banner entirely */
@media (min-width: 901px) {
  .landscape-install-banner {
    display: none !important;
  }
}

/* Theme variants */
body[data-theme="purple"] .landscape-banner-content {
  border-bottom-color: rgba(155, 89, 182, 0.2);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4), 0 0 40px rgba(155, 89, 182, 0.08);
}

body[data-theme="purple"] .landscape-install-btn {
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  box-shadow: 0 2px 10px rgba(155, 89, 182, 0.3);
}

body[data-theme="red"] .landscape-banner-content {
  border-bottom-color: rgba(231, 76, 60, 0.2);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4), 0 0 40px rgba(231, 76, 60, 0.08);
}

body[data-theme="red"] .landscape-install-btn {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  box-shadow: 0 2px 10px rgba(231, 76, 60, 0.3);
}

body[data-theme="black"] .landscape-banner-content {
  border-bottom-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5), 0 0 40px rgba(255, 255, 255, 0.03);
}

body[data-theme="black"] .landscape-install-btn {
  background: linear-gradient(135deg, #ffffff, #e0e0e0);
  color: #1a1a1a;
  box-shadow: 0 2px 10px rgba(255, 255, 255, 0.2);
}

/* Smaller screens in landscape - more compact */
@media (orientation: landscape) and (max-height: 500px) {
  .landscape-banner-content {
    padding: 6px 12px;
    gap: 10px;
  }

  .landscape-banner-icon img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .landscape-banner-title {
    font-size: 0.8rem;
  }

  .landscape-banner-subtitle {
    font-size: 0.7rem;
  }

  .landscape-install-btn {
    padding: 6px 16px;
    font-size: 0.8rem;
  }

  .landscape-dismiss-btn {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
  }
}

/* Very short landscape screens */
@media (orientation: landscape) and (max-height: 400px) {
  .landscape-banner-content {
    padding: 4px 10px;
  }

  .landscape-banner-icon img {
    width: 28px;
    height: 28px;
  }

  .landscape-banner-text {
    flex-direction: row;
    gap: 8px;
    align-items: center;
  }

  .landscape-banner-subtitle {
    display: none;
  }
}


/* Mobile: avoid end-gaps + avoid over-scaling (JS also disables scaling on mobile) */
@media (max-width: 900px) {
  .piano-wrapper {
    justify-content: flex-start;
  }

  .piano-keys-list {
    width: max-content;
    justify-content: flex-start;
    transform-origin: left center;
  }
}
