:root {
  --green: #2f7d4f;
  --green-dark: #245f3d;
  --ink: #1c1c1e;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f5f6f4;
  --card: #ffffff;
  --danger: #d8341f;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  --radius: 14px;
}

* { box-sizing: border-box; }

/* The HTML `hidden` attribute must win over any author `display` rule below
   (e.g. .panel { display:flex }), otherwise "hidden" elements stay on screen. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Login ---------- */
.auth-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #d9efe1 0%, transparent 60%),
    linear-gradient(180deg, #eef4ee 0%, #f5f6f4 100%);
}
.auth-card {
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 40px 34px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.auth-logo {
  width: 96px; height: 96px; border-radius: 22px; display: block; margin: 0 auto;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.auth-card h1 { margin: 12px 0 6px; font-size: 26px; letter-spacing: -0.02em; }
.auth-sub { color: var(--muted); margin: 0 0 26px; font-size: 15px; }
.auth-buttons { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.apple-btn { width: 280px; height: 44px; cursor: pointer; }
#google-btn-container { min-height: 44px; display: flex; justify-content: center; }
.auth-disabled {
  font-size: 12.5px; color: var(--muted); background: #f1f2f0;
  border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; width: 280px;
}
.auth-disabled code { background: #e3e6e1; padding: 1px 5px; border-radius: 5px; }
.auth-error {
  background: #fdecea; color: #8a1c0f; border: 1px solid #f5c2bb;
  border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; font-size: 14px;
}
.auth-foot { color: var(--muted); font-size: 12px; margin: 26px 0 0; }

/* ---------- Map shell ---------- */
#map { position: fixed; inset: 0; z-index: 0; }

.toolbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.toolbar-title { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.toolbar-logo { width: 26px; height: 26px; border-radius: 7px; display: block; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tb-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background 0.15s, transform 0.05s;
}
.tb-btn:hover { background: #f0f2ef; }
.tb-btn:active { transform: translateY(1px); }
#btn-add { background: var(--green); color: #fff; border-color: var(--green); }
#btn-add:hover { background: var(--green-dark); }

.map-controls { position: fixed; right: 14px; bottom: 24px; z-index: 1000; }
.round-btn {
  width: 46px; height: 46px; border-radius: 50%; border: none;
  background: #fff; box-shadow: var(--shadow); font-size: 22px; cursor: pointer;
  color: var(--green);
}

.mode-banner {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 1000;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 14px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
  max-width: calc(100% - 28px);
}
.mode-active #map { cursor: crosshair; }
.link-btn { background: none; border: none; color: #9fe3b8; cursor: pointer; font-weight: 600; font-size: 14px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 2000;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 28px);
}
.toast-error { background: var(--danger); }

/* ---------- Marker pins ---------- */
.tm-pin-wrap { background: transparent; border: none; }
.tm-pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  border: 2px solid #fff;
  display: grid; place-items: center;
}
.tm-pin-glyph { transform: rotate(45deg); font-size: 16px; line-height: 1; }

/* ---------- Panel ---------- */
.scrim {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.28); z-index: 1500;
}
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 1600;
  width: 380px; max-width: 100%;
  background: var(--card); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: slidein 0.18s ease-out;
}
@keyframes slidein { from { transform: translateX(20px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.panel-header h2 { margin: 0; font-size: 18px; }
.icon-btn { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--muted); padding: 4px 8px; }
.panel-body { padding: 18px; overflow-y: auto; }

/* ---------- Detail ---------- */
.detail-photo { width: 100%; border-radius: 12px; margin-bottom: 14px; display: block; }
.detail-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.detail-kind { font-weight: 700; font-size: 16px; }
.detail-note { background: #f4f5f2; border-radius: 10px; padding: 12px; margin: 0 0 14px; white-space: pre-wrap; }
.pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill-green { background: #e3f6ea; color: #1b6b3a; }
.pill-amber { background: #fdf0d8; color: #8a5a00; }

.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0 0 18px; font-size: 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; text-align: right; }

/* ---------- Forms & buttons ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 15px; font-family: inherit; background: #fff;
}
textarea.input { resize: vertical; }
.muted { color: var(--muted); font-size: 13px; margin: 0; }

.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.actions-inline { flex-direction: row; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 11px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-align: center; transition: background 0.15s;
}
.btn:hover { background: #f0f2ef; }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: var(--green-dark); }
.btn-danger { color: var(--danger); border-color: #f0c3bb; }
.btn-danger:hover { background: #fdecea; }
.btn-small { padding: 7px 12px; font-size: 13px; flex: 1; min-width: 80px; }
.btn-file { display: inline-flex; align-items: center; justify-content: center; }

hr { border: none; border-top: 1px solid var(--line); margin: 6px 0; }

/* ---------- Areas ---------- */
.area-list { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.area-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.area-title { font-weight: 700; }
.area-desc { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; }

/* ---------- Account ---------- */
.account-head { display: flex; gap: 14px; align-items: center; margin-bottom: 4px; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; background: var(--green); color: #fff;
  display: grid; place-items: center; font-size: 22px; font-weight: 700; flex: 0 0 auto;
}
.account-name { font-weight: 700; font-size: 17px; }
.points { color: var(--green-dark); font-size: 13px; margin-top: 4px; font-weight: 600; }
.toggle-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }

/* ---------- Leaderboard ---------- */
.leaderboard { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.leaderboard li { display: flex; justify-content: space-between; gap: 12px; }
.leaderboard li.me { font-weight: 700; color: var(--green-dark); }
.lb-points { color: var(--muted); }
.leaderboard li.me .lb-points { color: var(--green-dark); }

@media (max-width: 560px) {
  .toolbar-title { display: none; }
  .panel { width: 100%; }
  .tb-btn { padding: 8px 12px; }
}
