:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #dfe2e6;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent: #3388ff;
  --error: #d1453b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1e2126;
    --border: #2c3038;
    --text: #eef0f2;
    --muted: #9aa1ab;
    --accent: #5b9bff;
    --error: #ff6b61;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Login */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 1.4rem;
}

.login-card .muted {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: 0.9rem;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  margin-bottom: 12px;
  font-size: 1rem;
}

.login-card button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.error {
  color: var(--error);
  font-size: 0.9rem;
}

/* Dashboard */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
}

.topbar .logout {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.dash {
  display: grid;
  grid-template-columns: 1fr 320px;
  height: calc(100vh - 53px);
}

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

.panel {
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.pet-name {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.stat {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.stat .label {
  color: var(--muted);
}

.range-select {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.range-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

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

.boost-btn {
  width: 100%;
  margin-top: 16px;
  padding: 10px 0;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
}

.boost-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.boost-status {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 8px 0 0;
  min-height: 1.2em;
}

.boost-status.clickable {
  cursor: pointer;
  text-decoration: underline;
}

.hint {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 16px;
  min-height: 1.2em;
}

.leaderboard {
  margin-top: auto;
  padding-top: 16px;
}

.leaderboard-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-empty {
  color: var(--muted);
  font-size: 0.85rem;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: var(--bg);
  text-align: left;
  width: 100%;
  color: var(--text);
  font: inherit;
}

.leaderboard-item:hover {
  border-color: var(--accent);
}

.leaderboard-rank {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.leaderboard-info {
  min-width: 0;
}

.leaderboard-address {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 560px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.modal h2 {
  margin: 0 24px 4px 0;
  font-size: 1.1rem;
}

.modal-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 12px;
}

#trip-modal-map {
  width: 100%;
  height: 320px;
  border-radius: 8px;
}

@media (max-width: 720px) {
  .dash {
    grid-template-columns: 1fr;
    grid-template-rows: 55vh 1fr;
    height: auto;
    min-height: calc(100vh - 53px);
  }

  .panel {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  #trip-modal-map {
    height: 220px;
  }
}
