@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;800&display=swap');

:root {
  --main-bg-gradient: linear-gradient(45deg, #FC466B 0%, #3F5EFB 100%);
  --text-color: white;
  --font-family: 'Poppins', sans-serif;
  --border-radius: 10px;
  --box-shadow: 0 5px 15px rgba(255, 65, 108, 0.4);
  --active-box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
  --active-border: 2px solid black;
}

html, body {
  background: var(--main-bg-gradient);
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  font-family: var(--font-family);
}

h1 {
  color: var(--text-color);
  font-size: clamp(2rem, 5vw, 4rem); 
  letter-spacing: clamp(2px, 1vw, 8px);
  text-shadow: 3px 3px 0px rgba(0,0,0,0.2);
  animation: titlePulse 2s infinite;
  text-align: center;
  padding: 0 1rem;
}

.pad {
  width: min(90%, 380px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(4px, 1vw, 8px);
  padding: clamp(10px, 3vw, 20px);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
  justify-items: center; 
}

.key {
  width: clamp(70px, 20vw, 95px);
  height: clamp(70px, 20vw, 95px);
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 600;
  color: var(--text-color);
  background: linear-gradient(135deg, rgba(255,255,255,0.2), rgba(255,255,255,0.1));
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 15px;
  box-shadow: 0 8px 15px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
  cursor: pointer;
  opacity: 0.9;
}

.key:nth-child(1) { background: linear-gradient(135deg, #FF6B6B, #FFE66D); }
.key:nth-child(2) { background: linear-gradient(135deg, #4ECDC4, #6EE7B7); }
.key:nth-child(3) { background: linear-gradient(135deg, #A78BFA, #818CF8); }
.key:nth-child(4) { background: linear-gradient(135deg, #FF85E4, #FF7EB3); }
.key:nth-child(5) { background: linear-gradient(135deg, #FFA41B, #FFD93D); }
.key:nth-child(6) { background: linear-gradient(135deg, #00F5A0, #00D9F5); }
.key:nth-child(7) { background: linear-gradient(135deg, #F472B6, #FB7185); }
.key:nth-child(8) { background: linear-gradient(135deg, #34D399, #60A5FA); }
.key:nth-child(9) { background: linear-gradient(135deg, #9333EA, #6366F1); }

.sound {
  font-size: clamp(10px, 2vw, 12px);
  text-transform: uppercase;
  color: rgba(255,255,255,0.9);
  margin-top: 8px;
  letter-spacing: 2px;
}

.key.playing {
  opacity: 1;
  background: linear-gradient(135deg, #FC466B, #3F5EFB);
  transform: scale(0.95);
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
}

.key.playing .sound {
  color: var(--text-color);
  transform: scale(1.2);
  transition: all 0.2s ease;
}

.controls {
  width: min(90%, 400px);
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

#record, #play {
  width: clamp(120px, 35%, 140px); 
  padding: clamp(8px, 2vw, 12px) clamp(15px, 3vw, 25px);
  margin: clamp(10px, 2vw, 20px) clamp(5px, 1vw, 10px);
  border: none;
  border-radius: var(--border-radius);
  color: var(--text-color);
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  border: 2px solid transparent;
}

#record {
  background: linear-gradient(45deg, #ef2554, #FF4B2B);
  box-shadow: var(--box-shadow);
}

#play {
  background: linear-gradient(45deg, #00F260, #0575E6);
  box-shadow: 0 5px 10px rgba(0, 242, 96, 0.4);
}

#record.active, #play.active {
  background: linear-gradient(45deg, #d31b46, #cc2d0f);
  transform: scale(0.95);
  box-shadow: var(--active-box-shadow);
  border: var(--active-border); 
}

@keyframes titlePulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); } 
  100% { transform: scale(1); }
}

@media screen and (max-width: 480px) {
  .pad {
    gap: 8px;
    padding: 15px;
  }

  .controls {
    justify-content: center;
  }

  .key {
    border-radius: 10px;
  }

  .sound {
    letter-spacing: 1px;
  }
}


@media screen and (max-width: 320px) {
  .pad {
    grid-template-columns: repeat(2, 1fr); 
    gap: 6px;
    padding: 10px;
  }

  h1 {
    font-size: 1.5rem;
    letter-spacing: 4px;
  }
}