/* ===== JOGO DA REPRESA (só nesta página) ===== */
.jv-area {
  color: #1a1a1a;
}
.jv-area p,
.jv-area li,
.jv-area small {
  color: #333;
  line-height: 1.6;
}
.jv-area h2,
.jv-area h3 {
  color: #0b1020;
}

.titulo-jogo {
  margin: 24px 0 12px;
  text-align: center;
}
.titulo-jogo h2 {
  margin: 0 0 6px;
  font-size: clamp(1.6rem, 3vw + 1rem, 2.4rem);
  background: linear-gradient(90deg, #22d3ee, #0ea5e9);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.5px;
}
.titulo-jogo p {
  margin: 0;
  color: #555;
}

.jv-intro {
  margin-top: 8px;
  text-align: center;
}

/* Bloco final "Como funciona (resumo)" */
.exercicio {
  margin: 18px 0 10px;
  padding: 14px 16px;
  background: #f1f5f9;
  border: 1px solid #dde3ea;
  border-radius: 12px;
}
.exercicio h3 {
  margin-top: 0;
}
.exercicio ul {
  margin: 8px 0 6px 18px;
}
.exercicio li {
  margin-bottom: 4px;
}
.aviso {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: #475569;
}

/* =========================================================
   REPRESA — ESTILOS ESPECÍFICOS (cena + console)
   ========================================================= */

/* ---------- VARIÁVEIS GERAIS (cores, medidas) ---------- */
:root {
  --sky: #eaf6ff;
  --mountain: #c7d2fe;
  --water: #39a2ff;
  --water-dark: #0b74c9;
  --mud: #b98a5a;
  --mud-dark: #816043;
  --dam: #8b9299;
  --gate: #6b7280;
  --spill-blue: #9dd7ff;
  --spill-mud: #bfa07a;
  --pipe: #94a3b8;
  --pipe-flow-blue: #39a2ff;
  --pipe-flow-mud: #8b6a44;
  --power: #d1d5db;
  --text: #0f172a;

  --ok: #ecfdf5;
  --warn: #fffbeb;
  --danger: #fef2f2;

  --panel-bg: #ffffff;
  --panel-border: #e2e8f0;

  --radius: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);

  --play-h: clamp(520px, 78vh, 820px);

  --btn-h: 40px;
  --meta-w: 148px;
}

/* Largura do conteúdo desta página */
main.container {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding-left: 12px;
  padding-right: 12px;
}

/* ---------- GRID DO JOGO ---------- */
.represa-app {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(680px, 1fr) 420px;
  align-items: stretch;
  margin: 16px auto 24px;
}

/* Cartões da cena e painel */
.scene-card,
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: var(--play-h);
  max-height: var(--play-h);
  padding: 12px;
}

/* Cena (SVG) ocupando todo o cartão */
.scene-card {
  display: flex;
}
.scene-card svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Painel (console) */
.panel {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.section {
  border: 1px solid #dde3ea;
  border-radius: 12px;
  padding: 5px;
  margin-bottom: 5px;
  background: #f8fafc;
}
.section-title {
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.3px;
  color: #334155;
  margin-bottom: 6px;
  text-transform: uppercase;
}

/* Linhas do painel */
.row-1 {
  display: grid;
  margin: 2px;
  grid-template-columns: 1fr;
  gap: 6px;
}
.row-2 {
  display: grid;
  margin: 2px;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.row-3 {
  display: grid;
  margin: 2px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) var(--meta-w);
  gap: 6px;
  align-items: center;
}

/* Botões do painel */
.panel-btn {
  height: var(--btn-h);
  min-height: var(--btn-h);
  width: 100%;
  border: 1px solid #c7d2e0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 1px 0 #fff inset, 0 1px 1px rgba(0, 0, 0, 0.382);
  transition: transform 0.04s ease, filter 0.15s ease;
  font-size: 12px;
}
.panel-btn:active {
  transform: translateY(1px);
}
.panel-btn:hover {
  filter: brightness(0.98);
}
.panel-btn.wide {
  grid-column: 1 / -1;
}
.panel-btn .ico {
  font-size: 14px;
  line-height: 0;
}

/* Cores dos botões */
.btn-rain {
  background: linear-gradient(#eaf5ff, #cde8ff);
  border-color: #98c8ff;
}
.btn-rain:hover {
  background: linear-gradient(#e1f0ff, #c2e0ff);
}
.btn-sun {
  background: linear-gradient(#ffe8cc, #ffd199);
  border-color: #ffbc66;
}
.btn-sun:hover {
  background: linear-gradient(#ffe1bd, #ffc880);
}
.btn-combo {
  background: linear-gradient(#efe3ff, #d8c4ff);
  border-color: #c1abff;
}
.btn-clear {
  background: linear-gradient(#f3f4f6, #e5e7eb);
  border-color: #cbd5e1;
}
.btn-open {
  background: linear-gradient(#dcfce7, #bbf7d0);
  border-color: #86efac;
}
.btn-close {
  background: linear-gradient(#f1f5f9, #e2e8f0);
  border-color: #cbd5e1;
}
.btn-danger {
  background: linear-gradient(#fee2e2, #fecaca);
  border-color: #fca5a5;
}

/* Chips e métricas */
.panel-meta,
.panel-stat {
  font-size: 12px;
  color: #1f2937;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.panel-meta {
  height: var(--btn-h);
  min-height: var(--btn-h);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nowrap {
  white-space: nowrap;
}

/* Status */
.status {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  background: var(--ok);
  margin-top: 8px;
}
.status.warn {
  background: var(--warn);
}
.status.danger {
  background: var(--danger);
}
.hint {
  color: #64748b;
  font-size: 12px;
}

/* ---------- CENA (SVG) ---------- */
.sky {
  fill: var(--sky);
}
.mountain {
  fill: var(--mountain);
}
.water {
  fill: url(#waterGrad);
  transition: fill 0.3s ease;
}
.dry-water {
  fill: #d9c2a3;
}
.dam {
  fill: var(--dam);
}
.gate {
  fill: var(--gate);
}
.spill {
  fill: var(--spill-blue);
}
/* Margem da represa (grama, píer, vegetação) */
#scene .shore {
  fill: #5fbf5f; /* grama verdinha na borda da água */
}

#scene .pier-wood {
  fill: #8b5a2b; /* madeira do píer */
}

#scene .pier-pillar {
  fill: #704225; /* pilares do píer */
}

#scene .reeds line {
  stroke: #356b3b;
  stroke-width: 3;
  stroke-linecap: round;
}

#scene .reeds circle {
  fill: #4caf50;
}

.powerhouse {
  fill: var(--power);
  stroke: #9ca3af;
  cursor: pointer;
  transition: filter 0.2s, stroke 0.2s, stroke-width 0.2s;
}
.powerhouse.armed {
  stroke: #10b981;
  stroke-width: 3;
  filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.5));
}
.label {
  font-size: 14px;
  fill: #334155;
  font-weight: 700;
}
.label.small {
  font-size: 12px;
}
.turbine-body {
  fill: #9ca3af;
}
.turbine-blade {
  fill: #6b7280;
}
.downstream {
  fill: #cae6ff;
}

.safe-line {
  stroke: #64748b;
  stroke-dasharray: 6 4;
  stroke-width: 2;
}
.safe-text,
.depth-note {
  fill: #475569;
  font-size: 12px;
}
.crest-line {
  stroke: #475569;
  stroke-dasharray: 4 4;
  stroke-width: 2;
}
.crest-text {
  fill: #334155;
  font-size: 12px;
}

.gauge-track {
  fill: #e2e8f0;
}
.gauge-ticks line {
  stroke: #94a3b8;
  stroke-width: 2;
}
.gauge-ticks text {
  fill: #64748b;
  font-size: 11px;
}

/* Nuvens */
.cloud {
  fill: #ffffff;
  stroke: none;
  transition: fill 0.35s ease, opacity 0.25s ease;
}
.clouds.rainy .cloud {
  fill: #1e3a8a;
  stroke: none;
}
.cloud-stroke {
  stroke: none;
  stroke-width: 0;
}

/* Pequenina animação herdada das puffs iniciais */
.puff {
  animation: drift 24s linear infinite;
}
.puff.slow {
  animation-duration: 36s;
}
@keyframes drift {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(60px);
  }
}

/* Sol */
.sun .sun-core {
  fill: #facc15;
}
.sun .sun-rays line {
  stroke: #fde047;
  stroke-linecap: round;
  stroke-width: 4;
}
.sun-visible {
  opacity: 1 !important;
}
.sun-rotate .sun-rays {
  animation: sunSpin 10s linear infinite;
}
@keyframes sunSpin {
  to {
    transform: rotate(360deg);
  }
}

/* Gotas de chuva */
.raindrop {
  stroke: var(--water-dark);
  stroke-width: 2.4;
  stroke-linecap: round;
  transform-box: fill-box;
  animation: rainFall 1.05s linear forwards;
}
@keyframes rainFall {
  to {
    transform: translateY(280px);
    opacity: 0.2;
  }
}

/* Canos e cidades */
.pipe {
  stroke: var(--pipe);
  stroke-width: 8;
  fill: none;
}
.pipe-flow {
  stroke: var(--pipe-flow-blue);
  stroke-width: 4;
  fill: none;
  stroke-dasharray: 14 16;
  animation: flow 1.2s linear infinite;
}
@keyframes flow {
  to {
    stroke-dashoffset: -60;
  }
}
.city {
  fill: #cbd5e1;
  stroke: #94a3b8;
}
.city-top {
  fill: #94a3b8;
}

/* Peixes */
.fish {
  opacity: 0.95;
}
.fish-body {
  stroke: rgba(0, 0, 0, 0.08);
  stroke-width: 0.6;
}
.fish-eye {
  fill: #ffffff;
  stroke: #0f172a;
  stroke-width: 0.6;
}

/* Textos da cena com contorno branco */
.label,
.safe-text,
.depth-note,
.crest-text {
  paint-order: stroke;
  stroke: #ffffffcc;
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  background: #fff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  z-index: 1200;
  font-weight: 700;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.warn {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}
.toast.danger {
  background: #fee2e2;
  border-color: #fecaca;
  color: #7f1d1d;
}
.toast.info {
  background: #e0f2fe;
  border-color: #bae6fd;
  color: #075985;
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1000;
  color: #fff;
  text-align: center;
}
.overlay-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
  padding: 20px 24px;
  border-radius: 14px;
  max-width: 540px;
}
.overlay-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.overlay-btn {
  margin-top: 12px;
  border: none;
  background: #22c55e;
  color: #0b3a1c;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
}

/* Texto claro dentro do pop-up */
.overlay p,
.overlay li,
.overlay small {
  color: #f9fafb;
  line-height: 1.6;
}

.floodFX {
  position: fixed;
  inset: 0;
  background: rgba(11, 116, 201, 0.65);
  animation: floodRise 1.6s forwards;
  z-index: 999;
}
@keyframes floodRise {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0%);
  }
}

/* ---------- RESPONSIVO ---------- */
@media (max-width: 1200px) {
  .represa-app {
    grid-template-columns: minmax(600px, 1fr) 360px;
  }
  :root {
    --play-h: clamp(500px, 72vh, 760px);
  }
}
@media (max-width: 1080px) {
  .represa-app {
    grid-template-columns: 1fr;
  }
  .panel {
    min-height: auto;
    max-height: none;
    overflow: visible;
  }
  .scene-card {
    min-height: auto;
    max-height: none;
  }
  .scene-card svg {
    height: clamp(480px, 70vh, 780px);
  }
}

/* Telas maiores: mais espaço pro painel */
@media (min-width: 1280px) {
  .represa-app {
    grid-template-columns: minmax(720px, 1.3fr) 440px;
  }
  .row-3 {
    grid-template-columns:
      minmax(0, 1.25fr)
      minmax(0, 1.25fr)
      minmax(120px, var(--meta-w));
  }
}
