body {
  display: flex;
  justify-content: flex-start; 
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100dvh;
  background-color: transparent; 
  font-family: "Courier New", Courier, monospace;
  margin: 0;
  color: rgb(190, 190, 190);
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  background-color: #000000;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

/* --- FLOATING SETTINGS BUTTON --- */
#btn-settings {
  position: fixed;
  top: 15px;
  right: 15px;
  z-index: 3000;
  background: rgba(30, 30, 30, 0.8);
  border: 1px solid #555;
  color: white;
  border-radius: 50%;
  width: 45px;
  height: 45px;
  font-size: 22px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0,0,0,0.5);
  transition: background-color 0.2s, transform 0.2s;
}

#btn-settings:active {
  transform: scale(0.9);
  background: rgba(60, 60, 60, 0.9);
}

/* --- LOADING OVERLAY --- */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.9);
  z-index: 3000;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  color: #00d2ff;
  font-family: "Courier New", Courier, monospace;
  transition: opacity 0.5s;
}

#loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #333;
  border-top: 5px solid #00d2ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* --- DROP ZONE OVERLAY --- */
#drop-zone {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000; 
  display: none; 
  justify-content: center;
  align-items: center;
  flex-direction: column;
  color: white;
  border: 4px dashed #5cb85c;
  box-sizing: border-box;
}

#drop-zone.active {
  display: flex;
}

.drop-text {
  font-size: 24px;
  font-weight: bold;
  pointer-events: none;
}

/* --- SYNTHESIA VISUALIZER CANVAS --- */
#synthesia-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 83vh; 
  height: 83dvh; 
  z-index: 100;   
  pointer-events: none; 
}

/* --- TRADITIONAL PIANO STRIP (FIXED BOTTOM) --- */
#piano-strip {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 17vh; 
  height: 17dvh; 
  margin: 0;
  padding: 0;
  background: #222;
  border-top: 4px solid #111;
  display: block;
  overflow: hidden; 
  z-index: 1000; 
}

.piano-wrapper {
  position: relative;
  height: 100%;
  width: 100%;
  margin: 0 auto; 
}

.p-key {
  position: absolute;
  box-sizing: border-box;
  border-bottom-left-radius: 3px;
  border-bottom-right-radius: 3px;
  cursor: pointer;
  transition: background-color 0.1s;
  top: 0;
  display: flex;
  flex-direction: column; /* Stack labels vertically */
  justify-content: flex-end; /* Align to bottom */
  align-items: center;
  padding-bottom: 2px;
  gap: 1px; /* Small space between dual labels */
  font-size: 10px;
  font-weight: bold;
  overflow: hidden;
}

/* Common Label Style */
.key-label {
  font-size: 9px;
  font-weight: bold;
  line-height: 9px;
  /* text-shadow removed for cleaner visuals */
}

/* Left Board Label (Cyan) */
.key-label.lbl-left {
  color: #00d2ff;
}

/* Right Board Label (Pink) */
.key-label.lbl-right {
  color: #c87ad1;
}

/* Adjust Black Key text size slightly */
.p-key.black .key-label {
  font-size: 8px;
}

.p-key.white {
  background: #acacac;
  border: 1px solid #666; 
  border-top: none;
  height: 100%;
  z-index: 1;
  color: #333;
}
.p-key.white:active,
.p-key.white.active {
  background: #555555;
}

.p-key.black {
  background: #111;
  border: 1px solid #000;
  border-top: none;
  height: 65%; 
  z-index: 10;
  color: #ddd;
  font-size: 9px;
  padding-bottom: 5px;
}
.p-key.black:active,
.p-key.black.active {
  background: #7b7b7b;
}

/* --- QUICK CONTROLS (ALWAYS VISIBLE) --- */
#quick-controls {
  position: fixed;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 25px;
  background: rgba(15, 15, 15, 0.85);
  padding: 12px 25px;
  border-radius: 12px;
  border: 1px solid #333;
  z-index: 2000;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

/* --- SETTINGS PANEL (GEAR ICON MODAL) --- */
#settings-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  opacity: 0;
  pointer-events: none;
  
  background: rgba(20, 20, 20, 0.98);
  border: 1px solid #444;
  border-radius: 16px;
  padding: 30px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  max-width: 80%;
  z-index: 2500;
  max-height: 85dvh;
  overflow-y: auto;
  
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
  box-shadow: 0 10px 40px rgba(0,0,0,0.9);
}

#settings-panel.settings-visible {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.control-group {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.control-label {
  font-size: 10px;
  color: #aaa;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-row {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(111, 111, 111, 0.3); 
  padding: 4px;
  border-radius: 6px;
}

.control-btn {
  background: rgba(111, 111, 111, 0.3); 
  border: none;
  color: white;
  width: 25px;
  height: 25px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  /* Box shadow removed for performance */
}

.control-btn:active {
  transform: translateY(2px);
  background: rgba(111, 111, 111, 0.3); 
}

.control-btn.recording {
  background-color: #d9534f;
  animation: pulse-red 1s infinite;
}

.control-btn.playing {
  background-color: #5cb85c;
}

.control-btn.paused {
  background-color: #f0ad4e;
  animation: pulse-yellow 1s infinite;
}

#btn-reset-memory {
  width: 120px;
  font-size: 11px;
  background: linear-gradient(to bottom, #ff4444, #cc0000);
}

#btn-reset-memory:hover {
  background: linear-gradient(to bottom, #ff6666, #ee0000);
}

@keyframes pulse-red {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

@keyframes pulse-yellow {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

.control-val {
  width: 35px;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
}

.side-label {
  color: #888;
  font-size: 9px;
  margin-bottom: 2px;
}

/* --- PLAYBACK CONTROLS --- */
.playback-controls {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
}

#record-select {
  background: rgba(0,0,0,0.5);
  color: white;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 2px;
  font-family: inherit;
  font-size: 10px;
  max-width: 120px;
}

/* --- VERTICAL PROGRESS BAR (RIGHT SIDE) --- */
#progress-container {
  position: fixed;
  right: 0;
  top: 0;
  height: 83vh;      /* Span full height minus piano strip (100vh - 17vh) */
  height: 83dvh;
  width: 50px;       /* Clickable area width */
  z-index: 2500;     /* Above other overlays */
  background: rgba(0, 0, 0, 0.0); /* Transparent but captures hover if needed */
  pointer-events: auto;
}

#progress-bar {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  top: 50%;
  left: 50%;
  /* Rotate -90deg: Bottom is 0 (Start), Top is 100 (End) */
  transform: translate(-50%, -50%) rotate(-90deg); 
  
  /* NOTE: Because it's rotated, 'width' becomes the visual height */
  width: calc(83vh - 10px); /* Full height minus small margin */
  width: calc(83dvh - 10px);
  height: 8px;       /* Thickness of the bar */
  
  background: rgba(80, 80, 80, 0.6);
  outline: none;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  transition: background 0.2s, height 0.2s;
}

#progress-bar:hover {
  background: rgba(100, 100, 100, 0.9);
  height: 12px; /* Thicken on hover */
}

/* Chrome/Safari Thumb */
#progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #00d2ff;
  cursor: pointer;
  box-shadow: 0 0 5px rgba(0, 210, 255, 0.8);
  transition: transform 0.1s;
}

#progress-bar::-webkit-slider-thumb:hover {
  transform: scale(1.3);
  background: #fff;
}

/* Firefox Thumb */
#progress-bar::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: #00d2ff;
  cursor: pointer;
  box-shadow: 0 0 5px rgba(0, 210, 255, 0.8);
}

#board-wrapper {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 0px; 
  
  /* Centering */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  
  /* Layering: Lower than canvas (100) but visible */
  z-index: 50; 
  
  pointer-events: none; /* contain: layout paint; is removed */
}

#board-left, #board-right {
  pointer-events: auto;
}

/* --- WICKI BOARD STYLING --- */
.wicki-board {
  position: relative;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
}

.row {
  display: flex;
  margin-bottom: 15px;
}

/* Dynamic Wicki-Hayden Staggering */
.even-row { margin-left: -84px; }
.odd-row { margin-left: 0px; }

/* --- KEY STYLING --- */
.key {
  width: 60px;
  height: 60px;
  border-radius: 50%; 
  margin: 0 12px;
  cursor: pointer;
  position: relative;
  will-change: transform, background-color; 
  transition: transform 0.05s, background-color 0.1s; 
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  font-size: 16px;
  font-weight: bold;
  font-family: sans-serif;
  box-sizing: border-box;
  border: 2px solid transparent;
}

.key:active,
.key.active {
  box-shadow: 0 0 0 #000;
  transition: none;
}

.key.natural {
  background: rgba(254, 254, 254, 0.4); 
  color: #000000;
}
.key.natural.active {
  background: rgba(255, 255, 255, 0.6);
}

.key.accidental {
  background: rgba(104, 104, 104, 0.4);
  color: #c1c1c1;
}
.key.accidental.active {
  background: rgba(75, 75, 75, 0.2);
}

/* --- PERSISTENT PLAYED NOTE MARKER --- */
.key.played-note {
  border-style: solid;
  border-width: 2px;
}

#board-left .key.played-note {
  border-color: #00d2ff;
}

#board-right .key.played-note {
  border-color: #c87ad1;
}

/* ==========================================
   MOBILE & TOUCH OVERRIDES
   ========================================== */
body.is-mobile .desktop-only {
  display: none !important;
}

body.is-mobile #piano-strip {
  display: none !important;
}

body.is-mobile #synthesia-canvas {
  height: 100vh !important;
  height: 100dvh !important;
}

body.is-mobile #progress-container {
  height: 100vh !important;
  height: 100dvh !important;
}

body.is-mobile #progress-bar {
  width: calc(100vh - 10px) !important;
  width: calc(100dvh - 10px) !important;
}

body.is-mobile #board-wrapper {
  transform: translate(-50%, -50%) scale(0.65);
}

body.is-mobile ::-webkit-scrollbar {
  display: none !important;
}

body.is-mobile {
  -ms-overflow-style: none !important;
  scrollbar-width: none !important;
  overflow: hidden !important;
  touch-action: none !important;
}

/* Hide the fullscreen button on desktop mode */
body:not(.is-mobile) .mobile-only {
  display: none !important;
}
/* --- FORCE STRIP ON MOBILE --- */
body.force-strip #piano-strip {
  display: block !important;
}
body.force-strip #synthesia-canvas {
  height: 83vh !important;
  height: 83dvh !important;
}
body.force-strip #progress-container {
  height: 83vh !important;
  height: 83dvh !important;
}
body.force-strip #progress-bar {
  width: calc(83vh - 10px) !important;
  width: calc(83dvh - 10px) !important;
}

/* --- WICKI BOARD RANGE HIGHLIGHTING --- */
.p-key.out-of-range:not(.active):not(:active) {
  opacity: 0.25;
}

/* --- RESET MODAL --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  z-index: 4000; /* Highest z-index to sit above everything */
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: rgba(20, 20, 20, 0.98);
  border: 1px solid #555;
  border-radius: 12px;
  padding: 25px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-width: 90%;
  width: 320px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.9);
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.reset-option {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
  color: #ccc;
}

.reset-option input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

/* --- SETTINGS PANEL CUSTOM SCROLLBAR --- */
#settings-panel::-webkit-scrollbar {
  display: block !important;
  width: 8px;
}

#settings-panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  margin-top: 15px;
  margin-bottom: 15px;
}

#settings-panel::-webkit-scrollbar-thumb {
  background: #666;
  border-radius: 10px;
}

#settings-panel::-webkit-scrollbar-thumb:hover {
  background: #888;
}

/* --- WICKI BOARD RIPPLE EFFECT --- */
.ripple {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid #fff;
  pointer-events: none;
  box-sizing: border-box;
  animation: ripple-expand 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  z-index: 5;
}

@keyframes ripple-expand {
  0% {
    width: 100%;
    height: 100%;
    opacity: 0.8;
    border-width: 4px;
  }
  100% {
    width: 250%;
    height: 250%;
    opacity: 0;
    border-width: 0;
  }
}
