/* Tribal Conquest - Medieval Travian-style UI Theme */
:root {
  --bg-primary: #181410;
  --bg-secondary: #261f18;
  --bg-card: #2f261e;
  --bg-card-hover: #3d3228;
  --parchment: #e8d8b8;
  --parchment-dark: #d4be94;
  --border-gold: #c29d53;
  --border-dark: #4a3b2c;
  --text-main: #f5eedb;
  --text-muted: #b8a68e;
  --text-dark: #3a2b1a;
  
  --res-wood: #2e7d32;
  --res-clay: #d84315;
  --res-iron: #455a64;
  --res-crop: #f9a825;
  
  --accent-red: #c62828;
  --accent-green: #2e7d32;
  --accent-blue: #1565c0;
  --accent-gold: #f59e0b;
  
  --tribe-romans: #b91c1c;
  --tribe-teutons: #1e3a8a;
  --tribe-gauls: #15803d;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  user-select: none;
}

body {
  background-color: var(--bg-primary);
  background-image: radial-gradient(#2d2319 1px, transparent 1px);
  background-size: 20px 20px;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-gold);
  border-radius: 4px;
}

/* Authentication Screen - Standardized in theme.css */

.auth-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border-dark);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  cursor: pointer;
  font-weight: bold;
  color: var(--text-muted);
  transition: all 0.2s;
}

.auth-tab.active {
  color: var(--border-gold);
  border-bottom: 3px solid var(--border-gold);
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: bold;
  margin-bottom: 6px;
  color: var(--parchment-dark);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-dark);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--border-gold);
}

.tribe-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 6px;
}

.tribe-card {
  padding: 12px 8px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-dark);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.tribe-card:hover {
  border-color: var(--border-gold);
}

.tribe-card.active {
  border-color: var(--border-gold);
  background: #3f3224;
  box-shadow: 0 0 10px rgba(194, 157, 83, 0.4);
}

.tribe-icon {
  font-size: 1.8rem;
  margin-bottom: 4px;
}

.tribe-name {
  font-weight: bold;
  font-size: 0.9rem;
}

.tribe-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.2;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: linear-gradient(180deg, #d4a753, #9e7529);
  color: #1a1205;
  border: 1px solid #ffe29a;
  border-radius: 6px;
  font-size: 1.05rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  transition: filter 0.2s;
}

.btn-primary:hover {
  filter: brightness(1.15);
}

/* Header & Top Navigation */
.main-header {
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-gold);
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 24px;
  background: #1e1812;
  border-bottom: 1px solid var(--border-dark);
}

.village-selector {
  display: flex;
  align-items: center;
  gap: 12px;
}

.village-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  padding: 4px 12px;
  border-radius: 6px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
}

.village-coords {
  color: var(--accent-gold);
  font-size: 0.85rem;
}

.user-status {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.9rem;
}

.tribe-pill {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: bold;
  text-transform: uppercase;
}

.tribe-pill.romans { background: var(--tribe-romans); color: white; }
.tribe-pill.teutons { background: var(--tribe-teutons); color: white; }
.tribe-pill.gauls { background: var(--tribe-gauls); color: white; }

/* Resource Bar */
.resource-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: #251d16;
  flex-wrap: wrap;
}

.resource-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-dark);
  padding: 6px 14px;
  border-radius: 6px;
  min-width: 140px;
}

.res-icon {
  font-size: 1.3rem;
}

.res-info {
  display: flex;
  flex-direction: column;
}

.res-amount {
  font-weight: bold;
  font-size: 0.95rem;
}

.res-rate {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.res-cap {
  color: var(--text-muted);
  font-weight: normal;
  font-size: 0.8rem;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-secondary);
}

.nav-btn {
  padding: 8px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-dark);
  color: var(--text-main);
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  position: relative;
}

.nav-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-gold);
}

.nav-btn.active {
  background: linear-gradient(180deg, #c29d53, #7a5e26);
  color: #1a1205;
  border-color: #ffe49e;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.badge-counter {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--accent-red);
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: bold;
  border: 1px solid white;
}

/* Incoming Attack Siren Alert Banner */
.attack-alert-banner {
  background: linear-gradient(90deg, #b91c1c, #7f1d1d, #b91c1c);
  background-size: 200% 200%;
  animation: alertPulse 2s ease infinite;
  color: white;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  border-bottom: 2px solid #ef4444;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.5);
}

@keyframes alertPulse {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* LAN Link Sharing Header Banner */
.lan-share-banner {
  background: #1e293b;
  border-bottom: 1px solid #3b82f6;
  color: #93c5fd;
  padding: 6px 20px;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lan-url-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f172a;
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid #1e3a8a;
}

.lan-url-text {
  color: #60a5fa;
  font-family: monospace;
  font-weight: bold;
}

.copy-btn {
  background: #2563eb;
  color: white;
  border: none;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.75rem;
  cursor: pointer;
}

/* Main Content Container */
.game-container {
  flex: 1;
  max-width: 1320px;
  width: 100%;
  margin: 16px auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

.guide-scroll-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.guide-step-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-dark);
  border-left: 3px solid var(--border-gold);
  border-radius: 6px;
  padding: 8px 10px;
}

.guide-step-title {
  font-size: 0.82rem;
  font-weight: bold;
  color: var(--border-gold);
  margin-bottom: 3px;
}

.guide-step-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.guide-step-desc b {
  color: var(--parchment);
}

.main-view-panel {
  background: var(--bg-card);
  border: 2px solid var(--border-gold);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-height: 580px;
  position: relative;
}

.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.side-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.side-card-title {
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--border-gold);
  border-bottom: 1px solid var(--border-dark);
  padding-bottom: 8px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Circular / Hexagonal Resource Field View */
.fields-view-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.fields-map {
  width: 480px;
  height: 480px;
  position: relative;
  background: radial-gradient(circle, #5b4629 0%, #352614 60%, #1f160c 100%);
  border: 3px solid var(--border-gold);
  border-radius: 50%;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.8), 0 10px 25px rgba(0,0,0,0.7);
  margin: 10px auto;
}

.center-village-portal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 110px;
  height: 110px;
  background: radial-gradient(circle, #85612f, #3b2811);
  border: 3px solid var(--border-gold);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(194, 157, 83, 0.6);
  transition: transform 0.2s;
  z-index: 10;
}

.center-village-portal:hover {
  transform: translate(-50%, -50%) scale(1.06);
}

.field-slot {
  position: absolute;
  width: 58px;
  height: 58px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.6);
  border: 2px solid rgba(255,255,255,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}

.field-slot:hover {
  transform: translate(-50%, -50%) scale(1.15);
  box-shadow: 0 0 15px var(--border-gold);
  z-index: 20;
}

.field-slot.wood { background: radial-gradient(circle, #43a047, #1b5e20); }
.field-slot.clay { background: radial-gradient(circle, #f4511e, #bf360c); }
.field-slot.iron { background: radial-gradient(circle, #78909c, #263238); }
.field-slot.crop { background: radial-gradient(circle, #fbc02d, #f57f17); color: #2e1d00; }

.field-level-badge {
  font-size: 0.8rem;
  font-weight: 900;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 1px 6px;
  border-radius: 8px;
  margin-top: 2px;
}

.field-slot.crop .field-level-badge {
  color: #ffeb3b;
}

/* Village Center Building Plots View */
.village-center-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.building-plot {
  background: var(--bg-secondary);
  border: 2px solid var(--border-dark);
  border-radius: 8px;
  padding: 12px 8px;
  min-height: 95px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.building-plot:hover {
  border-color: var(--border-gold);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.building-plot.empty {
  border-style: dashed;
  opacity: 0.6;
}

.building-plot.empty:hover {
  opacity: 1;
}

.plot-icon {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.plot-name {
  font-size: 0.82rem;
  font-weight: bold;
}

.plot-level {
  font-size: 0.75rem;
  color: var(--accent-gold);
  font-weight: bold;
}

/* Construction Queue Widget */
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.queue-item {
  background: var(--bg-primary);
  border-left: 4px solid var(--border-gold);
  padding: 8px 12px;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.queue-info-title {
  font-size: 0.85rem;
  font-weight: bold;
}

.queue-timer {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--accent-gold);
}

/* Modal Dialogs - Overridden and standardized in theme.css */

.upgrade-cost-row {
  display: flex;
  gap: 16px;
  background: var(--bg-primary);
  padding: 10px 14px;
  border-radius: 6px;
  margin: 14px 0;
  justify-content: space-around;
}

.cost-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: bold;
}

.cost-item.insufficient {
  color: var(--accent-red);
}

/* Action Buttons */
.btn-secondary {
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-dark);
  color: var(--text-main);
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
}

.btn-secondary:hover {
  border-color: var(--border-gold);
}

.btn-danger {
  padding: 6px 12px;
  background: #7f1d1d;
  color: white;
  border: 1px solid #dc2626;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

/* Chat Drawer on Bottom Right */
.chat-drawer {
  position: fixed;
  bottom: 0;
  right: 24px;
  width: 320px;
  background: var(--bg-card);
  border: 2px solid var(--border-gold);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  box-shadow: 0 -5px 25px rgba(0,0,0,0.6);
  z-index: 90;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.chat-drawer.collapsed {
  transform: translateY(calc(100% - 40px));
}

.chat-header {
  padding: 10px 14px;
  background: #231b14;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-dark);
  border-radius: 8px 8px 0 0;
}

.chat-messages-container {
  height: 250px;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #1c150e;
}

.chat-msg {
  font-size: 0.82rem;
  line-height: 1.3;
}

.chat-sender {
  font-weight: bold;
  color: var(--border-gold);
}

.chat-input-row {
  display: flex;
  padding: 8px;
  background: var(--bg-card);
  gap: 6px;
}

.chat-input {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-dark);
  color: white;
  border-radius: 4px;
  font-size: 0.85rem;
  outline: none;
}

.chat-send-btn {
  padding: 6px 12px;
  background: var(--border-gold);
  color: #1a1205;
  border: none;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
}

/* Battle Reports */
.report-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-dark);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.report-card:hover {
  border-color: var(--border-gold);
  background: var(--bg-secondary);
}

.report-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
}

.report-badge.attack_won, .report-badge.defense_won { background: #166534; color: #86efac; }
.report-badge.attack_lost, .report-badge.defense_lost { background: #991b1b; color: #fca5a5; }
.report-badge.reinforce, .report-badge.trade, .report-badge.settle { background: #1e40af; color: #93c5fd; }

/* Responsive adjustments */
@media (max-width: 1100px) {
  .game-container {
    grid-template-columns: 1fr 290px;
  }
  .left-guide-panel {
    grid-column: 1 / -1;
    order: 3;
  }
}

@media (max-width: 768px) {
  .game-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .nav-tabs {
    overflow-x: auto;
    justify-content: flex-start;
    padding: 6px 10px;
    -webkit-overflow-scrolling: touch;
  }
  .nav-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
  }
  .resource-bar {
    gap: 8px;
    padding: 6px 10px;
  }
  .resource-item {
    min-width: 45%;
    padding: 4px 8px;
  }
  .fields-map {
    width: 310px;
    height: 310px;
  }
  .center-village-portal {
    width: 75px;
    height: 75px;
  }
  .field-slot {
    width: 40px;
    height: 40px;
  }
  .village-center-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .chat-drawer {
    width: 100%;
    right: 0;
    left: 0;
    border-radius: 12px 12px 0 0;
  }
}
