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

:root {
  --panel-bg: rgba(255, 255, 255, 0.92);
  --ink: #23305a;
  --accent: #ff5c8a;
  --radius: 18px;
  --shadow: 0 6px 0 rgba(35, 48, 90, 0.18), 0 12px 30px rgba(35, 48, 90, 0.15);
  font-family: "Avenir Next", "Nunito", "Segoe UI", system-ui, sans-serif;
}

html, body { height: 100%; overflow: hidden; }

body {
  background: linear-gradient(#7ec8ff 0%, #b9e4ff 45%, #e8f8e0 100%);
  color: var(--ink);
  user-select: none;
}

#scene { position: fixed; inset: 0; display: block; }

/* ---------- panels ---------- */
.panel {
  background: var(--panel-bg);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  pointer-events: auto;
}

#hud-topleft {
  position: fixed; top: 14px; left: 14px; z-index: 5;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
  pointer-events: none;
}
#hud-topright {
  position: fixed; top: 14px; right: 14px; z-index: 5; pointer-events: none;
}

.title-panel { display: flex; flex-direction: column; align-items: stretch; }
.app-title { font-weight: 900; font-size: 20px; letter-spacing: 0.5px; line-height: 1.05; }
.app-title span { display: block; font-size: 12px; color: var(--accent); letter-spacing: 2px; }

/* collapsible top-left group (title toggles PLZ + weather) */
.loc-toggle {
  display: flex; align-items: center; gap: 12px;
  background: none; border: none; padding: 0; cursor: pointer;
  color: inherit; font: inherit; text-align: left;
}
.chev { font-size: 13px; font-weight: 900; margin-left: auto; transition: transform .15s; }
.loc-body { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; pointer-events: none; }
.loc-summary { display: none; margin-top: 7px; font-weight: 800; font-size: 12px; color: #46507a; }
#hud-topleft.collapsed .loc-body { display: none; }
#hud-topleft.collapsed .loc-summary { display: block; }
#hud-topleft.collapsed .title-panel .chev { transform: rotate(-90deg); }

.place-panel { display: flex; flex-direction: column; gap: 8px; }
.plz-chip {
  border: 2.5px solid var(--ink); background: #ffe066; color: var(--ink);
  font-weight: 800; font-size: 14px; padding: 7px 12px; border-radius: 12px;
  cursor: pointer; box-shadow: 0 3px 0 rgba(35,48,90,.25); text-align: center;
}
.plz-chip:active { transform: translateY(2px); box-shadow: none; }
.radius-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 800; font-size: 12.5px; }
.radius-row select {
  border: 2.5px solid var(--ink); border-radius: 10px; background: #fff; color: var(--ink);
  font-weight: 800; font-size: 12.5px; padding: 5px 8px; cursor: pointer;
}

/* ---------- weather widget ---------- */
.weather-panel { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 190px; }
.weather-panel.wx-off { opacity: 0.65; }
.wx-info { display: flex; align-items: center; gap: 9px; }
.wx-emoji { font-size: 26px; line-height: 1; }
.wx-text { line-height: 1.05; }
.wx-temp { font-weight: 900; font-size: 17px; }
.wx-cond { font-weight: 700; font-size: 11.5px; color: #5a648c; }

.switch { position: relative; width: 46px; height: 26px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .slider {
  position: absolute; inset: 0; border: 2.5px solid var(--ink); border-radius: 999px;
  background: #cdd6ea; transition: background .15s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 2.5px;
  background: #fff; border: 2px solid var(--ink); border-radius: 50%; transition: transform .15s;
}
.switch input:checked + .slider { background: #3ddc84; }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---------- lightning flash ---------- */
#flash {
  position: fixed; inset: 0; z-index: 3; pointer-events: none;
  background: #fbfdff; opacity: 0; mix-blend-mode: screen;
}

/* ---------- type filter ---------- */
.filter-panel { width: 210px; }
.filter-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 900; font-size: 13px; margin-bottom: 8px; }
.filter-toggle {
  display: flex; align-items: center; gap: 8px; flex: 1; white-space: nowrap;
  background: none; border: none; padding: 0; cursor: pointer;
  color: inherit; font: inherit; font-weight: 900; font-size: 13px; text-align: left;
}
.filter-panel.collapsed { width: auto; }
.filter-panel.collapsed .filter-head { margin-bottom: 0; }
.filter-panel.collapsed #filter-body { display: none; }
.filter-panel.collapsed .mini-btn { display: none; }
.filter-panel.collapsed .chev { transform: rotate(-90deg); }
.mini-btn {
  border: 2px solid var(--ink); background: #eef2ff; border-radius: 9px; color: var(--ink);
  font-weight: 800; font-size: 11px; padding: 3px 8px; cursor: pointer;
}
.mini-btn:hover { background: #ffe066; }
.type-filter { display: flex; flex-direction: column; gap: 6px; }
.type-btn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  border: 2.5px solid var(--ink); border-radius: 11px; background: #fff;
  padding: 6px 9px; cursor: pointer; font-weight: 800; font-size: 13px; color: var(--ink);
  transition: opacity .12s, filter .12s;
}
.type-btn .swatch { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--ink); flex: none; }
.type-btn .emoji { font-size: 15px; }
.type-btn .cnt { margin-left: auto; font-size: 11px; font-weight: 800; color: #5a648c; }
.type-btn.off { opacity: 0.4; filter: grayscale(0.8); background: #eef1f7; }
.filter-hint { margin-top: 9px; font-size: 10.5px; font-weight: 700; color: #5a648c; line-height: 1.4; }

/* ---------- timeline + week list ---------- */
#hud-bottom {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  width: min(900px, calc(100vw - 28px)); z-index: 5;
  display: flex; flex-direction: column; gap: 10px;
}
.timeline-panel { padding: 12px 16px 8px; }
.tl-row { display: flex; align-items: center; gap: 12px; }
.tl-info { margin-bottom: 6px; }

.today-btn {
  height: 44px; border-radius: 14px; border: 3px solid var(--ink);
  background: #fff; color: var(--ink); font-size: 13px; font-weight: 800;
  cursor: pointer; padding: 0 14px; box-shadow: 0 4px 0 rgba(35,48,90,.25);
  letter-spacing: .3px;
}
.today-btn:active { transform: translateY(2px); box-shadow: none; }

.big-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 3px solid var(--ink);
  background: #3ddc84; color: var(--ink); font-size: 19px; font-weight: 900;
  cursor: pointer; box-shadow: 0 4px 0 rgba(35,48,90,.25);
}
.big-btn.paused { background: #ffd23f; }
.big-btn:active { transform: translateY(2px); box-shadow: none; }

.speed-btn {
  border: 2.5px solid var(--ink); background: #fff; border-radius: 12px;
  font-weight: 800; font-size: 12.5px; padding: 8px 10px; cursor: pointer; color: var(--ink);
  box-shadow: 0 3px 0 rgba(35,48,90,.2);
}
.speed-btn:active { transform: translateY(2px); box-shadow: none; }

.clock { font-weight: 900; font-size: 17px; flex: 1; }
.active-count { font-weight: 800; font-size: 13px; color: #5a648c; }

#density { width: 100%; height: 26px; display: block; border-radius: 6px; }

.track {
  position: relative; flex: 1; height: 22px; margin: 6px 0 4px;
  background: #dfe6f7; border: 2.5px solid var(--ink); border-radius: 12px;
  cursor: pointer; touch-action: none;
}
.track-fill {
  position: absolute; inset: 0; width: 0%; border-radius: 9px;
  background: linear-gradient(90deg, #6fc3ff, #ff5c8a);
}
.playhead {
  position: absolute; top: 50%; left: 0%;
  width: 30px; height: 30px; transform: translate(-50%, -50%);
  background: #fff; border: 3px solid var(--ink); border-radius: 50%;
  box-shadow: 0 3px 0 rgba(35,48,90,.3); cursor: grab;
}
.playhead::after {
  content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--accent);
}
.months { display: flex; font-size: 11px; font-weight: 800; color: #5a648c; padding: 0 4px; }

/* week list */
.week-panel { padding: 10px 14px 12px; }
.week-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
#week-label { font-weight: 900; font-size: 14px; }
.week-sub { font-weight: 700; font-size: 12px; color: #5a648c; }
.week-list {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: thin;
}
.week-list::-webkit-scrollbar { height: 7px; }
.week-list::-webkit-scrollbar-thumb { background: #c4cef0; border-radius: 4px; }
.wk-card {
  flex: 0 0 auto; width: 150px; text-align: left;
  border: 2.5px solid var(--ink); border-radius: 12px; background: #fff;
  padding: 7px 9px; cursor: pointer; color: var(--ink);
  border-left-width: 7px; transition: transform .1s, box-shadow .1s, background .1s;
}
.wk-card:hover { transform: translateY(-2px); box-shadow: 0 4px 0 rgba(35,48,90,.2); }
.wk-card.live { background: #fff7d6; box-shadow: 0 0 0 3px rgba(255,92,138,.5); }
.wk-card .wk-name { font-weight: 800; font-size: 12px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-card .wk-meta { font-weight: 700; font-size: 10.5px; color: #5a648c; margin-top: 3px; }
.wk-card .wk-top { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.wk-card .wk-emoji { font-size: 13px; }
.wk-card .wk-live-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; display: none; }
.wk-card.live .wk-live-dot { display: block; box-shadow: 0 0 0 3px rgba(61,220,132,.35); }
.week-empty { font-weight: 700; font-size: 12.5px; color: #5a648c; padding: 6px 2px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(35, 48, 90, 0.45); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal-backdrop.hidden { display: none; }
.modal {
  width: min(430px, calc(100vw - 40px));
  background: #fff; border: 4px solid var(--ink); border-radius: 26px;
  box-shadow: 0 10px 0 rgba(35,48,90,.3), 0 24px 60px rgba(0,0,0,.35);
  padding: 28px 28px 22px; text-align: center;
}
.modal-emoji { font-size: 46px; }
.modal h1 { font-size: 26px; font-weight: 900; margin: 6px 0 8px; }
.modal p { font-size: 14px; color: #5a648c; font-weight: 600; margin-bottom: 18px; }
#plz-form { display: flex; gap: 10px; max-width: 100%; }
#plz-input {
  flex: 1; min-width: 0; font-size: 22px; font-weight: 900; letter-spacing: 3px; text-align: center;
  border: 3px solid var(--ink); border-radius: 14px; padding: 10px; color: var(--ink); outline: none;
}
#plz-input:focus { border-color: var(--accent); }
#plz-form button {
  border: 3px solid var(--ink); background: var(--accent); color: #fff;
  font-weight: 900; font-size: 15px; padding: 0 18px; border-radius: 14px; cursor: pointer;
  box-shadow: 0 4px 0 rgba(35,48,90,.25);
}
#plz-form button:active { transform: translateY(2px); box-shadow: none; }
.plz-error { min-height: 20px; color: #d33; font-weight: 700; font-size: 13px; margin-top: 8px; }
.chips { margin-top: 8px; font-size: 12px; font-weight: 700; color: #5a648c;
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.chips button {
  border: 2px solid var(--ink); background: #eef2ff; border-radius: 10px; color: var(--ink);
  font-weight: 800; font-size: 12px; padding: 5px 9px; cursor: pointer;
}
.chips button:hover { background: #ffe066; }

/* ---------- event detail card ---------- */
.detail-card {
  position: fixed; z-index: 15; left: 50%; top: 96px; transform: translateX(-50%);
  width: min(400px, calc(100vw - 28px));
  background: #fff; border: 3px solid var(--ink); border-radius: 20px;
  box-shadow: 0 10px 0 rgba(35,48,90,.22), 0 20px 50px rgba(35,48,90,.28);
  padding: 18px 20px 20px; pointer-events: auto;
}
.detail-card.hidden { display: none; }
.detail-close {
  position: absolute; top: 12px; right: 12px; width: 30px; height: 30px;
  border: 2.5px solid var(--ink); background: #fff; border-radius: 10px;
  font-weight: 900; font-size: 14px; color: var(--ink); cursor: pointer; line-height: 1;
}
.detail-close:hover { background: #ffe066; }
.detail-type {
  display: inline-block; font-weight: 900; font-size: 12px; color: #fff;
  border-radius: 9px; padding: 3px 10px; border: 2px solid var(--ink); margin-right: 34px;
}
.detail-name { font-size: 20px; font-weight: 900; line-height: 1.15; margin: 9px 0 10px; }
.detail-meta { display: flex; flex-direction: column; gap: 3px; font-weight: 700; font-size: 13px; color: #46507a; margin-bottom: 11px; }
.detail-meta .wx { color: #5a648c; }
.detail-desc { font-size: 13.5px; font-weight: 500; line-height: 1.5; color: #2c3557; margin-bottom: 15px; }
.detail-link {
  display: inline-block; text-decoration: none; max-width: 100%; box-sizing: border-box;
  border: 3px solid var(--ink); background: var(--accent); color: #fff;
  font-weight: 900; font-size: 13.5px; padding: 9px 15px; border-radius: 13px;
  box-shadow: 0 4px 0 rgba(35,48,90,.25);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
}
.detail-link:hover { filter: brightness(1.05); }
.detail-link:active { transform: translateY(2px); box-shadow: none; }
.detail-src { margin-top: 10px; font-size: 10.5px; font-weight: 700; color: #8a93b4; }

/* ---------- tooltip ---------- */
#tooltip {
  position: fixed; z-index: 10; pointer-events: none; display: none;
  background: var(--panel-bg); border: 3px solid var(--ink); border-radius: 14px;
  box-shadow: var(--shadow); padding: 10px 13px; max-width: 260px; font-size: 13px;
}
#tooltip .t-name { font-weight: 900; font-size: 14px; margin-bottom: 3px; }
#tooltip .t-line { font-weight: 700; color: #5a648c; }
#tooltip .t-type { display: inline-block; font-weight: 900; font-size: 11px; color: #fff;
  border-radius: 8px; padding: 2px 8px; margin-bottom: 4px; border: 2px solid var(--ink); }

/* ---------- legal fine print ---------- */
#legal-footer {
  position: fixed; right: 8px; bottom: 3px; z-index: 6;
  font-size: 9.5px; font-weight: 600; color: rgba(35, 48, 90, 0.55);
  pointer-events: auto; user-select: none;
}
#legal-footer a {
  color: inherit; text-decoration: none;
}
#legal-footer a:hover { color: var(--ink); text-decoration: underline; }

.legal-modal { position: relative; text-align: left; }
.legal-modal h2 { font-size: 19px; font-weight: 900; margin-bottom: 12px; margin-right: 34px; }
.legal-modal p { font-size: 13px; font-weight: 500; line-height: 1.55; color: #2c3557; margin-bottom: 10px; }
.legal-modal a { color: var(--accent); font-weight: 700; }

@media (max-width: 720px) {
  .filter-panel { width: 170px; }
  .app-title { font-size: 16px; }
  #hud-topleft { top: 10px; left: 10px; gap: 7px; }
  #hud-topright { top: 10px; right: 10px; }
  .loc-body { gap: 7px; }
  .panel { padding: 8px 11px; }

  /* condensed timeline */
  #hud-bottom { bottom: 8px; width: calc(100vw - 16px); gap: 6px; }
  .timeline-panel { padding: 8px 10px 6px; }
  .tl-row { gap: 8px; }
  .tl-info { margin-bottom: 2px; }
  .today-btn { height: 34px; font-size: 11px; border-radius: 11px; padding: 0 10px; }
  .big-btn { width: 34px; height: 34px; font-size: 15px; border-radius: 11px; }
  .speed-btn { font-size: 11px; padding: 6px 8px; }
  .clock { font-size: 13px; }
  .active-count { font-size: 11px; }
  #density { height: 14px; }
  .track { height: 18px; margin: 4px 0 2px; }
  .playhead { width: 24px; height: 24px; }
  .months { font-size: 10px; }

  /* condensed week strip */
  .week-panel { padding: 7px 10px 8px; }
  .week-head { margin-bottom: 5px; }
  #week-label { font-size: 12.5px; }
  .week-sub { font-size: 11px; }
  .wk-card { width: 128px; padding: 5px 7px; }
  .wk-card .wk-name { font-size: 11px; }
  .wk-card .wk-meta { font-size: 9.5px; margin-top: 2px; }
}
