/*
 * Quiz Jumper — Main Styles
 * Calm, zen pond aesthetic for educational maths game
 */

/* ============================================
   CSS Custom Properties — Color Palette
   ============================================ */

:root {
  /* Water — soft blue-green tones */
  --water-lightest: #e8f4f0;
  --water-light: #b8d8ce;
  --water-mid: #7ab5a5;
  --water-dark: #4a8f7d;
  --water-deep: #2d6b5a;

  /* Lily pad green - lighter than the frog so they stay distinct. */
  --lily-light: #b9e3a4;
  --lily-mid: #9bd286;
  --lily-dark: #6fae5b;

  /* UI Neutrals */
  --neutral-bg: #f5f9f7;
  --neutral-surface: #ffffff;
  --neutral-text: #2d3b36;
  --neutral-text-muted: #6b7d75;
  --neutral-border: #c8d9d2;

  /* Frog colors - a touch darker than the lily pads so the frog
     reads against them. */
  --frog-body: #4f9b1f;
  --frog-body-dark: #2f6e10;
  --frog-belly: #c5e6a8;
  --frog-eye-white: #ffffff;
  --frog-eye-pupil: #1a1a1a;

  /* Feedback colors */
  --success: #4caf50;
  --error: #e57373;
  --warning: #ffb74d;

  /* Shadows & depth */
  --shadow-sm: 0 1px 3px rgba(45, 90, 74, 0.12);
  --shadow-md: 0 4px 12px rgba(45, 90, 74, 0.15);
  --shadow-lg: 0 8px 24px rgba(45, 90, 74, 0.2);

  /* Spacing scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;

  /* Border radius */
  --radius-sm: 0.5rem;
  --radius-md: 1rem;
  --radius-lg: 1.5rem;
  --radius-full: 9999px;

  /* Font stack — friendly rounded system fonts */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.25rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;
}

/* ============================================
   Reset & Normalize
   ============================================ */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--neutral-text);
  background: linear-gradient(
    180deg,
    var(--water-lightest) 0%,
    var(--water-light) 100%
  );
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--water-dark);
  outline-offset: 2px;
}

/* ============================================
   Typography
   ============================================ */

.qj-heading {
  font-weight: 600;
  line-height: 1.2;
  color: var(--neutral-text);
  letter-spacing: -0.01em;
}
.qj-text {
  font-size: var(--font-size-base);
  color: var(--neutral-text);
}

/* ============================================
   Button
   ============================================ */

.qj-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  min-height: 44px; /* Touch-friendly */
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--neutral-surface);
  background: var(--lily-mid);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, box-shadow 0.15s ease,
    transform 0.1s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.qj-button:hover {
  background: var(--lily-dark);
  box-shadow: var(--shadow-md);
}

.qj-button:active {
  transform: scale(0.98);
}

.qj-button--primary {
  background: var(--water-dark);
  color: var(--neutral-surface);
}

.qj-button--primary:hover {
  background: var(--water-deep);
}

.qj-button--secondary {
  background: var(--neutral-surface);
  color: var(--water-dark);
  border: 2px solid var(--water-mid);
}

.qj-button--secondary:hover {
  background: var(--water-lightest);
  border-color: var(--water-dark);
}

.qj-button--large {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-lg);
  min-height: 56px;
}

.qj-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ============================================
   Spacer
   ============================================ */

.qj-spacer {
  flex: 1 1 auto;
}

/* ============================================
   Game-Specific Styles
   ============================================ */

/* Game view container */
.qj-game-view {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================
   Overlay & End Screen
   ============================================ */

.qj-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 90, 74, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: overlay-fade-in 300ms ease-out;
}

.qj-overlay--victory {
  background: rgba(45, 90, 74, 0.75);
}

@keyframes overlay-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.qj-end-screen {
  background: var(--neutral-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: 400px;
  width: 90%;
  animation: screen-pop-in 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.qj-end-screen--victory {
  background: linear-gradient(
    180deg,
    var(--neutral-surface) 0%,
    var(--water-lightest) 100%
  );
  border: 3px solid var(--success);
  max-width: 450px;
}

.qj-end-screen-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

@keyframes screen-pop-in {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Victory screen specific styles */
.qj-victory-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.qj-victory-frog {
  width: 80px;
  height: 64px;
  background: var(--frog-body);
  border-radius: 50% 50% 45% 45%;
  position: relative;
  animation: victory-frog-bounce 0.6s ease-in-out infinite;
}

.qj-victory-frog::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 10px;
  width: 18px;
  height: 18px;
  background: var(--frog-eye-white);
  border-radius: 50%;
  box-shadow: 32px 0 0 var(--frog-eye-white);
}

.qj-victory-frog::after {
  content: "";
  position: absolute;
  top: -6px;
  left: 15px;
  width: 8px;
  height: 8px;
  background: var(--frog-eye-pupil);
  border-radius: 50%;
  box-shadow: 32px 0 0 var(--frog-eye-pupil);
}

@keyframes victory-frog-bounce {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-10px) scale(1.05);
  }
}

.qj-victory-title {
  color: var(--success);
  margin: 0;
}

.qj-victory-message {
  color: var(--neutral-text-muted);
  font-size: var(--font-size-lg);
}

@keyframes frog-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes frog-jump {
  0% { transform: translateY(0); }
  50% { transform: translateY(-40px); }
  100% { transform: translateY(0); }
}

@keyframes frog-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

@keyframes frog-worried {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ============================================
   Scrollbar Styling
   ============================================ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--water-lightest);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
  background: var(--water-mid);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--water-dark);
}

/* ============================================
   Selection Styling
   ============================================ */

::selection {
  background: var(--water-light);
  color: var(--neutral-text);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 640px) {
  :root {
    --font-size-2xl: 1.75rem;
    --font-size-xl: 1.25rem;
  }
}

/* ============================================
   Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 640px) {
  .qj-victory-frog {
    width: 64px;
    height: 52px;
  }

  .qj-victory-frog::before {
    top: -10px;
    left: 8px;
    width: 14px;
    height: 14px;
    box-shadow: 26px 0 0 var(--frog-eye-white);
  }

  .qj-victory-frog::after {
    top: -5px;
    left: 12px;
    width: 6px;
    height: 6px;
    box-shadow: 26px 0 0 var(--frog-eye-pupil);
  }
}

/* ============================================
   Page layouts (landing, play, admin)
   ============================================ */

.qj-page {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-height: 100vh;
  min-height: 100dvh;
}

.qj-page-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--water-deep);
  text-align: center;
  margin: 0;
  letter-spacing: -0.01em;
}

.qj-page-subtitle {
  text-align: center;
  color: var(--neutral-text-muted);
  margin-top: calc(-1 * var(--space-md));
}

/* Top action bar with back link */
.qj-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.qj-back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  background: var(--neutral-surface);
  color: var(--water-dark);
  font-weight: 600;
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: background 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.qj-back-link:hover {
  background: var(--water-lightest);
}

.qj-back-link:active {
  transform: scale(0.97);
}

/* Landing page */
.qj-landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-xl);
  text-align: center;
}

.qj-landing h1 {
  font-size: clamp(2.5rem, 8vw, 4rem);
  color: var(--water-deep);
  letter-spacing: -0.02em;
  margin-bottom: 0;
}

.qj-landing-frog {
  width: 96px;
  height: 76px;
  background: var(--frog-body);
  border-radius: 50% 50% 45% 45%;
  position: relative;
  box-shadow: var(--shadow-md);
  animation: frog-idle 2.4s ease-in-out infinite;
}

.qj-landing-frog::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 14px;
  width: 20px;
  height: 20px;
  background: var(--frog-eye-white);
  border-radius: 50%;
  box-shadow: 38px 0 0 var(--frog-eye-white);
}

.qj-landing-frog::after {
  content: "";
  position: absolute;
  top: -7px;
  left: 20px;
  width: 8px;
  height: 8px;
  background: var(--frog-eye-pupil);
  border-radius: 50%;
  box-shadow: 38px 0 0 var(--frog-eye-pupil);
}

.qj-landing .qj-button {
  min-width: 180px;
}

/* Pond grid (play view) */
.qj-pond-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-md);
}

.qj-pond-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-md);
  background: radial-gradient(
    circle at 30% 30%,
    var(--lily-light) 0%,
    var(--lily-mid) 70%,
    var(--lily-dark) 100%
  );
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  color: var(--neutral-text);
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.qj-pond-card::before {
  /* Subtle highlight to suggest a glossy lily-pad surface */
  content: "";
  position: absolute;
  top: 8%;
  left: 12%;
  width: 30%;
  height: 18%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  filter: blur(6px);
  pointer-events: none;
}

.qj-pond-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.qj-pond-card:active {
  transform: translateY(0);
}

.qj-pond-name {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--neutral-text);
}

.qj-difficulty {
  display: flex;
  gap: 2px;
}

.qj-star {
  font-size: 1rem;
  line-height: 1;
}

.qj-star-filled {
  color: var(--warning);
}

.qj-star-empty {
  color: rgba(255, 255, 255, 0.5);
}

/* Admin page */
.qj-admin-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.qj-admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  background: var(--neutral-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.qj-admin-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.qj-admin-info .qj-text:first-child {
  font-weight: 600;
  color: var(--neutral-text);
}

.qj-admin-info .qj-text:last-child {
  font-size: var(--font-size-sm);
  color: var(--neutral-text-muted);
}

.qj-admin-buttons {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

.qj-button-danger {
  background: var(--error);
}

.qj-button-danger:hover {
  background: #c95252;
}

/* ============================================
   NEW POND PATH LAYOUT (Redesigned)
   ============================================

   Horizontal pond path with vertically stacked lily pads.
   No question pads - only answer pads in columns.
*/

/* Main pond path container - horizontal flex for all columns.
   Hides the scrollbar; the camera follows the frog programmatically
   via scrollIntoView() as the active column changes.
   Shores have flex-grow: 1 (see .qj-shore) so when the pond is narrower
   than the viewport the shores extend to the edges and the columns end
   up centred. When the pond overflows, shores shrink back to their
   flex-basis and pondPath scrolls horizontally. */
.qj-pond-path {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  height: 100%;
  min-height: 200px;
  position: relative;
  scrollbar-width: none;
}

.qj-pond-path::-webkit-scrollbar {
  display: none;
}



/* Columns container takes its intrinsic width so pondPath scrolls
   horizontally when there are more columns than fit at once. */
.qj-pond-columns {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex: 0 0 auto;
  gap: var(--space-md);
}

/* Pond column - vertical flex column for one question's options.
   Width is calculated so up to --visible-cols columns + both shores
   fit in the pond row exactly. */
.qj-pond-column {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
  width: calc(
    (100cqi - 2 * var(--shore-width) - (var(--visible-cols) - 1) * var(--space-md))
    / var(--visible-cols)
  );
  scroll-snap-align: center;
  transition: opacity 0.3s ease;
}


/* Column visibility states. Note: dimming is applied per-pad (via
   .qj-lilypad--dimmed) rather than column-wide so individual pads can
   opt back in to full opacity (e.g. the visible "stepped" path). */
.qj-pond-column--clear,
.qj-pond-column--dimmed {
  opacity: 1;
}

/* Lily pad and column sizing.
   --visible-cols drops in portrait so columns stay wide enough.
   --max-pads is set per-pond in JS (= max option count of any question).
   --pad-size is computed on the lily pad itself so it picks up the
   per-pond --max-pads from the .qj-pond-game ancestor. */
:root {
  --shore-width: 50px;
  --visible-cols: 5;
  --pond-overhead: 160px;
  --pad-gap: 0.5rem;
  --max-pads: 5;
}

/* Portrait / narrow viewports: show fewer columns at once so pads stay big. */
@media (max-aspect-ratio: 1/1) {
  :root {
    --visible-cols: 3;
  }
}
@media (max-aspect-ratio: 3/4) {
  :root {
    --visible-cols: 2;
  }
}

/* --pad-size is hoisted to the column so both .qj-lilypad and its
   sibling .qj-pill can read it. */
.qj-pond-column {
  --pad-size-by-height: calc(
    (100dvh - var(--pond-overhead) - (var(--max-pads) - 1) * var(--pad-gap))
    / var(--max-pads)
  );
  --pad-size-by-width: calc(
    (100cqi - 2 * var(--shore-width) - (var(--visible-cols) - 1) * var(--space-md))
    / var(--visible-cols) - 2 * var(--space-xs)
  );
  --pad-size: clamp(
    36px,
    min(var(--pad-size-by-height), var(--pad-size-by-width)),
    220px
  );
}

.qj-lilypad {
  width: var(--pad-size);
  height: var(--pad-size);
  border-radius: 50%;
  background: var(--lily-light);
  border: 3px solid var(--lily-dark);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.3s ease, opacity 0.3s ease, background-color 0.15s ease;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.qj-lilypad:hover {
  background: var(--lily-mid);
  transform: scale(1.05);
}

.qj-lilypad:active {
  transform: scale(0.95);
}

/* Lily pad states */
.qj-lilypad--clear {
  opacity: 1;
}

.qj-lilypad--dimmed {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.qj-lilypad--dimmed:hover {
  background: var(--lily-light);
  transform: none;
}

/* Sunk state - for wrong answers. Pad shrinks in place to about 40%
   and fades, suggesting a half-submerged pad rather than disappearing. */
.qj-lilypad--sunk {
  transform: scale(0.4);
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
  transition: transform 0.5s ease-in, opacity 0.5s ease-in;
}

.qj-lilypad--sunk:hover {
  background: var(--lily-light);
  transform: scale(0.4);
}

/* Stepped state - the visible "correct path" of pads the frog has
   landed on. Stays full-colour and undimmed but hides its number so
   it reads as a footprint rather than an answer choice. */
.qj-lilypad--stepped {
  pointer-events: none;
  cursor: default;
  opacity: 1;
}

.qj-lilypad--stepped:hover {
  background: var(--lily-light);
  transform: none;
}

/* Pad + pill option wrapper. The wrapping <button> is the tap target.
   The round .qj-lilypad inside is the frog's landing geometry; the
   .qj-pill overlay carries the option text and may extend past the
   pad for long content. See mockups/pill-labels.html. */
.qj-pad-option {
  position: relative;
  width: var(--pad-size);
  height: var(--pad-size);
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  /* Let the pill spill beyond the pad horizontally without affecting
     column layout. */
  overflow: visible;
}

/* Inner pad fills the wrapper so existing sizing rules and
   getBoundingClientRect() targets keep working unchanged. */
.qj-pad-option > .qj-lilypad {
  width: 100%;
  height: 100%;
}

.qj-pad-option:disabled {
  cursor: default;
}

.qj-pill {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;

  background: rgba(255, 255, 255, 0.6);
  color: var(--neutral-text);
  border: 2px solid rgba(45, 90, 74, 0.4);
  border-radius: var(--radius-full, 9999px);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);

  padding: 0.45em 0.9em;
  font-size: clamp(0.95rem, 2vh, 1.15rem);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  /* Only break inside a word when nothing else fits. */
  overflow-wrap: break-word;
  /* Absolute-positioned pills auto-shrink to their containing block
     unless told to size to content. width: max-content lets the pill
     grow as wide as its text needs, until max-width caps it and the
     text wraps onto further lines. */
  width: max-content;
  max-width: calc(var(--pad-size) * 2.2);
  min-width: calc(var(--pad-size) * 0.55);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  transition: background-color 0.15s ease, border-color 0.15s ease,
              transform 0.2s ease;
}

.qj-pad-option:hover .qj-pill {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(45, 90, 74, 0.7);
}

.qj-pad-option:active .qj-pill {
  transform: translate(-50%, -50%) scale(0.96);
}

/* Pill is hidden whenever the underlying pad is not in its active
   answer-choice state. Uses :has() to react to state classes that
   live on the inner .qj-lilypad. */
.qj-pad-option:has(.qj-lilypad--dimmed) .qj-pill,
.qj-pad-option:has(.qj-lilypad--stepped) .qj-pill,
.qj-pad-option:has(.qj-lilypad--sunk) .qj-pill {
  display: none;
}

/* Disable interaction on the wrapper when its pad is stepped/sunk/
   dimmed, mirroring the old pointer-events rules on the bare pad. */
.qj-pad-option:has(.qj-lilypad--dimmed),
.qj-pad-option:has(.qj-lilypad--stepped),
.qj-pad-option:has(.qj-lilypad--sunk) {
  pointer-events: none;
  cursor: default;
}

/* Shore banks - LHS (start) and RHS (end).
   flex-grow: 1 lets each shore expand to fill spare space when the
   pond is narrower than the viewport, centring the columns between
   them. flex-basis keeps a sensible minimum width when the pond
   overflows and the path scrolls. */
.qj-shore {
  background: #e3d2b5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  flex-basis: var(--shore-width);
  flex-grow: 1;
  height: 100%;
  min-height: 120px;
}

.qj-shore--start {
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  border-right: 3px solid var(--lily-dark);
}

.qj-shore--end {
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  border-left: 3px solid var(--lily-dark);
}

/* Frog on top - z-index above pads */
.qj-frog {
  width: 40px;
  height: 32px;
  background: var(--frog-body);
  border-radius: 50% 50% 45% 45%;
  position: absolute;
  flex-shrink: 0;
  z-index: 100;
  transition: left 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), top 0.4s ease;
}

/* Frog eyes */
.qj-frog::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 5px;
  width: 12px;
  height: 12px;
  background: var(--frog-eye-white);
  border-radius: 50%;
  box-shadow: 18px 0 0 var(--frog-eye-white);
}

.qj-frog::after {
  content: '';
  position: absolute;
  top: -6px;
  left: 9px;
  width: 5px;
  height: 5px;
  background: var(--frog-eye-pupil);
  border-radius: 50%;
  box-shadow: 18px 0 0 var(--frog-eye-pupil);
}

/* Question display - text above pond, sits in its own row so it doesn't
   overlap the lives/progress in the status bar. */
.qj-question-display {
  background: var(--neutral-surface);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-xl, 1.25rem);
  box-shadow: var(--shadow-md);
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--neutral-text);
  /* Long questions wrap onto further lines rather than overflowing. */
  white-space: normal;
  text-align: center;
  max-width: min(90%, 60ch);
  line-height: 1.3;
}

/* Brief highlight flash applied each time a new question is revealed. */
.qj-question-display--reveal {
  animation: question-reveal 600ms ease-out;
}

@keyframes question-reveal {
  0% {
    transform: scale(0.85);
    box-shadow: 0 0 0 0 var(--lily-mid);
    background: var(--lily-light);
  }
  40% {
    transform: scale(1.08);
    box-shadow: 0 0 0 12px rgba(155, 210, 134, 0);
    background: var(--neutral-surface);
  }
  100% {
    transform: scale(1);
    box-shadow: var(--shadow-md);
    background: var(--neutral-surface);
  }
}

/* Status bar - exit + lives + progress at top */
.qj-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--neutral-surface);
  border-bottom: 2px solid var(--neutral-border);
  flex-shrink: 0;
}

.qj-exit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  min-height: 36px;
  border-radius: var(--radius-full);
  background: var(--water-lightest);
  color: var(--water-deep);
  font-weight: 600;
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
}

.qj-exit:hover {
  background: var(--water-light);
}

.qj-exit:active {
  transform: scale(0.96);
}

/* Lives display */
.qj-lives {
  display: flex;
  gap: var(--space-xs);
}

.qj-heart {
  font-size: 1.25rem;
  line-height: 1;
}

.qj-heart--filled {
  color: var(--error);
}

.qj-heart--empty {
  color: var(--neutral-border);
}

/* Progress display */
.qj-progress {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--neutral-text-muted);
}

/* Frog states (updated for new layout) */
.qj-frog--idle {
  animation: frog-idle 2s ease-in-out infinite;
}

.qj-frog--jumping {
  animation: frog-jump 0.4s ease-out;
}

.qj-frog--happy {
  animation: frog-bounce 0.3s ease-out 2;
}

.qj-frog--worried {
  animation: frog-worried 0.25s ease-in-out;
}

.qj-frog--sad {
  transform: rotate(180deg) translateY(20px);
}

/* Losing animation: two quick spins before the end screen appears. */
.qj-frog--losing {
  animation: frog-losing 0.8s ease-in forwards;
}

@keyframes frog-losing {
  0%   { transform: rotate(0deg)   scale(1); }
  100% { transform: rotate(720deg) scale(0.9); }
}

.qj-frog--hopping-to-shore {
  animation: frog-hop-to-shore 0.5s ease-out forwards;
}

@keyframes frog-hop-to-shore {
  0% {
    transform: translateY(0) scaleX(1);
  }
  20% {
    transform: translateY(-40px) scaleX(0.9);
  }
  50% {
    transform: translateY(-50px) scaleX(1.1);
  }
  80% {
    transform: translateY(-25px) scaleX(1);
  }
  100% {
    transform: translateY(0) scaleX(1);
  }
}

/* Full-screen pond game view */
.qj-pond-game {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: linear-gradient(
    180deg,
    var(--water-lightest) 0%,
    var(--water-light) 100%
  );
  position: relative;
  overflow: hidden;
}

/* Question area - above pond path */
.qj-question-area {
  flex-shrink: 0;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-lg);
}

/* Pond row - contains path and shores. Acts as a container query context
   so columns can size themselves relative to the pond's visible width. */
.qj-pond-row {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  container-type: inline-size;
}

/* New pond path layout media queries */
@media (max-width: 640px) {
  :root {
    --pond-overhead: 140px;
    --shore-width: 40px;
  }

  .qj-pond-path {
    gap: var(--space-sm);
  }

  .qj-pond-columns {
    gap: var(--space-sm);
  }

  .qj-pond-column {
    gap: var(--space-xs);
  }

  .qj-shore {
    min-height: 100px;
  }

  .qj-frog {
    width: 32px;
    height: 26px;
  }

  .qj-frog::before {
    top: -8px;
    left: 4px;
    width: 10px;
    height: 10px;
    box-shadow: 14px 0 0 var(--frog-eye-white);
  }

  .qj-frog::after {
    top: -5px;
    left: 7px;
    width: 4px;
    height: 4px;
    box-shadow: 14px 0 0 var(--frog-eye-pupil);
  }
}

@media (min-width: 1024px) {
  .qj-pond-path {
    gap: var(--space-xl);
  }

  .qj-frog {
    width: 48px;
    height: 38px;
  }
}

/* ============================================
   Pond Form (Admin)
   ============================================ */

.qj-pond-form {
  background: var(--neutral-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: 100%;
  animation: screen-pop-in 300ms ease-out;
}

.qj-pond-form-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--water-deep);
  margin: 0 0 var(--space-lg) 0;
  text-align: center;
}

.qj-pond-form-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.qj-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.qj-form-group label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--neutral-text-muted);
}

.qj-input,
.qj-select {
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--neutral-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-family: inherit;
  color: var(--neutral-text);
  background: var(--neutral-surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.qj-input:focus,
.qj-select:focus {
  outline: none;
  border-color: var(--water-dark);
  box-shadow: 0 0 0 3px rgba(74, 143, 125, 0.15);
}

.qj-input-number {
  width: 100px;
}

.qj-range-inputs {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.qj-range-separator {
  color: var(--neutral-text-muted);
  font-size: var(--font-size-sm);
}

.qj-generator-params {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--water-lightest);
  border-radius: var(--radius-md);
  border: 1px solid var(--neutral-border);
}

.qj-pond-form-buttons {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
  margin-top: var(--space-lg);
}

/* Admin list with edit button */
.qj-admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  background: var(--neutral-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.qj-admin-row-actions {
  display: flex;
  gap: var(--space-sm);
}

.qj-button-icon {
  padding: var(--space-sm);
  min-height: 36px;
  min-width: 36px;
  border-radius: var(--radius-md);
}

.qj-button-icon svg {
  width: 18px;
  height: 18px;
}

/* Modal */
.qj-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 90, 74, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: overlay-fade-in 300ms ease-out;
  padding: var(--space-lg);
}

.qj-modal-content {
  max-height: 90vh;
  overflow-y: auto;
}
