:root {
  --bg:      #0a0e0a;
  --bg2:     #111611;
  --bg3:     #1a221a;
  --border:  #2a3a2a;
  --accent:  #7cfc00;
  --danger:  #ff4444;
  --warn:    #ff9900;
  --rad:     #aaff00;
  --text:    #c8d8c0;
  --text2:   #6a8a6a;
  --gold:    #d4a800;
  --nav-h:   56px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', monospace;
  overflow: hidden;
  font-size: 14px;
}

/* ── Экраны ── */
.screen {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--nav-h);
  flex-direction: column;
  overflow: hidden;
}
.screen.active { display: flex; }

#screen-loading {
  bottom: 0;
  background: var(--bg);
  align-items: center;
  justify-content: center;
}

/* ── Загрузка ── */
.loading-wrap { text-align: center; padding: 20px; }
.zone-logo { font-size: 64px; animation: pulse-rad 2s infinite; }
.zone-title {
  font-size: 22px;
  font-weight: bold;
  color: var(--accent);
  letter-spacing: 4px;
  margin: 12px 0 4px;
  text-shadow: 0 0 20px var(--accent);
}
.zone-sub { color: var(--text2); font-size: 11px; letter-spacing: 3px; margin-bottom: 30px; }
.loading-bar {
  width: 200px;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  margin: 0 auto 10px;
  overflow: hidden;
}
.loading-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
  box-shadow: 0 0 8px var(--accent);
}
.loading-text { color: var(--text2); font-size: 12px; }

/* ── Верхняя панель (для экранов не-карты) ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.survival-bar { display: flex; gap: 10px; flex-wrap: wrap; }
.sb {
  font-size: 12px;
  color: var(--text);
  background: var(--bg3);
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.sb.warn  { border-color: var(--warn); color: var(--warn); }
.sb.crit  { border-color: var(--danger); color: var(--danger); animation: blink 1s infinite; }
.rubles { font-size: 13px; color: var(--gold); font-weight: bold; }

/* ── Карта — полноэкранная ── */
.screen-map-full {
  bottom: var(--nav-h);
  top: 0;
}
.map-overlay-tl {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}
.map-rubles {
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 8px rgba(0,0,0,0.9), 1px 1px 0 #000;
  letter-spacing: 1px;
}
.map-location-tag {
  font-size: 11px;
  color: rgba(200,220,180,0.8);
  text-shadow: 0 0 6px rgba(0,0,0,0.9);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ── Карта ── */
#map-canvas {
  display: block;
  cursor: pointer;
  touch-action: none;
  flex-shrink: 0;
}

.tile-popup {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  box-shadow: 0 0 15px rgba(124,252,0,0.3);
  z-index: 10;
}
.tile-popup.hidden { display: none; }
.tile-popup button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
}
#tile-danger { color: var(--warn); font-size: 12px; }

/* ── Заголовок экрана ── */
.screen-header {
  padding: 12px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: bold;
  color: var(--accent);
  letter-spacing: 1px;
  flex-shrink: 0;
}

.screen-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}
.screen-scroll::-webkit-scrollbar { width: 3px; }
.screen-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Карточки ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}
.card-title {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: bold;
}

/* ── Персонаж ── */
.char-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}
.char-avatar-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
#char-avatar-canvas {
  border-radius: 6px;
  display: block;
  box-shadow: 0 0 12px rgba(124,252,0,0.2);
}
.avatar-gender-row {
  display: flex;
  gap: 4px;
}
.gender-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 5px;
  padding: 3px 10px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.gender-btn.active {
  background: rgba(124,252,0,0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.char-meta { flex: 1; min-width: 0; }
.char-name { font-size: 16px; font-weight: bold; color: var(--text); }
.char-faction { font-size: 12px; margin: 2px 0; }
.char-level { font-size: 11px; color: var(--text2); margin: 4px 0 2px; }

.stats-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.skill-pts-banner {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(124,252,0,0.1);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.btn-skills {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}
.skill-list { display: flex; flex-direction: column; gap: 8px; }
.skill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.btn-skill-up {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}
.end-day-btn {
  width: 100%;
  padding: 14px;
  background: var(--bg3);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.warn-text { color: var(--warn) !important; }
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.stat-label { color: var(--text2); }
.stat-val   { color: var(--text); font-weight: bold; }

.exp-bar-wrap {
  background: var(--bg3);
  height: 6px;
  border-radius: 3px;
  margin: 6px 0;
  overflow: hidden;
}
.exp-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.5s; box-shadow: 0 0 6px var(--accent); }

.survival-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}
.surv-item { display: flex; flex-direction: column; gap: 3px; }
.surv-label { font-size: 11px; color: var(--text2); }
.surv-bar-wrap { background: var(--bg3); height: 8px; border-radius: 4px; overflow: hidden; }
.surv-bar { height: 100%; border-radius: 4px; transition: width 0.5s; }
.surv-bar.hp  { background: #4caf50; }
.surv-bar.rad { background: var(--rad); box-shadow: 0 0 6px var(--rad); }
.surv-bar.hun { background: #ff9800; }
.surv-bar.thi { background: #2196f3; }
.surv-bar.fat { background: #9c27b0; }

/* ── Инвентарь ── */
.inv-tabs {
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--text2);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.equip-slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 8px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.eslot {
  background: var(--bg3);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.eslot.filled { border-color: var(--accent); color: var(--text); }

.item-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 6px;
}
.item-card.equipped { border-color: var(--accent); }
.item-icon { font-size: 22px; width: 32px; text-align: center; flex-shrink: 0; }
.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 13px; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-stats { font-size: 11px; color: var(--text2); margin-top: 2px; }
.item-qty   { font-size: 11px; color: var(--gold); }
.dur-bar-wrap { background: var(--bg3); height: 3px; border-radius: 2px; margin-top: 4px; }
.dur-bar { height: 100%; background: var(--accent); border-radius: 2px; }
.item-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.btn-use   { background: var(--accent); color: var(--bg); border: none; border-radius: 5px; padding: 4px 8px; font-family: inherit; font-size: 11px; cursor: pointer; }
.btn-equip { background: transparent; color: var(--accent); border: 1px solid var(--accent); border-radius: 5px; padding: 4px 8px; font-family: inherit; font-size: 11px; cursor: pointer; }
.btn-drop  { background: transparent; color: var(--text2); border: 1px solid var(--border); border-radius: 5px; padding: 4px 8px; font-family: inherit; font-size: 11px; cursor: pointer; }

/* ── Торговля ── */
.trader-list { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.trader-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.trader-card:active { border-color: var(--accent); background: var(--bg3); }

.trader-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.back-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 6px;
  padding: 4px 10px;
  font-family: inherit;
  cursor: pointer;
}
.trade-tabs {
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 6px;
}
.shop-price { color: var(--gold); font-size: 12px; margin-top: 2px; }
.buy-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}
.sell-price { color: var(--warn); font-size: 12px; }
.sell-btn {
  background: transparent;
  color: var(--warn);
  border: 1px solid var(--warn);
  border-radius: 6px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Бой ── */
.battle-header {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  background: #1a0000;
  border-bottom: 1px solid #440000;
  color: var(--danger);
  font-weight: bold;
  flex-shrink: 0;
}

.battle-field {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 20px 10px;
  flex: 1;
  background: radial-gradient(ellipse at center, #1a1a0a 0%, #0a0a0a 100%);
}
.combatant { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 120px; }
.combatant-icon { font-size: 48px; }
.combatant-name { font-size: 12px; color: var(--text2); text-align: center; }
.hp-bar-wrap { width: 100%; height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.hp-bar { height: 100%; width: 100%; background: #4caf50; border-radius: 4px; transition: width 0.4s; }
.hp-bar.enemy { background: var(--danger); }
.hp-text { font-size: 11px; color: var(--text2); }
.vs-label { font-size: 28px; }

.battle-log {
  padding: 8px 12px;
  background: rgba(0,0,0,0.6);
  border-top: 1px solid #330000;
  border-bottom: 1px solid #330000;
  min-height: 60px;
  max-height: 80px;
  overflow-y: auto;
  font-size: 12px;
  color: var(--text2);
  flex-shrink: 0;
}
.log-line { padding: 2px 0; }
.log-line.atk  { color: var(--danger); }
.log-line.heal { color: #4caf50; }
.log-line.info { color: var(--text2); }

.battle-items-bar {
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.5);
  border-top: 1px solid #220000;
  overflow-x: auto;
  flex-shrink: 0;
}
.battle-item-btn {
  background: #003300;
  color: #88ff88;
  border: 1px solid #004400;
  border-radius: 6px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}
.battle-item-btn:disabled { opacity: 0.4; }

.battle-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  padding: 8px;
  background: #0a0808;
  flex-shrink: 0;
}
.battle-actions button {
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
}
.btn-atk   { background: #8b0000; color: #ffcccc; }
.btn-dodge { background: #003366; color: #cceeff; }
.btn-item  { background: #006600; color: #ccffcc; }
.btn-flee  { background: #333; color: var(--text2); }
.battle-actions button:disabled { opacity: 0.4; }

/* ── Навигация ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  display: flex;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  z-index: 100;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text2);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}
.nav-btn span:first-child { font-size: 20px; }
.nav-btn.active { color: var(--accent); }

/* ── Тост ── */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 30, 10, 0.95);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 999;
  box-shadow: 0 0 15px rgba(124,252,0,0.4);
  white-space: nowrap;
}
.toast.hidden { display: none; }

/* ── Анимации ── */
@keyframes pulse-rad {
  0%, 100% { opacity: 1; transform: scale(1); text-shadow: 0 0 0 rgba(124,252,0,0); }
  50% { opacity: 0.7; transform: scale(1.05); text-shadow: 0 0 30px rgba(124,252,0,0.8); }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Скрыть/показать ── */
.hidden { display: none !important; }

/* ── Чат ── */
.chat-wrap {
  position: fixed;
  bottom: var(--nav-h);
  left: 0;
  right: 0;
  z-index: 200;
  pointer-events: none;
}
.chat-toggle {
  pointer-events: all;
  position: absolute;
  bottom: 0;
  left: 10px;
  background: rgba(10,20,10,0.92);
  border: 1px solid var(--border);
  border-bottom: none;
  color: var(--text2);
  font-family: inherit;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.chat-wrap.chat-open .chat-toggle {
  color: var(--accent);
  border-color: var(--accent);
}
.chat-badge {
  color: var(--danger);
  font-size: 10px;
}
.chat-body {
  pointer-events: all;
  position: absolute;
  bottom: 28px;
  left: 0;
  right: 0;
  height: 220px;
  background: rgba(8,14,8,0.96);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.chat-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 11px;
  padding: 6px 4px;
  cursor: pointer;
  transition: color 0.2s;
}
.chat-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-msg {
  font-size: 12px;
  line-height: 1.4;
  word-break: break-word;
}
.chat-name {
  font-weight: bold;
  margin-right: 6px;
  font-size: 11px;
}
.chat-text {
  color: var(--text);
}
.chat-time {
  color: var(--text2);
  font-size: 10px;
  margin-left: 6px;
}
.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  outline: none;
}
.chat-input:focus { border-color: var(--accent); }
.chat-send {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

/* ── Кланы ── */
.clan-section { padding: 12px; }
.clan-section-title {
  font-size: 11px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.clan-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.clan-card:active { border-color: var(--accent); }
.clan-tag {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 13px;
  font-weight: bold;
  color: var(--accent);
  min-width: 40px;
  text-align: center;
  flex-shrink: 0;
}
.clan-info { flex: 1; }
.clan-name { font-size: 14px; font-weight: bold; }
.clan-meta { font-size: 11px; color: var(--text2); margin-top: 2px; }
.clan-join-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.clan-create-form {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.clan-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 6px;
  outline: none;
}
.clan-input:focus { border-color: var(--accent); }
.clan-create-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 9px;
  font-family: inherit;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
}
.my-clan-banner {
  background: rgba(124,252,0,0.08);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}
.my-clan-tag-big {
  font-size: 24px;
  font-weight: bold;
  color: var(--accent);
}
.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.member-role {
  font-size: 10px;
  color: var(--text2);
  text-transform: uppercase;
  margin-left: auto;
}
.member-lvl {
  font-size: 11px;
  color: var(--gold);
}

/* Навбар с 5 кнопками — чуть меньше */
.bottom-nav .nav-btn { font-size: 9px; }
.bottom-nav .nav-btn span:first-child { font-size: 18px; }
