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

:root {
  --gold: #d4a843;
  --gold-light: #f0d078;
  --gold-dark: #a07828;
  --parchment: #f5ead0;
  --parchment-dark: #e8d8b4;
  --ink: #2c1810;
  --ink-light: #4a3228;
  --red-accent: #8b2020;
  --green-accent: #2d5a1e;
  --blue-accent: #1e3a5a;
  --bg-dark: #1a1208;
  --bg-panel: #2a1f10;
  --border-ornate: #6b5030;
}

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

body {
  font-family: 'Crimson Text', Georgia, serif;
  background: var(--bg-dark);
  color: var(--parchment);
  line-height: 1.7;
  font-size: 17px;
  position: relative;
}
body::before {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 800px;
  height: 800px;
  background: url('/images/white-rusty.png') center/contain no-repeat;
  opacity: 0.04;
  pointer-events: none;
  z-index: 0;
}

a { color: var(--gold); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--gold-light); }

/* Navigation */
.nav {
  background: var(--bg-panel);
  border-bottom: 2px solid var(--border-ornate);
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.nav .brand {
  font-family: 'Cinzel', serif;
  font-size: 1.1em;
  color: var(--gold);
  margin-right: 20px;
  letter-spacing: 2px;
}
.nav a {
  color: var(--gold);
  text-decoration: none;
  font-family: 'Cinzel', serif;
  font-size: 0.82em;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: 3px;
  transition: all 0.2s;
}
.nav a:hover, .nav a.active {
  border-color: var(--gold-dark);
  background: rgba(212,168,67,0.1);
}
.nav a.active { color: var(--gold-light); }
.nav .nav-profile {
  display: flex; align-items: center; gap: 6px; margin-left: auto;
}
.nav .nav-avatar {
  width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--gold-dark);
}
.nav .nav-login {
  margin-left: auto;
  background: rgba(88, 101, 242, 0.2);
  border: 1px solid #5865f2;
  padding: 4px 12px;
  border-radius: 4px;
  color: #7289da;
  font-size: 0.85em;
}
.nav .nav-login:hover { background: rgba(88, 101, 242, 0.35); color: #99aaf5; }
.nav .nav-logout { font-size: 0.75em; color: #8a7a60; }
.nav .nav-logout:hover { color: var(--parchment); }
.nav .status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-left: 12px;
}
.nav .status-dot.online { background: #4caf50; box-shadow: 0 0 6px #4caf50; }
.nav .status-dot.offline { background: #f44336; box-shadow: 0 0 6px #f44336; }
.nav .status-text { font-size: 0.75em; color: #8a7a60; margin-left: 6px; }

/* Hero */
.hero {
  text-align: center;
  padding: 50px 20px 40px;
  background: linear-gradient(180deg, #0d0a04 0%, #1a1208 40%, #2a1f10 100%);
  border-bottom: 3px solid var(--gold-dark);
  position: relative;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 3px;
  background: var(--gold);
  box-shadow: 0 0 20px var(--gold);
}
.hero h1 {
  font-family: 'Cinzel', serif;
  font-size: 2.8em;
  color: var(--gold);
  text-shadow: 0 2px 20px rgba(212,168,67,0.3);
  letter-spacing: 4px;
  margin-bottom: 8px;
}
.hero .subtitle {
  font-size: 1.1em;
  color: var(--parchment-dark);
  font-style: italic;
}

/* Content */
.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 30px 80px;
}

/* Section headings */
h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.8em;
  color: var(--gold);
  border-bottom: 2px solid var(--border-ornate);
  padding-bottom: 10px;
  margin-bottom: 25px;
}
h3 {
  font-family: 'Cinzel', serif;
  font-size: 1.3em;
  color: var(--gold-light);
  margin: 25px 0 15px;
}

p { margin-bottom: 15px; }

/* Stats cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin: 25px 0;
}
.stat-card {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-ornate);
  border-radius: 8px;
  padding: 25px;
  text-align: center;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--gold-dark); }
.stat-number {
  font-family: 'Cinzel', serif;
  font-size: 2.5em;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 5px;
}
.stat-label {
  font-size: 0.9em;
  color: var(--parchment-dark);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: 'Cinzel', serif;
  font-size: 0.7em;
}

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin: 20px 0;
}
.card {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-ornate);
  border-radius: 8px;
  padding: 22px;
  transition: border-color 0.2s;
  display: block;
  color: inherit;
}
.card:hover { border-color: var(--gold-dark); color: inherit; }
.card h4 {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  margin: 0 0 10px;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card p, .card .meta {
  font-size: 0.95em;
  color: var(--parchment-dark);
  margin: 4px 0;
}

/* Color swatch */
.color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.15);
  display: inline-block;
  flex-shrink: 0;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  font-size: 0.8em;
  font-weight: 600;
  font-family: 'Cinzel', serif;
}
.badge-won { background: var(--green-accent); color: #cfe8c8; }
.badge-lost { background: var(--red-accent); color: #f0c8c8; }
.badge-draw { background: #555; color: #ccc; }
.badge-active { background: #b44700; color: #ffe0c0; }
.badge-declared { background: var(--blue-accent); color: #c0d8f0; }

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
}
.data-table th {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  text-align: left;
  padding: 10px 15px;
  border-bottom: 2px solid var(--border-ornate);
  font-size: 0.85em;
  cursor: pointer;
  user-select: none;
}
.data-table th:hover { color: var(--gold-light); }
.data-table td {
  padding: 10px 15px;
  border-bottom: 1px solid rgba(107,80,48,0.2);
  vertical-align: middle;
}
.data-table tr:hover td {
  background: rgba(212,168,67,0.05);
}
.data-table .rank {
  font-family: 'Cinzel', serif;
  color: var(--gold-dark);
  font-weight: 700;
  width: 40px;
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 40px;
  margin: 20px 0;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-ornate);
}
.timeline-item {
  position: relative;
  margin-bottom: 16px;
  padding: 12px 18px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  border: 1px solid rgba(107,80,48,0.3);
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -33px;
  top: 16px;
  width: 12px;
  height: 12px;
  background: var(--gold-dark);
  border-radius: 50%;
  border: 2px solid var(--gold);
}
.timeline-item.war-declared::before { background: var(--blue-accent); border-color: #5588cc; }
.timeline-item.war-activated::before { background: #b44700; border-color: #ff8800; }
.timeline-item.war-resolved::before { background: var(--green-accent); border-color: #66bb66; }
.timeline-item.kingdom-founded::before { background: var(--gold); }
.timeline-item.kingdom-disbanded::before { background: var(--red-accent); border-color: #cc5555; }
.timeline-item strong {
  color: var(--gold-light);
  font-family: 'Cinzel', serif;
  font-size: 0.9em;
}
.timeline-item .time {
  font-size: 0.8em;
  color: #8a7a60;
  float: right;
}

/* Info boxes */
.info-box {
  background: rgba(212,168,67,0.08);
  border-left: 4px solid var(--gold-dark);
  padding: 18px 22px;
  margin: 20px 0;
  border-radius: 0 6px 6px 0;
}
.info-box.warning { background: rgba(139,32,32,0.15); border-left-color: var(--red-accent); }
.info-box.success { background: rgba(45,90,30,0.15); border-left-color: var(--green-accent); }
.info-box.blue { background: rgba(30,58,90,0.15); border-left-color: var(--blue-accent); }
.info-box strong { color: var(--gold-light); }

/* War cards */
.war-card {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-ornate);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 15px;
}
.war-card.active { border-color: #b44700; }
.war-vs {
  font-family: 'Cinzel', serif;
  font-size: 1.1em;
  color: var(--gold);
  flex: 1;
}
.war-vs span { color: var(--parchment-dark); font-size: 0.8em; }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-bar select {
  background: var(--bg-panel);
  color: var(--parchment);
  border: 1px solid var(--border-ornate);
  padding: 6px 12px;
  border-radius: 4px;
  font-family: 'Crimson Text', serif;
  font-size: 0.95em;
}
.filter-bar label {
  font-size: 0.9em;
  color: var(--parchment-dark);
}

/* Map page */
.map-page { display: flex; height: calc(100vh - 49px); overflow: hidden; }
.map-container {
  flex: 1;
  position: relative;
  background: #111;
  cursor: grab;
}
.map-container.dragging { cursor: grabbing; }
.map-container canvas {
  position: absolute;
  top: 0; left: 0;
}
.map-sidebar {
  width: 280px;
  background: var(--bg-panel);
  border-left: 2px solid var(--border-ornate);
  overflow-y: auto;
  padding: 15px;
  flex-shrink: 0;
}
.map-sidebar h3 {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 0.9em;
  margin: 15px 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border-ornate);
}
.map-sidebar h3:first-child { margin-top: 0; }

/* Map legend items */
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.85em;
}
.legend-item a { color: var(--parchment); }
.legend-item a:hover { color: var(--gold-light); }
.legend-color { width: 14px; height: 14px; border-radius: 2px; flex-shrink: 0; }
.legend-name { flex: 1; }
.legend-tiles { color: #8a7a60; font-size: 0.85em; }

/* Map war list */
.war-item {
  padding: 6px 0;
  border-bottom: 1px solid rgba(107,80,48,0.2);
  font-size: 0.85em;
}
.war-item:last-child { border-bottom: none; }
.war-item .war-vs { font-size: 0.9em; color: var(--parchment); font-family: 'Crimson Text', serif; }
.war-item .war-state { font-size: 0.8em; color: #b44700; }

/* Zoom controls */
.zoom-controls {
  position: absolute;
  top: 10px; right: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 10;
}
.zoom-btn {
  width: 36px; height: 36px;
  background: rgba(42,31,16,0.9);
  border: 1px solid var(--border-ornate);
  color: var(--gold);
  font-size: 1.2em;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cinzel', serif;
}
.zoom-btn:hover { background: rgba(212,168,67,0.2); border-color: var(--gold-dark); }

/* Tooltip */
#tooltip {
  display: none;
  position: fixed;
  background: rgba(26,18,8,0.95);
  border: 1px solid var(--border-ornate);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  z-index: 1000;
  pointer-events: none;
  max-width: 250px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.tt-title { font-family: 'Cinzel', serif; color: var(--gold); font-size: 14px; margin-bottom: 4px; }
.tt-row { color: var(--parchment-dark); margin: 2px 0; }
.tt-war { color: #ff6633; margin-top: 4px; font-weight: 600; }
.tt-immune { color: #44aaff; margin-top: 4px; }

/* Kingdom detail */
.kingdom-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 25px;
}
.kingdom-color-large {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 2px solid rgba(255,255,255,0.15);
}
.tile-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}
.tile-tag {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-ornate);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: 'Courier New', monospace;
  color: var(--parchment-dark);
}
.tile-tag.keep {
  border-color: #e0a526;
  color: #e0a526;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #8a7a60;
  font-style: italic;
}

/* Footer */
footer {
  text-align: center;
  padding: 25px;
  border-top: 2px solid var(--border-ornate);
  color: #6a5a40;
  font-size: 0.85em;
}

/* Profile */
.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
}
.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--gold-dark);
  box-shadow: 0 0 12px rgba(212, 168, 67, 0.3);
}
.profile-header h2 {
  font-family: 'Cinzel', serif;
  color: var(--gold-light);
  margin-bottom: 4px;
}
.profile-header .meta {
  color: #8a7a60;
  font-size: 0.9em;
}
.profile-header code {
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.85em;
}

/* Leaderboard tabs */
.lb-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 25px;
  border-bottom: 2px solid var(--border-ornate);
}
.lb-tab {
  background: none;
  border: none;
  font-family: 'Cinzel', serif;
  font-size: 1em;
  color: var(--parchment-dark);
  padding: 10px 24px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}
.lb-tab:hover { color: var(--gold-light); }
.lb-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* Leaderboard panels */
.lb-panel { display: none; }
.lb-panel.active { display: block; }

/* Player boards (category sub-panels) */
.player-board { display: none; }
.player-board.active { display: block; }

/* Command tables */
.cmd-table td:first-child { white-space: nowrap; }
.cmd-table code {
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.9em;
}

/* Responsive */
@media (max-width: 768px) {
  .hero h1 { font-size: 2em; }
  .content { padding: 25px 15px 60px; }
  .nav a { font-size: 0.72em; padding: 4px 8px; }
  .nav .brand { font-size: 0.9em; margin-right: 10px; }
  .card-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .map-page { flex-direction: column; }
  .map-sidebar { width: 100%; height: 200px; border-left: none; border-top: 2px solid var(--border-ornate); }
  .map-container { height: calc(100vh - 250px); }
  .nav .nav-login { font-size: 0.72em; padding: 3px 8px; }
  .nav .nav-profile { font-size: 0.72em; }
  .profile-header { flex-direction: column; text-align: center; }
}
