/* V9 — Fix It interactive plumbing game */

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent2: #f97316;
  --ok: #4ade80;
  --danger: #f87171;
  --font: 'Fredoka', system-ui, sans-serif;
  --body: 'DM Sans', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}
a { color: var(--accent); text-decoration: none; }
kbd { background: var(--surface2); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.85em; }

.header {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 2px solid var(--surface2);
}
.logo-well { background: #fff; border-radius: 8px; padding: 3px 8px; }
.logo__brand { height: 40px; width: auto; }
.header__score {
  margin-left: auto; font-size: 0.85rem; color: var(--muted);
  font-family: var(--font);
}
.header__score strong { color: var(--ok); font-size: 1.1rem; }
.btn-call {
  font-family: var(--font); font-weight: 600;
  padding: 0.45rem 0.9rem; background: var(--accent2); color: #fff;
  border-radius: 999px; font-size: 0.85rem;
}

.intro { padding: 1.5rem 1.25rem 0.5rem; max-width: 560px; }
.intro h1 {
  font-family: var(--font); font-size: clamp(1.4rem, 4vw, 1.9rem);
  line-height: 1.15; margin-bottom: 0.5rem;
}
.intro h1 em { font-style: normal; color: var(--accent); }
.intro p { color: var(--muted); font-size: 0.95rem; }

.game {
  margin: 1rem;
  background: var(--surface);
  border-radius: 16px;
  border: 2px solid var(--surface2);
  overflow: hidden;
  max-width: 520px;
}
.job-banner {
  padding: 0.6rem 1rem;
  background: linear-gradient(90deg, var(--danger), #ea580c);
  font-family: var(--font); font-size: 0.8rem; font-weight: 600;
  letter-spacing: 0.04em; text-align: center;
}
.job-banner.is-ok { background: linear-gradient(90deg, #15803d, var(--ok)); }

.coach {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.75rem 1rem; background: #1e293b;
  border-bottom: 1px solid #334155;
  min-height: 3.5rem;
}
.coach__step {
  flex-shrink: 0; width: 28px; height: 28px;
  display: grid; place-items: center;
  background: var(--accent2); color: #fff;
  font-family: var(--font); font-weight: 700; font-size: 0.9rem;
  border-radius: 50%;
}
.coach__text { font-size: 0.9rem; color: #e2e8f0; line-height: 1.45; padding-top: 0.15rem; }
.coach__text strong { color: #7dd3fc; }

.action-meter { height: 4px; background: #334155; }
.action-meter__fill { height: 100%; width: 0%; background: var(--ok); transition: width 0.2s; }

.problem-pulse {
  fill: none; stroke: #ef4444; stroke-width: 3;
  animation: pulse-ring 1.2s ease-out infinite;
  pointer-events: none;
}
.problem-pulse--hidden { display: none; }
@keyframes pulse-ring {
  0% { opacity: 1; stroke-width: 4; }
  100% { opacity: 0; stroke-width: 1; }
}

.hotspot { cursor: pointer; }
.leak-joint { fill: rgba(239,68,68,0.15); stroke: rgba(239,68,68,0.5); stroke-width: 2; stroke-dasharray: 4 2; }
.leak-joint.is-fixed { pointer-events: none; opacity: 0; }

.scene-wrap { position: relative; background: #e8eef4; }
.scene { position: relative; }
.scene__svg { width: 100%; height: auto; display: block; }
.scene-hint {
  position: absolute; bottom: 8px; left: 0; right: 0;
  text-align: center; font-size: 0.75rem; color: #475569;
  padding: 0 0.5rem;
}
.scene--drain { padding: 1rem; background: #0c1220; text-align: center; position: relative; }

.snake-hud {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.8rem; color: var(--muted); margin-bottom: 0.5rem;
  font-family: var(--font);
}
.snake-hud strong { color: var(--ok); font-size: 1rem; }
.snake-hud__hint { font-size: 0.7rem; opacity: 0.8; }

#snakeCanvas {
  width: 100%; max-width: 400px; height: auto; display: block;
  margin: 0 auto; border-radius: 8px;
  background: #1a2744; border: 3px solid #475569;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.5);
}

.snake-overlay {
  position: absolute; inset: 2.5rem 1rem 5rem; max-width: 400px;
  margin: 0 auto; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(15,23,42,0.88); border-radius: 8px;
  border: 2px solid var(--surface2);
}
.snake-overlay[hidden] { display: none; }
.snake-overlay__title {
  font-family: var(--font); font-size: 1.4rem; color: var(--accent);
  margin-bottom: 0.35rem; letter-spacing: 0.08em;
}
.snake-overlay__sub {
  font-size: 0.85rem; color: var(--muted); max-width: 24ch;
  margin-bottom: 1rem; line-height: 1.4;
}

.snake-dpad {
  display: grid; grid-template-rows: auto auto auto;
  justify-items: center; gap: 0.25rem;
  margin-top: 0.75rem; max-width: 140px; margin-inline: auto;
}
.snake-dpad__mid { display: flex; gap: 2.5rem; }
.snake-dpad button {
  width: 48px; height: 48px;
  font-size: 1.1rem; font-weight: 700;
  background: var(--surface2); color: var(--text);
  border: 2px solid #475569; border-radius: 10px;
  cursor: pointer; font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}
.snake-dpad button:active { background: var(--accent); color: #0f172a; }

.btn-push {
  font-family: var(--font); font-weight: 600;
  padding: 0.55rem 1.5rem; background: var(--accent); color: #0f172a;
  border: none; border-radius: 8px; cursor: pointer; font-size: 0.95rem;
}

.hotspot { cursor: pointer; }
.leak-joint.is-fixed { pointer-events: none; }
.leak-drops .drop {
  animation: drip 0.8s ease-in infinite;
}
@keyframes drip {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(28px); opacity: 0; }
}
.plunger-anim { transition: transform 0.15s, opacity 0.15s; }
.plunger-anim.is-active { opacity: 1; }
.plunger-anim.is-pump { transform: translateY(25px); }

.toolbelt {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem;
  padding: 0.75rem;
  background: #0c1220;
}
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  padding: 0.6rem 0.25rem;
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  font-family: var(--body); font-size: 0.65rem;
}
.tool:hover { transform: translateY(-2px); }
.tool.is-selected { border-color: var(--accent); background: #1e3a5f; }
.tool.is-needed { border-color: var(--accent2); animation: tool-glow 1.5s ease infinite; }
.tool.is-dimmed { opacity: 0.4; }
.tool.is-disabled { opacity: 0.35; pointer-events: none; }
.tool__badge {
  position: absolute; top: -6px; right: -4px;
  font-size: 0.55rem; font-weight: 700; text-transform: uppercase;
  background: var(--accent2); color: #fff;
  padding: 0.15rem 0.35rem; border-radius: 4px;
  letter-spacing: 0.04em;
}
.tool { position: relative; }
@keyframes tool-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(249,115,22,0.5); }
  50% { box-shadow: 0 0 0 6px rgba(249,115,22,0); }
}
.tool__icon { font-size: 1.5rem; line-height: 1; }
.tool__name { font-weight: 600; }

.job-dots {
  display: flex; justify-content: center; gap: 0.5rem;
  padding: 0.75rem; background: #0c1220;
}
.job-dots .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface2);
  transition: background 0.3s, transform 0.3s;
}
.job-dots .dot.is-done { background: var(--ok); transform: scale(1.2); }
.job-dots .dot.is-current { background: var(--accent2); box-shadow: 0 0 8px var(--accent2); }

.cta-strip {
  padding: 1.5rem 1.25rem; max-width: 520px;
}
.cta-strip p { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; }
.cta-strip blockquote { font-size: 0.9rem; border-left: 3px solid var(--accent); padding-left: 0.75rem; color: var(--muted); }

.book { padding: 1.5rem 1.25rem 3rem; max-width: 520px; }
.book h2 { font-family: var(--font); font-size: 1.35rem; margin-bottom: 0.35rem; }
.book h2 em { font-style: normal; color: var(--accent2); }
.book p { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }
.book form { display: flex; flex-direction: column; gap: 0.5rem; }
.book input, .book select, .book button {
  padding: 0.65rem; border-radius: 8px; border: 1px solid var(--surface2);
  background: var(--surface); color: var(--text); font-family: var(--body);
}
.book button {
  background: var(--accent2); border: none; font-weight: 600;
  font-family: var(--font); cursor: pointer; color: #fff;
}
.form-ok { margin-top: 0.5rem; color: var(--ok); font-size: 0.9rem; }

.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,23,42,0.88);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.overlay[hidden] { display: none; }
.overlay__card {
  background: var(--surface);
  border: 2px solid var(--surface2);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  max-width: 360px; text-align: center;
}
.overlay__card h2 { font-family: var(--font); font-size: 1.5rem; margin-bottom: 0.75rem; }
.overlay__card p { color: var(--muted); margin-bottom: 1.25rem; font-size: 0.95rem; }
.tutorial {
  text-align: left; margin: 0 0 1.25rem; padding-left: 1.25rem;
  color: var(--muted); font-size: 0.9rem; line-height: 1.6;
}
.tutorial em { color: #f87171; font-style: normal; font-weight: 600; }
.btn-start {
  display: inline-block; font-family: var(--font); font-weight: 600;
  padding: 0.75rem 1.5rem; background: var(--accent2); color: #fff;
  border: none; border-radius: 999px; cursor: pointer; font-size: 1rem;
}
.overlay__actions { display: flex; flex-direction: column; gap: 0.5rem; }
.btn-ghost {
  display: inline-block; padding: 0.65rem; color: var(--accent);
  font-weight: 600; font-family: var(--font);
}
.link-replay {
  margin-top: 1rem; background: none; border: none;
  color: var(--muted); cursor: pointer; font-size: 0.85rem;
  text-decoration: underline;
}
.overlay--win .overlay__card { border-color: var(--ok); }

.callbar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  text-align: center; padding: 0.85rem;
  background: var(--accent2); color: #fff;
  font-family: var(--font); font-weight: 600;
}

.flash-ok { animation: flashOk 0.5s ease; }
@keyframes flashOk {
  0%, 100% { filter: none; }
  50% { filter: drop-shadow(0 0 12px var(--ok)); }
}

@media (max-width: 480px) {
  .callbar { display: block; }
  body { padding-bottom: 3rem; }
}

@media (min-width: 900px) {
  main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 2rem;
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem;
  }
  .intro { grid-column: 1 / -1; max-width: none; }
  .game { margin: 0; max-width: none; }
  .cta-strip, .book { max-width: none; }
}
