* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --ink-primary: #24140a;
  --ink-secondary: #523118;
  --ink-muted: #7a5433;
  --ink-red: #8f1a1a;
  --wax-red: #a81c1c;
  --wax-dark: #660e0e;
  --brass-gold: #b38234;
  --parchment-bg: #ebdcc4;
  --font-title: 'MedievalSharp', 'Vazirmatn', serif;
  --font-body: 'Vazirmatn', serif;
}

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: #120904;
  font-family: var(--font-body);
  color: var(--ink-primary);
  direction: rtl;
  text-align: right;
}

/* Full Screen Canvas Viewport */
#gameCanvasContainer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: default;
  z-index: 1;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ==========================================================================
   TOP RTS HUD BAR (Parchment Header)
   ========================================================================== */
.top-hud-bar {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  z-index: 100;
  background-color: #f7ede0;
  background-image: url('../assets/parchment_card.jpg');
  background-size: cover;
  border: 2.5px solid #6b3e18;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.75), inset 0 0 30px rgba(90, 50, 20, 0.2);
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

/* Realm Identity */
.realm-crest-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.realm-seal-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid #6b3e18;
  background: radial-gradient(circle at 35% 35%, #d13232, var(--wax-red) 60%, var(--wax-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  overflow: hidden;
  flex-shrink: 0;
}
.realm-seal-icon img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 50%;
}

.realm-titles h2 {
  font-family: var(--font-title);
  font-size: 14px;
  font-weight: 900;
  color: var(--ink-primary);
  line-height: 1.2;
}
.realm-titles span {
  font-size: 10px;
  color: var(--ink-muted);
  font-weight: 700;
}

/* Resource Counters */
.resources-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(90, 50, 20, 0.08);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(100, 55, 20, 0.25);
}

.res-pill {
  display: flex;
  align-items: center;
  gap: 6px;
}

.res-pill img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid #784c28;
  background: #fdfaf4;
  object-fit: cover;
}

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

.res-meta .name {
  font-size: 9px;
  color: var(--ink-muted);
  font-weight: 800;
}

.res-meta .val {
  font-size: 12px;
  font-weight: 900;
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
}

/* Status & Action Buttons */
.top-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-btn {
  background: linear-gradient(180deg, #ffffff 0%, #ebd7be 100%);
  border: 1.5px solid #6b3e18;
  color: var(--ink-primary);
  box-shadow: 0 3px 8px rgba(50, 25, 10, 0.2), inset 0 1px 0 rgba(255,255,255,0.9);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  transition: all 0.15s ease;
}

.hud-btn:hover {
  background: #ffffff;
  border-color: var(--ink-red);
  color: var(--ink-red);
  transform: translateY(-1px);
}

.hud-btn.siege {
  background: linear-gradient(180deg, #b91c1c 0%, #7f1d1d 100%);
  color: #ffffff;
  border-color: #5c0f0f;
  box-shadow: 0 4px 12px rgba(185, 28, 28, 0.4);
}
.hud-btn.siege:hover {
  filter: brightness(1.15);
}

.status-indicator-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #15803d;
  background: #166534;
  color: #ffffff;
  letter-spacing: 0.3px;
}

/* ==========================================================================
   BOTTOM COMMAND DECK & DOCK (RTS Control Console)
   ========================================================================== */
.bottom-console-dock {
  position: absolute;
  bottom: 10px;
  left: 12px;
  right: 12px;
  z-index: 100;
  display: grid;
  grid-template-columns: 200px 1fr 280px;
  gap: 12px;
  pointer-events: none;
}

@media (max-width: 950px) {
  .bottom-console-dock {
    grid-template-columns: 1fr;
  }
}

.console-panel {
  pointer-events: auto;
  background-color: #f7ede0;
  background-image: url('../assets/parchment_card.jpg');
  background-size: cover;
  border: 2px solid #6b3e18;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.75), inset 0 0 25px rgba(90, 50, 20, 0.15);
  padding: 10px;
  position: relative;
}

/* Panel 1: Minimap Radar */
.minimap-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#minimapCanvas {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  border: 2px solid #784c28;
  background: #2b587d;
  cursor: crosshair;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.6), 0 4px 10px rgba(0,0,0,0.3);
}

.minimap-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--ink-secondary);
  margin-top: 4px;
}

/* Panel 2: Center Command Card (Selected Unit / Building) */
.command-card-panel {
  display: flex;
  gap: 14px;
  align-items: stretch;
}

.selection-identity-box {
  width: 180px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 1px dashed rgba(100, 55, 20, 0.35);
  padding-left: 10px;
}

.unit-avatar-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.unit-portrait-img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  border: 1.5px solid #6b3e18;
  object-fit: cover;
  background: #ffffff;
}

.unit-hp-bar {
  width: 100%;
  height: 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #6b3e18;
  margin-top: 2px;
}

.unit-hp-fill {
  height: 100%;
  background: #16a34a;
  width: 100%;
  transition: width 0.2s ease;
}

.troop-heads-display {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}

.troop-head-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #784c28;
  border: 1px solid #24140a;
}
.troop-head-dot.dead {
  background: #d4c5b0;
  opacity: 0.3;
}

/* Action Buttons Grid (Training, Move, Attack, Build) */
.command-actions-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.cmd-action-btn {
  background: linear-gradient(180deg, #fdfaf4 0%, #ebd7be 100%);
  border: 1.5px solid #784c28;
  border-radius: 6px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.15s ease;
  box-shadow: 0 2px 5px rgba(50, 25, 10, 0.15);
}

.cmd-action-btn:hover {
  background: #ffffff;
  border-color: var(--ink-red);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(143, 26, 26, 0.3);
}

.cmd-action-btn:active {
  transform: translateY(1px);
}

.cmd-action-btn img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.cmd-action-btn span {
  font-size: 10px;
  font-weight: 800;
  color: var(--ink-primary);
  white-space: nowrap;
}

.cmd-action-btn .cost-tag {
  font-size: 8px;
  color: var(--ink-muted);
  font-weight: 700;
}

/* Panel 3: Spells Deck & Hero Actions */
.hero-spells-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-mini-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.hero-mini-header img {
  width: 32px;
  height: 36px;
  border-radius: 4px;
  border: 1px solid #784c28;
  object-fit: cover;
}

.hero-mini-name {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-primary);
}

.spells-deck-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.spell-card-btn {
  background: #fdfaf4;
  border: 1.5px solid #784c28;
  border-radius: 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.spell-card-btn:hover {
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.4);
}

.spell-hotkey-badge {
  position: absolute;
  top: 2px;
  left: 2px;
  font-size: 8px;
  font-weight: 900;
  background: #24140a;
  color: #fff;
  padding: 1px 4px;
  border-radius: 2px;
}

.spell-card-btn img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.spell-card-btn .name {
  font-size: 9px;
  font-weight: 800;
  color: var(--ink-primary);
}

.spell-card-btn .mana-cost {
  font-size: 8px;
  color: #1e4d7a;
  font-weight: 700;
}

/* ==========================================================================
   DIPLOMACY & CHAT MODALS
   ========================================================================== */
.modal-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active {
  display: flex;
}

.parchment-modal-box {
  width: 100%;
  max-width: 680px;
  background-color: #ebdcc4;
  background-image: url('../assets/parchment_master.jpg');
  background-size: cover;
  border: 3px double #633e1d;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.9), inset 0 0 40px rgba(90, 50, 20, 0.3);
  padding: 24px;
  position: relative;
}

.modal-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid rgba(100, 55, 20, 0.4);
}
.modal-header-row h3 {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 800;
}

.close-modal-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  font-weight: 900;
  color: var(--ink-red);
  cursor: pointer;
}

/* Notification Banner */
.in-game-event-banner {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  background: rgba(168, 28, 28, 0.95);
  border: 2px solid #ffd700;
  color: #ffffff;
  padding: 8px 24px;
  border-radius: 6px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8);
  font-family: var(--font-title);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1px;
  display: none;
}
.in-game-event-banner.active {
  display: block;
  animation: pulseAlert 2s infinite;
}

@keyframes pulseAlert {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.03); }
}
