:root {
  --bg: #f1e6cf;
  --panel: #fdf6e3;
  --border: #8a6d3b;
  --text: #3b2f1e;
  --accent: #6b8e3c;
  --wood: #7a5230;
  --stone: #8a8a8a;
  --iron: #4a5568;
  --gems: #2a6fb0;
  --error: #b03a2a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--border);
  color: #fff;
  flex-wrap: wrap;
}

.brand { font-weight: bold; font-size: 1.2rem; }

.nav a {
  color: #fff;
  text-decoration: none;
  margin-right: 1rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
}
.nav a.active, .nav a:hover { background: rgba(255,255,255,0.2); }

.resources { display: flex; gap: 1rem; font-weight: bold; }
.resources .gems { color: #ffe08a; }

.content { max-width: 1020px; margin: 0 auto; padding: 1.5rem; }

h1 { color: var(--border); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.resource-grid { display: flex; flex-direction: column; gap: 0.75rem; }
.resource-bar { display: grid; grid-template-columns: 90px 1fr 220px; align-items: center; gap: 0.75rem; }
.resource-label { font-weight: bold; }

.bar {
  background: #e0d3b0;
  border: 1px solid var(--border);
  border-radius: 4px;
  height: 14px;
  overflow: hidden;
}
.bar-fill { height: 100%; }
.bar-fill.wood { background: var(--wood); }
.bar-fill.stone { background: var(--stone); }
.bar-fill.iron { background: var(--iron); }

.resource-value { font-size: 0.9rem; color: #555; }

.boost-hint { color: var(--gems); font-weight: bold; }

.queue { list-style: none; padding: 0; margin: 0; }
.queue li { padding: 0.4rem 0; border-bottom: 1px dashed #ccc; }
.countdown { font-weight: bold; }

table.buildings { width: 100%; border-collapse: collapse; }
table.buildings th, table.buildings td { text-align: left; padding: 0.5rem; border-bottom: 1px solid #e0d3b0; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  font-weight: bold;
}
button:disabled { background: #b7b7a4; cursor: not-allowed; }
button:hover:not(:disabled) { filter: brightness(1.1); }

.button-link {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  padding: 0.4rem 0.9rem;
  font-weight: bold;
}
.button-link:hover { filter: brightness(1.1); }

.donate-panel { margin-top: 1rem; }
.donate-button { background: #c0392b; }

.achievement-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.achievement-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}
.achievement-item.is-locked { opacity: 0.6; }
.achievement-icon { font-size: 1.6rem; }
.achievement-body { flex: 1; }
.achievement-body p { margin: 0.2rem 0; }
.achievement-reward { font-weight: bold; color: var(--gems); white-space: nowrap; }

.muted { color: #777; }

.banner { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.banner-error { background: #f8d7da; color: var(--error); border: 1px solid var(--error); }
.banner-achievement { background: #fff3cd; color: #7a5c00; border: 1px solid #e0b400; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.shop-item { background: #fff; border: 1px solid #e0d3b0; border-radius: 6px; padding: 1rem; }
.shop-item h3 { margin-top: 0; }

.garrison-grid { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.garrison-item {
  background: #fff;
  border: 1px solid #e0d3b0;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
}

input[type="number"] {
  width: 4.5rem;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
}

.recruit-form { display: flex; gap: 0.5rem; align-items: center; }

.attack-form, .scout-form, .found-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; }
.attack-form label, .scout-form label, .found-form label { display: flex; flex-direction: column; font-size: 0.8rem; gap: 0.2rem; }
.scout-form { margin-top: 0.4rem; }
.found-form input[type="number"] { width: 5rem; }

.village-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.village-list li { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.8rem; }
.village-list li.is-active { border-color: var(--accent); font-weight: bold; }

.reports { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.report { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 1rem; }
.report-sieg, .report-spionage-erfolg, .report-spionage-abgewehrt, .report-dorf-gegruendet, .report-dorf-erobert { border-left: 4px solid var(--accent); }
.report-niederlage, .report-spionage-abgefangen, .report-spionage-opfer, .report-gruendung-fehlgeschlagen, .report-dorf-verloren { border-left: 4px solid var(--error); }
.loyalty-hint { cursor: help; }
.report-head { margin-bottom: 0.4rem; }
.report-body { font-size: 0.9rem; color: #555; }

.auth-content { max-width: 380px; }
.auth-panel h1 { margin-top: 0; }
.auth-form { display: flex; flex-direction: column; gap: 0.9rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: bold; }
.auth-form input[type="text"], .auth-form input[type="password"] {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
}

.logout-form { display: inline; }
.logout-form button {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.5);
  padding: 0.25rem 0.6rem;
}
.username, .account-link { font-weight: normal; opacity: 0.85; margin-right: 0.5rem; }
.account-link { color: inherit; text-decoration: underline; }

/* Karte */
.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e0d3b0;
}

.map-pan { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.map-pan-row { display: flex; gap: 2px; }
.pan-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  text-decoration: none;
  font-weight: bold;
}
.pan-btn:hover { filter: brightness(1.1); }

.map-zoom { display: flex; gap: 2px; }
.zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  text-decoration: none;
  font-weight: bold;
}
.zoom-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.zoom-btn:hover:not(.active) { filter: brightness(0.95); }

.map-jump-form { display: flex; align-items: end; gap: 0.5rem; }
.map-jump-form label { display: flex; flex-direction: column; font-size: 0.8rem; gap: 0.2rem; }
.map-jump-form input { width: 4.5rem; padding: 0.3rem; border: 1px solid var(--border); border-radius: 4px; }

.map-legend { display: flex; gap: 1rem; font-size: 0.85rem; margin-left: auto; }
.legend-item { display: flex; align-items: center; gap: 0.35rem; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-swatch.own { background: var(--gems); }
.legend-swatch.barbarian { background: var(--accent); }
.legend-swatch.enemy { background: var(--error); }

.map-layout { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; }

.map-grid-wrapper { overflow-x: auto; }
.map-grid { display: grid; }
.map-corner { background: var(--panel); }
.map-col-label, .map-row-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: #8a7a5c;
}
.map-row-label { justify-content: flex-end; padding-right: 4px; }

.map-cell {
  position: relative;
  background: #a9c179;
  border: 1px solid #96ac6a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.map-cell.terrain-forest { background: #8fae63; }
.map-cell.terrain-forest::before { content: "🌲"; font-size: 14px; opacity: 0.7; }
.map-cell.terrain-water { background: #6fa8c4; }

.map-village {
  font-size: 16px;
  text-decoration: none;
  filter: drop-shadow(0 0 1px rgba(0,0,0,0.6));
  cursor: pointer;
}
.map-village.own { filter: drop-shadow(0 0 2px var(--gems)) drop-shadow(0 0 2px var(--gems)); }
.map-village.own-other { opacity: 0.7; }

.minimap-wrapper { flex-shrink: 0; }
.minimap {
  position: relative;
  width: 180px;
  height: 180px;
  background: #d8cfa8;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.minimap-dot {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.minimap-dot.own { background: var(--gems); width: 7px; height: 7px; box-shadow: 0 0 0 1px #fff; }
.minimap-dot.barbarian { background: var(--accent); }
.minimap-dot.enemy { background: var(--error); }
.minimap-viewport {
  position: absolute;
  border: 1.5px dashed var(--gems);
  box-sizing: border-box;
  pointer-events: none;
}
.minimap-hint { font-size: 0.75rem; max-width: 180px; margin-top: 0.5rem; }

/* Grafische Dorfansicht */
.village-scene {
  position: relative;
  width: 100%;
  height: 450px;
  border-radius: 10px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at center, rgba(255,255,255,0.15) 0%, rgba(0,0,0,0.08) 75%),
    repeating-linear-gradient(45deg, #a9c179 0 3px, #a3ba72 3px 6px);
  border: 3px solid var(--border);
}

.village-building {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  transition: transform 0.15s ease;
  z-index: 1;
}
.village-building:hover { transform: translate(-50%, -50%) scale(1.08); z-index: 2; }

.village-building img {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 3px rgba(0,0,0,0.35));
}
.village-building.is-empty img { filter: grayscale(1) opacity(0.5); }

.village-building-level {
  position: absolute;
  bottom: 22%;
  right: 6%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: bold;
  min-width: 1.3em;
  text-align: center;
  padding: 0.05em 0.3em;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.village-building.is-empty .village-building-level { background: #8a8a8a; }

.village-building-name {
  margin-top: 0.2rem;
  font-size: 0.7rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 0 3px #000, 0 1px 2px #000;
  white-space: nowrap;
}

.village-building-progress {
  position: absolute;
  top: -0.6rem;
  background: var(--gems);
  color: #fff;
  font-size: 0.65rem;
  font-weight: bold;
  padding: 0.1em 0.4em;
  border-radius: 4px;
  white-space: nowrap;
}

.village-building.is-building img { animation: village-pulse 1.4s ease-in-out infinite; }
@keyframes village-pulse {
  0%, 100% { filter: drop-shadow(0 4px 3px rgba(0,0,0,0.35)) brightness(1); }
  50% { filter: drop-shadow(0 4px 6px rgba(42,111,176,0.6)) brightness(1.15); }
}
