:root {
  --bg-gradient: linear-gradient(135deg, #1f2421 0%, #213a2d 50%, #15201b 100%);
  --dino-green: #38b000;
  --dino-belly: #ffe066;
  --earth-brown: #8b5a2b;
  --accent-orange: #ff7b00;
  --accent-yellow: #ffb703;
  --card-bg: rgba(28, 38, 32, 0.92);
  --text-light: #f8f9fa;
  --text-muted: #c7d1cc;
  --border-glow: rgba(74, 222, 128, 0.35);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  background: var(--bg-gradient);
  font-family: 'Fredoka', sans-serif;
  color: var(--text-light);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  overflow-x: hidden;
  user-select: none;
}

.game-wrapper {
  width: 100%;
  max-width: 1000px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* Header */
.game-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.title-container h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #a7f3d0;
  text-shadow: 0 2px 10px rgba(52, 211, 153, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-container .subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1.3rem;
  padding: 8px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

/* Canvas Area */
.canvas-container {
  position: relative;
  width: 100%;
  aspect-ratio: 960 / 400;
  background-color: #79b5dc;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 0 3px rgba(74, 222, 128, 0.25);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

/* Overlays */
.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(12, 18, 15, 0.85);
  backdrop-filter: blur(6px);
  z-index: 20;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.game-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.game-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.overlay-card {
  background: var(--card-bg);
  border: 2px solid rgba(74, 222, 128, 0.4);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  border-radius: 24px;
  padding: 28px 36px;
  text-align: center;
  max-width: 540px;
  width: 90%;
  animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.dino-avatar-bounce {
  font-size: 3.2rem;
  margin-bottom: 4px;
  animation: dinoFloat 1.4s ease-in-out infinite alternate;
}

.dino-avatar-dizzy {
  font-size: 3.2rem;
  margin-bottom: 4px;
}

@keyframes dinoFloat {
  from { transform: translateY(0) rotate(-2deg); }
  to { transform: translateY(-8px) rotate(3deg); }
}

.overlay-card h2 {
  font-size: 1.7rem;
  color: #6ee7b7;
  font-weight: 700;
  margin-bottom: 8px;
}

.flavor-text {
  font-size: 1rem;
  color: #e2e8f0;
  margin-bottom: 18px;
  line-height: 1.4;
}

/* Controls Guide in Overlay */
.controls-guide {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(0, 0, 0, 0.3);
  padding: 14px;
  border-radius: 16px;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.key-item {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.95rem;
  text-align: left;
}

.key-badge {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  padding: 6px 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Buttons */
.primary-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  border: none;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 12px 32px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.45);
  transition: all 0.2s ease;
  outline: none;
}

.primary-btn:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(245, 158, 11, 0.6);
}

.primary-btn:active {
  transform: translateY(1px);
}

.pulse {
  animation: pulseBtn 1.8s infinite;
}

@keyframes pulseBtn {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.hint-text {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-top: 10px;
}

/* Game Over Card */
.game-over-title {
  color: #f87171 !important;
}

.final-scores {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 16px 0 20px;
}

.score-box {
  background: rgba(0, 0, 0, 0.4);
  padding: 12px 24px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.score-box.highlight {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.1);
}

.score-label {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 1px;
}

.score-val {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.4rem;
  color: #fbbf24;
  margin-top: 6px;
}

.new-record-badge {
  background: linear-gradient(90deg, #ec4899, #f59e0b);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: inline-block;
  animation: pulseBtn 1s infinite;
}

/* Controls Bar at Bottom */
.controls-bar {
  display: flex;
  gap: 16px;
  width: 100%;
  justify-content: center;
}

.control-key-card {
  flex: 1;
  max-width: 320px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.control-key-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(74, 222, 128, 0.5);
}

.control-key-card.active-key {
  background: rgba(74, 222, 128, 0.25);
  border-color: #4ade80;
  transform: translateY(2px) scale(0.98);
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.5);
}

.key-cap {
  font-size: 1.6rem;
  background: #1e293b;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  box-shadow: 0 4px 0 #0f172a;
}

.key-info {
  display: flex;
  flex-direction: column;
}

.key-info strong {
  font-size: 0.95rem;
  color: #6ee7b7;
}

.key-info span {
  font-size: 0.8rem;
  color: #94a3b8;
}

/* Footer */
.game-footer {
  text-align: center;
  font-size: 0.85rem;
  color: #64748b;
  padding-bottom: 8px;
}

/* Controles Táteis na Tela (Celular e Tablet) */
.mobile-controls {
  display: none;
  width: 100%;
  max-width: 680px;
  gap: 16px;
  justify-content: center;
  align-items: stretch;
  padding: 4px 0;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Exibe em telas de toque ou quando a classe show-touch-controls estiver ativa */
body.show-touch-controls .mobile-controls,
@media (hover: none) and (pointer: coarse), (max-width: 820px) {
  .mobile-controls {
    display: flex !important;
  }
}

.mobile-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px 20px;
  min-height: 72px;
  border-radius: 20px;
  border: 3px solid;
  cursor: pointer;
  outline: none;
  font-family: 'Fredoka', sans-serif;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.08s ease;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.mobile-btn-up {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: #34d399;
  color: #ffffff;
}

.mobile-btn-down {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-color: #fbbf24;
  color: #ffffff;
}

.mobile-btn:active,
.mobile-btn.touch-active {
  transform: translateY(4px) scale(0.96);
  filter: brightness(1.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.mobile-btn-up.touch-active {
  box-shadow: 0 0 22px rgba(52, 211, 153, 0.85);
}

.mobile-btn-down.touch-active {
  box-shadow: 0 0 22px rgba(251, 191, 36, 0.85);
}

.mobile-btn-cap {
  font-size: 2.2rem;
  background: rgba(0, 0, 0, 0.25);
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.mobile-btn-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.btn-main-label {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.btn-sub-label {
  font-size: 0.85rem;
  opacity: 0.92;
  font-weight: 500;
}

/* Em dispositivos móveis com controles táteis ativos */
body.show-touch-controls #desktopControls,
@media (hover: none) and (pointer: coarse) {
  #desktopControls {
    display: none;
  }
}

@media (max-width: 600px) {
  body {
    padding: 8px;
  }
  .title-container h1 { font-size: 1.25rem; }
  .title-container .subtitle { font-size: 0.75rem; }
  .controls-bar { flex-direction: column; align-items: stretch; }
  .control-key-card { max-width: 100%; }
  
  .mobile-btn {
    padding: 12px 14px;
    min-height: 64px;
    gap: 10px;
  }
  .mobile-btn-cap {
    width: 44px;
    height: 44px;
    font-size: 1.8rem;
  }
  .btn-main-label {
    font-size: 1.15rem;
  }
  .btn-sub-label {
    font-size: 0.75rem;
  }
}
