/* Musical Pipes — styles */

:root {
  --mp-navy: #1b2245;
  --mp-navy-deep: #131836;
  --mp-panel: #232b58;
  --mp-ivory: #fdf8ee;
  --mp-teal: #099695;
  --mp-green: #6abb4a;
  --mp-gold: #ffd25b;
  --mp-red: #e72829;
  --mp-text: #fdf8ee;
  --mp-shadow: rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body.pipes-page {
  font-family: "Nunito", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -100px, #2a3468 0%, var(--mp-navy) 55%, var(--mp-navy-deep) 100%);
  color: var(--mp-text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

[hidden] { display: none !important; }

.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px clamp(10px, 3vw, 24px) 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}



/* ------------------------------------------------------------------ */
/* Buttons (brand rule: solid green / teal, never gradients)          */
/* ------------------------------------------------------------------ */
.action-btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 13px 26px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--mp-teal);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.28);
  cursor: pointer;
}
.action-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28); }
.action-btn.primary { background: var(--mp-green); }
.action-btn.small { padding: 9px 16px; font-size: 14px; border-radius: 11px; }

/* ------------------------------------------------------------------ */
/* Level select                                                        */
/* ------------------------------------------------------------------ */
.select-screen { text-align: center; }

.app-title {
  margin: 34px 0 2px;
  font-size: clamp(30px, 6vw, 44px);
  font-weight: 900;
  letter-spacing: 0.01em;
}
.app-title .t-pipe { color: var(--mp-gold); }

.select-sub {
  margin: 0 0 20px;
  font-size: 16px;
  font-weight: 700;
  color: rgba(253, 248, 238, 0.75);
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin: 0 auto;
  max-width: 720px;
}

.level-card {
  appearance: none;
  border: 2px solid rgba(253, 248, 238, 0.16);
  border-radius: 16px;
  background: var(--mp-panel);
  color: var(--mp-ivory);
  padding: 14px 10px 12px;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  position: relative;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.level-card:not(.locked):hover { transform: translateY(-2px); border-color: rgba(253, 248, 238, 0.45); }
.level-card .lc-num {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 15px;
  color: #fff;
  margin-bottom: 6px;
}
.level-card .lc-name { display: block; font-weight: 900; font-size: 14px; line-height: 1.25; }
.level-card .lc-stars { display: block; margin-top: 6px; font-size: 15px; letter-spacing: 2px; color: var(--mp-gold); min-height: 19px; }
.level-card .lc-stars .off { color: rgba(253, 248, 238, 0.22); }
.level-card.locked { opacity: 0.45; cursor: default; }
.level-card.locked .lc-stars { color: rgba(253, 248, 238, 0.4); letter-spacing: 0; font-size: 17px; }

/* theme accents on the number chip */
.theme-meadow .lc-num { background: var(--mp-green); }
.theme-garden .lc-num { background: #ea6ba3; }
.theme-river  .lc-num { background: var(--mp-teal); }
.theme-works  .lc-num { background: #f39422; }

/* ------------------------------------------------------------------ */
/* Game screen                                                         */
/* ------------------------------------------------------------------ */
.game-screen { display: flex; flex-direction: column; align-items: center; }

.hud {
  width: 100%;
  max-width: 700px;
  margin: 52px auto 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.hud-level { font-size: clamp(19px, 4vw, 26px); font-weight: 900; margin: 0; }
.hud-moves { font-size: 15px; font-weight: 800; color: rgba(253, 248, 238, 0.8); }
.hud-moves b { color: var(--mp-gold); font-size: 18px; }

.hud-blurb {
  width: 100%;
  max-width: 700px;
  margin: 0 auto 14px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: rgba(253, 248, 238, 0.68);
}

/* Board frame: room for the START / FINISH spouts on every side */
.board-wrap {
  position: relative;
  width: 100%;
  max-width: 880px;
  padding: 62px 30px;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 6px;
  background: rgba(19, 24, 54, 0.65);
  border: 3px solid rgba(253, 248, 238, 0.18);
  border-radius: 18px;
  padding: 8px;
  box-shadow: 0 10px 30px var(--mp-shadow);
}

.tile {
  appearance: none;
  border: none;
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  background: #333;                 /* replaced inline with the note color */
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.18), inset 0 -5px 0 rgba(0, 0, 0, 0.16);
}
.tile:focus-visible { outline: 3px solid var(--mp-gold); outline-offset: 2px; }

.tile svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: transform 0.19s cubic-bezier(0.34, 1.4, 0.64, 1);
  will-change: transform;
  pointer-events: none;
}

.tile .note-tag {
  position: absolute;
  left: 8px;
  top: 6px;
  font-size: clamp(12px, 2.6vw, 17px);
  font-weight: 900;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.tile.hint-pulse svg { animation: hintPulse 0.55s ease 3; }
@keyframes hintPulse {
  0%, 100% { filter: none; }
  50% { filter: drop-shadow(0 0 12px #fff) brightness(1.35); }
}

.tile.flow-lit { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.85), inset 0 -5px 0 rgba(0, 0, 0, 0.16); }

/* board is inert while the liquid flows / celebration shows */
.board.locked .tile { cursor: default; }

/* START / FINISH spouts */
.spout {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  transform: translate(-50%, -50%);
}
.spout .spout-cap {
  position: relative;
  display: grid;
  place-items: center;
  /* A square footprint so a rotated arrow keeps the same box on every edge —
     otherwise a 90deg turn makes the layout box wide while the art is tall,
     and the START / FINISH label lands underneath the arrow. */
  width: 76px;
  height: 76px;
  /* No plate behind it any more: the marker floats on the dark background so
     it reads as a piece of pipe rather than a badge. */
}
.spout .spout-arrow {
  width: 74px;
  height: auto;
  display: block;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.5));
  transform: rotate(var(--rot, 0deg));
}


.spout .spout-flag {
  position: absolute;
  top: -10px;
  right: -6px;
  width: 26px;
  height: 26px;
  display: block;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}
.spout .spout-flag svg { width: 100%; height: 100%; display: block; }
.spout .spout-label {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: rgba(253, 248, 238, 0.85);
  background: rgba(19, 24, 54, 0.85);
  border-radius: 6px;
  padding: 2px 6px;
}
/* while liquid is moving, the arrow nudges the way it points (the
   rotation rides along, so this reads correctly on all four edges) */
.spout.pouring .spout-arrow { animation: nudge 0.7s ease-in-out infinite; }
@keyframes nudge {
  0%, 100% { transform: rotate(var(--rot, 0deg)) translateX(0); }
  50% { transform: rotate(var(--rot, 0deg)) translateX(4px); }
}
@media (prefers-reduced-motion: reduce) {
  .spout.pouring .spout-arrow { animation: none; }
}

/* toolbar under the board */
.toolbar {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ------------------------------------------------------------------ */
/* Celebration panel                                                   */
/* ------------------------------------------------------------------ */
.panel-veil {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(12, 16, 38, 0.66);
  display: grid;
  place-items: center;
  padding: 18px;
}
.panel {
  width: min(430px, 94vw);
  background: var(--mp-panel);
  border: 3px solid rgba(253, 248, 238, 0.22);
  border-radius: 22px;
  padding: 26px 22px 22px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  animation: panelIn 0.3s cubic-bezier(0.34, 1.45, 0.64, 1);
}
@keyframes panelIn { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.panel h2 { margin: 0 0 4px; font-size: 27px; font-weight: 900; color: var(--mp-gold); }
.panel .panel-sub { margin: 0 0 12px; font-weight: 800; font-size: 15px; color: rgba(253, 248, 238, 0.8); }

.star-row { font-size: 42px; letter-spacing: 6px; margin: 4px 0 8px; color: var(--mp-gold); }
.star-row .off { color: rgba(253, 248, 238, 0.18); }
.star-row .pop { display: inline-block; animation: starPop 0.45s cubic-bezier(0.34, 1.6, 0.64, 1) backwards; }
.star-row .pop:nth-child(2) { animation-delay: 0.18s; }
.star-row .pop:nth-child(3) { animation-delay: 0.36s; }
@keyframes starPop { from { transform: scale(0); } to { transform: scale(1); } }

.panel .stat-row { font-size: 15px; font-weight: 800; margin: 2px 0; color: rgba(253, 248, 238, 0.85); }
.panel .stat-row b { color: #fff; }

.panel-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

#classScoreSlot { margin-top: 12px; }

/* melody note chips inside the panel */
.melody-chips {
  display: flex;
  gap: 5px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 8px 0 2px;
}
.melody-chips .chip {
  min-width: 44px;
  min-height: 44px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(0, 0, 0, 0.2);
}

@media (max-width: 480px) {
  .board-wrap { padding: 52px 18px; }
  .board { gap: 4px; padding: 6px; }

  /* Smaller markers on a phone, and the square footprint shrinks with them so
     the label still clears the arrow on every edge. */
  .spout .spout-cap { width: 58px; height: 58px; }
  .spout .spout-arrow { width: 56px; }
  .spout .spout-flag { width: 20px; height: 20px; top: -6px; right: -2px; }
}
