@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Cinzel:wght@500;700&display=swap');

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #030308;
  color: #e0f2fe;
  font-family: 'Share Tech Mono', monospace;
}

#glCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  transition: filter 0.22s ease-out, transform 0.22s ease-out;
}

#glCanvas.glitch-pulse {
  filter: contrast(1.25) saturate(1.7) hue-rotate(35deg) drop-shadow(5px 0 0 rgba(255, 20, 147, 0.65)) drop-shadow(-5px 0 0 rgba(0, 240, 255, 0.65));
  transform: scale(1.012);
}

/* CRT Scanline & Liminal Vignette Overlay */
.scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 40%, rgba(3, 4, 10, 0.75) 100%),
              repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.12) 0px, rgba(0, 0, 0, 0.12) 1px, transparent 2px, transparent 4px);
  z-index: 10;
}

/* Center Reticle */
.reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  pointer-events: none;
  z-index: 20;
}
.reticle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 2px;
  background: #38bdf8;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

/* HUD Overlay */
#dreamHud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
  z-index: 30;
  transition: filter 0.2s ease;
}

#dreamHud.anomaly-pulse {
  filter: invert(0.2) hue-rotate(90deg) drop-shadow(0 0 16px #38bdf8);
}

.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.title-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dream-title {
  font-family: 'Cinzel', serif;
  font-size: 24px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #f8fafc;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
}

.room-badge {
  display: inline-block;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 4px 10px;
  border-radius: 4px;
  color: #38bdf8;
  font-size: 13px;
  letter-spacing: 1.5px;
}

.hud-metrics {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-size: 13px;
  color: #94a3b8;
}

.hud-metric-row {
  background: rgba(15, 23, 42, 0.6);
  padding: 4px 8px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hud-controls-top {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.hud-btn, .hud-select {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #e0f2fe;
  padding: 6px 12px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.hud-btn:hover, .hud-select:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

/* Trap caption */
#trapBanner {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Cinzel', serif;
  font-size: 22px;
  letter-spacing: 3px;
  color: #f8fafc;
  text-shadow: 0 0 14px rgba(167, 139, 250, 0.95), 0 0 30px rgba(56, 189, 248, 0.6);
  pointer-events: none;
  transition: opacity 0.8s ease;
  text-align: center;
  max-width: 80%;
}

#trapBanner.hidden {
  opacity: 0;
}

/* Entity Interaction Prompt */
#interactionPrompt {
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid #38bdf8;
  padding: 10px 24px;
  border-radius: 4px;
  color: #e0f2fe;
  font-size: 14px;
  letter-spacing: 1.5px;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.5);
  transition: opacity 0.3s ease, transform 0.2s ease;
  animation: pulsePrompt 2s infinite alternate;
}

#interactionPrompt.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -40%);
}

@keyframes pulsePrompt {
  0% { transform: translate(-50%, -50%) scale(0.98); }
  100% { transform: translate(-50%, -50%) scale(1.02); }
}

/* Mythological Communion Modal */
#communionModal {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 760px;
  background: rgba(8, 12, 24, 0.96);
  border: 1px solid rgba(56, 189, 248, 0.5);
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(56, 189, 248, 0.3);
  padding: 24px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 16px;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#communionModal.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(30px);
}

.communion-header {
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

.communion-portrait {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid #38bdf8;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.7);
  background: #030712;
}

.communion-portrait.hidden {
  display: none;
}

.communion-glyph {
  font-size: 32px;
  color: #38bdf8;
  text-shadow: 0 0 10px #38bdf8;
}

.communion-speaker-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.communion-speaker {
  font-family: 'Cinzel', serif;
  font-size: 20px;
  color: #f8fafc;
  letter-spacing: 2px;
}

.communion-culture {
  font-size: 12px;
  color: #38bdf8;
  letter-spacing: 1px;
}

.communion-text {
  font-size: 15px;
  line-height: 1.6;
  color: #e2e8f0;
  background: rgba(3, 7, 18, 0.6);
  padding: 14px 18px;
  border-radius: 4px;
  border-left: 3px solid #38bdf8;
  min-height: 70px;
}

.communion-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.communion-option-btn {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #cbd5e1;
  padding: 10px 16px;
  text-align: left;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.communion-option-btn:hover,
.communion-option-btn:focus {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #ffffff;
  padding-left: 22px;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.5), inset 0 0 10px rgba(56, 189, 248, 0.15);
}

.communion-option-btn:active {
  transform: scale(0.985);
}

.communion-footer {
  display: flex;
  justify-content: flex-end;
}

.communion-close-btn {
  background: transparent;
  border: 1px solid #64748b;
  color: #94a3b8;
  padding: 6px 14px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
}
.communion-close-btn:hover {
  border-color: #e0f2fe;
  color: #ffffff;
}

.hud-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.nav-hint {
  font-size: 12px;
  color: #64748b;
  letter-spacing: 1px;
}

/* Click to Awaken Splash Overlay */
#clickOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 4, 10, 0.88);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#clickOverlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-card {
  max-width: 600px;
  padding: 40px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(56, 189, 248, 0.25);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.overlay-title {
  font-family: 'Cinzel', serif;
  font-size: 36px;
  letter-spacing: 6px;
  color: #f8fafc;
  text-shadow: 0 0 15px rgba(56, 189, 248, 0.9);
}

.overlay-subtitle {
  color: #38bdf8;
  font-size: 14px;
  letter-spacing: 2px;
}

.overlay-desc {
  font-size: 14px;
  line-height: 1.6;
  color: #cbd5e1;
}

.overlay-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: rgba(3, 7, 18, 0.6);
  padding: 16px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
  text-align: left;
}

.overlay-controls span {
  color: #38bdf8;
}

.awaken-cta {
  font-size: 15px;
  padding: 14px 28px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  border-radius: 4px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: bold;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.5);
  animation: pulseGlow 2.5s infinite alternate;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 15px rgba(56, 189, 248, 0.3); }
  100% { box-shadow: 0 0 30px rgba(56, 189, 248, 0.8); }
}
