* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #34587d; color: #eef0f6;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  user-select: none; -webkit-user-select: none;
}
#map { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: crosshair; touch-action: none; }
#map.dragging { cursor: grabbing; }
[hidden] { display: none !important; }

.panel {
  background: rgba(24, 27, 40, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(4px);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08); color: #eef0f6; border: 0;
  border-radius: 6px; min-width: 32px; height: 30px; padding: 0 8px;
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.18); }
.icon-btn.small { min-width: 22px; height: 22px; padding: 0 6px; font-size: 13px; }

/* Лидеры */
#leaderboard { position: fixed; top: 10px; left: 10px; width: 300px; padding: 6px 8px 8px; font-size: 12.5px; }
.lb-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; padding: 0 2px 4px; color: #b9c0d6; }
#leaderboard table { width: 100%; border-collapse: collapse; }
#leaderboard th { color: #8c93aa; font-weight: 600; text-align: right; padding: 3px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
#leaderboard td { text-align: right; padding: 4px; white-space: nowrap; }
#leaderboard th:first-child, #leaderboard td:first-child { text-align: left; width: 26px; color: #8c93aa; }
#leaderboard .name { text-align: left; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
#leaderboard td.name { display: flex; align-items: center; gap: 6px; }
#leaderboard .dot { width: 9px; height: 9px; border-radius: 2px; flex: none; }
#leaderboard tr.me td { background: rgba(150, 80, 220, 0.25); font-weight: 700; }
#leaderboard tr.sep td { padding: 0; height: 4px; }
#leaderboard.collapsed table { display: none; }

/* Верхняя панель */
#topbar { position: fixed; top: 10px; right: 10px; display: flex; gap: 6px; align-items: center; padding: 6px 8px; }
#timer { font-variant-numeric: tabular-nums; font-weight: 700; padding: 0 6px; }

#banner {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  padding: 10px 18px; font-size: 17px; font-weight: 600; text-align: center;
}
#banner small { display: block; font-size: 12px; color: #aab1c7; font-weight: 400; margin-top: 2px; }

/* Нижняя панель */
#bottom { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(560px, calc(100vw - 20px)); display: flex; flex-direction: column; gap: 6px; }
#attacks { display: flex; flex-wrap: wrap; gap: 6px; }
.attack {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; font-size: 13px;
  background: rgba(24, 27, 40, 0.86); border-radius: 8px; border-left: 4px solid #6aa0ff;
}
.attack b { color: #9cc0ff; }
.attack .x { background: #c0392b; color: #fff; border: 0; border-radius: 5px; width: 22px; height: 22px; cursor: pointer; font-weight: 700; }
.attack .x:hover { background: #e74c3c; }
.attack.incoming { border-left-color: #e74c3c; }
.attack.incoming b { color: #ff9c9c; }

#controls { padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.chip { background: rgba(255, 255, 255, 0.08); border-radius: 6px; padding: 4px 8px; font-size: 13px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip.green { color: #7ee08a; }
#popbar { position: relative; flex: 1; height: 26px; background: rgba(255, 255, 255, 0.08); border-radius: 6px; overflow: hidden; }
#popfill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #2f6fd6, #4f95ff); transition: width 0.1s linear; }
#poptext { position: relative; display: block; text-align: center; line-height: 26px; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
#ratio { flex: 1; accent-color: #4f95ff; cursor: pointer; }

#tooltip {
  position: fixed; pointer-events: none; z-index: 5; padding: 6px 9px; font-size: 12.5px; line-height: 1.4;
  background: rgba(16, 18, 28, 0.92); border-radius: 7px; border: 1px solid rgba(255, 255, 255, 0.1); white-space: nowrap;
}
#tooltip .t-name { font-weight: 700; font-size: 13.5px; }
#tooltip .muted { color: #9aa2b8; }

#toasts { position: fixed; top: 110px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 6; }
.toast { padding: 7px 14px; border-radius: 8px; background: rgba(24, 27, 40, 0.92); font-size: 14px; font-weight: 600; animation: toastIn 0.2s ease-out; transition: opacity 0.4s; }
.toast.good { border-left: 4px solid #4caf50; }
.toast.bad { border-left: 4px solid #e74c3c; }
.toast.info { border-left: 4px solid #6aa0ff; }
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

#pausedLabel { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 40px; font-weight: 800; letter-spacing: 6px; color: rgba(255, 255, 255, 0.85); text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5); pointer-events: none; }

/* Меню */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(12, 16, 28, 0.55); z-index: 10; padding: 16px; }
.card { width: min(440px, 100%); background: rgba(24, 27, 40, 0.96); border-radius: 14px; padding: 24px 26px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); display: flex; flex-direction: column; gap: 12px; }
.card h1 { margin: 0; font-size: 30px; letter-spacing: 0.5px; background: linear-gradient(90deg, #b98cff, #6fb1ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { margin: 0; color: #aab1c7; font-size: 14px; line-height: 1.45; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #aab1c7; flex: 1; }
.field b { color: #fff; }
.field-row { display: flex; gap: 12px; }
.field input:not([type=range]), .field select {
  background: #11141f; color: #eef0f6; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 7px;
  padding: 8px 10px; font-size: 14px; font-family: inherit; outline: none;
}
.field input:focus, .field select:focus { border-color: #6f8dff; }
.field input[type=range] { accent-color: #8f6bff; }
button.primary, button.secondary { border: 0; border-radius: 9px; padding: 11px; font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit; }
button.primary { background: linear-gradient(90deg, #8a55e6, #4f7ff0); color: #fff; }
button.primary:hover { filter: brightness(1.1); }
button.secondary { background: rgba(255, 255, 255, 0.08); color: #eef0f6; }
button.secondary:hover { background: rgba(255, 255, 255, 0.15); }
.help { font-size: 12.5px; color: #9aa2b8; line-height: 1.6; border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 10px; }
.help b { color: #d7dbea; }
.help .goal { margin-top: 4px; color: #c9b3ff; }

@media (max-width: 900px) {
  #banner { top: auto; bottom: 150px; font-size: 15px; }
  #toasts { top: auto; bottom: 200px; }
}
@media (max-width: 720px) {
  #leaderboard { width: 220px; font-size: 11px; }
  #leaderboard .name { max-width: 90px; }
}
