/* Aqua Splash: Water the Sprout!
 * 100% Seamless Pipes, Animated Fluid Flow & Tactile Design for 8+ Kids
 */

:root {
  --bg-sky-top: #e0f2fe;
  --bg-sky-mid: #f0fdf4;
  --bg-sky-bottom: #fef3c7;

  --card-bg: rgba(255, 255, 255, 0.96);
  --card-border: #bae6fd;
  --card-shadow: 0 16px 36px rgba(2, 132, 199, 0.16);

  --color-blue: #0284c7;
  --color-blue-dark: #0369a1;
  --color-cyan: #06b6d4;
  --color-green: #10b981;
  --color-green-dark: #059669;
  --color-yellow: #f59e0b;
  --color-yellow-dark: #d97706;
  --color-coral: #f43f5e;
  --color-purple: #8b5cf6;

  --water-empty: #f8fafc;
  --water-flow: #0ea5e9;
  --water-flow-bright: #38bdf8;
  --water-bubble: #ffffff;

  --pipe-outer: #ffffff;
  --pipe-border: #0284c7;
  --pipe-shadow: #bae6fd;
  --flange-color: #fbbf24;
  --flange-border: #d97706;

  --board-bg: #f1f5f9;
  --tile-bg: #ffffff;
  --tile-bg-alt: #f8fafc;

  --text-title: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;

  --font-family: 'Fredoka', 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 10px;
  --radius-md: 20px;
  --radius-lg: 30px;
  --radius-pill: 9999px;

  --tile-size: 110px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background: linear-gradient(145deg, var(--bg-sky-top) 0%, var(--bg-sky-mid) 50%, var(--bg-sky-bottom) 100%);
  color: var(--text-body);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Background floating clouds */
.cloud-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-pill);
  filter: blur(2px);
  animation: floatCloud linear infinite;
}

.cloud-1 {
  width: 280px; height: 85px;
  top: 8%; left: -300px;
  animation-duration: 50s;
}

.cloud-2 {
  width: 380px; height: 110px;
  top: 42%; left: -420px;
  animation-duration: 70s;
  animation-delay: 15s;
}

.cloud-3 {
  width: 220px; height: 75px;
  top: 78%; left: -250px;
  animation-duration: 55s;
  animation-delay: 8s;
}

@keyframes floatCloud {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(100vw + 500px)); }
}

/* Container */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 780px;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  min-height: 100vh;
}

/* Header */
.app-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.6rem;
  background: var(--card-bg);
  border: 4px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-emoji {
  font-size: 2.6rem;
  line-height: 1;
  animation: bounceLogo 2.5s infinite ease-in-out;
}

@keyframes bounceLogo {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(6deg); }
}

.brand-title {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--color-blue);
  letter-spacing: -0.01em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

.header-controls {
  display: flex;
  gap: 0.75rem;
}

.btn-round {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-pill);
  background: #ffffff;
  border: 3px solid var(--card-border);
  box-shadow: 0 4px 0 #bae6fd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-round:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #bae6fd;
  background: #f0f9ff;
}

.btn-round:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #bae6fd;
}

/* HUD Info Bar */
.hud-bar {
  width: 100%;
  display: grid;
  grid-template-columns: 1.3fr 1.1fr 1fr;
  gap: 0.9rem;
}

.hud-pill {
  background: var(--card-bg);
  border: 4px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hud-caption {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.hud-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-title);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hud-sub {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-blue);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.star-rack {
  display: flex;
  gap: 4px;
  font-size: 1.35rem;
}

.star-rack span {
  color: #cbd5e1;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.25s ease;
}

.star-rack span.active {
  color: #f59e0b;
  transform: scale(1.15);
  text-shadow: 0 2px 8px rgba(245, 158, 11, 0.5);
}

/* Board Game Area */
.board-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: auto 0;
  position: relative;
}

.board-card {
  background: var(--card-bg);
  border: 5px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--card-shadow), 0 20px 50px rgba(2, 132, 199, 0.12);
  position: relative;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.water-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
  border-radius: var(--radius-lg);
}

/* 100% SEAMLESS PIPE GRID - ZERO GAPS, ZERO MARGINS, ZERO BORDER-RADIUS ON CELLS */
.pipe-grid {
  display: grid;
  gap: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  background: #e2e8f0;
  border: 7px solid #0284c7;
  border-radius: 20px;
  box-shadow: 0 10px 25px rgba(2, 132, 199, 0.2), inset 0 3px 10px rgba(0,0,0,0.12);
  overflow: hidden;
}

/* INDIVIDUAL TILE - NO GAPS, SEAMLESS TOUCHING */
.pipe-tile {
  position: relative;
  width: var(--tile-size);
  height: var(--tile-size);
  background: var(--tile-bg);
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: visible;
  transition: filter 0.15s ease, background 0.15s ease;
}

/* Checkerboard alternating floor pattern */
.pipe-tile:nth-child(even) {
  background: var(--tile-bg-alt);
}

.pipe-tile:hover {
  filter: brightness(1.05);
  z-index: 10;
}

.pipe-tile:active {
  filter: brightness(0.95);
}

.pipe-tile.locked {
  background: #fffbeb !important;
  cursor: not-allowed;
}

.pipe-tile.locked::after {
  content: '⭐';
  position: absolute;
  bottom: 4px;
  right: 4px;
  font-size: 16px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
  z-index: 12;
}

.pipe-tile.hint-pulse {
  animation: bounceHint 0.8s infinite ease-in-out;
  background: #fef3c7 !important;
  z-index: 20;
}

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

/* SVG Inside Tile - fills 100% flush to boundaries */
.pipe-svg {
  width: 100%;
  height: 100%;
  display: block;
  transform-origin: center center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: visible;
}

/* SVG Pipe Vector Elements */
.pipe-casing {
  fill: none;
  stroke: var(--pipe-border);
  stroke-width: 26;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
}

.pipe-body {
  fill: none;
  stroke: #e0f2fe;
  stroke-width: 20;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
}

.pipe-highlight {
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 14;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
}

.pipe-core {
  fill: none;
  stroke: #bae6fd;
  stroke-width: 10;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  transition: stroke 0.25s ease, filter 0.25s ease;
}

/* Active Flowing Water Stream */
.pipe-tile.flowing .pipe-core {
  stroke: #0284c7;
  filter: drop-shadow(0 0 6px rgba(14, 165, 233, 0.9));
}

/* Animated Water Stream Bubbles Moving Through Pipe */
.pipe-stream {
  fill: none;
  stroke: #ffffff;
  stroke-width: 3.5;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  stroke-dasharray: 6 10;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.pipe-tile.flowing .pipe-stream {
  opacity: 0.95;
  animation: flowMotion 0.55s linear infinite;
}

@keyframes flowMotion {
  from { stroke-dashoffset: 16; }
  to { stroke-dashoffset: 0; }
}

/* Flange / Joint Ring */
.pipe-joint {
  fill: var(--flange-color);
  stroke: var(--flange-border);
  stroke-width: 1.5;
}

/* Fountain Source & Sprout Sink */
.fountain-badge, .sprout-badge {
  position: absolute;
  font-size: 2.3rem;
  z-index: 15;
  pointer-events: none;
  line-height: 1;
}

.fountain-badge {
  top: 6px;
  left: 6px;
  animation: wigglePump 3s infinite ease-in-out;
}

.sprout-badge {
  bottom: 6px;
  right: 6px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sprout-badge.blooming {
  animation: flowerBloom 1.2s infinite alternate ease-in-out;
}

@keyframes wigglePump {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15) rotate(-6deg); }
}

@keyframes flowerBloom {
  0% { transform: scale(1.15) rotate(-6deg); }
  100% { transform: scale(1.4) rotate(6deg); }
}

/* Tactile 3D Action Buttons */
.actions-bar {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 0.85rem;
}

.btn-next-celebrate {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  color: #ffffff !important;
  border-color: #047857 !important;
  box-shadow: 0 5px 0 #047857 !important;
  animation: pulseNextBtn 1.2s infinite ease-in-out !important;
}

@keyframes pulseNextBtn {
  0%, 100% { transform: scale(1); box-shadow: 0 5px 0 #047857; }
  50% { transform: scale(1.06); box-shadow: 0 7px 18px rgba(16, 185, 129, 0.45); }
}

.action-btn {
  background: #ffffff;
  border: 3px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.9rem 0.5rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-title);
  box-shadow: 0 5px 0 #bae6fd;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.action-btn span.btn-emoji {
  font-size: 1.6rem;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #bae6fd;
  background: #f8fafc;
}

.action-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #bae6fd;
}

/* Secondary Modes */
.modes-bar {
  width: 100%;
  display: flex;
  gap: 0.85rem;
}

.btn-pill {
  flex: 1;
  background: #ffffff;
  border: 3px solid var(--card-border);
  border-radius: var(--radius-pill);
  padding: 0.85rem 1.4rem;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-blue);
  box-shadow: 0 5px 0 #bae6fd;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn-pill:hover {
  background: #f0f9ff;
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #bae6fd;
}

.btn-pill:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #bae6fd;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.modal-box {
  background: #ffffff;
  border: 5px solid #bae6fd;
  border-radius: var(--radius-lg);
  padding: 2.2rem 1.8rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 25px 60px rgba(2, 132, 199, 0.28);
  transform: scale(0.9);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.modal-backdrop.active .modal-box {
  transform: scale(1);
}

.modal-emoji-header {
  font-size: 4rem;
  margin-bottom: 0.5rem;
  animation: bounceLogo 2s infinite ease-in-out;
}

.modal-heading {
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-blue);
  margin-bottom: 0.5rem;
}

.modal-text {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 1.4rem;
  line-height: 1.5;
}

.victory-stars {
  display: flex;
  gap: 0.75rem;
  font-size: 3.2rem;
  margin-bottom: 1.4rem;
}

.victory-stars span {
  color: #e2e8f0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.victory-stars span.pop {
  color: #f59e0b;
  transform: scale(1.25);
  filter: drop-shadow(0 4px 10px rgba(245, 158, 11, 0.5));
}

.score-card {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background: #f0fdf4;
  border: 3px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.6rem;
}

.score-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-green-dark);
  text-transform: uppercase;
}

.score-val {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-green-dark);
}

.btn-candy {
  width: 100%;
  background: var(--color-green);
  color: #ffffff;
  border: none;
  padding: 1.1rem 1.8rem;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 800;
  box-shadow: 0 6px 0 var(--color-green-dark);
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn-candy:hover {
  background: #34d399;
  transform: translateY(-2px);
  box-shadow: 0 8px 0 var(--color-green-dark);
}

.btn-candy:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--color-green-dark);
}

.level-select-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.6rem 0.25rem;
  margin-bottom: 1.4rem;
}

.level-card {
  background: #ffffff;
  border: 3px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-title);
  box-shadow: 0 4px 0 #bae6fd;
  transition: all 0.1s ease;
}

.level-card:hover {
  transform: translateY(-2px);
  border-color: var(--color-blue);
  box-shadow: 0 6px 0 #38bdf8;
}

.level-card.done {
  background: #f0fdf4;
  border-color: #86efac;
  box-shadow: 0 4px 0 #4ade80;
  color: var(--color-green-dark);
}

.level-card.current {
  border-color: var(--color-yellow);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.55);
}

.level-card-stars {
  font-size: 0.8rem;
  color: #f59e0b;
  margin-top: 3px;
}

@media (max-width: 600px) {
  .app-container {
    padding: 0.75rem;
    gap: 0.8rem;
  }
  .brand-title {
    font-size: 1.5rem;
  }
  .brand-emoji {
    font-size: 2rem;
  }
  .hud-value {
    font-size: 1.2rem;
  }
  .board-card {
    padding: 8px;
  }
}
