@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@600;700;900&family=Space+Grotesk:wght@400;500;700&display=swap');

:root {
  --color-c: #ef4444;
  --color-d: #f97316;
  --color-e: #facc15;
  --color-f: #84cc16;
  --color-g: #22c55e;
  --color-a: #a855f7;
  --color-b: #ec4899;
  --color-c5: #ef4444;
  --color-d5: #f97316;
  --color-fondo: #05081d;
  --color-texto: #e8f0ff;
  --color-exito: #4ade80;
  --color-error: #fb7185;
  --color-vida: #fb7185;
  --panel-bg: rgba(11, 17, 49, 0.8);
  --panel-border: rgba(167, 139, 250, 0.38);
  --bar-duration-css: 2.4s;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--color-texto);
  background:
    radial-gradient(55% 45% at 50% 18%, rgba(96, 165, 250, 0.36), transparent 70%),
    radial-gradient(40% 28% at 85% 26%, rgba(216, 180, 254, 0.25), transparent 72%),
    radial-gradient(35% 30% at 14% 15%, rgba(56, 189, 248, 0.2), transparent 72%),
    linear-gradient(180deg, #090f32 0%, #070a21 55%, #040615 100%);
  overflow-x: hidden;
  overflow-y: auto;
  display: block;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 24% 34%, rgba(248, 250, 252, 0.16) 0 1px, transparent 1.5px) 0 0/170px 170px,
    radial-gradient(circle at 72% 65%, rgba(219, 234, 254, 0.14) 0 1px, transparent 1.5px) 0 0/150px 150px;
  opacity: 0.75;
  z-index: -2;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(38% 28% at 50% 24%, rgba(192, 132, 252, 0.2), transparent 76%),
    radial-gradient(45% 35% at 50% 100%, rgba(56, 189, 248, 0.14), transparent 80%);
  z-index: -1;
}

#game-world {
  width: min(92vw, 980px);
  height: 320px;
  position: relative;
  border-radius: 22px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  background:
    linear-gradient(180deg, rgba(30, 41, 82, 0.55), rgba(16, 24, 52, 0.7)),
    radial-gradient(120% 130% at 10% 20%, rgba(56, 189, 248, 0.13), transparent 65%),
    radial-gradient(120% 130% at 85% 15%, rgba(192, 132, 252, 0.12), transparent 70%);
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(191, 219, 254, 0.1),
    0 16px 45px rgba(0, 0, 0, 0.45),
    0 0 28px rgba(59, 130, 246, 0.22);
  margin: 78px auto 0 auto;
}

#game-world::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0) 0%, rgba(15, 23, 42, 0.28) 90%),
    repeating-linear-gradient(90deg, rgba(148, 163, 184, 0.08), rgba(148, 163, 184, 0.08) 1px, transparent 1px, transparent 80px);
  mix-blend-mode: screen;
  opacity: 0.38;
}

.note-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  position: absolute;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.04rem;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.4);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
  z-index: 5;
  animation: spawn-pop 0.3s ease-out forwards;
}

@keyframes spawn-pop {
  from {
    transform: translateY(-50%) scale(0.5);
    opacity: 0;
  }

  to {
    transform: translateY(-50%) scale(1);
    opacity: 1;
  }
}

.timing-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 2px solid rgba(224, 242, 254, 0.88);
  border-radius: 50%;
  opacity: 0;
}

.note-circle.has-timing-ring .timing-ring {
  animation: shrink-and-fade-in var(--bar-duration-css) linear forwards;
}

@keyframes shrink-and-fade-in {
  0% {
    transform: scale(2.5);
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  98% {
    transform: scale(1);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 0.7;
  }
}

.note-circle.correct {
  box-shadow: 0 0 20px 5px rgba(74, 222, 128, 0.7);
  border-color: var(--color-exito);
}

.note-circle.incorrect {
  box-shadow: 0 0 20px 5px rgba(251, 113, 133, 0.72);
  border-color: var(--color-error);
}

#ui-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background:
    radial-gradient(55% 48% at 50% 24%, rgba(30, 58, 138, 0.45), rgba(2, 6, 23, 0.86)),
    rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(4px);
  transition: opacity 0.35s;
  padding: 1rem;
}

#ui-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  display: none !important;
}

.hidden {
  display: none !important;
}

#start-screen,
#game-over-screen {
  width: min(94vw, 760px);
  border-radius: 28px;
  padding: 1.35rem 1.5rem 1.5rem;
  border: 1px solid var(--panel-border);
  background:
    linear-gradient(180deg, rgba(21, 33, 76, 0.92), rgba(11, 17, 49, 0.85)),
    var(--panel-bg);
  box-shadow:
    inset 0 0 0 1px rgba(191, 219, 254, 0.09),
    0 20px 55px rgba(0, 0, 0, 0.45),
    0 0 30px rgba(167, 139, 250, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--color-texto);
}

.start-hero {
  width: 100%;
  text-align: center;
  margin-bottom: 0.95rem;
  position: relative;
  isolation: isolate;
}

.start-hero::before,
.start-hero::after {
  content: "";
  position: absolute;
  left: 50%;
  pointer-events: none;
  border-radius: 50%;
  border: 1px solid rgba(147, 197, 253, 0.28);
  z-index: -1;
}

.start-hero::before {
  width: min(72vw, 470px);
  aspect-ratio: 1 / 1;
  top: -30px;
  transform: translateX(-50%) rotate(-14deg);
  animation: orbit-slow 18s linear infinite;
}

.start-hero::after {
  width: min(58vw, 360px);
  aspect-ratio: 1 / 1;
  top: 2px;
  transform: translateX(-50%) rotate(12deg);
  opacity: 0.8;
  animation: orbit-slow 13s linear infinite reverse;
}

@keyframes orbit-slow {
  from {
    transform: translateX(-50%) rotate(0deg);
  }

  to {
    transform: translateX(-50%) rotate(360deg);
  }
}

.canon-logo {
  width: min(100%, 520px);
  display: block;
  margin: 0 auto 0.2rem;
  filter:
    drop-shadow(0 0 14px rgba(125, 211, 252, 0.7)) drop-shadow(0 0 28px rgba(192, 132, 252, 0.35));
  animation: logo-float 4.6s ease-in-out infinite;
}

@keyframes logo-float {

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

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

#start-screen h1 {
  display: none;
  margin: 0.1rem 0 0.12rem;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(1.3rem, 2.3vw, 1.62rem);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #dbeafe;
  text-shadow: 0 0 14px rgba(125, 211, 252, 0.34);
}

#start-screen p {
  margin: 0;
  font-size: clamp(0.94rem, 1.8vw, 1.06rem);
  color: rgba(224, 242, 254, 0.85);
  text-align: center;
}

#game-over-screen h2 {
  margin: 0.2rem 0 0.45rem;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(1.4rem, 2.7vw, 1.95rem);
  letter-spacing: 0.1em;
  color: #dbeafe;
}

#game-over-screen p {
  margin: 0.2rem 0 1rem;
  color: rgba(224, 242, 254, 0.85);
}

#game-settings {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  margin-bottom: 1.1rem;
  width: min(100%, 780px);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
  text-align: left;
}

.setting-group label {
  color: #bfdbfe;
  font-weight: 700;
  margin-bottom: 0.05rem;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.option-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  gap: 0.5rem;
}

.option-btn {
  position: relative;
  text-align: center;
  border: 1px solid rgba(147, 197, 253, 0.22);
  background: rgba(30, 41, 82, 0.74);
  color: #dbeafe;
  border-radius: 12px;
  font-size: 0.98rem;
  font-weight: 700;
  padding: 0.56rem 0.35rem;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s, background 0.15s;
  user-select: none;
}

.option-btn.locked-premium {
  opacity: 0.65;
}

.option-btn.locked-premium::after {
  content: "";
  position: absolute;
  top: -10px;
  right: -8px;
  width: 14px;
  height: 14px;
  background-color: rgba(255, 255, 255, 0.45);
  mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C9.243 2 7 4.243 7 7V10H6V20H18V10H17V7C17 4.243 14.757 2 12 2ZM9 7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V10H9V7ZM12 17C10.895 17 10 16.105 10 15C10 13.895 10.895 13 12 13C13.105 13 14 13.895 14 15C14 16.105 13.105 17 12 17Z" fill="white"/></svg>');
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C9.243 2 7 4.243 7 7V10H6V20H18V10H17V7C17 4.243 14.757 2 12 2ZM9 7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V10H9V7ZM12 17C10.895 17 10 16.105 10 15C10 13.895 10.895 13 12 13C13.105 13 14 13.895 14 15C14 16.105 13.105 17 12 17Z" fill="white"/></svg>');
  mask-size: contain;
  -webkit-mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-position: center;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.option-btn.active {
  border-color: rgba(125, 211, 252, 0.95);
  background: linear-gradient(150deg, rgba(56, 189, 248, 0.78), rgba(99, 102, 241, 0.8));
  color: #fff;
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.28);
}

#difficulty-selector .option-btn.active {
  background: linear-gradient(150deg, rgba(74, 222, 128, 0.76), rgba(20, 184, 166, 0.77));
  box-shadow: 0 6px 18px rgba(74, 222, 128, 0.26);
}

#difficulty-selector .option-btn:nth-child(2).active {
  background: linear-gradient(150deg, rgba(56, 189, 248, 0.78), rgba(99, 102, 241, 0.8));
}

#difficulty-selector .option-btn:nth-child(3).active {
  background: linear-gradient(150deg, rgba(251, 113, 133, 0.78), rgba(168, 85, 247, 0.78));
  box-shadow: 0 6px 18px rgba(251, 113, 133, 0.23);
}

.option-btn:hover:not(.active) {
  border-color: rgba(196, 181, 253, 0.44);
  background: rgba(51, 65, 117, 0.83);
  transform: translateY(-1px);
}

input[type="range"] {
  accent-color: #7dd3fc;
  background: rgba(148, 163, 184, 0.2);
  height: 7px;
  border-radius: 999px;
  width: 100%;
}

input[type="checkbox"] {
  accent-color: #7dd3fc;
  transform: scale(1.15);
  margin-right: 0.58em;
}

#start-btn,
#retry-btn {
  margin-top: 0.45rem;
  font-size: 1rem;
  font-weight: 800;
  padding: 0.76rem 2.2rem;
  border-radius: 14px;
  border: 1px solid rgba(191, 219, 254, 0.5);
  background: linear-gradient(135deg, #38bdf8 5%, #6366f1 52%, #a855f7 100%);
  color: #ffffff;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  box-shadow: 0 10px 24px rgba(56, 189, 248, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  cursor: pointer;
  transition: transform 0.14s, box-shadow 0.16s, filter 0.16s;
  width: min(100%, 340px);
  display: block;
}

#start-btn:hover,
#retry-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(56, 189, 248, 0.34);
  filter: brightness(1.05);
}

#piano {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 30px auto 0 auto;
  position: relative;
  z-index: 5;
}

.piano-key {
  width: 60px;
  height: 112px;
  border: 1px solid rgba(148, 163, 184, 0.42);
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 10px;
  font-weight: 700;
  transition: transform 0.1s, background-color 0.1s, box-shadow 0.15s;
  background: linear-gradient(180deg, rgba(30, 41, 82, 0.8), rgba(15, 23, 42, 0.75));
  margin-right: 3px;
  box-shadow: inset 0 0 0 1px rgba(219, 234, 254, 0.07);
}

.piano-key.active {
  transform: scale(0.95);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.35), rgba(99, 102, 241, 0.42));
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.28);
}

.key-char {
  font-size: 1.18rem;
  font-weight: 700;
}

.key-name {
  font-size: 0.78rem;
  color: rgba(191, 219, 254, 0.88);
}

#game-stats {
  position: absolute;
  top: 14px;
  left: 18px;
  right: 18px;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--color-texto);
  font-weight: 700;
  pointer-events: none;
}

.stat {
  text-align: left;
}

.stat span {
  display: block;
}

.stat span:first-child {
  font-size: 0.76rem;
  color: rgba(191, 219, 254, 0.72);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat span:last-child {
  font-family: "Orbitron", sans-serif;
  font-size: 1.68rem;
}

#combo-value.pop {
  animation: pop-combo 0.2s ease-out;
}

@keyframes pop-combo {
  50% {
    transform: scale(1.2);
  }
}

#lives-container {
  font-size: 1.42rem;
  letter-spacing: 4px;
  color: var(--color-vida);
  text-shadow: 0 0 10px rgba(251, 113, 133, 0.55);
}

@media (max-width: 950px) {
  #game-world {
    width: min(96vw, 980px);
  }

  #piano {
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {

  #start-screen,
  #game-over-screen {
    width: min(96vw, 760px);
    padding: 1rem 0.85rem 1.15rem;
    border-radius: 20px;
  }

  .start-hero::before,
  .start-hero::after {
    display: none;
  }

  #game-settings {
    width: min(100%, 96vw);
    gap: 0.78rem;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .option-selector {
    grid-template-columns: repeat(auto-fit, minmax(106px, 1fr));
    gap: 0.42rem;
  }

  .option-btn {
    font-size: 0.9rem;
    border-radius: 10px;
    padding: 0.5rem 0.3rem;
  }
}

@media (max-width: 620px) {
  #game-world {
    height: 285px;
    margin-top: 62px;
  }

  #piano {
    margin-top: 14px;
    gap: 4px;
  }

  .piano-key {
    width: 42px;
    height: 72px;
    padding-bottom: 6px;
  }

  .key-char {
    font-size: 0.95rem;
  }

  .key-name {
    font-size: 0.63rem;
  }
}