@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700;900&family=Rajdhani:wght@500;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body, html {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: #050510;
  font-family: 'Rajdhani', sans-serif;
  color: #ffffff;
  touch-action: none;
  overscroll-behavior: none;
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  touch-action: none;
}

/* ================= HUD (Otimizado sem backdrop-filter pesado) ================= */
#hud {
  position: absolute;
  top: env(safe-area-inset-top, 16px);
  padding-top: 10px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  z-index: 10;
  pointer-events: none;
  padding-left: 10px;
  padding-right: 10px;
  flex-wrap: nowrap;
}

.hud-box {
  background: rgba(8, 12, 24, 0.92);
  border: 1px solid rgba(0, 240, 255, 0.45);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
  padding: 5px 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
}

.hud-label {
  font-family: 'Orbitron', monospace;
  font-size: 0.58rem;
  letter-spacing: 1.5px;
  color: #00f0ff;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.hud-value {
  font-family: 'Orbitron', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
}

.hud-perf-box {
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  border-color: rgba(0, 255, 170, 0.5);
}

.hud-perf-box:hover, .hud-perf-box:active {
  transform: scale(1.05);
  border-color: #00ffaa;
}

.highlight-fps {
  color: #00ffaa;
  font-size: 0.95rem;
  letter-spacing: 1px;
}

.hud-btn {
  pointer-events: auto;
  background: rgba(14, 18, 36, 0.92);
  border: 1px solid rgba(255, 0, 128, 0.5);
  box-shadow: 0 0 8px rgba(255, 0, 128, 0.2);
  color: #fff;
  font-size: 1.15rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
  touch-action: manipulation;
}

.hud-btn:hover, .hud-btn:active {
  transform: scale(1.08);
  border-color: #ff007f;
}

/* ================= CONTROLES VIRTUAIS MOBILE ================= */
#mobile-controls {
  position: absolute;
  bottom: env(safe-area-inset-bottom, 20px);
  margin-bottom: 12px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 18px;
  z-index: 15;
  pointer-events: none;
}

.m-dpad {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.m-actions {
  pointer-events: auto;
}

.m-touch-btn {
  background: rgba(10, 16, 32, 0.90);
  border: 2px solid rgba(0, 240, 255, 0.6);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
  color: #00f0ff;
  border-radius: 16px;
  width: 66px;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  transition: transform 0.08s ease, background 0.08s ease;
}

.m-touch-btn:active, .m-touch-btn.active {
  transform: scale(0.92);
  background: rgba(0, 240, 255, 0.4);
  border-color: #00ffff;
  color: #ffffff;
}

.m-touch-btn.m-btn-jump {
  width: 105px;
  height: 66px;
  border-color: rgba(255, 0, 128, 0.7);
  box-shadow: 0 0 12px rgba(255, 0, 128, 0.25);
  color: #ff007f;
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 1.5px;
  display: flex;
  flex-direction: row;
  gap: 6px;
}

.m-touch-btn.m-btn-jump:active, .m-touch-btn.m-btn-jump.active {
  background: rgba(255, 0, 128, 0.45);
  border-color: #ff0099;
  color: #ffffff;
}

/* ================= TELAS & OVERLAYS ================= */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, rgba(14, 12, 30, 0.94) 0%, rgba(5, 5, 14, 0.98) 100%);
  z-index: 20;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  padding: 16px;
}

.hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.screen-content {
  background: rgba(12, 17, 34, 0.94);
  border: 2px solid rgba(0, 240, 255, 0.45);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.15);
  padding: 28px 22px;
  border-radius: 16px;
  text-align: center;
  max-width: 460px;
  width: 100%;
  animation: floatIn 0.3s ease-out;
}

@keyframes floatIn {
  from {
    transform: translateY(14px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.game-title {
  font-family: 'Orbitron', monospace;
  font-size: 2.3rem;
  font-weight: 900;
  letter-spacing: 3px;
  color: #ffffff;
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.7);
  margin-bottom: 6px;
}

.game-title .highlight {
  color: #ff007f;
  text-shadow: 0 0 12px rgba(255, 0, 127, 0.7);
}

.game-subtitle {
  color: #9ab4d0;
  font-size: 0.95rem;
  margin-bottom: 16px;
  line-height: 1.4;
}

/* ================= SELETOR DE DESEMPENHO / QUALIDADE ================= */
.quality-settings-box {
  background: rgba(6, 10, 22, 0.85);
  border: 1px solid rgba(0, 255, 170, 0.35);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 16px;
  text-align: left;
}

.quality-title {
  font-family: 'Orbitron', monospace;
  font-size: 0.75rem;
  color: #00ffaa;
  letter-spacing: 1px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quality-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.quality-btn {
  background: rgba(14, 20, 40, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 7px 4px;
  color: #a0b2cc;
  font-family: 'Orbitron', monospace;
  font-size: 0.68rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  touch-action: manipulation;
}

.quality-btn:hover {
  border-color: #00f0ff;
  color: #fff;
}

.quality-btn.active {
  background: rgba(0, 255, 170, 0.2);
  border-color: #00ffaa;
  color: #00ffaa;
  font-weight: bold;
  box-shadow: 0 0 8px rgba(0, 255, 170, 0.25);
}

.quality-tip {
  font-size: 0.72rem;
  color: #8c9cb0;
  margin-top: 6px;
  line-height: 1.25;
}

/* ================= GUIA DE CONTROLES ================= */
.controls-guide {
  background: rgba(6, 10, 22, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: #d0e0f0;
}

.key {
  background: #1a2238;
  border: 1px solid #00f0ff;
  box-shadow: 0 2px 0 #0088aa;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Orbitron', monospace;
  font-size: 0.72rem;
  color: #00f0ff;
  font-weight: bold;
}

.mouse-icon {
  font-size: 0.95rem;
  font-weight: bold;
}

/* ================= BOTÕES ================= */
.primary-btn {
  font-family: 'Orbitron', monospace;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 13px 26px;
  background: linear-gradient(135deg, #ff007f 0%, #aa00ff 100%);
  border: none;
  border-radius: 28px;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(255, 0, 128, 0.4);
  transition: transform 0.15s ease;
  width: 100%;
  touch-action: manipulation;
}

.primary-btn:hover, .primary-btn:active {
  transform: translateY(-2px) scale(1.02);
}

.high-score-display {
  margin-top: 12px;
  font-size: 0.9rem;
  color: #ffe600;
  font-family: 'Orbitron', monospace;
  letter-spacing: 1px;
}

/* ================= GAME OVER ================= */
.gameover-title {
  font-family: 'Orbitron', monospace;
  font-size: 1.7rem;
  color: #ff3344;
  text-shadow: 0 0 15px rgba(255, 51, 68, 0.6);
  margin-bottom: 4px;
}

.gameover-subtitle {
  color: #8c9cb0;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.result-card {
  background: rgba(10, 14, 28, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
}

.result-card.full-width {
  grid-column: span 2;
}

.result-label {
  font-size: 0.72rem;
  color: #8c9cb0;
  margin-bottom: 2px;
}

.result-value {
  font-family: 'Orbitron', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
}

.result-value.highlight {
  font-size: 1.55rem;
  color: #00f0ff;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}

.record-card {
  background: rgba(255, 230, 0, 0.12);
  border: 1px solid #ffe600;
  color: #ffe600;
  font-family: 'Orbitron', monospace;
  font-weight: bold;
  font-size: 0.8rem;
  padding: 6px;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.8; }
  to { opacity: 1; text-shadow: 0 0 8px #ffe600; }
}

/* ================= RESPONSIVIDADE MOBILE ================= */
@media (max-width: 600px) {
  #hud {
    gap: 6px;
    padding-left: 6px;
    padding-right: 6px;
  }
  .hud-box {
    padding: 4px 8px;
  }
  .hud-label {
    font-size: 0.52rem;
    letter-spacing: 0.8px;
  }
  .hud-value {
    font-size: 0.95rem;
  }
  .highlight-fps {
    font-size: 0.85rem;
  }
  .hud-btn {
    width: 36px;
    height: 36px;
    font-size: 1.05rem;
  }
  .screen-content {
    padding: 20px 16px;
  }
  .game-title {
    font-size: 1.85rem;
    letter-spacing: 2px;
  }
  .game-subtitle {
    font-size: 0.88rem;
    margin-bottom: 12px;
  }
  .quality-options {
    gap: 4px;
  }
  .quality-btn {
    font-size: 0.62rem;
    padding: 6px 2px;
  }
  .controls-guide {
    padding: 10px;
    gap: 6px;
  }
  .control-item {
    font-size: 0.82rem;
  }
  .primary-btn {
    font-size: 0.98rem;
    padding: 12px 18px;
  }

  .m-touch-btn {
    width: 58px;
    height: 58px;
  }
  .m-touch-btn.m-btn-jump {
    width: 92px;
    height: 58px;
    font-size: 0.75rem;
  }
  #mobile-controls {
    padding: 0 10px;
  }
}
