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

:root {
  --bg: #1a1a2e;
  --bg-light: #16213e;
  --accent: #0f3460;
  --primary: #e94560;
  --text: #eee;
  --text-dim: #999;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #ef4444;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Status bar */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-light);
  font-size: 13px;
  z-index: 1000;
}

.status-bar .title { font-weight: 600; }
.status-bar .player-ident {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 65%;
}
.status-bar .status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
}
.status-dot.online { background: var(--success); }

/* Map container */
.map-container {
  flex: 1;
  position: relative;
}

#map { width: 100%; height: 100%; }

/* Bottom toolbar */
.toolbar {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-light);
  z-index: 1000;
}

.toolbar button {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}

.toolbar button:active { opacity: 0.7; }
.toolbar button.primary { background: var(--primary); }
.toolbar button.sync { background: var(--success); color: #000; }

/* Bottom navigation tabs */
.nav-tabs {
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--accent);
}

.nav-tabs button {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}

.nav-tabs button.active {
  color: var(--primary);
  border-top: 2px solid var(--primary);
}

/* Join screen */
.join-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
  text-align: center;
}

.join-screen h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.join-screen .event-name {
  font-size: 18px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.join-screen .team-name {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 32px;
}

.join-screen input {
  width: 100%;
  max-width: 300px;
  padding: 14px 16px;
  border: 2px solid var(--accent);
  border-radius: 10px;
  background: var(--bg-light);
  color: var(--text);
  font-size: 18px;
  text-align: center;
  outline: none;
}

.join-screen input:focus {
  border-color: var(--primary);
}

.join-screen .join-btn {
  width: 100%;
  max-width: 300px;
  margin-top: 16px;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}

.join-screen .join-btn:disabled {
  opacity: 0.5;
}

.join-screen .loading {
  margin-top: 20px;
  color: var(--text-dim);
}

.join-screen .join-section {
  width: 100%;
  max-width: 320px;
  margin-top: 16px;
}

.join-screen .join-section-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.join-screen .team-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.team-btn {
  padding: 10px 18px;
  border: 2px solid var(--accent);
  border-radius: 10px;
  background: var(--bg-light);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.team-btn:hover {
  border-color: var(--primary);
  background: rgba(255,255,255,0.05);
}

.team-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.team-btn .team-meta {
  font-size: 11px;
  opacity: 0.7;
  margin-left: 4px;
}

.team-btn.active .team-meta {
  opacity: 0.85;
}

.join-screen .pin-input {
  width: 140px;
  text-align: center;
  font-size: 20px;
  letter-spacing: 8px;
  padding: 10px 12px;
}

.join-screen .hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  opacity: 0.7;
}

/* Queue badge */
.queue-badge {
  background: var(--warning);
  color: #000;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

/* Player tooltip */
.player-tooltip {
  background: rgba(0,0,0,0.8) !important;
  border: none !important;
  color: #fff !important;
  font-size: 11px !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  box-shadow: none !important;
}

.player-tooltip::before {
  border-top-color: rgba(0,0,0,0.8) !important;
}

/* Leaflet overrides for dark theme */
.leaflet-control-zoom a {
  background: var(--bg-light) !important;
  color: var(--text) !important;
  border-color: var(--accent) !important;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-light);
  color: var(--text);
  border-radius: 8px;
}

.leaflet-popup-tip { background: var(--bg-light); }

/* Pick location overlay */
.pick-instruction {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1001;
  display: flex;
  align-items: center;
}

/* Marker form panel */
.marker-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-light);
  border-radius: 12px 12px 0 0;
  padding: 10px 12px;
  z-index: 1002;
  max-height: 45vh;
  overflow-y: auto;
}

.marker-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 600;
}

.marker-close-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.category-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 2px;
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.category-btn.selected {
  background: var(--accent);
}

.category-icon {
  font-size: 14px;
  font-weight: bold;
}

.category-label {
  font-size: 8px;
  margin-top: 2px;
}

.marker-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
}

.marker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.marker-photo-btn {
  padding: 8px 16px;
  background: var(--accent);
  border: none;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

.photo-status {
  font-size: 12px;
  color: var(--text-dim);
}

.priority-toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--warning);
  cursor: pointer;
}

.marker-submit-btn {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  border: none;
  color: white;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.marker-submit-btn:disabled {
  opacity: 0.5;
}

/* Team list */
.team-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.team-member {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--accent);
  cursor: pointer;
}

.team-member:active { background: var(--accent); }
.team-member.me { background: rgba(233, 69, 96, 0.1); }

.member-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.member-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
}
.member-dot.online { background: var(--success); }

.member-name { font-weight: 500; }

.member-team {
  font-size: 12px;
  opacity: 0.7;
}

.member-detail {
  text-align: right;
  font-size: 13px;
  color: var(--text-dim);
}

.member-lastseen {
  display: block;
  font-size: 11px;
  opacity: 0.6;
}

/* Settings */
.settings-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.settings-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--accent);
}

.settings-section h3 {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
}

.settings-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
}

.settings-leave-btn {
  width: 100%;
  padding: 12px;
  background: var(--danger);
  border: none;
  color: white;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

/* Measure tool */
.measure-label span {
  background: rgba(0,0,0,0.8);
  color: #e94560;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.measure-total span {
  background: rgba(233, 69, 96, 0.9);
  color: white;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* GPS status bar */
.gps-status {
  text-align: center;
  font-size: 11px;
  padding: 3px 8px;
  background: var(--bg-light);
  color: var(--text-dim);
}
.gps-status.gps-waiting { color: var(--warning); }
.gps-status.gps-active { color: var(--success); }
.gps-status.gps-denied, .gps-status.gps-error, .gps-status.gps-unavailable { color: var(--danger); }

/* Center on me button */
.btn-center-me {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 1000;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  background: var(--bg-light);
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  touch-action: manipulation;
}
.btn-center-me:active {
  background: var(--primary);
}

/* Heading cone */
.heading-cone {
  background: none !important;
  border: none !important;
}

/* Popup delete button */
.popup-delete-btn {
  margin-top: 6px;
  padding: 4px 10px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

/* Marker detail card */
.marker-detail-card {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1002;
  background: var(--bg-light);
  border-radius: 16px 16px 0 0;
  padding: 16px;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
}

.marker-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.marker-card-cat {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
  flex-shrink: 0;
}

.marker-card-title {
  flex: 1;
  font-size: 16px;
}

.marker-card-title b { display: block; }

.marker-card-author {
  font-size: 12px;
  color: var(--text-dim);
}

.marker-card-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
}

.marker-card-photo {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
}

.marker-card-text {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.4;
}

.marker-card-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.btn-edit-marker {
  flex: 1;
  padding: 8px;
  background: var(--accent);
  border: none;
  color: white;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.btn-delete-marker {
  padding: 8px 16px;
  background: var(--danger);
  border: none;
  color: white;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.btn-save-marker {
  width: 100%;
  padding: 10px;
  background: var(--success);
  border: none;
  color: white;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.mc-category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.mc-cat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
}

.mc-cat-btn.selected {
  background: rgba(255,255,255,0.1);
}

/* Marker icon with label */
.marker-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
  position: relative;
}
/* Tools menu */
.tools-menu {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1002;
  background: var(--bg-light);
  border-radius: 16px 16px 0 0;
  padding: 16px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
}

.tools-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 600;
}

.tools-menu-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tools-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  text-align: left;
}

.tools-menu-item:active { background: var(--accent); }

.tools-icon { font-size: 20px; }

/* Grid converter rows */
.grid-row {
  margin-bottom: 8px;
}
.grid-row label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  display: block;
  margin-bottom: 2px;
}
.grid-value {
  font-family: monospace;
  font-size: 14px;
  color: var(--text);
  padding: 4px 8px;
  background: var(--bg);
  border-radius: 4px;
  cursor: pointer;
  user-select: all;
}

.marker-icon-label {
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  margin-top: 2px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.8);
}

/* Share compact panel */
.share-compact-panel {
  position: fixed;
  bottom: 115px;
  left: 0;
  right: 0;
  z-index: 1003;
  background: var(--bg-light);
  border-radius: 12px;
  padding: 8px 12px;
  margin: 0 8px;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.4);
}

.share-compact-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.share-tab {
  padding: 4px 12px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}

.share-tab.active {
  background: var(--accent);
  color: var(--text);
}

.share-section {
  padding: 4px 0;
}

/* Crosshair overlay */
.crosshair {
  position: absolute;
  top: calc(50% - 150px);
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1100;
  pointer-events: none;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.5));
}

/* Marker pulse animation for highlighted/urgent markers */
.marker-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 0, 0, 0.3);
  animation: pulse-ring 1.5s ease-out infinite;
  pointer-events: none;
}

@keyframes pulse-ring {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

/* Chat list */
.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--accent);
  cursor: pointer;
}
.chat-item:active { background: var(--accent); }

.chat-item-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}

.chat-item-info { flex: 1; overflow: hidden; }
.chat-item-name { font-weight: 600; font-size: 14px; }
.chat-item-preview { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-meta { font-size: 11px; color: var(--text-dim); text-align: right; flex-shrink: 0; }

.chat-unread {
  background: var(--danger);
  color: white;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  display: inline-block;
  margin-top: 4px;
}

/* Chat messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg { display: flex; flex-direction: column; max-width: 80%; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg.theirs { align-self: flex-start; align-items: flex-start; }

.chat-msg-sender { font-size: 11px; font-weight: 600; margin-bottom: 2px; }

.chat-msg-bubble {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}
.chat-msg.mine .chat-msg-bubble { background: var(--accent); color: var(--text); border-bottom-right-radius: 4px; }
.chat-msg.theirs .chat-msg-bubble { background: var(--bg); color: var(--text); border-bottom-left-radius: 4px; }

.chat-msg-time { font-size: 10px; color: var(--text-dim); margin-top: 2px; }

/* Chat input bar */
.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-light);
  border-top: 1px solid var(--accent);
}

/* Chat badge */
.chat-badge {
  background: var(--danger);
  color: white;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  margin-left: 4px;
}

/* Chat toast notification */
.chat-toast {
  position: fixed;
  top: 50px;
  left: 10px;
  right: 10px;
  z-index: 2000;
  background: var(--bg-light);
  border: 1px solid var(--accent);
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.chat-toast-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.chat-toast-from { font-size: 12px; font-weight: 700; color: var(--primary); }
.chat-toast-close { background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; }
.chat-toast-text { font-size: 14px; color: var(--text); }

/* Chat toast actions */
.chat-toast-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

.chat-toast-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-accept {
  background: var(--success);
  color: #fff;
}

.toast-dismiss {
  background: var(--danger);
  color: #fff;
}

.chat-toast-text {
  cursor: pointer;
}
.chat-toast-text:active {
  opacity: 0.7;
}

.chat-toast-time {
  font-size: 11px;
  color: var(--text-dim);
}

/* Admin toast - gold border + gradient */
.chat-toast-admin {
  border-left-width: 5px;
  background: linear-gradient(135deg, var(--bg-light) 0%, rgba(255,215,0,0.1) 100%);
}

/* Chat send button */
.chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-send-btn:active { opacity: 0.7; }
