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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0f0f1a;
  color: #e8e8f0;
  min-height: 100vh;
  padding: 1rem;
}

.app { width: 100%; }

.header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.header-title { font-size: 1.5rem; font-weight: 600; }
.header-sub { font-size: 0.85rem; color: #888; display: block; }

.settings-btn {
  font-size: 13px; background: #1a1a2e; border: 1px solid #333;
  color: #aaa; border-radius: 8px; padding: .4rem .75rem;
  cursor: pointer; display: flex; align-items: center; gap: 5px; white-space: nowrap;
}
.settings-btn:hover { background: #2a2a3e; color: #e8e8f0; }

/* Settings overlay */
.settings-wrap {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
}
.settings-panel {
  background: #1a1a2e; border: 1px solid #2a2a4a; border-radius: 14px;
  width: 480px; max-width: calc(100vw - 2rem); display: flex; flex-direction: column;
  max-height: calc(100vh - 4rem);
}
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid #2a2a4a;
  font-weight: 600; font-size: 15px;
}
.settings-close {
  background: none; border: none; color: #888; cursor: pointer; font-size: 16px;
  padding: 2px 4px; border-radius: 4px;
}
.settings-close:hover { color: #e8e8f0; background: #2a2a3e; }
.settings-body { display: flex; flex: 1; overflow: hidden; }
.settings-nav {
  display: flex; flex-direction: column; gap: 4px;
  padding: .75rem; border-right: 1px solid #2a2a4a; min-width: 130px;
}
.snav-btn {
  background: none; border: none; color: #aaa; cursor: pointer;
  text-align: left; padding: .5rem .75rem; border-radius: 8px;
  font-size: 13px; display: flex; align-items: center; gap: 7px;
}
.snav-btn:hover { background: #2a2a3e; color: #e8e8f0; }
.snav-btn.active { background: #2a4a8a; color: #e8e8f0; }
.settings-content { flex: 1; padding: 1rem; overflow-y: auto; }
.settings-sect { display: flex; flex-direction: column; gap: 10px; }
.sadd-row { display: flex; gap: 8px; }
.sadd-row input {
  flex: 1; font-size: 14px; background: #0f0f1a; color: #e8e8f0;
  border: 1px solid #333; border-radius: 8px; padding: .4rem .6rem;
}
.sadd-row button {
  font-size: 13px; background: #2a4a8a; border: 1px solid #3a5a9a;
  color: #e8e8f0; border-radius: 8px; padding: .4rem .75rem;
  cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 4px;
}
.sadd-row button:hover { background: #3a5aaa; }
.slist { display: flex; flex-direction: column; gap: 6px; }
.slist-item {
  display: flex; align-items: center; gap: 8px;
  background: #0f0f1a; border: 1px solid #222; border-radius: 8px;
  padding: .4rem .6rem;
}
.slist-item input {
  flex: 1; background: transparent; border: none; color: #e8e8f0;
  font-size: 14px; outline: none;
}
.slist-item input:focus { color: #fff; }
.slist-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.slist-item-actions button {
  background: none; border: 1px solid #333; color: #888;
  border-radius: 6px; padding: .25rem .45rem; cursor: pointer; font-size: 12px;
}
.slist-item-actions button:hover { background: #2a2a3e; color: #e8e8f0; }
.slist-item-actions button.del:hover { background: #3a1a1a; color: #f88; border-color: #622; }

.toolbar {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: .75rem;
}
.toolbar input, .toolbar select, .toolbar button {
  font-size: 14px; border-radius: 8px; border: 1px solid #333;
  background: #1a1a2e; color: #e8e8f0; padding: .45rem .75rem;
}
.toolbar input[type="text"] { flex: 1; min-width: 120px; }
.toolbar select { width: 130px; }
.toolbar button {
  background: #2a4a8a; border-color: #3a5a9a; cursor: pointer;
  white-space: nowrap; display: flex; align-items: center; gap: 5px;
}
.toolbar button:hover { background: #3a5aaa; }

.error-banner {
  background: #4a1a1a; border: 1px solid #8a2a2a; border-radius: 8px;
  padding: .5rem .75rem; margin-bottom: .75rem; font-size: 13px; color: #f88;
}

.stats { display: flex; gap: 8px; margin-bottom: .75rem; flex-wrap: wrap; }
.stat {
  background: #1a1a2e; border: 1px solid #2a2a4a; border-radius: 8px;
  padding: .4rem .75rem; font-size: 13px; color: #aaa;
}
.stat strong { color: #e8e8f0; font-weight: 600; }

.outer { display: flex; gap: 16px; align-items: flex-start; }

.arena {
  position: relative; flex: 1; aspect-ratio: 16 / 7;
  background: #0d1b2a;
  border-radius: 16px; overflow: hidden;
  border: 1px solid #2a2a4a;
}
.arena-bg {
  position: absolute; inset: 0; z-index: 0;
  background-size: cover; background-position: center;
  transition: opacity 1.5s ease-in-out;
}
.arena-overlay {
  position: absolute; inset: 0; z-index: 1;
  background: rgba(0,0,0,0.35);
  pointer-events: none;
}
canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; }

.empty, .loading {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  color: rgba(255,255,255,0.35); font-size: 14px; pointer-events: none;
  z-index: 2;
}

@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 1s linear infinite; }

.legend-panel { display: flex; flex-direction: column; gap: 5px; padding: .5rem 0; min-width: 110px; }
.leg-title { font-size: 11px; font-weight: 600; color: #666; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 2px; }
.leg { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #aaa; margin-bottom: 2px; }
.legdot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.leg-sz { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #aaa; margin-bottom: 4px; }
.leg-sz.faded { opacity: 0.4; }
.leg-bubble {
  display: inline-block; border-radius: 50%; flex-shrink: 0;
  background: rgba(80,140,220,0.35); border: 2px solid rgba(80,140,220,0.9);
}
.leg-bubble.large { width: 18px; height: 18px; }
.leg-bubble.small { width: 13px; height: 13px; }
.leg-bubble.grey { background: rgba(140,140,140,0.35); border-color: rgba(140,140,140,0.9); }

/* Modal */
.modal-wrap {
  position: absolute; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.modal {
  background: #1e1e32; border-radius: 12px; border: 1px solid #333;
  padding: 1.25rem; width: 260px; display: flex; flex-direction: column; gap: 12px;
}
.modal h3 { font-size: 15px; font-weight: 600; }
.modal label { font-size: 12px; color: #888; display: block; margin-bottom: 3px; }
.modal input, .modal select, .modal textarea {
  width: 100%; font-size: 14px; background: #0f0f1a; color: #e8e8f0;
  border: 1px solid #333; border-radius: 6px; padding: .4rem .6rem;
  font-family: inherit; resize: vertical;
}
.mact { display: flex; gap: 8px; justify-content: flex-end; }
.mact button {
  font-size: 13px; padding: .35rem .7rem; border-radius: 6px;
  border: 1px solid #444; background: #2a2a3e; color: #e8e8f0; cursor: pointer;
}
.mact button:hover { background: #3a3a4e; }
.dbtn { color: #f88 !important; border-color: #622 !important; }
.dbtn:hover { background: #3a1a1a !important; }

/* Password gate */
.pw-gate {
  position: fixed; inset: 0; z-index: 100;
  background: #0f0f1a;
  display: flex; align-items: center; justify-content: center;
}
.pw-box {
  background: #1a1a2e; border: 1px solid #2a2a4a; border-radius: 16px;
  padding: 2rem; display: flex; flex-direction: column; gap: 14px;
  width: 300px; align-items: center;
}
.pw-box h2 { font-size: 1.4rem; font-weight: 600; }
.pw-box p { font-size: 0.85rem; color: #888; }
.pw-box input {
  width: 100%; font-size: 14px; background: #0f0f1a; color: #e8e8f0;
  border: 1px solid #333; border-radius: 8px; padding: .5rem .75rem;
  text-align: center; letter-spacing: 2px;
}
.pw-box button {
  width: 100%; font-size: 14px; background: #2a4a8a; border: 1px solid #3a5a9a;
  color: #e8e8f0; border-radius: 8px; padding: .5rem; cursor: pointer;
}
.pw-box button:hover { background: #3a5aaa; }
.pw-error { font-size: 13px; color: #f88; }
