@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700&family=Cinzel:wght@400;500;600&family=EB+Garamond:ital,wght@0,400;0,500;1,400&display=swap');

:root {
  --gold: #c8a84b;
  --gold-bright: #f0cc66;
  --gold-dim: #7a6030;
  --blue-core: #4488ff;
  --teal: #44bbcc;
  --text: #d0c8b8;
  --text-dim: #786858;
  --panel-bg: rgba(4, 8, 18, 0.94);
  --border: rgba(180, 150, 60, 0.25);
}

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

html,
body {
  width: 100%;
  height: 100%;
  background: #000005;
  overflow: hidden;
  font-family: 'EB Garamond', serif;
  color: var(--text);
  user-select: none;
}

#canvas {
  display: block;
  position: fixed;
  inset: 0;
  cursor: crosshair;
}

/* ─── HUD Header ─────────────────────────────────────── */
#hud-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
  background: linear-gradient(to bottom, rgba(0, 0, 5, 0.9) 0%, transparent 100%);
}

#hud-top h1 {
  font-family: 'Cinzel Decorative', serif;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.35em;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(200, 168, 75, 0.6);
}

#hud-top .subtitle {
  position: absolute;
  top: 42px;
  font-family: 'Cinzel', serif;
  font-size: 9px;
  letter-spacing: 0.4em;
  color: var(--gold-dim);
  text-transform: uppercase;
}

/* ─── Legend ─────────────────────────────────────────── */
#legend {
  position: fixed;
  bottom: 28px;
  left: 32px;
  z-index: 20;
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(0, 0, 5, 0.9), 0 0 20px rgba(0, 0, 5, 0.7);
}

#legend h3 {
  font-family: 'Cinzel', serif;
  font-size: 8px;
  letter-spacing: 0.3em;
  color: var(--gold-dim);
  margin-bottom: 10px;
  text-transform: uppercase;
}

.leg {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}

.leg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.leg-label {
  font-size: 11px;
  color: #888078;
  letter-spacing: 0.1em;
}

/* ─── Footer ─────────────────────────────────────────── */
#footer {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: none;
  font-family: 'Cinzel', serif;
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: 0 1px 6px rgba(0, 0, 5, 0.9);
}

#footer a {
  pointer-events: auto;
  color: var(--gold);
  text-decoration: none;
  text-shadow: 0 0 20px rgba(200, 168, 75, 0.55);
}

#footer a:hover,
#footer a:focus-visible {
  color: var(--gold-bright);
  text-shadow: 0 0 28px rgba(240, 204, 102, 0.75);
}

/* ─── Controls hint ──────────────────────────────────── */
#controls-hint {
  position: fixed;
  bottom: 28px;
  right: 32px;
  z-index: 20;
  text-align: right;
  pointer-events: none;
}

.hint-line {
  font-size: 10px;
  color: #44403a;
  letter-spacing: 0.12em;
  margin-bottom: 4px;
}

/* ─── Info Panel ─────────────────────────────────────── */
#info-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 360px;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  z-index: 30;
  transform: translateX(100%);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(20px);
  overflow: hidden;
}

#info-panel.open {
  transform: translateX(0);
}

/* Decorative corner lines */
#info-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 40px;
  border-top: 1px solid var(--gold);
  border-left: 1px solid var(--gold);
  opacity: 0.6;
}

#info-panel::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 40px;
  height: 40px;
  border-bottom: 1px solid var(--gold);
  border-right: 1px solid var(--gold);
  opacity: 0.6;
}

#panel-header {
  padding: 40px 36px 28px;
  border-bottom: 1px solid rgba(180, 150, 60, 0.15);
  flex-shrink: 0;
}

#panel-zone-tag {
  font-family: 'Cinzel', serif;
  font-size: 8px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  margin-bottom: 10px;
  opacity: 0.7;
}

#panel-name {
  font-family: 'Cinzel Decorative', serif;
  font-size: 22px;
  font-weight: 400;
  line-height: 1.2;
  color: #fff;
  text-shadow: 0 0 30px currentColor;
  margin-bottom: 8px;
}

#panel-meta {
  font-size: 12px;
  color: var(--gold-dim);
  letter-spacing: 0.05em;
  font-style: italic;
}

#panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 36px;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}

#panel-body::-webkit-scrollbar {
  width: 3px;
}

#panel-body::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
}

.panel-section {
  margin-bottom: 28px;
}

.panel-section-title {
  font-family: 'Cinzel', serif;
  font-size: 8px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--gold-dim), transparent);
}

.panel-section p {
  font-size: 14px;
  line-height: 1.8;
  color: #b8b0a0;
  font-weight: 400;
}

.book-entry {
  margin-bottom: 18px;
  padding-left: 14px;
  border-left: 2px solid rgba(180, 150, 60, 0.3);
}

.book-entry:last-child {
  margin-bottom: 0;
}

.book-title {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--gold);
  margin-bottom: 5px;
  text-transform: uppercase;
}

.book-text {
  font-size: 13px;
  line-height: 1.75;
  color: #989082;
}

.book-text em {
  color: #b8aa90;
  font-style: italic;
}

#panel-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 28px;
  height: 28px;
  background: none;
  border: 1px solid rgba(180, 150, 60, 0.3);
  color: var(--gold-dim);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  pointer-events: all;
}

#panel-close:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(180, 150, 60, 0.1);
}

/* ─── Tooltip (hover label) ──────────────────────────── */
#tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 25;
  padding: 8px 14px;
  background: rgba(4, 8, 20, 0.9);
  border: 1px solid rgba(180, 150, 60, 0.4);
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--gold-bright);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
  backdrop-filter: blur(8px);
}

#tooltip.visible {
  opacity: 1;
}

/* Scanline overlay for realism */
#scanlines {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom,
      transparent 0px,
      transparent 3px,
      rgba(0, 0, 0, 0.03) 3px,
      rgba(0, 0, 0, 0.03) 4px);
}

/* Vignette */
#vignette {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
      transparent 40%,
      rgba(0, 0, 5, 0.7) 100%);
}

/* ─── Mobile adjustments ─────────────────────────────── */
@media (max-width: 600px) {
  #hud-top h1 {
    font-size: 15px;
    letter-spacing: 0.2em;
    padding: 0 16px;
  }

  #hud-top .subtitle {
    font-size: 7px;
    letter-spacing: 0.25em;
  }

  #legend {
    left: 16px;
    bottom: 36px;
  }

  #footer {
    font-size: 6px;
    letter-spacing: 0.1em;
    white-space: nowrap;
    bottom: 10px;
  }

  #controls-hint {
    right: 16px;
    bottom: 36px;
  }

  #info-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 50vh;
    border-left: none;
    border-top: 1px solid var(--border);
    transform: translateY(100%);
  }

  #info-panel.open {
    transform: translateY(0);
  }
}
