:root {
  --bg: #0a0e1a;
  --panel: rgba(22, 29, 50, 0.72);
  --cell: rgba(255, 255, 255, 0.025);
  --ink: #efe9da;
  --muted: #8f95a8;
  --faint: #5d6377;
  --line: rgba(239, 233, 218, 0.1);
  --gold: #e9d39b;
  --sun: #e59a8f;
  --sat: #93acd8;
  --serif: "Shippori Mincho", "Yu Mincho", serif;
  --sans: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); color-scheme: dark; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 70% 38% at 70% 0%, rgba(64, 80, 140, 0.35) 0%, transparent 70%),
    radial-gradient(ellipse 60% 30% at 10% 30%, rgba(40, 52, 100, 0.25) 0%, transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }
.stars { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.stars svg { display: block; }

/* ---------- ヘッダー ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 880px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 4px;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-family: var(--serif); font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand-moon { width: 15px; height: 15px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fffaf0, #d8caa4); box-shadow: 0 0 10px rgba(243, 230, 194, 0.45); }
.top nav { display: flex; gap: 14px; font-size: 12px; }
.top nav a { color: var(--muted); text-decoration: none; white-space: nowrap; }

.app { max-width: 880px; margin: 0 auto; padding: 0 16px calc(env(safe-area-inset-bottom) + 40px); }

/* ---------- 次の満月 ---------- */
.hero {
  display: flex; align-items: center; gap: 16px;
  padding: 24px 4px 26px;
}
.moon { width: 84px; height: 84px; flex: none; }
.moon svg, .dm svg, .ic svg { width: 100%; height: 100%; overflow: visible; display: block; }
.label { font-size: 12px; letter-spacing: 0.3em; color: var(--gold); }
.date {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(28px, 8.8vw, 48px); white-space: nowrap; line-height: 1.15; letter-spacing: 0.02em; margin-top: 4px;
}
.date small { font-size: 0.42em; font-weight: 500; margin-left: 0.1em; color: var(--muted); }
.time { font-family: var(--serif); font-size: 18px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.time .name { font-family: var(--sans); font-size: 12px; color: var(--muted); margin-left: 10px; letter-spacing: 0.05em; }
.countdown {
  display: inline-block; margin-top: 10px; padding: 4px 13px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; color: var(--muted);
}
.countdown b { color: var(--ink); font-weight: 500; font-size: 15px; }

/* ---------- 月カレンダー ---------- */
.cal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px 10px 16px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.nav { width: 44px; height: 44px; font-size: 28px; line-height: 1; color: var(--muted); border-radius: 50%; }
.nav:disabled { opacity: 0.2; }
.cal-title { position: relative; font-family: var(--serif); font-size: 15px; color: var(--muted); text-align: center; }
.cal-title b { font-size: 26px; color: var(--ink); font-weight: 700; margin: 0 2px; }
.cal-title small { font-size: 13px; margin-left: 4px; }
.cal-title input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.today-btn { display: block; margin: 0 auto; font-size: 12px; color: var(--gold); padding: 2px 10px; }

.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-top: 8px; touch-action: pan-y; }
.wd { text-align: center; font-size: 11px; color: var(--faint); padding: 4px 0 6px; }
.wd.sun { color: var(--sun); opacity: 0.75; }
.wd.sat { color: var(--sat); opacity: 0.75; }
.day {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  min-height: 86px; padding: 6px 0 5px;
  background: var(--cell);
  border: 1px solid transparent; border-radius: 10px;
  transition: border-color 0.15s, background 0.15s;
}
.day:hover { background: rgba(255, 255, 255, 0.05); }
.day .num { font-size: 12px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.day.sun .num { color: var(--sun); }
.day.sat .num { color: var(--sat); }
.day .ic { width: 30px; height: 30px; margin-top: 5px; }
.day .age { font-size: 10px; color: var(--faint); margin-top: 3px; font-variant-numeric: tabular-nums; }
.day .ev { margin-top: 2px; font-size: 9.5px; line-height: 1.2; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.day .ev i { display: block; font-style: normal; }
.day .rs { display: none; }
.day.full {
  background: radial-gradient(circle at 50% 38%, rgba(243, 230, 194, 0.22), rgba(233, 211, 155, 0.06) 65%);
  border-color: rgba(233, 211, 155, 0.35);
}
.day.full .ic { filter: drop-shadow(0 0 6px rgba(243, 230, 194, 0.7)); }
.day.full .ev, .day.full .age { color: var(--gold); }
.day.today .num {
  background: var(--ink); color: var(--bg);
  border-radius: 999px; padding: 1px 6px;
}
.day.sel { border-color: rgba(233, 211, 155, 0.7); }
.month-link { display: block; margin: 12px 4px 0; font-size: 13px; color: var(--gold); text-decoration: none; }
.cal-note { margin: 12px 4px 0; font-size: 11px; color: var(--faint); line-height: 1.6; }

.detail { margin-top: 12px; padding: 18px; background: rgba(0, 0, 0, 0.22); border-radius: 14px; }
.dh { display: flex; gap: 16px; align-items: center; }
.dm { width: 64px; height: 64px; flex: none; }
.dd { font-family: var(--serif); font-size: 21px; font-weight: 500; }
.dd small { font-size: 13px; color: var(--muted); }
.hol { font-size: 12px; color: var(--sun); margin-top: 2px; }
.ph { font-size: 14px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.ph.gold { color: var(--gold); }
.tg { font-size: 12px; color: var(--gold); margin-top: 2px; }
.detail dl { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.detail dl div { text-align: center; }
.detail dt { font-size: 11px; color: var(--muted); }
.detail dd { font-family: var(--serif); font-size: 18px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.place { margin-top: 12px; font-size: 12px; color: var(--muted); }
.place span { color: var(--ink); }
.place u { color: var(--gold); text-decoration: none; }

/* ---------- これからの満月 ---------- */
.upcoming, .reads { margin-top: 48px; padding: 0 4px; }
.upcoming h2, .reads h2 {
  font-size: 13px; font-weight: 500; letter-spacing: 0.2em; color: var(--muted);
  padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.list { list-style: none; }
.list li {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; row-gap: 2px;
  padding: 14px 2px; border-bottom: 1px solid var(--line);
}
.list .d { font-family: var(--serif); font-size: 19px; font-weight: 500; }
.list .d small { font-size: 13px; color: var(--muted); margin-left: 2px; }
.list .t { font-family: var(--serif); font-size: 17px; font-variant-numeric: tabular-nums; color: var(--muted); }
.list .n { grid-column: 1 / -1; font-size: 12px; color: var(--faint); }
.list .tag { grid-column: 1 / -1; font-size: 12px; color: var(--gold); }
.list li.next .d, .list li.next .t { color: var(--gold); }
.add {
  display: block; width: 100%; margin-top: 24px; padding: 15px;
  font-size: 15px; font-weight: 500; color: var(--bg); background: var(--gold); border-radius: 12px;
}
.add:active { opacity: 0.85; }

.reads ul { list-style: none; }
.reads li a {
  display: block; padding: 14px 2px; border-bottom: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-size: 15px; line-height: 1.6;
}
.reads .more { display: inline-block; margin-top: 14px; font-size: 13px; color: var(--gold); text-decoration: none; }

.note { margin-top: 40px; font-size: 11px; line-height: 1.7; color: var(--faint); text-align: center; }
.foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 14px; }
.foot-links a { color: var(--muted); text-decoration: none; }

/* ---------- 地点の選択 ---------- */
.sheet {
  margin: auto auto 0; width: 100%; max-width: 460px;
  border: 0; border-radius: 20px 20px 0 0;
  background: #141a2c; color: var(--ink);
  padding: 24px 20px calc(env(safe-area-inset-bottom) + 20px);
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.55); }
.sheet h2 { font-size: 15px; font-weight: 500; text-align: center; margin-bottom: 20px; }
.geo { width: 100%; padding: 14px; border-radius: 12px; background: var(--gold); color: var(--bg); font-weight: 500; }
.geo-msg { font-size: 12px; color: var(--muted); text-align: center; min-height: 1.6em; margin: 8px 0; }
.pref { display: block; font-size: 12px; color: var(--muted); }
.pref select {
  display: block; width: 100%; margin-top: 6px; padding: 13px 12px;
  font: inherit; font-size: 15px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
}
.close { display: block; width: 100%; margin-top: 16px; padding: 12px; color: var(--muted); }

/* ---------- 広い画面 ---------- */
@media (min-width: 760px) {
  .top { padding-top: 22px; }
  .top nav { font-size: 13px; gap: 20px; }
  .hero { justify-content: center; gap: 40px; padding: 44px 0 40px; }
  .date { font-size: 52px; }
  .moon { width: 150px; height: 150px; }
  .cal { padding: 20px 20px 22px; }
  .grid { gap: 5px; }
  .day { min-height: 128px; padding: 8px 0 8px; }
  .day .num { font-size: 14px; }
  .day .ic { width: 40px; height: 40px; margin-top: 6px; }
  .day .age { font-size: 11px; }
  .day .ev { font-size: 11px; }
  .day .ev i { display: inline; margin-left: 3px; }
  .day .rs { display: block; margin-top: auto; padding-top: 4px; font-size: 10.5px; line-height: 1.45; color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; }
  .upcoming, .reads { max-width: 560px; margin-left: auto; margin-right: auto; }
}
