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

:root {
  --parch: #f4ecd8;
  --parch-deep: #e8dcb6;
  --ink: #3a2c1a;
  --gold: #b08d3a;
  --shadow: rgba(58, 44, 26, 0.25);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --mono: 'IBM Plex Mono', 'Courier New', monospace;
  --client-c: #5d7a3a;
  --internal-c: #6b4f8a;
  --startup-c: #3a6a8a;
  --personal-c: #a8843a;
}

html, body { width: 100%; height: 100%; }
body {
  font-family: var(--mono);
  font-weight: 400;
  background: var(--parch);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(176, 141, 58, 0.10), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(176, 141, 58, 0.08), transparent 50%);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Header */
#hdr {
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px;
  display: flex; align-items: center;
  padding: 0 1.5rem;
  background: rgba(244, 236, 216, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--gold);
  z-index: 10;
  gap: 1.5rem;
}
.back {
  font-family: var(--mono); font-size: 0.85rem;
  color: var(--gold); text-decoration: none;
  padding: 0.4rem 0.8rem; border: 1px solid var(--gold); border-radius: 4px;
  transition: all 200ms;
}
.back:hover { background: var(--gold); color: var(--parch); }
#hdr h1 {
  font-family: var(--serif); font-size: 1.6rem; font-style: italic; font-weight: 400;
  color: var(--ink);
}
#hud {
  margin-left: auto;
  font-size: 0.75rem; color: var(--gold);
  letter-spacing: 0.08em; text-transform: uppercase;
}

/* Layout */
main {
  position: fixed; top: 56px; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: 1fr 320px;
  gap: 0;
}
#map-wrap {
  position: relative;
  background: var(--parch);
  overflow: hidden;
}
#world {
  width: 100%; height: 100%;
  display: block;
}

/* HUD overlays */
#controls-help {
  position: absolute; bottom: 1rem; left: 1rem;
  font-size: 0.7rem; color: var(--gold);
  background: rgba(244, 236, 216, 0.85);
  padding: 0.7rem 1rem;
  border-radius: 4px;
  border: 1px solid rgba(176, 141, 58, 0.3);
  letter-spacing: 0.05em;
  pointer-events: none;
  user-select: none;
  line-height: 1.6;
}
#status {
  position: absolute; top: 1rem; left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem; color: var(--gold);
  background: rgba(244, 236, 216, 0.85);
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
  pointer-events: none;
}
#hint {
  position: absolute; top: 4rem; left: 50%;
  transform: translateX(-50%);
  background: var(--gold); color: var(--parch);
  padding: 0.55rem 1.3rem; border-radius: 4px;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  display: none;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 4px 12px var(--shadow);
}
#hint.visible { display: block; }

/* Party sidebar */
#party {
  background: var(--parch-deep);
  border-left: 1px solid var(--gold);
  padding: 1rem;
  overflow-y: auto;
}
.party-title {
  font-family: var(--serif); font-size: 1.2rem; font-style: italic;
  color: var(--ink); margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--gold); padding-bottom: 0.4rem;
}
.party-totals { font-size: 0.7rem; color: var(--gold); letter-spacing: 0.05em; margin-bottom: 0.8rem; }
.character {
  display: grid; grid-template-columns: 36px 1fr; gap: 0.6rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px dashed rgba(176, 141, 58, 0.3);
}
.character:last-child { border-bottom: none; }
.character.you {
  background: rgba(176, 141, 58, 0.10);
  border-radius: 4px;
  margin: 0 -0.4rem; padding-left: 0.4rem; padding-right: 0.4rem;
}
.character-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--parch); border: 1px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
}
.character-icon svg { width: 20px; height: 20px; stroke: var(--ink); fill: none; }
.character-name {
  font-family: var(--serif); font-size: 0.95rem; font-style: italic;
  color: var(--ink);
  display: flex; justify-content: space-between; align-items: baseline;
}
.you-tag { font-size: 0.6rem; color: var(--gold); letter-spacing: 0.1em; text-transform: uppercase; font-style: normal; margin-left: 0.3rem; }
.character-class { font-size: 0.65rem; color: var(--gold); letter-spacing: 0.1em; text-transform: uppercase; }
.character-level { font-size: 0.75rem; color: var(--gold); }
.xp-bar { height: 4px; background: rgba(176, 141, 58, 0.25); border-radius: 2px; margin-top: 0.3rem; overflow: hidden; }
.xp-bar-fill { height: 100%; background: var(--gold); }
.xp-bar-text { font-size: 0.62rem; color: rgba(58, 44, 26, 0.6); margin-top: 0.15rem; }

/* SVG map content */
.biome-bg { opacity: 0.14; }
.biome-divider { stroke: rgba(176, 141, 58, 0.25); stroke-width: 1; stroke-dasharray: 6 6; fill: none; }
.biome-label {
  font-family: var(--serif); font-size: 26px; font-style: italic;
  fill: var(--ink); text-anchor: middle;
  opacity: 0.45;
  letter-spacing: 0.02em;
}

/* Region "buildings" */
.region {
  cursor: pointer;
  transition: filter 200ms;
}
.region:hover { filter: brightness(1.18) drop-shadow(0 0 10px var(--gold)); }
.region-bg { fill: var(--parch-deep); stroke: var(--gold); stroke-width: 2; }
.region-name {
  font-family: var(--serif); font-size: 14px; font-style: italic;
  fill: var(--ink); text-anchor: middle;
}
.region-stats {
  font-family: var(--mono); font-size: 10px;
  fill: var(--gold); text-anchor: middle;
  letter-spacing: 0.05em;
}
.region-level-badge {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  fill: var(--parch); text-anchor: middle;
}

/* Items (collectibles) */
.item { cursor: pointer; }
.item-aura { fill: rgba(176, 141, 58, 0.18); }
.item.priority-now .item-aura { fill: rgba(192, 57, 43, 0.22); }

/* Player */
#player { pointer-events: none; }
.player-aura { fill: rgba(176, 141, 58, 0.30); }
.player-circle { fill: var(--gold); stroke: var(--ink); stroke-width: 2.5; }
.player-icon { stroke: var(--ink); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Modal (pickup) */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn 200ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--parch);
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 2rem 2.5rem;
  max-width: 460px;
  text-align: center;
  box-shadow: 0 12px 48px var(--shadow);
  animation: pop 320ms cubic-bezier(0.2, 1.2, 0.4, 1);
}
@keyframes pop { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }
.modal-card.priority-now { border-color: #c0392b; }
.modal-card.priority-next { border-color: #3a6a8a; }
.modal-glyph { margin-bottom: 1rem; display: flex; justify-content: center; }
.modal-title {
  font-family: var(--serif); font-size: 1.5rem; font-style: italic;
  color: var(--ink); margin-bottom: 0.6rem; line-height: 1.3;
}
.modal-meta {
  display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap;
  margin-bottom: 1.4rem;
  font-size: 0.7rem; color: var(--gold); letter-spacing: 0.05em;
}
.tag { padding: 0.15rem 0.5rem; border: 1px solid rgba(176, 141, 58, 0.4); border-radius: 3px; }
.tag.priority-now { color: #c0392b; border-color: #c0392b; }
.modal-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.btn-primary, .btn-secondary {
  font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 0.6rem 1.1rem;
  border-radius: 4px; cursor: pointer; transition: all 150ms;
}
.btn-primary { background: var(--gold); color: var(--parch); border: none; }
.btn-primary:hover { opacity: 0.85; transform: translateY(-1px); }
.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--gold); }
.btn-secondary:hover { background: rgba(176, 141, 58, 0.12); }

/* Region detail panel */
.region-panel {
  position: fixed; top: 4.5rem; right: 1rem; bottom: 1rem;
  width: 420px;
  background: var(--parch);
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 1.5rem;
  overflow-y: auto;
  box-shadow: -4px 0 16px var(--shadow);
  z-index: 50;
  animation: slideIn 280ms ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.region-panel-close {
  position: absolute; top: 0.5rem; right: 0.5rem;
  background: transparent; border: none;
  font-size: 1.4rem; color: var(--gold); cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.region-panel-close:hover { background: rgba(176, 141, 58, 0.15); }
.region-panel-title {
  font-family: var(--serif); font-size: 1.6rem; font-style: italic;
  color: var(--ink); margin-bottom: 0.3rem;
}
.region-panel-meta { font-size: 0.75rem; color: var(--gold); margin-bottom: 1rem; letter-spacing: 0.05em; }
.quest-list { display: flex; flex-direction: column; gap: 0.6rem; }
.quest-row {
  background: var(--parch-deep);
  border-left: 3px solid var(--gold);
  padding: 0.7rem 0.9rem;
  border-radius: 0 4px 4px 0;
}
.quest-row.done { opacity: 0.55; }
.quest-row.done .quest-row-title { text-decoration: line-through; }
.quest-row.blocked { border-left-color: #c0392b; }
.quest-row.in_progress { border-left-color: #2980b9; }
.quest-row-title { font-family: var(--serif); font-size: 1rem; color: var(--ink); margin-bottom: 0.3rem; }
.quest-row-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; font-size: 0.7rem; color: var(--gold); letter-spacing: 0.05em; }
.quest-complete-btn {
  margin-top: 0.5rem;
  background: var(--gold); color: var(--parch); border: none;
  font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 0.4rem 0.8rem;
  border-radius: 3px; cursor: pointer;
}
.quest-complete-btn:hover { opacity: 0.85; }

/* +XP floater */
.xp-float {
  position: fixed;
  font-family: var(--mono); font-size: 1.1rem; font-weight: 500;
  color: var(--gold);
  pointer-events: none;
  z-index: 200;
  animation: xpFloat 1200ms cubic-bezier(0.2, 0.8, 0.4, 1) forwards;
  text-shadow: 0 1px 3px var(--shadow);
}
@keyframes xpFloat {
  0% { opacity: 0; transform: translateY(0) scale(0.8); }
  20% { opacity: 1; transform: translateY(-12px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-80px) scale(1); }
}

/* Empty / error */
.empty, .error {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  font-family: var(--serif); font-size: 1.2rem; font-style: italic;
  color: var(--ink);
  text-align: center;
  padding: 2rem;
  gap: 1rem;
}
.error { color: #c0392b; }
.error button {
  background: var(--gold); color: var(--parch); border: none;
  padding: 0.5rem 1rem; border-radius: 4px;
  font-family: var(--mono); cursor: pointer;
}
