html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background-color: #0a0e1a; 
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

canvas {
  display: block;     
  width: 100vw;       
  height: 100vh;      
}

/* ==================== FPS COUNTER ==================== */
.fps-counter {
  position: fixed;
  top: 16px;
  right: 16px;
  background: rgba(26, 32, 44, 0.9);
  backdrop-filter: blur(10px);
  color: #4fd1c7;
  padding: 8px 16px;
  border-radius: 6px;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 14px;
  font-weight: 600;
  z-index: 100;
  border: 1px solid rgba(79, 209, 199, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ==================== TOOLTIP ==================== */
.controls-tooltip {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26, 32, 44, 0.95);
  backdrop-filter: blur(10px);
  color: #e2e8f0;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(79, 209, 199, 0.2);
  z-index: 100;
  transition: opacity 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.controls-tooltip.hidden {
  opacity: 0;
  pointer-events: none;
}

.tooltip-key {
  background: rgba(79, 209, 199, 0.2);
  color: #4fd1c7;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 12px;
  border: 1px solid rgba(79, 209, 199, 0.3);
}

/* ==================== CONTROLS TOGGLE ==================== */
.controls-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1001;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: rgba(26, 32, 44, 0.95);
  backdrop-filter: blur(10px);
  color: #4fd1c7;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  border: 1px solid rgba(79, 209, 199, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.controls-toggle:hover {
  background: rgba(26, 32, 44, 1);
  border-color: rgba(79, 209, 199, 0.5);
  transform: scale(1.05);
}

/* ==================== CONTROLS PANEL ==================== */
.controls-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 380px;
  height: 100vh;
  background: rgba(26, 32, 44, 0.98);
  backdrop-filter: blur(12px);
  border-right: 1px solid rgba(79, 209, 199, 0.2);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
}

.controls-panel.controls-visible {
  transform: translateX(0);
}

.controls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(79, 209, 199, 0.2);
  background: rgba(0, 0, 0, 0.3);
  min-height: 40px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #4fd1c7;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.header-right {
  display: flex;
  align-items: center;
}

.controls-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #718096;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.controls-close:hover {
  background: rgba(79, 209, 199, 0.1);
  color: #4fd1c7;
}

/* ==================== CONTENT AREA ==================== */
.controls-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.controls-content::-webkit-scrollbar { 
  width: 6px; 
}

.controls-content::-webkit-scrollbar-track { 
  background: transparent; 
}

.controls-content::-webkit-scrollbar-thumb {
  background: rgba(79, 209, 199, 0.3);
  border-radius: 3px;
}

.controls-content::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 209, 199, 0.5);
}

/* ==================== SECTIONS ==================== */
.control-section { 
  margin-bottom: 28px; 
}

.control-section h4 {
  margin: 0 0 16px 0;
  font-size: 15px;
  font-weight: 600;
  color: #4fd1c7;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==================== CONTROL GROUPS ==================== */
.control-group {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}

.control-group label {
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e0;
  min-width: 80px;
  flex-shrink: 0;
}

/* ==================== INPUTS ==================== */

/* Range Sliders */
.control-group input[type="range"] {
  --track-bg: #2d3748;
  --fill-bg: #4fd1c7;
  --thumb-size: 16px;
  --track-height: 6px;
  
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  flex: 1;
}

.control-group input[type="range"]::-webkit-slider-runnable-track {
  height: var(--track-height);
  border-radius: calc(var(--track-height) / 2);
  background: var(--track-bg);
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--thumb-size);
  height: var(--thumb-size);
  border-radius: 50%;
  background: linear-gradient(135deg, #4fd1c7, #38b2ac);
  margin-top: calc((var(--thumb-size) - var(--track-height)) / -2);
  border: 2px solid #1a202c;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 3px 8px rgba(79, 209, 199, 0.4);
}

.control-group input[type="range"]::-moz-range-track {
  height: var(--track-height);
  border-radius: calc(var(--track-height) / 2);
  background: var(--track-bg);
}

.control-group input[type="range"]::-moz-range-thumb {
  width: var(--thumb-size);
  height: var(--thumb-size);
  border-radius: 50%;
  background: linear-gradient(135deg, #4fd1c7, #38b2ac);
  border: 2px solid #1a202c;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Checkboxes */
.control-group input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 22px;
  background: rgba(45, 55, 72, 0.8);
  border: 1px solid rgba(79, 209, 199, 0.2);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
  outline: none;
}

.control-group input[type="checkbox"]:hover {
  border-color: rgba(79, 209, 199, 0.5);
}

.control-group input[type="checkbox"]:checked {
  background: linear-gradient(135deg, #4fd1c7, #38b2ac);
  border-color: #4fd1c7;
}

.control-group input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e2e8f0;
  top: 1px;
  left: 1px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.control-group input[type="checkbox"]:checked::before {
  left: 23px;
  background: #1a202c;
}

/* Color Inputs */
.control-group input[type="color"] {
  width: 36px;
  height: 28px;
  border: 2px solid rgba(79, 209, 199, 0.3);
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  padding: 0;
  transition: all 0.2s ease;
}

.control-group input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.control-group input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.control-group input[type="color"]:hover {
  border-color: #4fd1c7;
  transform: scale(1.05);
}

/* Select Dropdowns */
.control-group select {
  flex: 1;
  padding: 8px 12px;
  background: rgba(45, 55, 72, 0.8);
  border: 1px solid rgba(79, 209, 199, 0.2);
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.control-group select:hover {
  border-color: rgba(79, 209, 199, 0.5);
}

.control-group select:focus {
  border-color: #4fd1c7;
  box-shadow: 0 0 0 3px rgba(79, 209, 199, 0.1);
}

.control-group select option {
  background: #2d3748;
  color: #e2e8f0;
}

/* Value Display Spans */
.control-group span {
  min-width: 42px;
  text-align: right;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  background: rgba(45, 55, 72, 0.8);
  padding: 4px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* ==================== BUTTONS ==================== */
.action-button {
  width: 100%;
  padding: 10px 16px;
  background: linear-gradient(135deg, #4fd1c7, #38b2ac);
  border: none;
  border-radius: 6px;
  color: #1a202c;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.action-button:hover {
  transform: translateY(-2px);
  /* box-shadow: 0 4px 12px rgba(79, 209, 199, 0.4); */
}

.action-button:active {
  transform: translateY(0);
}

.action-button.primary {
  background: linear-gradient(135deg, #4fd1c7, #38b2ac);
  color: #1a202c;
}

.action-button.secondary {
  background: linear-gradient(135deg, #4fd1c7, #38b2ac);
  color: white;
}

.action-button.danger {
  background: linear-gradient(135deg, #fc8181, #f56565);
  color: white;
}

.action-button-small {
  padding: 4px 12px;
  background: linear-gradient(135deg, #4fd1c7, #38b2ac);
  border: none;
  border-radius: 4px;
  color: #1a202c;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.action-button-small:hover {
  transform: scale(1.05);
  /* box-shadow: 0 2px 8px rgba(79, 209, 199, 0.4); */
}

/* ==================== STATS DISPLAY ==================== */
.stats-display, .game-stats {
  background: rgba(45, 55, 72, 0.6);
  border: 1px solid rgba(79, 209, 199, 0.2);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 20px;
}

.stat-item {
  flex: 1;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #a0aec0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.stat-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: #e2e8f0;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

.stat-value.highlight {
  color: #4fd1c7;
}

/* ==================== GAME STATUS ==================== */
.game-status {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  padding: 12px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.4);
  margin-bottom: 16px;
  display: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==================== INFO BOX ==================== */
.info-box {
  margin-top: 16px;
  padding: 14px;
  background: rgba(45, 55, 72, 0.6);
  border-radius: 6px;
  border-left: 3px solid #4fd1c7;
  font-size: 12px;
  color: #cbd5e0;
  line-height: 1.6;
}

.info-box strong {
  color: #4fd1c7;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .controls-panel { 
    width: 100vw; 
  }
  .controls-toggle { 
    top: 12px; 
    left: 12px; 
  }
  .fps-counter {
    top: 12px;
    right: 12px;
  }
}

/* ==================== FOCUS STATES ==================== */
.controls-toggle:focus,
.controls-close:focus,
.control-group input:focus,
.action-button:focus {
  outline: 2px solid #4fd1c7;
  outline-offset: 2px;
}

/* ==================== SEED INPUT ==================== */
.seed-input {
  flex: 1;
  padding: 6px 10px;
  background: rgba(45, 55, 72, 0.8);
  border: 1px solid rgba(79, 209, 199, 0.2);
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 13px;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  outline: none;
  transition: all 0.2s ease;
}

.seed-input:hover {
  border-color: rgba(79, 209, 199, 0.4);
}

.seed-input:focus {
  border-color: #4fd1c7;
  box-shadow: 0 0 0 2px rgba(79, 209, 199, 0.2);
}

.seed-input::-webkit-inner-spin-button,
.seed-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.seed-input {
  -moz-appearance: textfield;
}

.game-status.win {
    color: #4fd1c7; /* Ciano do tema */
    border: 1px solid rgba(79, 209, 199, 0.3); /* Borda sutil */
}

.game-status.lose {
    color: #fc8181; /* Vermelho suave */
    border: 1px solid rgba(252, 129, 129, 0.3); /* Borda sutil */
}


/* ==================== TOOLTIP (HUD STYLE) ==================== */
.controls-tooltip {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  
  /* Visual de Vidro Tecnológico */
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(79, 209, 199, 0.15);
  box-shadow: 
    0 4px 24px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  
  padding: 12px 24px;
  border-radius: 12px;
  color: #a0aec0;
  
  display: flex;
  align-items: center;
  gap: 24px;
  
  z-index: 100;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none; /* Permite clicar através do tooltip se necessário */
}

.controls-tooltip.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
}

/* Seções Internas */
.tooltip-section {
  display: flex;
  align-items: center;
  gap: 20px;
}

.tooltip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.tooltip-item span {
  color: #e2e8f0;
  text-shadow: 0 0 10px rgba(0,0,0,0.5);
}

/* Separador Vertical */
.tooltip-separator {
  width: 1px;
  height: 24px;
  background: linear-gradient(to bottom, transparent, rgba(79, 209, 199, 0.3), transparent);
}

/* --- Estilização das Teclas (Keyboard Keys) --- */
.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  
  background: linear-gradient(180deg, rgba(30, 40, 55, 0.9) 0%, rgba(20, 25, 35, 0.9) 100%);
  border: 1px solid rgba(79, 209, 199, 0.3);
  border-bottom-width: 2px; /* Efeito 3D */
  border-radius: 4px;
  
  font-family: 'SF Mono', 'Monaco', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #4fd1c7;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.key-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-right: 4px;
}

.key-row {
  display: flex;
  gap: 2px;
}

/* --- Ícones de Mouse (Pure CSS) --- */
.mouse-icon {
  width: 16px;
  height: 24px;
  border: 2px solid rgba(160, 174, 192, 0.5);
  border-radius: 8px;
  position: relative;
  box-sizing: border-box;
}

/* Linha divisória dos botões do mouse */
.mouse-icon::before {
  content: '';
  position: absolute;
  top: 6px;
  left: -2px;
  right: -2px;
  height: 1px;
  background: transparent; 
  /* Não desenhamos a linha inteira, usamos box-shadow ou lógica específica abaixo */
}

/* Representação do clique */
.mouse-icon.left-click {
  background: linear-gradient(90deg, #4fd1c7 50%, transparent 50%);
  border-color: #4fd1c7;
}
/* Ajuste fino para preencher apenas a parte superior esquerda */
.mouse-icon.left-click::after {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 50%; height: 8px;
  background: #4fd1c7;
  border-top-left-radius: 5px;
}

.mouse-icon.right-click {
  border-color: #4fd1c7;
}
.mouse-icon.right-click::after {
  content: '';
  position: absolute;
  top: 0; right: 0; width: 50%; height: 8px;
  background: #4fd1c7;
  border-top-right-radius: 5px;
}

.mouse-icon.middle-click {
  border-color: #4fd1c7;
}
.mouse-icon.middle-click::after {
  content: '';
  position: absolute;
  top: 2px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 6px;
  background: #4fd1c7;
  border-radius: 2px;
}

.mouse-icon.scroll-click {
    border-color: rgba(160, 174, 192, 0.5);
}
.mouse-icon.scroll-click::after {
  content: '';
  position: absolute;
  top: 3px; left: 50%; transform: translateX(-50%);
  width: 2px; height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  animation: scroll-anim 1.5s infinite;
}

@keyframes scroll-anim {
  0% { transform: translateX(-50%) translateY(0); opacity: 1; }
  100% { transform: translateX(-50%) translateY(6px); opacity: 0; }
}

/* Responsividade: Em telas pequenas, quebra em duas linhas */
@media (max-width: 900px) {
  .controls-tooltip {
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    width: 90%;
    bottom: 20px;
  }
  
  .tooltip-separator {
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(79, 209, 199, 0.3), transparent);
  }
  
  .tooltip-section {
    flex-wrap: wrap;
    justify-content: center;
  }
}
/* ==================== CONTROLS FOOTER ==================== */
.controls-footer {
  margin-top: 24px;
  padding: 12px 0 0 0;
  text-align: center;
  font-size: 13px;
  color: #a0aec0;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  letter-spacing: 0.2px;
  opacity: 0.85;
  border-top: 1px solid rgba(79, 209, 199, 0.12);
}