:root {
  --bg: #0e1014;
  --ink: #e8e4d8;
  --ink-dim: #9a968c;
  --ink-faint: #55524b;
  --amber: #e8b04a;
  --cyan: #7fd4e6;
  --panel: rgba(16, 18, 24, 0.92);
  --panel-line: rgba(255, 255, 255, 0.08);
  --serif: ui-serif, Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}

canvas#base, canvas#overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
}
canvas#base { cursor: grab; }
canvas#base.dragging { cursor: grabbing; }
canvas#base.hovering { cursor: pointer; }
canvas#overlay { pointer-events: none; }

/* ---- top-left: month title ---- */
#hud-tl {
  position: fixed;
  top: 28px;
  left: 34px;
  pointer-events: none;
  user-select: none;
  z-index: 3;
}
#month-name {
  font-family: var(--serif);
  font-size: clamp(44px, 8vw, 96px);
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 0.95;
  color: var(--ink);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
  transition: opacity 0.45s ease;
}
#month-name.fading { opacity: 0.25; }
#month-sub {
  margin-top: 8px;
  font-size: clamp(13px, 1.6vw, 17px);
  color: var(--ink-dim);
  letter-spacing: 0.08em;
}
#mode-note {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--ink-faint);
  max-width: 340px;
  letter-spacing: 0.02em;
}

/* ---- top-right: controls ---- */
#hud-tr {
  position: fixed;
  top: 26px;
  right: 26px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  z-index: 5;
}
#chips { display: flex; gap: 6px; }
.chip, #tour-btn, #share-btn, #people-btn {
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  color: var(--ink-dim);
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.chip:hover, #tour-btn:hover, #share-btn:hover, #people-btn:hover { color: var(--ink); border-color: rgba(255,255,255,0.22); }
.chip.active, #people-btn.active { color: var(--bg); background: var(--ink); border-color: var(--ink); font-weight: 600; }
#share-btn { font-size: 15px; padding: 7px 12px; }

#search-wrap { position: relative; }
#search {
  width: 210px;
  padding: 8px 14px;
  font-size: 13.5px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  color: var(--ink);
  outline: none;
  backdrop-filter: blur(6px);
}
#search:focus { border-color: rgba(232, 176, 74, 0.55); }
#search::placeholder { color: var(--ink-faint); }
#search-results {
  position: absolute;
  top: 42px;
  right: 0;
  width: 260px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  overflow: hidden;
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
#search-results li {
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--ink-dim);
  cursor: pointer;
}
#search-results li.sel, #search-results li:hover { background: rgba(232, 176, 74, 0.14); color: var(--ink); }

/* ---- season dial ---- */
#dial-wrap {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  transition: opacity 0.4s;
  filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.5));
}
#dial-wrap.disabled { opacity: 0.3; pointer-events: none; }
#dial-wrap svg { display: block; }

/* ---- county card ---- */
#card {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 348px;
  background: var(--panel);
  border-left: 1px solid var(--panel-line);
  backdrop-filter: blur(14px);
  padding: 26px 24px 30px;
  overflow-y: auto;
  z-index: 6;
  transform: translateX(0);
  animation: cardIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  scrollbar-width: thin;
}
@keyframes cardIn { from { transform: translateX(60px); opacity: 0; } to { transform: none; opacity: 1; } }
#card-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--ink-dim);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
}
#card-close:hover { color: var(--ink); }
#card h2 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 500;
  padding-right: 26px;
  line-height: 1.15;
}
#card-spark { margin: 16px 0 4px; }
#card-spark-note { font-size: 10.5px; color: var(--ink-faint); margin-bottom: 14px; letter-spacing: 0.02em; }
#card-rain { margin: 2px 0 2px; }
#card-rain-note { font-size: 10.5px; color: var(--ink-faint); margin-bottom: 14px; letter-spacing: 0.02em; }
#card-stats {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 7px;
  font-size: 13.5px;
  border-top: 1px solid var(--panel-line);
  padding-top: 14px;
}
#card-stats dt { color: var(--ink-dim); }
#card-stats dd { text-align: right; font-variant-numeric: tabular-nums; }
.est-badge {
  font-size: 9.5px;
  color: var(--amber);
  border: 1px solid rgba(232, 176, 74, 0.4);
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 6px;
  vertical-align: 1px;
}
/* ---- tour ---- */
#tour-caption {
  position: fixed;
  bottom: 110px;
  left: 34px;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  padding: 16px 40px 14px 18px;
  backdrop-filter: blur(10px);
  z-index: 7;
  animation: cardIn 0.4s ease;
}
#tour-text { font-family: var(--serif); font-size: 16.5px; line-height: 1.4; }
#tour-exit {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: var(--ink-dim);
  font-size: 20px;
  cursor: pointer;
}
#tour-dots { display: flex; gap: 5px; margin-top: 10px; }
#tour-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint); }
#tour-dots span.on { background: var(--amber); }

/* ---- misc ---- */
#tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
  z-index: 8;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}
#tooltip b { color: var(--amber); font-weight: 600; }
#toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 999px;
  z-index: 9;
}
#hint {
  position: fixed;
  bottom: 30px;
  left: 34px;
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  z-index: 2;
  transition: opacity 1.2s;
}
#hint.gone { opacity: 0; }
#credit {
  position: fixed;
  bottom: 10px;
  right: 12px;
  font-size: 10.5px;
  color: var(--ink-faint);
  text-decoration: none;
  z-index: 2;
}
#credit:hover { color: var(--ink-dim); }

/* ---- mobile ---- */
@media (max-width: 640px) {
  #hud-tl { top: 16px; left: 18px; }
  #month-name { font-size: 40px; }
  #mode-note { max-width: 240px; }
  #hud-tr {
    top: auto;
    bottom: 88px;
    right: 12px;
    left: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  #search { width: 150px; }
  #search-results { bottom: 44px; top: auto; }
  #card {
    top: auto;
    bottom: 0;
    height: auto;
    max-height: 58vh;
    width: 100vw;
    border-left: none;
    border-top: 1px solid var(--panel-line);
    border-radius: 18px 18px 0 0;
    animation: sheetIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  @keyframes sheetIn { from { transform: translateY(80px); opacity: 0; } to { transform: none; opacity: 1; } }
  #dial-wrap { bottom: 14px; }
  #hint { display: none; }
  #tour-caption { left: 12px; right: 12px; max-width: none; bottom: 150px; }
}
