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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  color: #e8dcc0;
  user-select: none;
}

#world { position: absolute; inset: 0; display: block; cursor: default; }

.hidden { display: none !important; }

/* ---------- оверлеи (меню, конец игры) ---------- */

.overlay {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at center, rgba(60,40,15,0.5), rgba(0,0,0,0.92)),
    repeating-linear-gradient(45deg, #1a120a 0 24px, #15100a 24px 48px);
}

.menu-box {
  background: linear-gradient(#3a2c18, #241a0e);
  border: 3px solid #7a5c34;
  outline: 2px solid #15100a;
  box-shadow: 0 0 60px rgba(0,0,0,0.9), inset 0 0 30px rgba(0,0,0,0.5);
  padding: 28px 36px;
  min-width: 480px;
  max-width: 620px;
  text-align: center;
}

.menu-box h1 {
  font-size: 34px;
  color: #e2c044;
  text-shadow: 2px 2px 0 #000;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.subtitle { color: #b09a70; font-size: 13px; margin-bottom: 18px; }

#playerTable { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
#playerTable th { color: #b09a70; font-size: 12px; padding: 3px; }
#playerTable td { padding: 3px 5px; }
#playerTable input[type=text], #playerTable select {
  background: #15100a; color: #e8dcc0;
  border: 1px solid #7a5c34; padding: 4px 6px; font-size: 13px;
  width: 100%;
}
.color-swatch { display: inline-block; width: 22px; height: 22px; border: 2px solid #000; cursor: pointer; }

.menu-row {
  display: flex; gap: 14px; justify-content: center; align-items: center;
  margin: 12px 0; font-size: 14px;
}
.menu-row select {
  background: #15100a; color: #e8dcc0;
  border: 1px solid #7a5c34; padding: 4px 8px; margin-left: 6px;
}

.btn {
  background: linear-gradient(#8a6b42, #5d4426);
  border: 2px solid #2c1f10;
  box-shadow: inset 0 1px 0 #c8a868, 0 2px 4px rgba(0,0,0,0.6);
  color: #f4e8c8; text-shadow: 1px 1px 0 #000;
  cursor: pointer; font-family: inherit;
}
.btn:hover { background: linear-gradient(#a0804f, #6e522f); }
.btn:active { box-shadow: inset 0 2px 6px rgba(0,0,0,0.6); }
.btn.big { font-size: 20px; padding: 10px 40px; margin-top: 8px; }
.btn.small { font-size: 13px; padding: 4px 12px; }
.btn.tiny { font-size: 14px; padding: 2px 8px; }
.btn.off { filter: grayscale(1) brightness(0.7); }

.help {
  margin-top: 18px; font-size: 12px; color: #b09a70;
  border-top: 1px solid #5d4426; padding-top: 10px; text-align: left;
}

/* ---------- верхняя панель ---------- */

#gameUI { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
#gameUI > * { pointer-events: auto; }

#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  height: 36px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 14px;
  background: linear-gradient(#3a2c18, #241a0e);
  border-bottom: 2px solid #7a5c34;
  font-size: 15px;
}
#topbar .res b { color: #f4e8c8; min-width: 44px; display: inline-block; }
#ageLabel { color: #e2c044; font-weight: bold; }
#gameTime { color: #b09a70; }
.spacer { flex: 1; }

/* ---------- уведомления ---------- */

#notifications {
  position: absolute; top: 44px; left: 12px;
  display: flex; flex-direction: column; gap: 4px;
  pointer-events: none !important;
}
.notice {
  background: rgba(20,14,6,0.85);
  border-left: 3px solid #e2c044;
  padding: 4px 10px; font-size: 13px;
  animation: fadeout 6s forwards;
}
@keyframes fadeout { 0%,70% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- нижняя панель (графика interfac.drs, экран 1280×1024) ---------- */

#bottombar {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 218px;
  display: flex;
}

/* зона команд: тёмная текстура с колонной слева (316×218) */
#cmdZone {
  position: relative;
  width: 316px; flex: 0 0 316px;
  background: url('web-assets/images/hud-cmd.png');
}

/* зона информации: пергамент, тянется на свободную ширину */
#infoZone {
  position: relative;
  flex: 1 1 auto; min-width: 0;
  background: url('web-assets/images/hud-info.png');
  background-size: 100% 100%;
}

/* зона миникарты: рама с чёрным ромбом (427×218, ромб x15..408 y17..202) */
#mapZone {
  position: relative;
  width: 427px; flex: 0 0 427px;
  background: url('web-assets/images/hud-map.png');
}

#minimap {
  position: absolute; left: 15px; top: 17px;
  width: 394px; height: 186px;
  cursor: pointer;
}

#infoPanel {
  position: absolute; inset: 14px 20px 14px 18px;
  display: flex; gap: 10px;
  font-size: 13px;
  color: #2c1d0c;
  overflow: hidden;
}
#infoPortrait { flex: 0 0 auto; }
#infoPortrait:empty { display: none; }
#infoBody { flex: 1; min-width: 0; overflow-y: auto; scrollbar-width: thin; }
#infoTitle { font-size: 15px; font-weight: bold; color: #3a2408; margin-bottom: 4px; text-shadow: 0 1px 0 rgba(255,240,200,0.5); }
#infoStats div { margin: 1px 0; }
#infoStats .grow { color: #1e6e1e; }
.qitem { display: inline-block; vertical-align: middle; border: 1px solid #6a5638; background: #181410; margin: 2px; cursor: pointer; line-height: 0; padding: 1px; }
.qitem:hover { border-color: #e2c044; }

/* портрет выбранного объекта — иконка в фаске */
.portrait-frame {
  display: inline-block; line-height: 0;
  padding: 3px;
  background: #181410;
  border: 1px solid #000;
  box-shadow: inset 1px 1px 0 #b89868, inset -1px -1px 0 #2c1f10;
}
.hpbar { width: 58px; height: 7px; background: #401808; border: 1px solid #2c1d0c; margin-top: 3px; }
.hpbar i { display: block; height: 100%; background: linear-gradient(#58c858, #2e8a2e); }
.hpnum { font-size: 11px; text-align: center; margin-top: 1px; }

/* сетка команд 5×3 поверх текстуры (отступ под колонну и бордюры) */
#commandPanel {
  position: absolute; left: 32px; top: 40px;
  width: 280px; height: 150px;
  display: grid;
  grid-template-columns: repeat(5, 52px);
  grid-auto-rows: 46px;
  gap: 4px 5px;
  align-content: start;
  justify-content: start;
}

/* кнопка AoE2: иконка в рисованной фаске */
.cmd {
  position: relative;
  width: 52px; height: 46px;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: #181410;
  border: 1px solid #000;
  box-shadow: inset 1px 1px 0 #b89868, inset -1px -1px 0 #2c1f10,
              inset 2px 2px 0 #6a5638, inset -2px -2px 0 #443322;
  cursor: pointer;
  overflow: hidden;
  font-family: inherit;
  font-size: 11px;
  color: #f4e8c8;
}
.cmd:hover { filter: brightness(1.25); }
.cmd:active, .cmd.active {
  box-shadow: inset 1px 1px 0 #2c1f10, inset -1px -1px 0 #b89868,
              inset 2px 2px 0 #443322, inset -2px -2px 0 #6a5638;
}
.cmd.active { outline: 1px solid #e2c044; outline-offset: -1px; }
.cmd:disabled { filter: grayscale(1) brightness(0.5); cursor: not-allowed; }
.cmd .ico { font-size: 20px; line-height: 1; pointer-events: none; }
.cmd .cost { display: none; }
.cmd .hk {
  position: absolute; top: 1px; left: 3px;
  font-size: 9px; color: #ffe9a0; text-shadow: 1px 1px 0 #000; opacity: 0.9;
  pointer-events: none;
}
.cmd .badge {
  position: absolute; bottom: 1px; right: 3px;
  font-size: 11px; font-weight: bold; color: #ffe9a0; text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}

/* фрагмент спрайт-листа */
.sprite-ico-wrap { display: inline-block; overflow: hidden; line-height: 0; pointer-events: none; }
.sprite-ico { display: inline-block; background-repeat: no-repeat; }

/* мини-иконки статов (лист 50731, 144×69, кадр 36×23, масштаб 0.7) */
.sico {
  display: inline-block; vertical-align: -3px;
  width: 25px; height: 16px;
  background: url('web-assets/sprites/interface/50731.png') no-repeat;
  background-size: 101px 48px;
}
.sico-attack { background-position: -76px -16px; }
.sico-armor { background-position: 0 -32px; }
.sico-pierce { background-position: -50px -32px; }

/* переключатель страниц команд — последний слот сетки */
.cmd-page {
  grid-column: 5; grid-row: 3;
  font-size: 11px; font-weight: bold;
  display: flex; align-items: center; justify-content: center; gap: 2px;
}

/* всплывающая карточка над панелью команд */
#cmdTooltip {
  position: absolute; left: 8px; bottom: 224px;
  min-width: 200px; max-width: 340px; width: max-content;
  background: linear-gradient(#3a2c18, #241a0e);
  border: 2px solid #7a5c34;
  box-shadow: 0 2px 10px rgba(0,0,0,0.8);
  padding: 6px 10px;
  font-size: 12px;
  color: #e8dcc0;
  pointer-events: none;
  z-index: 20;
}
#cmdTooltip b { color: #e2c044; }
#cmdTooltip .tip-note { margin-top: 2px; color: #b09a70; }

/* рынок и дань — на пергаменте инфо-зоны */
#marketExtra { margin-top: 4px; }
#marketExtra select {
  background: #f0e0c0; color: #2c1d0c;
  border: 1px solid #7a5c34; font-size: 11px;
}

@media (max-width: 1180px) {
  #mapZone { flex: 0 0 240px; width: 240px; overflow: hidden; }
  #minimap { left: 10px; top: 17px; width: 220px; height: 104px; }
}

/* ---------- дополнения: хоткеи, рынок, статистика ---------- */

.menu-box.wide { min-width: 620px; max-width: 760px; }

.cmd .hk {
  position: absolute; top: 2px; right: 4px;
  font-size: 9px; color: #e2c044; opacity: 0.85;
}
.cmd.active { outline: 2px solid #e2c044; }

#countdown {
  position: absolute; top: 40px; left: 50%;
  transform: translateX(-50%);
  background: rgba(60,10,10,0.85);
  border: 1px solid #e2c044;
  padding: 3px 14px; font-size: 14px; color: #ffd9a0;
  pointer-events: none;
}

#topbar .btn.tiny b { font-size: 12px; }

#statsWrap { margin: 10px 0; }
#scoreChart { background: rgba(0,0,0,0.4); border: 1px solid #5d4426; }
#statsTable { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
#statsTable th, #statsTable td { border: 1px solid #5d4426; padding: 3px 6px; }
#statsTable th { color: #b09a70; }

#techTreeBody {
  display: flex; gap: 10px; text-align: left;
  font-size: 12px; max-height: 60vh; overflow-y: auto;
}
#techTreeBody .agecol { flex: 1; border: 1px solid #5d4426; padding: 6px; }
#techTreeBody h3 { color: #e2c044; font-size: 13px; margin-bottom: 6px; }
#techTreeBody .ttitem { margin: 2px 0; }
#techTreeBody .ttitem.done { color: #7ad07a; }
#techTreeBody .ttitem.locked { color: #777; }

.market-row { display: flex; gap: 4px; align-items: center; margin: 2px 0; width: 100%; }
.market-row .btn { font-size: 11px; padding: 2px 6px; }

#infoStats .grow { color: #7ad07a; }
.subsel { cursor: pointer; }
.subsel:hover { color: #e2c044; }
