* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  margin: 0;
  padding: 0;
}

body {
  background-color: #0b0f19;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #f8fafc;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-container {
  position: relative;
  width: min(100vw, calc(100vh * 9 / 16));
  height: min(100vh, calc(100vw * 16 / 9));
  aspect-ratio: 9 / 16;
  background: #000;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  border-radius: 12px;
  overflow: hidden;
}

/* Telas e Modais */
.screen-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(8px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 16px;
  text-align: center;
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

.title-glow {
  font-size: clamp(1.8rem, 5.5vw, 2.5rem);
  font-weight: 900;
  background: linear-gradient(135deg, #f59e0b, #ec4899, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.subtitle {
  font-size: 1.1rem;
  color: #94a3b8;
  margin-bottom: 24px;
}

.form-card {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 24px;
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1.5px solid #475569;
  background: #0f172a;
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-field:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.btn-primary {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  border: none;
  padding: 14px 28px;
  font-size: 1.2rem;
  font-weight: bold;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.4);
  transition: transform 0.1s;
}

.btn-primary:active {
  transform: scale(0.96);
}

.btn-secondary {
  background: #475569;
  color: #f8fafc;
  border: none;
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
}

.btn-gold {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border: none;
  padding: 12px 24px;
  font-size: 1.1rem;
  font-weight: bold;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to bottom, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.7), transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px 14px 10px;
  gap: 6px;
  z-index: 20;
  pointer-events: none;
}

.hud-top-bar {
  display: flex;
  justify-content: center;
  width: 100%;
}

#hud-level-name {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 3px 12px;
  border-radius: 20px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 95%;
}

.hud-stats-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  width: 100%;
  gap: 4px;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  font-size: 0.82rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 3px 7px;
  border-radius: 8px;
}

#game-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #38bdf8;
  touch-action: none;
}

#trivia-modal {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  z-index: 60;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  overflow-y: auto;
}

.trivia-card {
  background: #1e293b;
  border: 2px solid #8b5cf6;
  border-radius: 20px;
  padding: 20px 18px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(139, 92, 246, 0.4);
  text-align: center;
}

.trivia-badge {
  display: inline-block;
  background: #8b5cf6;
  color: white;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 14px;
}

.trivia-question {
  font-size: 1.25rem;
  line-height: 1.5;
  color: #f8fafc;
  margin-bottom: 22px;
  font-weight: 600;
}

.trivia-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.option-btn {
  background: #334155;
  color: #f8fafc;
  border: 1.5px solid #475569;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.option-btn:hover {
  background: #475569;
  border-color: #38bdf8;
}

.option-btn.correct {
  background: #15803d !important;
  border-color: #22c55e !important;
}

.option-btn.wrong {
  background: #991b1b !important;
  border-color: #ef4444 !important;
}

.feedback-box {
  padding: 14px;
  border-radius: 10px;
  font-size: 1rem;
  margin-top: 12px;
  font-weight: 500;
  line-height: 1.4;
}

#touch-controls {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  padding: 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 25;
  pointer-events: none;
  touch-action: none;
}

.d-pad, .touch-walk-group {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.touch-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: pointer;
  transition: transform 0.08s, background 0.08s, border-color 0.08s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.walk-btn {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: rgba(30, 41, 59, 0.75);
  border: 2px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(10px);
  color: #ffffff;
}

.walk-btn:active, .walk-btn.touch-active {
  background: rgba(14, 165, 233, 0.65) !important;
  border-color: #38bdf8 !important;
  transform: scale(0.92);
}

.touch-icon {
  font-size: 1.7rem;
  font-weight: 900;
  line-height: 1;
}

.touch-sub {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-top: 2px;
  opacity: 0.85;
}

.jump-group, .touch-jump-group {
  pointer-events: auto;
}

.jump-btn {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: rgba(22, 163, 74, 0.65);
  border: 2.5px solid rgba(74, 222, 128, 0.9);
  backdrop-filter: blur(10px);
  color: #86efac;
}

.jump-btn:active, .jump-btn.touch-active {
  background: rgba(34, 197, 94, 0.9) !important;
  border-color: #86efac !important;
  transform: scale(0.92);
}

#certificate-modal {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 30, 0.96);
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow-y: auto;
}

#cert-canvas-preview {
  max-width: 95%;
  max-height: 44vh;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(245, 158, 11, 0.3);
  margin-bottom: 16px;
}

.cert-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}
