@charset "UTF-8";
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&family=Rajdhani:wght@600;700;800&family=Share+Tech+Mono&display=swap');

/* ==========================================================
   CIRCUITO PERFEITO CAUPLAS — DESIGN SYSTEM OFICIAL
   Paleta Clara / Branca em conformidade com o Jogo da Memória
   ========================================================== */

:root {
  /* Cores Oficiais e Primárias Cauplas */
  --cauplas-blue-primary: #0064f0;
  --cauplas-blue-vivid: #007bff;
  --cauplas-blue-cyan: #00adee;
  --cauplas-blue-dark: #091b38;
  --cauplas-blue-deep: #051024;
  --cauplas-blue-glow: rgba(0, 173, 238, 0.45);
  
  /* Fundos e Neutros (Paleta Clara Institucional) */
  --bg-app-light: #f4f7fb;
  --bg-card-light: #ffffff;
  --bg-subtle-gray: #e9eef5;
  --border-light: #d4e0ee;
  --border-technical: #cbd5e1;
  
  /* Tipografia */
  --text-primary: #0a1931;
  --text-secondary: #4a5d78;
  --text-muted: #7c8ea3;
  --text-white: #ffffff;
  
  /* Status */
  --status-success: #10b981;
  --status-danger: #ef4444;
  --status-warning: #f59e0b;
  
  /* Fluidos e Mangueiras Automotivas */
  --c-rubber-dark: #121720;
  --c-rubber-body: #1c242f;
  --c-clamp-metal: #adbdd1;
  --c-coolant-neon: #00f0ff;
  --c-coolant-glow: rgba(0, 240, 255, 0.55);

  /* Sombras e Raios */
  --shadow-sm: 0 4px 12px rgba(10, 25, 49, 0.06);
  --shadow-md: 0 10px 25px rgba(10, 25, 49, 0.1);
  --shadow-lg: 0 18px 45px rgba(10, 25, 49, 0.16);
  --shadow-glow: 0 0 25px rgba(0, 173, 238, 0.45);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.25, 1, 0.5, 1);
}

/* ==========================================================
   RESET & OTIMIZAÇÃO TOUCH-SCREEN
   ========================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: fixed;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 50% 20%, #ffffff 0%, var(--bg-app-light) 65%, #e1e8f2 100%);
  color: var(--text-primary);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* Background Gráfico com Textura Suave */
.bg-decorations {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-decorations::before {
  content: '';
  position: absolute;
  top: -15%;
  right: -10%;
  width: 650px;
  height: 650px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 173, 238, 0.1) 0%, rgba(0, 100, 240, 0.02) 60%, transparent 80%);
}

.bg-decorations::after {
  content: '';
  position: absolute;
  bottom: -15%;
  left: -10%;
  width: 700px;
  height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(9, 27, 56, 0.06) 0%, transparent 70%);
}

/* ==========================================================
   SPLASH SCREEN (5 SEGUNDOS COM PULSO DO ÍCONE)
   ========================================================== */
.splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  background: radial-gradient(circle at 50% 45%, #0e2f63 0%, var(--cauplas-blue-dark) 55%, var(--cauplas-blue-deep) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: opacity 0.75s ease, transform 0.75s ease, visibility 0.75s ease;
}

.splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(1.05);
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  max-width: 580px;
  padding: 30px;
}

.splash-cauplas-logo {
  width: clamp(160px, 40vw, 280px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 18px rgba(0, 173, 238, 0.5));
}

.splash-icon-wrapper {
  position: relative;
  width: 170px;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.splash-icon {
  width: 130px;
  height: 130px;
  object-fit: contain;
  filter: drop-shadow(0 10px 30px rgba(0, 173, 238, 0.65));
  animation: splash-icon-pulse 1.8s infinite ease-in-out;
  position: relative;
  z-index: 2;
}

.splash-pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 2px solid var(--cauplas-blue-cyan);
  animation: splash-ring-expand 1.8s infinite ease-out;
  pointer-events: none;
  z-index: 1;
}

.splash-title {
  font-size: 2.8rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #ffffff;
  text-shadow: 0 4px 24px rgba(0, 100, 240, 0.6);
  background: linear-gradient(135deg, #ffffff 40%, var(--cauplas-blue-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.15;
  margin: 0;
}

.splash-brand {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cauplas-blue-cyan);
  opacity: 0.92;
}

.splash-loader-bar {
  width: 240px;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 10px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.splash-loader-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--cauplas-blue-primary), var(--cauplas-blue-cyan));
  transform-origin: left;
  animation: splash-loader-progress 5s linear forwards;
}

@keyframes splash-icon-pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 8px 18px rgba(0, 173, 238, 0.45)); }
  50% { transform: scale(1.09); filter: drop-shadow(0 14px 38px rgba(0, 173, 238, 0.9)); }
}

@keyframes splash-ring-expand {
  0% { width: 130px; height: 130px; opacity: 0.85; }
  100% { width: 230px; height: 230px; opacity: 0; }
}

@keyframes splash-loader-progress {
  0% { transform: scaleX(0); }
  100% { transform: scaleX(1); }
}

/* ==========================================================
   CONTAINER SPA (GERENCIAMENTO DE TELAS)
   ========================================================== */
#app-container {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-smooth), transform 0.4s var(--ease-smooth);
}

.screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: scale(1);
}

/* ==========================================================
   CABEÇALHO PADRÃO (NAVBAR)
   ========================================================== */
.app-header {
  position: relative;
  width: 100%;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 20;
}

.logo-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.logo-video {
  height: 56px;
  max-width: 250px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 100, 240, 0.12));
}

.brand-badge {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cauplas-blue-primary);
  margin-top: 2px;
}

.header-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 48px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-light);
  background: var(--bg-card-light);
  color: var(--cauplas-blue-primary);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.header-nav-btn:active {
  transform: translateY(-50%) scale(0.92);
  background: var(--bg-subtle-gray);
  border-color: var(--cauplas-blue-primary);
}

.header-nav-btn.btn-portal {
  left: 24px;
  width: auto;
  min-width: 48px;
  padding: 0 16px;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.02em;
  color: var(--cauplas-blue-primary);
}

.header-nav-btn.btn-back {
  left: 24px;
  width: auto;
  padding: 0 16px;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
}

.btn-label-text {
  font-size: 0.9rem;
  font-weight: 700;
}

.header-actions-right {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions-right .header-nav-btn {
  position: static;
  transform: none;
  width: 48px;
}

.header-actions-right .header-nav-btn:active {
  transform: scale(0.92);
}

.btn-icon-only {
  width: 48px;
  padding: 0;
}

.hidden {
  display: none !important;
}

/* ==========================================================
   TELA 1: INÍCIO (MENU DE CONFIGURAÇÃO DE TEMPO)
   ========================================================== */
.screen-start {
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px 24px;
}

.start-content-wrapper {
  width: 100%;
  max-width: 580px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 22px;
}

.hero-banner {
  text-align: center;
}

.hero-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 2.3rem;
  font-weight: 800;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.hero-title-icon {
  width: 2.2em;
  height: 2.2em;
  object-fit: contain;
  filter: drop-shadow(0 2px 10px rgba(0, 100, 240, 0.35));
  flex-shrink: 0;
}

.hero-title span {
  color: var(--cauplas-blue-primary);
  background: linear-gradient(135deg, var(--cauplas-blue-primary) 0%, var(--cauplas-blue-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* Card de Configuração */
.config-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.config-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.config-label {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.config-tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cauplas-blue-primary);
  background: rgba(0, 100, 240, 0.1);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

/* Stepper Control [-] 50s [+] */
.stepper-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-app-light);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow: inset 0 2px 4px rgba(10, 25, 49, 0.04);
}

.stepper-btn {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg-card-light);
  color: var(--cauplas-blue-primary);
  font-size: 2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 100, 240, 0.12);
  transition: transform 0.15s ease, background 0.2s ease;
}

.stepper-btn:active {
  transform: scale(0.9);
  background: var(--cauplas-blue-primary);
  color: var(--text-white);
}

.stepper-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stepper-value {
  font-family: 'Rajdhani', sans-serif;
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
  color: var(--cauplas-blue-dark);
}

.stepper-sub {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

/* Botão Primário de Ação */
.btn-primary-action {
  width: 100%;
  max-width: 440px;
  padding: 18px 24px;
  border: none;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--cauplas-blue-vivid) 0%, var(--cauplas-blue-primary) 50%, #004ecc 100%);
  color: var(--text-white);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 100, 240, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: transform 0.18s var(--ease-spring), box-shadow 0.2s ease;
  animation: button-glow-pulse 3s infinite ease-in-out;
}

.btn-primary-action:active {
  transform: scale(0.95);
  box-shadow: 0 4px 12px rgba(0, 100, 240, 0.3);
}

.btn-primary-action .icon {
  font-size: 1.4rem;
}

@keyframes button-glow-pulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(0, 100, 240, 0.4); }
  50% { box-shadow: 0 12px 32px rgba(0, 173, 238, 0.65); }
}

.start-footer {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ==========================================================
   TELA 2: PARTIDA (GAMEPLAY) — APROVEITAMENTO TOTAL DA TELA
   ========================================================== */
.screen-game {
  width: 100vw;
  height: 100vh;
  justify-content: space-between;
  padding: 8px 16px 10px;
}

/* HUD Superior (Cronômetro e Status) */
.game-hud-bar {
  width: 100%;
  max-width: 98vw;
  margin: 0 auto 6px;
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: 16px;
  align-items: stretch;
}

.hud-item {
  background: var(--bg-card-light);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.hud-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hud-timer-value {
  font-family: 'Rajdhani', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--status-success);
}

.hud-timer.warning .hud-timer-value {
  color: var(--status-warning);
}

.hud-timer.danger .hud-timer-value {
  color: var(--status-danger);
  animation: pulse-danger-timer 0.8s infinite alternate;
}

@keyframes pulse-danger-timer {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0.6; transform: scale(1.05); }
}

.hud-timer-track {
  width: 100%;
  height: 6px;
  background: var(--bg-subtle-gray);
  border-radius: var(--radius-full);
  margin-top: 4px;
  overflow: hidden;
}

.hud-timer-fill {
  height: 100%;
  background: var(--status-success);
  border-radius: var(--radius-full);
  transition: width 0.3s linear, background-color 0.3s ease;
}

.hud-timer.warning .hud-timer-fill {
  background: var(--status-warning);
}

.hud-timer.danger .hud-timer-fill {
  background: var(--status-danger);
}

.hud-instructions {
  text-align: center;
  align-items: center;
  transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.hud-instructions.hud-leak-warning {
  background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%);
  border-color: var(--status-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18), var(--shadow-sm);
  animation: pulse-leak-box 1.1s ease-in-out infinite alternate;
}

.hud-instructions.hud-leak-warning .hud-tag {
  color: #b91c1c;
}

.hud-instructions.hud-leak-warning .hud-text {
  color: #991b1b;
  font-weight: 700;
}

@keyframes pulse-leak-box {
  from { box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.16), var(--shadow-sm); }
  to { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.32), var(--shadow-sm); }
}

.hud-tag {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--cauplas-blue-primary);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.hud-text {
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--text-secondary);
  font-weight: 500;
}

.hud-status {
  align-items: flex-end;
}

.circuit-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 4px;
}

.badge-open {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-connected {
  background: rgba(16, 185, 129, 0.15);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-leak {
  background: rgba(239, 68, 68, 0.16);
  color: #b91c1c;
  border: 1.5px solid rgba(239, 68, 68, 0.55);
  animation: pulse-leak-badge 0.9s ease-in-out infinite alternate;
}

@keyframes pulse-leak-badge {
  from { transform: scale(1); background: rgba(239, 68, 68, 0.14); }
  to { transform: scale(1.03); background: rgba(239, 68, 68, 0.26); }
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* ==========================================================
   ARENA DO CIRCUITO (USO TOTAL DA TELA EM TOTENS 16:9 E 9:16)
   Radiador + Grid 3x4 + Motor formam uma linha contínua SEM GAPS!
   ========================================================== */
.arena-pipeline-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: row; /* Sempre em linha para conexões perfeitas */
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 98vw;
  margin: 0 auto;
  min-height: 0;
  padding: 0;
  --cell-size: 160px;
}

/* Banner Flutuante de Alerta de Vazamento (Não bloqueia toques nas mangueiras!) */
.leak-alert-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: #ffffff;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 28px rgba(220, 38, 38, 0.45), 0 0 0 3px rgba(255, 255, 255, 0.85);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.28s var(--ease-spring), visibility 0.25s ease;
  max-width: 92%;
  text-align: center;
}

.leak-alert-banner.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.leak-alert-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* Módulo Lateral (Radiador e Motor) */
.station-block {
  width: clamp(140px, 15vw, 280px);
  height: 100%;
  background: var(--bg-card-light);
  border: 2px solid var(--border-light);
  padding: 0;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 5;
  flex-shrink: 0;
  overflow: hidden;
}

.station-radiator {
  border-top-left-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-lg);
  border-right: none; /* Encosta perfeitamente na borda esquerda do grid */
}

.station-engine {
  border-top-right-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
  border-left: none; /* Encosta perfeitamente na borda direita do grid */
}

.station-meta {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 6px;
  background: rgba(255, 255, 255, 0.92);
}

.station-icon {
  font-size: 1.35rem;
  flex-shrink: 0;
}

.station-sub {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  display: block;
}

.station-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.94rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

/* Centralização vertical absoluta: garante alinhamento 100% exato com a Linha 1 (meio da grade 3x4) */
.station-visual {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  pointer-events: none;
  z-index: 2;
}

.station-visual-radiator {
  justify-content: flex-end;
  padding-left: 10px;
  padding-right: 0;
}

.station-visual-engine {
  justify-content: flex-start;
  padding-left: 0;
  padding-right: 10px;
}

.station-body-svg {
  flex: 1;
  min-width: 0;
  height: 54%;
  display: block;
  z-index: 3;
}

.station-nozzle-svg {
  width: clamp(14px, calc(var(--cell-size) * 0.24), 28%);
  height: var(--cell-size);
  flex-shrink: 0;
  display: block;
  z-index: 2;
}

.station-visual-radiator .station-nozzle-svg {
  margin-left: -3px;
}

.station-visual-engine .station-nozzle-svg {
  margin-right: -3px;
}

.station-footer {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--border-light);
  padding-top: 6px;
  background: rgba(255, 255, 255, 0.92);
}

.arena-pipeline-wrapper.compact-stations .station-meta {
  top: 5px;
  left: 6px;
  right: 6px;
  gap: 4px;
  padding-bottom: 3px;
}

.arena-pipeline-wrapper.compact-stations .station-icon {
  font-size: 0.95rem;
}

.arena-pipeline-wrapper.compact-stations .station-sub {
  display: none;
}

.arena-pipeline-wrapper.compact-stations .station-title {
  font-size: 0.72rem;
}

.arena-pipeline-wrapper.compact-stations .station-footer {
  display: none;
}

.arena-pipeline-wrapper.compact-stations .station-body-svg {
  height: 62%;
}

.station-pill {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.engine-state-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  border-radius: 4px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.badge-overheat {
  background: rgba(239, 68, 68, 0.12);
  color: var(--status-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-pressure-loss {
  background: rgba(245, 158, 11, 0.18);
  color: #b45309;
  border: 1.5px solid rgba(239, 68, 68, 0.55);
  animation: pulse-leak-badge 0.9s ease-in-out infinite alternate;
}

.badge-cooled {
  background: rgba(16, 185, 129, 0.15);
  color: var(--status-success);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.engine-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Moldura Central da Grade de Mangueiras — Dimensões Exatas 4:3 em Pixels */
.grid-pipeline-frame {
  flex: 0 0 auto;
  background: #ffffff;
  border-top: 2px solid var(--border-light);
  border-bottom: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 4;
  overflow: hidden;
}

/* Grade 3x4 COM ZERO GAP ENTRE AS CÉLULAS (Células 100% Quadradas) */
.circuit-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 0; /* ZERO GAP: os tubos se tocam de ponta a ponta */
  margin: 0;
  padding: 0;
}

/* Célula de Mangueira */
.pipe-cell {
  position: relative;
  width: 100%;
  height: 100%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  touch-action: manipulation;
  border: none;
  outline: none;
  transition: background-color 0.18s ease;
}

.pipe-cell:hover {
  background-color: rgba(0, 100, 240, 0.03);
}

.pipe-cell:active {
  background-color: rgba(0, 100, 240, 0.07);
}

.pipe-cell.cell-leaking-critical {
  background-color: rgba(239, 68, 68, 0.07);
  animation: cell-leak-pulse 1s ease-in-out infinite alternate;
}

@keyframes cell-leak-pulse {
  from { background-color: rgba(239, 68, 68, 0.04); }
  to { background-color: rgba(239, 68, 68, 0.14); }
}

/* Rotor Interno da Célula que Gira */
.pipe-inner-rotor {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.22s cubic-bezier(0.34, 1.35, 0.64, 1);
  will-change: transform;
}

.pipe-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Indicadores Visuais de Vazamento nas Pontas Soltas (Fora do Rotor, Fixos nas Bordas N/L/S/O) */
.leak-markers-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}

.leak-jet {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 173, 238, 0.24);
  border: 2px solid #00adee;
  box-shadow: 0 0 10px rgba(0, 173, 238, 0.6);
  animation: leak-jet-pulse 0.85s ease-in-out infinite alternate;
}

.leak-jet::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00f0ff;
}

.leak-jet.critical {
  width: 30px;
  height: 30px;
  background: rgba(239, 68, 68, 0.28);
  border: 2.5px solid #ef4444;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.85);
}

.leak-jet.critical::after {
  content: '!';
  width: auto;
  height: auto;
  background: none;
  color: #b91c1c;
  font-family: 'Rajdhani', sans-serif;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

.leak-jet.dir-0 { top: 2px; left: 50%; transform: translateX(-50%); }
.leak-jet.dir-1 { right: 2px; top: 50%; transform: translateY(-50%); }
.leak-jet.dir-2 { bottom: 2px; left: 50%; transform: translateX(-50%); }
.leak-jet.dir-3 { left: 2px; top: 50%; transform: translateY(-50%); }

@keyframes leak-jet-pulse {
  from { opacity: 0.72; filter: brightness(0.95); }
  to { opacity: 1; filter: brightness(1.25); }
}

/* Rodapé do Gameplay */
.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 98vw;
  width: 100%;
  margin: 4px auto 0;
  padding-top: 4px;
  border-top: 1px solid var(--border-light);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-tip {
  font-weight: 500;
}

.footer-restart-btn {
  background: none;
  border: none;
  color: var(--cauplas-blue-primary);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.footer-restart-btn:hover {
  text-decoration: underline;
}

/* ==========================================================
   MODAIS E OVERLAYS
   ========================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 25, 49, 0.7);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

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

.modal-card {
  background: var(--bg-card-light);
  border-radius: var(--radius-lg);
  border: 3px solid var(--cauplas-blue-cyan);
  padding: 36px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 580px;
  width: 100%;
  box-shadow: var(--shadow-glow), 0 25px 60px rgba(0, 0, 0, 0.35);
  transform: translateY(20px) scale(0.96);
  transition: transform 0.35s var(--ease-spring);
}

.modal-overlay.modal-active .modal-card,
.modal-overlay.modal-active .idle-card {
  transform: translateY(0) scale(1);
}

.victory-trophy {
  font-size: 3.5rem;
  filter: drop-shadow(0 6px 12px rgba(255, 193, 7, 0.5));
  margin-bottom: 6px;
}

.defeat-icon {
  font-size: 3.5rem;
  margin-bottom: 6px;
}

.modal-kicker {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--cauplas-blue-primary);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.kicker-danger {
  color: var(--status-danger);
}

.modal-title {
  font-size: 2rem;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 10px;
}

.victory-text {
  background: linear-gradient(135deg, var(--cauplas-blue-primary), var(--cauplas-blue-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.defeat-text {
  color: var(--status-danger);
}

.modal-desc {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 20px;
}

/* Card de Prêmio */
.prize-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-app-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 18px;
  text-align: left;
  width: 100%;
}

.prize-img-box {
  width: 84px;
  height: 84px;
  background: #ffffff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 1px solid var(--border-light);
  flex-shrink: 0;
}

.prize-img-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.prize-badge {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--cauplas-blue-primary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 2px;
}

.prize-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.prize-spec {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Caixa de Voucher */
.voucher-box {
  width: 100%;
  background: linear-gradient(135deg, rgba(0, 100, 240, 0.08) 0%, rgba(0, 173, 238, 0.12) 100%);
  border: 2px dashed var(--cauplas-blue-primary);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 22px;
}

.voucher-tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 4px;
}

.voucher-code {
  font-family: 'Share Tech Mono', monospace;
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--cauplas-blue-dark);
  letter-spacing: 0.15em;
  text-shadow: 0 0 10px rgba(0, 173, 238, 0.3);
  margin-bottom: 4px;
}

.voucher-note {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--cauplas-blue-primary);
}

.defeat-stat-box {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  margin-bottom: 22px;
  width: 100%;
}

.defeat-stat-box span {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  display: block;
}

.defeat-stat-box strong {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1.3rem;
  color: var(--status-danger);
}

/* Botões do Fim de Partida */
.endgame-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.btn-endgame-action {
  width: 100%;
  max-width: 380px;
  font-size: 1.25rem;
  padding: 16px 28px;
}

.btn-retry-color {
  background: linear-gradient(135deg, #007bff 0%, #0064f0 100%);
}

.endgame-sub-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-sub-action {
  background: none;
  border: none;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.btn-sub-action:hover {
  background: var(--bg-subtle-gray);
  color: var(--cauplas-blue-primary);
}

/* Modal de Confirmação */
.confirm-card {
  max-width: 440px;
}

.confirm-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.modal-actions-row {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  width: 100%;
}

.modal-btn {
  flex: 1;
  padding: 12px 18px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 1rem;
  border: none;
  cursor: pointer;
}

.btn-secondary {
  background: var(--bg-subtle-gray);
  color: var(--text-primary);
}

.btn-primary {
  background: var(--cauplas-blue-primary);
  color: #ffffff;
}

/* ==========================================================
   MODO DE REPOUSO / ATRAÇÃO (IDLE SCREEN)
   Sem "Demonstração Interativa"
   ========================================================== */
.idle-overlay {
  background: radial-gradient(circle at 50% 50%, #ffffff 0%, #e8f0fa 70%, #d4e2f5 100%);
}

.idle-card {
  max-width: 650px;
  width: 100%;
  text-align: center;
  padding: 40px 30px;
}

.idle-badge {
  display: inline-block;
  background: rgba(0, 100, 240, 0.1);
  border: 1px solid var(--cauplas-blue-primary);
  border-radius: var(--radius-full);
  padding: 6px 18px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--cauplas-blue-primary);
  margin-bottom: 20px;
}

.idle-icon-wrap {
  margin-bottom: 20px;
}

.idle-brand-icon {
  width: 110px;
  height: 110px;
  filter: drop-shadow(0 8px 24px rgba(0, 100, 240, 0.3));
  animation: idle-float 3s ease-in-out infinite alternate;
}

@keyframes idle-float {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-8px) scale(1.05); }
}

.idle-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.idle-title span {
  color: var(--cauplas-blue-primary);
}

.idle-subtitle {
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 32px;
}

.idle-subtitle strong {
  color: var(--cauplas-blue-primary);
}

.idle-start-btn {
  margin: 0 auto;
}

.idle-footer-brand {
  margin-top: 36px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ==========================================================
   RESPONSIVIDADE HORIZONTAL VS VERTICAL (TOTEM 9:16)
   ========================================================== */

/* Quando a tela for vertical (Totens 9:16, e.g. 1080x1920 e smartphones) */
@media (max-aspect-ratio: 1/1) {
  .screen-game {
    padding: 12px 14px 16px;
    justify-content: space-between;
  }

  .game-hud-bar {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
    max-width: 98vw;
  }

  .hud-instructions {
    grid-column: 1 / -1;
    order: 3;
    padding: 8px 12px;
  }

  /* Mantém a arena HORIZONTAL com ligação contínua e proporção ideal no totem */
  .arena-pipeline-wrapper {
    flex-direction: row !important;
    width: 98vw;
    max-width: 1040px;
    flex: 1;
    min-height: 0;
    margin: 0 auto;
    align-items: center;
    justify-content: center;
  }

  .station-title {
    font-size: 0.78rem;
  }

  .station-icon {
    font-size: 1.05rem;
  }

  .station-pill {
    font-size: 0.64rem;
  }

  .leak-alert-banner {
    font-size: 0.86rem;
    padding: 8px 16px;
  }
}

/* Telas muito pequenas (smartphones compactos) */
@media (max-width: 480px) {
  .hero-title {
    font-size: 1.8rem;
  }

  .stepper-btn {
    width: 48px;
    height: 48px;
    font-size: 1.6rem;
  }

  .stepper-value {
    font-size: 2.2rem;
  }

  .btn-primary-action {
    font-size: 1.15rem;
    padding: 14px 20px;
  }

  .station-title {
    font-size: 0.66rem;
  }

  .station-footer {
    display: none;
  }
}
