/* ============================================
   7 PROVAS - DESIGN SYSTEM
   Competição de Lógica
   ============================================ */

/* === VARIÁVEIS === */
:root {
  /* Cores Base */
  --bg-primary: #0F172A;
  --bg-secondary: #1E293B;
  --bg-card: rgba(30, 41, 59, 0.8);
  --bg-card-hover: rgba(30, 41, 59, 0.95);
  
  /* Cores de Destaque */
  --accent-blue: #3B82F6;
  --accent-blue-light: #60A5FA;
  --accent-yellow: #F59E0B;
  --accent-yellow-light: #FBBF24;
  --accent-green: #22C55E;
  --accent-red: #EF4444;
  --accent-purple: #8B5CF6;
  
  /* Cores de Texto */
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  
  /* Bordas e Sombras */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.15);
  --glow-blue: rgba(59, 130, 246, 0.4);
  --glow-yellow: rgba(245, 158, 11, 0.4);
  
  /* Tipografia */
  --font-main: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Tamanhos */
  --header-height: 70px;
  --mobile-hud-height: 80px;
  --canvas-size: 650px;
  --sidebar-width: 280px;
}

/* === RESET & BASE === */
/* Font loaded via HTML link tag for better performance */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  color: var(--text-primary);
  background: var(--bg-primary);
  background-image: 
    radial-gradient(ellipse at top, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Textura geométrica sutil */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.hidden {
  display: none !important;
}

/* === HEADER FIXO === */
.game-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(15, 23, 42, 0.95) 100%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: baseline;
  gap: 4px;
  user-select: none;
}

.logo-number {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-yellow);
  text-shadow: 0 0 20px var(--glow-yellow);
}

.logo-text {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.season-badge {
  display: flex;
  flex-direction: column;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.season-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-blue-light);
}

.season-period {
  font-size: 11px;
  color: var(--text-muted);
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.game-mode-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
  border: 1px solid var(--accent-blue);
  border-radius: 20px;
  box-shadow: 0 0 20px var(--glow-blue);
}

.mode-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-blue-light);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.mode-progress {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-header {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-header:hover {
  background: var(--bg-card);
  border-color: var(--accent-blue);
}

.btn-header.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-blue-light);
}

/* === ÁREA PRINCIPAL === */
.game-main {
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  position: relative;
  z-index: 1;
}

/* === ESTADO IDLE - TELA INICIAL === */
.state-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-height));
  padding: 40px 24px;
  gap: 40px;
}

.hero-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 600px;
}

.hero-content {
  text-align: center;
  padding: 60px 40px;
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(30, 41, 59, 0.4) 100%);
  border: 1px solid var(--border-medium);
  border-radius: 24px;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.3),
    0 0 80px rgba(59, 130, 246, 0.1);
  position: relative;
  overflow: hidden;
}

.hero-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.hero-logo {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.hero-number {
  font-size: 72px;
  font-weight: 700;
  color: var(--accent-yellow);
  text-shadow: 0 0 40px var(--glow-yellow);
  line-height: 1;
}

.hero-text {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text-primary);
  line-height: 1;
}

.hero-tagline {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.hero-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.hero-status {
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-muted);
  min-height: 20px;
}

.hero-status.error {
  color: var(--accent-red);
}

/* === BOTÕES === */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 32px;
  background: linear-gradient(135deg, var(--accent-yellow) 0%, var(--accent-yellow-light) 100%);
  border: none;
  border-radius: 12px;
  color: var(--bg-primary);
  font-family: var(--font-main);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px var(--glow-yellow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary.btn-glow {
  box-shadow: 0 4px 20px var(--glow-yellow);
}

.btn-primary.btn-large {
  padding: 20px 48px;
  font-size: 18px;
}

.btn-primary.btn-full {
  width: 100%;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  background: transparent;
  border: 2px solid var(--border-medium);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--bg-card);
  border-color: var(--accent-blue);
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 14px;
  cursor: pointer;
  transition: color 0.2s ease;
}

.btn-ghost:hover {
  color: var(--text-primary);
}

.btn-icon {
  font-size: 1.1em;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent-blue-light);
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--accent-blue);
}

/* === HOME RANKING === */
.home-ranking {
  width: 100%;
  max-width: 600px;
}

.ranking-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 24px;
}

.ranking-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.ranking-icon {
  font-size: 20px;
}

.ranking-subtitle {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ranking-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
}

.ranking-position {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 24px;
}

.ranking-position.gold { color: #FFD700; }
.ranking-position.silver { color: #C0C0C0; }
.ranking-position.bronze { color: #CD7F32; }

.ranking-user {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
  margin-left: 12px;
}

.ranking-time {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-blue-light);
}

.ranking-season {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 8px;
}

.ranking-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* === ESTADO INSTRUCTION === */
.state-instruction {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - var(--header-height));
  padding: 40px 24px;
}

.instruction-card {
  width: 100%;
  max-width: 500px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.instruction-header {
  padding: 24px 28px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, transparent 100%);
  border-bottom: 1px solid var(--border-subtle);
}

.instruction-phase {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.instruction-meta {
  display: flex;
  gap: 16px;
}

.instruction-difficulty,
.instruction-level {
  font-size: 14px;
  color: var(--text-secondary);
}

.instruction-body {
  padding: 28px;
}

.instruction-section {
  margin-bottom: 24px;
}

.instruction-section:last-child {
  margin-bottom: 0;
}

.instruction-section h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-yellow);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.instruction-section p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.instruction-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

.instruction-hint {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.instruction-actions {
  padding: 24px 28px;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* === ESTADO PLAYING === */
.state-playing {
  padding: 24px;
  min-height: calc(100vh - var(--header-height));
}

.game-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--sidebar-width);
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}

.game-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 24px);
}

.sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 24px;
}

.level-info {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.level-phase {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.level-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.level-difficulty,
.level-number {
  font-size: 13px;
  color: var(--text-muted);
}

.level-difficulty strong,
.level-number strong {
  color: var(--text-secondary);
}

.level-objective h4 {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-yellow);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.level-objective p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.run-progress {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

.run-progress h4 {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-blue-light);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.progress-bar {
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-blue-light));
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  font-size: 12px;
  color: var(--text-muted);
}

.run-time {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.run-time-label {
  font-size: 12px;
  color: var(--text-muted);
}

.run-time-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-blue-light);
  font-variant-numeric: tabular-nums;
}

/* === CANVAS === */
.game-canvas-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#gameCanvas {
  width: 100%;
  max-width: var(--canvas-size);
  aspect-ratio: 1 / 1;
  background: radial-gradient(circle at 30% 30%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
    linear-gradient(180deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 2px solid var(--border-medium);
  border-radius: 16px;
  box-shadow: 
    0 0 60px rgba(59, 130, 246, 0.1),
    inset 0 0 40px rgba(0, 0, 0, 0.3);
}

.puzzle-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.puzzle-controls .controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.puzzle-controls .sequence {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.puzzle-controls .sequence span {
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}

.puzzle-controls button {
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.puzzle-controls button:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
}

/* === SIDEBAR DIREITA - TIMER E AÇÕES === */
.sidebar-right .sidebar-card {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.game-timer {
  text-align: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
}

.timer-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.timer-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-yellow);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 20px var(--glow-yellow);
}

.game-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.game-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border: none;
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-restart {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
}

.btn-restart:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
}

.btn-submit {
  background: linear-gradient(135deg, var(--accent-green) 0%, #34D399 100%);
  color: var(--bg-primary);
}

.btn-submit:hover {
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.4);
  transform: translateY(-2px);
}

.btn-exit {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.btn-exit:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--accent-red);
  color: var(--accent-red);
}

/* === ESTADO COMPLETED === */
.state-completed,
.state-failed {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.completion-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.completion-card {
  background: var(--bg-card);
  border: 2px solid var(--accent-green);
  border-radius: 24px;
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 0 60px rgba(34, 197, 94, 0.2);
  animation: slideUp 0.4s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.failed-overlay .completion-card {
  border-color: var(--accent-red);
  box-shadow: 0 0 60px rgba(239, 68, 68, 0.2);
}

.completion-header {
  margin-bottom: 28px;
}

.completion-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.completion-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.completion-stats {
  margin-bottom: 32px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row .stat-name {
  font-size: 14px;
  color: var(--text-muted);
}

.stat-row .stat-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-blue-light);
}

.completion-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* === MOBILE HUD === */
.mobile-hud {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-hud-height);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  z-index: 100;
}

.mobile-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mobile-timer-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-yellow);
  font-variant-numeric: tabular-nums;
}

.mobile-actions {
  display: flex;
  gap: 10px;
}

.mobile-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-main);
  cursor: pointer;
  min-width: 70px;
}

.mobile-btn-primary {
  background: linear-gradient(135deg, var(--accent-green) 0%, #34D399 100%);
  border: none;
  color: var(--bg-primary);
}

.mobile-btn-icon {
  font-size: 18px;
}

.mobile-btn-text {
  font-size: 11px;
  font-weight: 500;
}

/* === MODAIS === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 300;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: 20px;
  max-width: 900px;
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-small {
  max-width: 400px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-close:hover {
  background: var(--bg-card);
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(85vh - 70px);
}

/* === MODAL NÍVEIS === */
.phase-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
}

.phase-card:last-child {
  margin-bottom: 0;
}

.phase-card h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.difficulty-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.difficulty-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.level-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 100px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.level-tile:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
}

.level-tile.active {
  border-color: var(--accent-yellow);
  box-shadow: 0 0 0 2px var(--glow-yellow);
}

.level-tile span {
  font-size: 11px;
  color: var(--text-muted);
}

/* === MODAL AUTH === */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  padding: 14px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 15px;
  transition: border-color 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-error {
  padding: 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--accent-red);
  border-radius: 8px;
  color: var(--accent-red);
  font-size: 13px;
}

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-muted);
}

/* === RESPONSIVIDADE === */
@media (max-width: 1200px) {
  .game-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .game-sidebar {
    position: static;
  }
  
  .sidebar-left {
    order: 1;
  }
  
  .game-canvas-container {
    order: 2;
  }
  
  .sidebar-right {
    order: 3;
  }
  
  .sidebar-left .sidebar-card,
  .sidebar-right .sidebar-card {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
  }
  
  .level-info {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
  }
  
  .game-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 60px;
  }
  
  .game-header {
    padding: 0 16px;
  }
  
  .logo-number {
    font-size: 24px;
  }
  
  .logo-text {
    font-size: 18px;
  }
  
  .season-badge {
    display: none;
  }
  
  .header-center {
    display: none;
  }
  
  .hero-number {
    font-size: 48px;
  }
  
  .hero-text {
    font-size: 36px;
  }
  
  .hero-content {
    padding: 40px 24px;
  }
  
  .state-playing {
    padding: 16px;
    padding-bottom: calc(var(--mobile-hud-height) + 16px);
  }
  
  .game-layout {
    grid-template-columns: 1fr;
  }
  
  .sidebar-left,
  .sidebar-right {
    display: none;
  }
  
  .mobile-hud {
    display: flex !important;
  }
  
  #gameCanvas {
    max-width: 100%;
    border-radius: 12px;
  }
  
  .modal {
    margin: 16px;
    max-height: calc(100vh - 32px);
  }
  
  .completion-card {
    padding: 32px 24px;
  }
}

@media (max-width: 480px) {
  .hero-actions {
    width: 100%;
  }
  
  .btn-primary,
  .btn-secondary {
    width: 100%;
  }
  
  .mobile-btn {
    min-width: 60px;
    padding: 8px 12px;
  }
}

/* === ANIMAÇÕES === */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes revealCell {
  from { 
    transform: scale(0.9);
    opacity: 0.5;
  }
  to { 
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes victoryGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(34, 197, 94, 0.3); }
  50% { box-shadow: 0 0 40px rgba(34, 197, 94, 0.6); }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease;
}

#gameCanvas.shake {
  animation: shake 0.5s ease-in-out;
}

#gameCanvas.victory {
  animation: victoryGlow 1s ease-in-out infinite;
}

/* === PHASE 1 - MINAS LÓGICAS === */
.phase-1 #gameCanvas {
  background: radial-gradient(circle at 30% 30%, rgba(14, 165, 233, 0.05) 0%, transparent 50%),
    linear-gradient(180deg, #1E293B 0%, #0F172A 100%);
}

/* Mines info panel */
.mines-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.mines-counter {
  font-size: 16px;
  color: var(--text-primary);
}

.mines-counter strong {
  color: var(--accent-yellow);
  font-size: 18px;
}

.mines-info .hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Mobile touch targets for Phase 1 - minimum 44px */
@media (max-width: 768px) {
  #gameCanvas {
    touch-action: none; /* Prevent browser gestures */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  
  .mobile-hud .mobile-btn {
    min-width: 80px;
    min-height: 56px; /* Ensure 44px+ touch target */
    padding: 12px 16px;
  }
  
  .mobile-btn-icon {
    font-size: 20px;
  }
  
  .mobile-btn-text {
    font-size: 12px;
  }
}

/* === UTILITÁRIOS === */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mb-0 { margin-bottom: 0; }
.mt-auto { margin-top: auto; }
/* ============================================
   PHASE 2 - GRADE DE RESTRIÇÕES (Sudoku)
   Color Palette from PRD:
   - Fundo geral: #0B1220
   - Fundo do grid: #1E293B
   - Célula fixa: #334155
   - Célula editável: #0F172A
   - Número fixo: Branco
   - Número inserido: Azul claro
   - Conflito: Vermelho suave
   - Seleção ativa: Azul brilhante
   - Destaque linha/coluna: Azul translúcido
   ============================================ */

.phase-2 #gameCanvas,
.sudoku-controls #gameCanvas {
  background: radial-gradient(ellipse at 50% 0%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
    linear-gradient(180deg, #1E293B 0%, #0B1220 100%);
}

/* Sudoku Controls Panel */
.sudoku-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 0;
}

/* Rules Section */
.sudoku-rules {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 10px;
  padding: 12px 16px;
}

.sudoku-rules .rules-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: #3B82F6;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.sudoku-rules ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sudoku-rules li {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 3px 0;
  padding-left: 16px;
  position: relative;
}

.sudoku-rules li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: #60A5FA;
}

/* Number Keypad */
.sudoku-keypad {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.keypad-numbers {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

/* For 4x4 grid (4 numbers) */
.sudoku-keypad[data-size="4"] .keypad-numbers {
  grid-template-columns: repeat(4, 1fr);
}

/* For 5x5 grid (5 numbers) */
.sudoku-keypad[data-size="5"] .keypad-numbers {
  grid-template-columns: repeat(5, 1fr);
}

/* For 6x6 grid (6 numbers) */
.sudoku-keypad[data-size="6"] .keypad-numbers {
  grid-template-columns: repeat(3, 1fr);
}

/* For 9x9 grid (9 numbers) */
.sudoku-keypad[data-size="9"] .keypad-numbers {
  grid-template-columns: repeat(3, 1fr);
}

.sudoku-num-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 8px;
  background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  color: #FFFFFF;
  font-family: var(--font-main);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sudoku-num-btn:hover {
  background: linear-gradient(135deg, #334155 0%, #1E293B 100%);
  border-color: #3B82F6;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.sudoku-num-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* Clear Button */
.sudoku-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 10px 16px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: #EF4444;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sudoku-clear-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #EF4444;
}

.sudoku-clear-btn .clear-icon {
  font-size: 16px;
}

/* Hints Section */
.sudoku-hints {
  text-align: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.sudoku-hints .hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Grid Victory Animation for Sudoku */
@keyframes sudokuVictory {
  0% { 
    filter: brightness(1);
  }
  50% { 
    filter: brightness(1.2); 
  }
  100% { 
    filter: brightness(1);
  }
}

.sudoku-victory #gameCanvas {
  animation: sudokuVictory 0.6s ease-out;
}

/* Conflict Flash Animation */
@keyframes conflictFlash {
  0%, 100% { 
    background-color: rgba(239, 68, 68, 0.3);
  }
  50% { 
    background-color: rgba(239, 68, 68, 0.6);
  }
}

/* Mobile-specific Sudoku styles */
@media (max-width: 768px) {
  .sudoku-controls {
    padding: 0;
    gap: 12px;
  }
  
  .sudoku-rules {
    padding: 10px 12px;
  }
  
  .sudoku-rules li {
    font-size: 11px;
  }
  
  .keypad-numbers {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
  }
  
  .sudoku-num-btn {
    min-width: 48px;
    min-height: 48px;
    font-size: 20px;
    padding: 8px 6px;
  }
  
  .sudoku-clear-btn {
    padding: 12px 16px;
    font-size: 15px;
  }
  
  .sudoku-hints .hint {
    font-size: 10px;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .sudoku-num-btn {
    min-width: 40px;
    min-height: 40px;
    font-size: 16px;
  }
}

/* Large screen enhancements */
@media (min-width: 1200px) {
  .sudoku-num-btn {
    min-width: 50px;
    min-height: 50px;
    font-size: 20px;
  }
  
  .sudoku-rules li {
    font-size: 13px;
  }
}

/* Focus styles for keyboard navigation */
.sudoku-num-btn:focus {
  outline: 2px solid #3B82F6;
  outline-offset: 2px;
}

.sudoku-num-btn:focus:not(:focus-visible) {
  outline: none;
}

.sudoku-num-btn:focus-visible {
  outline: 2px solid #3B82F6;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

/* Canvas shake animation for errors */
@keyframes sudokuShake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-3px); }
  20%, 40%, 60%, 80% { transform: translateX(3px); }
}

#gameCanvas.sudoku-error {
  animation: sudokuShake 0.4s ease-in-out;
}

/* ============================================
   PHASE 3 - CONEXÕES (Flow-like)
   Color Palette from PRD:
   - Fundo geral: #0B1220
   - Grid base: #1F2937
   - Célula vazia: #111827
   - Linhas: Cores vibrantes distintas
   - Endpoint: Círculo preenchido com brilho
   - Linha ativa: Leve glow
   - Cruzamento inválido: Vermelho
   - Conclusão: Brilho suave
   ============================================ */

.phase-3 #gameCanvas,
.connections-controls #gameCanvas {
  background: radial-gradient(ellipse at 50% 50%, rgba(78, 205, 196, 0.06) 0%, transparent 60%),
    linear-gradient(180deg, #1F2937 0%, #0B1220 100%);
}

/* Connections Controls Panel */
.connections-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 0;
}

/* Rules Section */
.connections-rules {
  background: rgba(78, 205, 196, 0.08);
  border: 1px solid rgba(78, 205, 196, 0.2);
  border-radius: 10px;
  padding: 12px 16px;
}

.connections-rules .rules-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: #4ECDC4;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.connections-rules ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.connections-rules li {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 3px 0;
  padding-left: 16px;
  position: relative;
}

.connections-rules li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: #95E1D3;
}

/* Pair Legend */
.connections-legend {
  background: rgba(167, 139, 250, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.2);
  border-radius: 10px;
  padding: 12px 16px;
}

.connections-legend .legend-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: #A78BFA;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.legend-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.connection-pair-legend {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 
              inset 0 2px 4px rgba(255, 255, 255, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.connection-pair-legend:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4),
              0 0 12px currentColor,
              inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

/* Status Display */
.connections-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.1) 0%, rgba(78, 205, 196, 0.08) 100%);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 10px;
}

.connections-status .status-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.connections-status .status-value {
  font-size: 20px;
  font-weight: 700;
  color: #22C55E;
  text-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

.connections-status .status-separator {
  font-size: 16px;
  color: var(--text-muted);
}

.connections-status .status-total {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Hints */
.connections-hints {
  text-align: center;
  padding: 8px 0;
}

.connections-hints .hint {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* Victory Animation */
@keyframes connectionsVictoryPulse {
  0%, 100% { 
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
  50% { 
    box-shadow: 0 0 30px 10px rgba(34, 197, 94, 0.3);
  }
}

.connections-complete {
  animation: connectionsVictoryPulse 1.5s ease-in-out infinite;
}

/* Connection Line Glow Effect */
@keyframes connectionFlowPulse {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 2px currentColor); }
  50% { filter: brightness(1.2) drop-shadow(0 0 8px currentColor); }
}

.connection-line-active {
  animation: connectionFlowPulse 1s ease-in-out infinite;
}

/* Mobile-specific Connections styles */
@media (max-width: 768px) {
  .connections-controls {
    padding: 0;
    gap: 12px;
  }
  
  .connections-rules {
    padding: 10px 12px;
  }
  
  .connections-rules li {
    font-size: 11px;
  }
  
  .connections-legend {
    padding: 10px 12px;
  }
  
  .connection-pair-legend {
    width: 28px;
    height: 28px;
  }
  
  .connections-status {
    padding: 12px 14px;
  }
  
  .connections-status .status-value {
    font-size: 24px;
  }
  
  .connections-hints .hint {
    font-size: 10px;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .connection-pair-legend {
    width: 22px;
    height: 22px;
  }
  
  .connections-status .status-value {
    font-size: 18px;
  }
}

/* Large screen enhancements */
@media (min-width: 1200px) {
  .connection-pair-legend {
    width: 28px;
    height: 28px;
  }
  
  .connections-rules li {
    font-size: 13px;
  }
  
  .connections-status .status-value {
    font-size: 22px;
  }
}

/* Focus styles for keyboard navigation */
.connections-controls button:focus {
  outline: 2px solid #4ECDC4;
  outline-offset: 2px;
}

.connections-controls button:focus:not(:focus-visible) {
  outline: none;
}

.connections-controls button:focus-visible {
  outline: 2px solid #4ECDC4;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(78, 205, 196, 0.2);
}