/* ── LOADTALK ── retrofuturistic telecom command aesthetic ── */

:root {
  --bg: #0a0c10;
  --bg-panel: #0f1218;
  --bg-panel-hover: #141922;
  --border: #1c2333;
  --border-bright: #2a3654;
  --text: #c8cdd8;
  --text-dim: #5c6578;
  --text-bright: #e8ecf4;
  --accent: #00e5a0;
  --accent-dim: #00e5a033;
  --accent-glow: #00e5a066;
  --danger: #ff4f6e;
  --warn: #ffb547;
  --sidebar-w: 360px;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
  --font-display: 'Space Mono', monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── MAP ── */

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* ── MAP CONTROLS THEME ── */

.maplibregl-ctrl-group {
  background: var(--bg-panel) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4) !important;
}
.maplibregl-ctrl-group button {
  background: transparent !important;
  border-color: var(--border) !important;
}
.maplibregl-ctrl-group button:hover {
  background: var(--bg-panel-hover) !important;
}
.maplibregl-ctrl-group button .maplibregl-ctrl-icon {
  filter: invert(1) brightness(0.8);
}
.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon {
  filter: invert(1) brightness(0.8) !important;
}
.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon {
  filter: invert(48%) sepia(90%) saturate(500%) hue-rotate(130deg) brightness(1.2) !important;
}

.maplibregl-ctrl-attrib {
  background: rgba(10, 12, 16, 0.7) !important;
  border-radius: 4px !important;
}
.maplibregl-ctrl-attrib a {
  color: var(--text-dim) !important;
}
.maplibregl-ctrl-attrib-button {
  filter: invert(1) brightness(0.6) !important;
}

/* ── SIDEBAR TOGGLE ── */

.sidebar-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 40px;
  height: 40px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 0.3s cubic-bezier(.4,0,.2,1), background 0.15s;
}
.sidebar-toggle:hover { background: var(--bg-panel-hover); }
.sidebar.open ~ .sidebar-toggle { left: calc(var(--sidebar-w) + 16px); }

.toggle-icon {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--accent);
  position: relative;
  transition: background 0.2s;
}
.toggle-icon::before,
.toggle-icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: var(--accent);
}
.toggle-icon::before { top: -6px; }
.toggle-icon::after { top: 6px; }

/* ── SIDEBAR ── */

.sidebar {
  position: fixed;
  top: 0;
  left: calc(-1 * var(--sidebar-w));
  width: var(--sidebar-w);
  height: 100%;
  z-index: 100;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: left 0.3s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.sidebar.open { left: 0; }

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #101520 0%, var(--bg-panel) 100%);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 28px;
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent-glow));
  line-height: 1;
}

.logo h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text-bright);
  line-height: 1;
}

.logo-sub {
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--accent);
  text-transform: uppercase;
  opacity: 0.7;
}

/* ── TABS ── */

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 10px 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); }
.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 20%;
  width: 60%;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ── TAB PANELS ── */

.sidebar-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tab-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.tab-panel.active { display: block; }

.tab-panel::-webkit-scrollbar { width: 4px; }
.tab-panel::-webkit-scrollbar-track { background: transparent; }
.tab-panel::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 2px; }

/* ── PANELS ── */

.panel {
  margin-bottom: 20px;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text-dim);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ── FORMS ── */

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-group label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.input-group input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 1px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-group input::placeholder { color: var(--text-dim); font-size: 12px; }
.input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: #00ffb3;
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-secondary:hover {
  background: var(--accent-dim);
}

/* ── HOW TO PLAY ── */

.how-to-play {
  list-style: none;
  counter-reset: step;
}
.how-to-play li {
  counter-increment: step;
  padding: 6px 0 6px 28px;
  position: relative;
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
}
.how-to-play li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 6px;
  width: 18px;
  height: 18px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.how-to-play strong { color: var(--accent); }

/* ── CALL NUMBER ── */

.call-number {
  text-align: center;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 6px;
}
.call-label {
  display: block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.call-did {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--accent);
  text-decoration: none;
  text-shadow: 0 0 16px var(--accent-glow);
}
.call-did:hover {
  color: #00ffb3;
}

/* ── LEADERBOARD TABLE ── */

.lb-table {
  width: 100%;
  border-collapse: collapse;
}
.lb-table th {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.lb-table td {
  padding: 8px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.lb-row { cursor: pointer; }
.lb-table tr:hover td { background: var(--bg-panel-hover); }
.lb-row.active td { background: var(--accent-dim); }

.lb-rank {
  color: var(--text-dim);
  font-weight: 700;
  width: 30px;
}
.lb-name {
  font-weight: 600;
  color: var(--text-bright);
}
.lb-color {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.lb-emoji {
  margin-right: 6px;
  font-size: 14px;
  vertical-align: middle;
}
.lb-score {
  font-weight: 700;
  color: var(--accent);
  text-align: right;
  font-family: var(--font-display);
}
.lb-captures {
  color: var(--text-dim);
  text-align: right;
}

/* ── ACTIVITY FEED ── */

.activity-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
}
.activity-item:hover {
  background: var(--bg-panel-hover);
}
.activity-item:last-child { border-bottom: none; }

.activity-action {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 2px;
}
.activity-player {
  font-weight: 700;
  color: var(--text-bright);
}
.activity-verb {
  color: var(--text-dim);
}
.activity-verb.steal {
  color: var(--danger);
}
.activity-location {
  font-size: 11px;
  color: var(--text-dim);
}
.activity-time {
  font-size: 10px;
  color: var(--text-dim);
  opacity: 0.6;
}

/* ── PLAYER STATS ── */

.player-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  margin-top: 10px;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.player-name-row .lb-color { width: 10px; height: 10px; }
.player-emoji {
  font-size: 20px;
  line-height: 1;
}
.activity-emoji {
  font-size: 14px;
  line-height: 1;
}
.player-name-display {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-bright);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
}
.stat-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}
.stat-detail {
  font-size: 10px;
  color: var(--text-dim);
}
.stat-total {
  grid-column: 1 / -1;
}
.stat-total .stat-value {
  font-size: 24px;
}

/* ── LOADING ── */

.loading-pulse {
  text-align: center;
  padding: 20px;
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--text-dim);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ── EMPTY STATE ── */

.empty-state {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 1px;
}

/* ── MODAL ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  width: 340px;
  max-width: 90vw;
  box-shadow: 0 0 40px var(--accent-dim), 0 24px 48px rgba(0,0,0,0.5);
  animation: modalIn 0.25s cubic-bezier(.4,0,.2,1);
}
@keyframes modalIn {
  from { transform: scale(0.95) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-signal {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 24px 20px;
  text-align: center;
}
.modal-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.callsign-display {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
  padding: 8px 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 16px;
  user-select: all;
}

.pin-display {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 10px;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
  padding: 12px 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 16px;
  user-select: all;
}
.modal-warn {
  font-size: 12px;
  font-weight: 700;
  color: var(--warn);
  margin-bottom: 4px;
}
.modal-sub {
  font-size: 11px;
  color: var(--text-dim);
}

.modal-actions-row {
  display: flex;
  gap: 10px;
  padding: 0 20px 20px;
}
.modal-actions-row .btn {
  flex: 1;
}
.modal-reroll {
  border-color: var(--border-bright);
  color: var(--text-dim);
}
.modal-reroll:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

/* ── MAP POPUP ── */

.maplibregl-popup-content {
  background: var(--bg-panel) !important;
  border: 1px solid var(--border-bright) !important;
  border-radius: 6px !important;
  padding: 12px 16px !important;
  color: var(--text) !important;
  font-family: var(--font-mono) !important;
  font-size: 12px !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4) !important;
  max-width: 260px !important;
}
.maplibregl-popup-tip {
  border-top-color: var(--bg-panel) !important;
}
.popup-title {
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 4px;
  font-size: 13px;
}
.popup-addr {
  color: var(--text-dim);
  margin-bottom: 6px;
  font-size: 11px;
}
.popup-owner {
  font-weight: 600;
  padding: 4px 0;
}
.popup-uncaptured {
  color: var(--text-dim);
  font-style: italic;
}
.popup-inoperable {
  color: var(--danger);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 2px;
  padding: 4px 0;
}
.popup-number {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ── MODAL EMOJI ── */

.modal-emoji {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 16px;
}

/* ── EXPLORE BUTTON (mobile only) ── */

.btn-explore {
  display: none;
  width: 100%;
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
  text-align: center;
  margin-top: 8px;
}
.btn-explore:hover {
  background: var(--accent-dim);
}

/* ── RESPONSIVE ── */

@media (max-width: 600px) {
  :root { --sidebar-w: 100vw; }
  .sidebar { border-right: none; }
  .sidebar.open ~ .sidebar-toggle { display: none; }
  .btn-explore { display: block; }
}
