:root {
  --bg: #111827;
  --panel: #1f2937;
  --accent: #2563eb;
  --accent-2: #16a34a;
  --text: #f9fafb;
  --muted: #9ca3af;
  --danger: #ef4444;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior: none;
}

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

.hidden {
  display: none !important;
}

/* ---- ログイン ---- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #0f172a, #1e293b);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border-radius: 18px;
  padding: 28px 24px calc(24px + var(--safe-bottom));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.25;
}

.login-card .sub {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.login-welcome {
  margin: 0 0 12px;
  padding: 8px 10px;
  background: rgba(96, 165, 250, 0.12);
  border-radius: 8px;
  font-size: 13px;
  color: #93c5fd;
}

.login-device-id {
  margin: 10px 0 0;
  font-size: 10px;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.4;
}

.login-card .wide {
  width: 100%;
  margin-top: 8px;
}

.login-card label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

.login-card input[type="text"] {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #374151;
  background: #0b1220;
  color: var(--text);
  font-size: 16px;
}

.consent {
  display: flex !important;
  gap: 10px;
  align-items: flex-start;
  line-height: 1.5;
  margin-top: 4px;
}

.consent input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

#startBtn {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

#startBtn:disabled {
  background: #374151;
  color: #6b7280;
}

.error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 8px 0 0;
}

/* ---- トップバー ---- */
#topbar {
  position: fixed;
  top: calc(10px + var(--safe-top));
  left: 10px;
  right: 10px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(31, 41, 55, 0.92);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.on {
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.25);
  animation: pulse 1.6s infinite;
}

.dot.off {
  background: var(--muted);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.metric {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.metric strong {
  font-size: 20px;
}

.metric span {
  font-size: 12px;
  color: var(--muted);
}

.ghost {
  border: 1px solid #374151;
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

/* ---- サイドパネル ---- */
#panel {
  position: fixed;
  top: calc(64px + var(--safe-top));
  right: 10px;
  z-index: 500;
  width: 220px;
  max-height: 50vh;
  overflow-y: auto;
  background: rgba(31, 41, 55, 0.95);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

#panel h2 {
  margin: 0 0 10px;
  font-size: 14px;
}

.user-id-line {
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 10px;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.4;
}

#onlineList {
  list-style: none;
  margin: 0;
  padding: 0;
}

#onlineList li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#onlineList li:last-child {
  border-bottom: none;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.li-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.li-dist {
  color: var(--muted);
  font-size: 12px;
}

/* ---- 下部コントロール ---- */
#controls {
  position: fixed;
  bottom: calc(18px + var(--safe-bottom));
  left: 0;
  right: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 16px;
}

.round {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--panel);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.primary {
  flex: 1;
  max-width: 320px;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: var(--accent-2);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.primary.tracking {
  background: var(--danger);
}

/* ---- カバレッジ設定パネル ---- */
#coveragePanel {
  position: fixed;
  top: calc(64px + var(--safe-top));
  left: 10px;
  z-index: 500;
  width: 240px;
  background: rgba(31, 41, 55, 0.95);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.cov-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.cov-row select {
  flex: 1;
  margin-left: 8px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #374151;
  background: #0b1220;
  color: var(--text);
  font-size: 14px;
}

.cov-hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.ghost.active {
  background: var(--accent);
  border-color: var(--accent);
}

/* ---- 看板登録 ---- */
#pickHint {
  position: fixed;
  top: calc(70px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
}

#pickCancel {
  border: none;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
}

.sign-card {
  max-height: 90vh;
  overflow-y: auto;
}

.sign-card h2 {
  margin: 0 0 16px;
  font-size: 20px;
}

.sign-card select,
.sign-card textarea,
.sign-card input[type="text"],
.sign-card input[type="date"],
.sign-card input[type="file"] {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid #374151;
  background: #0b1220;
  color: var(--text);
  font-size: 15px;
}

.sign-card textarea {
  resize: vertical;
  font-family: inherit;
}

.two-col {
  display: flex;
  gap: 12px;
}

.two-col > label {
  flex: 1;
}

.btn.wide,
.wide {
  flex: 1;
}

button.wide {
  margin-top: 6px;
}

#signPreviewWrap {
  margin-bottom: 14px;
}

#signPreview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 10px;
}

/* 看板マーカーのポップアップ（チェキ詳細は cheki.css） */

.sign-popup .meta {
  font-size: 12px;
  color: #4b5563;
  line-height: 1.6;
}

.sign-popup .expired {
  color: var(--danger);
  font-weight: 700;
}

.sign-pin {
  font-size: 26px;
  line-height: 1;
  text-align: center;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

/* Leaflet マーカーのラベル */
.user-label {
  background: rgba(17, 24, 39, 0.85);
  color: #fff;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  border: none;
  box-shadow: none;
}

.me-marker {
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4);
}
