/* Piano Smash — a dark stage with a lit keyboard along the bottom.
   Four moods, each a [data-mood] block of custom properties. */

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

[data-mood="sunshine"] {
  --bg-a: #2a1b3d; --bg-b: #452a55; --bg-c: #7b3f5e;
  --glow: rgba(255, 190, 90, .5);
  --accent: #ffb03b;
  --accent-ink: #4a2a0c;
}
[data-mood="moonlight"] {
  --bg-a: #0b1430; --bg-b: #16264f; --bg-c: #2b4a7a;
  --glow: rgba(130, 180, 255, .45);
  --accent: #7ab8ff;
  --accent-ink: #10243f;
}
[data-mood="musicbox"] {
  --bg-a: #250f38; --bg-b: #421a5c; --bg-c: #7a3080;
  --glow: rgba(230, 150, 255, .45);
  --accent: #e08cff;
  --accent-ink: #3c1147;
}
[data-mood="meadow"] {
  --bg-a: #0e2a22; --bg-b: #1b4636; --bg-c: #3d7a4a;
  --glow: rgba(150, 235, 160, .42);
  --accent: #7fd88f;
  --accent-ink: #123a26;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #12101f;
  color: #fff;
  font-family: "Baloo 2", "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: none;
  cursor: default;
}

/* ------------------------------------------------------------------ stage */

.hall { position: fixed; inset: 0; overflow: hidden; }
.hall::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(#0a0817 0%, var(--bg-a) 38%, var(--bg-b) 70%, var(--bg-c) 100%);
  transition: background .5s ease;
}
/* A pool of light where the keyboard sits. */
.glow {
  position: absolute;
  left: 50%; bottom: 0;
  width: 140vw; height: 60vh;
  transform: translateX(-50%);
  background: radial-gradient(ellipse 50% 100% at 50% 100%, var(--glow) 0%, transparent 70%);
  will-change: opacity;
  animation: breathe 9s ease-in-out infinite alternate;
}
@keyframes breathe { to { opacity: .62; } }
/* Slow drifting haze, so the stage isn't dead flat. */
.haze {
  position: absolute; inset: -20%;
  background:
    radial-gradient(ellipse 30% 40% at 25% 35%, rgba(255,255,255,.05), transparent 60%),
    radial-gradient(ellipse 26% 34% at 75% 55%, rgba(255,255,255,.04), transparent 60%);
  will-change: transform;
  animation: swirl 44s ease-in-out infinite alternate;
}
@keyframes swirl { to { transform: translate3d(4vw, -3vh, 0) rotate(6deg); } }

#fx {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 5;
  pointer-events: none;
}

/* --------------------------------------------------------------- keyboard */

#keyboard {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 22vh;
  min-height: 90px;
  z-index: 6;
  /* box-shadow on the strip, not drop-shadow: a filter would re-rasterise the
     whole subtree of ~90 keys every time one of them flashes. */
  box-shadow: 0 -1vmin 3vmin rgba(0, 0, 0, .55);
}
.k {
  position: absolute;
  top: 0;
  border-radius: 0 0 6px 6px;
}
.k.white {
  height: 100%;
  background: linear-gradient(#fffefb 0%, #f2eee6 82%, #ded8cc 100%);
  border: 1px solid #b9b2a6;
  border-top: none;
  z-index: 1;
}
.k.black {
  height: 62%;
  background: linear-gradient(#3b3a44 0%, #1b1a22 78%, #0d0c12 100%);
  border: 1px solid #000;
  border-top: none;
  z-index: 2;
  border-radius: 0 0 5px 5px;
}

/* A struck key: flash the note's colour, then settle back. Re-adding the
   class restarts this, which is how repeated notes re-flash. */
.k.hit { animation: strike .55s ease-out; }
@keyframes strike {
  0%   { background: var(--glow); box-shadow: 0 0 3vmin var(--glow); filter: brightness(1.5); }
  100% { box-shadow: none; filter: none; }
}
.k.white.hit { animation-name: strike-white; }
@keyframes strike-white {
  0%   { background: var(--glow); box-shadow: 0 0 3vmin var(--glow); }
  100% { background: linear-gradient(#fffefb 0%, #f2eee6 82%, #ded8cc 100%); box-shadow: none; }
}
.k.black.hit { animation-name: strike-black; }
@keyframes strike-black {
  0%   { background: var(--glow); box-shadow: 0 0 2.4vmin var(--glow); }
  100% { background: linear-gradient(#3b3a44 0%, #1b1a22 78%, #0d0c12 100%); box-shadow: none; }
}

/* ------------------------------------------------------------------- gate */

#gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(6, 5, 16, .62);
  padding: 4vmin;
}
#gate.gone { display: none; }

.gate-card {
  position: relative;
  max-width: min(92vw, 700px);
  padding: 5vmin 6vmin;
  border-radius: 4vmin;
  text-align: center;
  color: #f4efe6;
  background: linear-gradient(rgba(30, 24, 48, .96), rgba(20, 16, 34, .96));
  box-shadow: 0 2vmin 6vmin rgba(0, 0, 0, .6), inset 0 0 0 .5vmin var(--accent);
}
.gate-card h1 {
  margin: 0;
  font-size: clamp(26px, 5.6vmin, 52px);
  letter-spacing: .5px;
  color: var(--accent);
  text-shadow: 0 0 3vmin var(--glow);
}
.tag { margin: 1.6vmin 0 3.6vmin; font-size: clamp(15px, 2.6vmin, 24px); color: #cbbfd8; }

#play {
  font: inherit;
  font-size: clamp(20px, 4.4vmin, 40px);
  font-weight: 700;
  color: var(--accent-ink);
  padding: 2.2vmin 7vmin;
  border: none;
  border-radius: 99px;
  background: linear-gradient(color-mix(in srgb, var(--accent) 75%, #fff), var(--accent));
  box-shadow: 0 1.2vmin 0 color-mix(in srgb, var(--accent) 55%, #000),
              0 2vmin 3vmin rgba(0, 0, 0, .45);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
#play:hover { transform: translateY(-.3vmin); }
#play:active {
  transform: translateY(1.1vmin);
  box-shadow: 0 .2vmin 0 color-mix(in srgb, var(--accent) 55%, #000);
}

.moods {
  display: flex;
  justify-content: center;
  gap: 1.4vmin;
  flex-wrap: wrap;
  margin: 4vmin 0 0;
}
.mood-btn {
  font: inherit;
  font-size: clamp(11px, 1.9vmin, 16px);
  font-weight: 700;
  color: #cbbfd8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4vmin;
  padding: 1.4vmin 2vmin;
  min-width: 18vmin;
  border: none;
  border-radius: 2.2vmin;
  background: rgba(255, 255, 255, .06);
  cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease, transform .1s ease;
}
.mood-btn b { font-size: clamp(18px, 3.4vmin, 30px); line-height: 1; }
.mood-btn:hover { background: rgba(255, 255, 255, .13); transform: translateY(-.3vmin); }
.mood-btn.on {
  color: #fff;
  background: rgba(255, 255, 255, .16);
  box-shadow: inset 0 0 0 .35vmin var(--accent), 0 0 2vmin var(--glow);
}

.mood-now { margin: 2vmin 0 0; font-size: clamp(11px, 1.8vmin, 15px); color: #9d90ad; }
.mood-now b { color: var(--accent); }

.notes {
  margin: 3vmin 0 0;
  padding: 0;
  list-style: none;
  font-size: clamp(12px, 1.95vmin, 16px);
  line-height: 1.8;
  color: #a89bb8;
}

.mute {
  position: fixed;
  top: 2.5vmin; right: 2.5vmin;
  width: 8vmin; height: 8vmin;
  max-width: 54px; max-height: 54px;
  font-size: clamp(18px, 3.6vmin, 26px);
  line-height: 1;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  box-shadow: inset 0 0 0 .35vmin var(--accent);
  cursor: pointer;
  z-index: 21;
}
.mute.off { filter: grayscale(1); opacity: .6; }

#exit-hint {
  position: fixed;
  left: 50%; top: 1.6vmin;
  transform: translateX(-50%);
  z-index: 15;
  padding: .8vmin 2.4vmin;
  border-radius: 99px;
  font-size: clamp(10px, 1.7vmin, 14px);
  color: rgba(255, 255, 255, .75);
  background: rgba(0, 0, 0, .35);
  opacity: 0;
  transition: opacity .5s ease;
  pointer-events: none;
}
#exit-hint.show { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .glow, .haze { animation: none !important; }
}
