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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
}

.screen {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Auth */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  padding: 20px;
}

.auth-card {
  background: #1e293b;
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  border: 1px solid #334155;
}

.auth-card h1 {
  text-align: center;
  font-size: 1.75rem;
  margin-bottom: 8px;
}

.subtitle {
  text-align: center;
  color: #94a3b8;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: #334155;
  color: #94a3b8;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.tab.active {
  background: #3b82f6;
  color: white;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  color: #cbd5e1;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #475569;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #3b82f6;
}

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn.primary {
  background: #3b82f6;
  color: white;
  width: 100%;
}

.btn.primary:hover {
  background: #2563eb;
}

.btn.danger {
  background: #ef4444;
  color: white;
  width: 100%;
}

.btn.danger:hover {
  background: #dc2626;
}

.btn.icon {
  background: transparent;
  color: #94a3b8;
  font-size: 1.25rem;
  padding: 8px 12px;
}

.btn.icon:hover {
  color: #e2e8f0;
  background: #334155;
}

.error {
  color: #f87171;
  font-size: 0.875rem;
  margin-top: 12px;
  text-align: center;
  min-height: 1.2em;
}

.msg {
  font-size: 0.875rem;
  margin-top: 8px;
  min-height: 1.2em;
}

.msg.success {
  color: #4ade80;
}

.msg.error {
  color: #f87171;
}

/* App */
#app-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}

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

.header-left h1 {
  font-size: 1.25rem;
}

.user-badge {
  background: #334155;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.875rem;
  color: #94a3b8;
}

.header-right {
  display: flex;
  gap: 4px;
}

.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#map {
  flex: 1;
  height: 100%;
  background: #0f172a;
}

.sidebar {
  width: 300px;
  background: #1e293b;
  border-left: 1px solid #334155;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: #0f172a;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #334155;
}

.panel h3 {
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: #cbd5e1;
}

.status {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 12px;
  text-align: center;
}

.status.online {
  background: #14532d;
  color: #4ade80;
}

.status.offline {
  background: #450a0a;
  color: #f87171;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hint {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 10px;
  text-align: center;
}

.user-list {
  list-style: none;
}

.user-list li {
  padding: 10px 12px;
  background: #1e293b;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-list li.empty {
  color: #64748b;
  justify-content: center;
  background: transparent;
}

.user-list .dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: #1e293b;
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid #334155;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #334155;
}

.modal-header h2 {
  font-size: 1.25rem;
}

.modal-body {
  padding: 20px;
}

.modal-body section {
  margin-bottom: 8px;
}

.modal-body h3 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: #93c5fd;
}

.modal-body hr {
  border: none;
  border-top: 1px solid #334155;
  margin: 20px 0;
}

.modal-body .btn.primary {
  margin-top: 4px;
}

/* Leaflet popup dark */
.leaflet-popup-content-wrapper {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
}

.leaflet-popup-tip {
  background: #1e293b;
}

/* Responsive */
@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid #334155;
  }
  #map {
    height: 60vh;
  }
}

/* Badge */
.badge {
  display: inline-block;
  background: #ef4444;
  color: white;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 2px;
  vertical-align: top;
}
.badge.hidden { display: none; }

/* Search */
.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.search-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #475569;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.95rem;
}
.btn.small {
  padding: 8px 14px;
  font-size: 0.85rem;
  width: auto;
}
.btn.outline {
  background: transparent;
  border: 1px solid #3b82f6;
  color: #3b82f6;
}
.btn.outline:hover {
  background: #3b82f6;
  color: white;
}
.btn.success {
  background: #22c55e;
  color: white;
}
.count {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: normal;
}

.user-list li .actions {
  display: flex;
  gap: 6px;
}
.user-list li .actions button {
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}
.online-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.offline-dot {
  width: 8px;
  height: 8px;
  background: #64748b;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.modal-content.wide {
  max-width: 520px;
}

/* Notifications panel */
.notif-panel {
  position: fixed;
  top: 60px;
  right: 16px;
  width: 340px;
  max-height: 70vh;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
  z-index: 900;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #334155;
}
.notif-header h3 {
  font-size: 1rem;
}
.notif-list {
  list-style: none;
  overflow-y: auto;
  max-height: 50vh;
  padding: 8px;
}
.notif-list li {
  padding: 12px;
  background: #0f172a;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.875rem;
  border-left: 3px solid #3b82f6;
}
.notif-list li.invite {
  border-left-color: #22c55e;
}
.notif-list li.empty {
  text-align: center;
  color: #64748b;
  background: transparent;
  border: none;
}
.notif-list .notif-time {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 4px;
}
.notif-list .notif-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}

/* Toast */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 14px 18px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  min-width: 280px;
  max-width: 360px;
  animation: slideIn 0.3s ease;
  border-left: 4px solid #3b82f6;
}
.toast.invite { border-left-color: #22c55e; }
.toast.friend { border-left-color: #a78bfa; }
.toast .toast-title {
  font-weight: 600;
  margin-bottom: 4px;
}
.toast .toast-msg {
  font-size: 0.875rem;
  color: #cbd5e1;
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Place search */
.selected-place {
  margin-top: 10px;
  padding: 10px;
  background: #1e293b;
  border-radius: 8px;
  border: 1px solid #334155;
}
.selected-place .place-name {
  font-size: 0.9rem;
  color: #93c5fd;
  word-break: break-all;
}
.place-result-item {
  cursor: pointer;
}
.place-result-item:hover {
  background: #334155 !important;
}

/* Avatar */
.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #3b82f6;
  margin-right: 4px;
}
.header-avatar.hidden { display: none; }

.avatar-edit {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #94a3b8;
  overflow: hidden;
  border: 2px solid #475569;
  flex-shrink: 0;
}
.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.list-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 8px;
  border: 1px solid #475569;
  flex-shrink: 0;
}
.list-avatar-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #94a3b8;
  margin-right: 8px;
  flex-shrink: 0;
  border: 1px solid #475569;
}

.clickable-user {
  cursor: pointer;
  transition: background 0.15s;
}
.clickable-user:hover {
  background: #334155 !important;
}
.clickable-user .go-icon {
  opacity: 0.5;
  font-size: 0.85rem;
}
.clickable-user:hover .go-icon {
  opacity: 1;
}
