:root {
  --bg: #070b1a;
  --card: rgba(18, 26, 51, 0.94);
  --text: #f4f7ff;
  --muted: #a8b3d6;
  --sun: #ffd54a;
  --accent: #7cf0c2;
  --water: #3db8ff;
  --mud: #e8d0a8;
  --pink: #ff8fb8;
  --safe: max(12px, env(safe-area-inset-bottom));
  --tap: 52px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Apple SD Gothic Neo", "Segoe UI", "Noto Sans KR", sans-serif;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 15% 0%, #1a2450 0%, transparent 40%),
    radial-gradient(circle at 90% 10%, #2a1848 0%, transparent 35%),
    var(--bg);
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 12px calc(88px + var(--safe));
}

@media (min-width: 900px) {
  .wrap { max-width: 1040px; padding-bottom: 40px; }
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand .avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(124, 240, 194, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 213, 74, 0.15);
  flex-shrink: 0;
  background: #1a2035;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.05rem, 4.2vw, 1.45rem);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-switch {
  display: flex;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  padding: 3px;
  border: 1px solid rgba(255,255,255,0.1);
}

.mode-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  padding: 8px 12px;
  border-radius: 999px;
  min-height: 40px;
  cursor: pointer;
}

.mode-switch button.on {
  background: linear-gradient(135deg, #5b8cff, #7cf0c2);
  color: #071018;
}

.loc {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(61,184,255,0.12);
  border: 1px solid rgba(61,184,255,0.3);
  color: #9fdfff;
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.date-card h2 { margin-bottom: 10px; }

.date-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.date-label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.date-input {
  font: inherit;
  font-weight: 700;
  min-height: var(--tap);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.35);
  color: var(--text);
  color-scheme: dark;
  flex: 1 1 auto;
  min-width: 9rem;
  max-width: 100%;
}

.date-result {
  margin: 10px 0 0;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--sun);
  text-align: center;
}

.card {
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.22);
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.muted { color: var(--muted); font-size: 0.92rem; }

/* Kid hero */
.kid-hero {
  text-align: center;
  padding: 8px 4px 4px;
}

.kid-moon {
  width: min(200px, 56vw);
  height: min(200px, 56vw);
  margin: 8px auto 12px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,0.15);
  box-shadow: 0 0 40px rgba(232,238,252,0.15);
  background: #0b1020;
}

.kid-moon canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.kid-title {
  font-size: clamp(1.4rem, 6vw, 1.9rem);
  font-weight: 900;
  color: var(--sun);
  margin: 0 0 4px;
}

.kid-sub {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 1.05rem;
}

/* Big kid buttons */
.kid-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.kid-btn {
  min-height: 88px;
  border: 0;
  border-radius: 18px;
  font: inherit;
  font-weight: 900;
  font-size: 1.05rem;
  cursor: pointer;
  color: #071018;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 8px;
  transition: transform 0.1s ease;
}

.kid-btn:active { transform: scale(0.97); }
.kid-btn .e { font-size: 1.8rem; line-height: 1; }
.kid-btn.water { background: linear-gradient(145deg, #7ad7ff, #3db8ff); }
.kid-btn.mud { background: linear-gradient(145deg, #f0d9a8, #c4a574); }
.kid-btn.moon { background: linear-gradient(145deg, #fff0a8, #ffd54a); }
.kid-btn.save { background: linear-gradient(145deg, #a6f5d4, #7cf0c2); grid-column: 1 / -1; min-height: 64px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(72px + var(--safe));
  transform: translateX(-50%) translateY(20px);
  background: rgba(124, 240, 194, 0.95);
  color: #071018;
  font-weight: 900;
  padding: 12px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Stickers list */
.sticker-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.sticker {
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.06);
}

.sticker .em { font-size: 1.5rem; }
.sticker .meta { flex: 1; min-width: 0; }
.sticker .meta strong { display: block; font-size: 0.98rem; }
.sticker .meta span { color: var(--muted); font-size: 0.82rem; }

/* Parent / graphs */
.hidden { display: none !important; }

canvas.chart {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  background: #050814;
  touch-action: none;
}

#orbitCanvas { cursor: grab; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}

.controls button,
.btn {
  border: 0;
  border-radius: 999px;
  min-height: var(--tap);
  padding: 10px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(135deg, #5b8cff, #7cf0c2);
  color: #071018;
}

.btn.secondary {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  color: var(--muted);
  font-size: 0.9rem;
}

.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  min-height: 36px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (max-width: 520px) {
  .steps { grid-template-columns: 1fr 1fr; }
}

.step {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  min-height: var(--tap);
}

.step.active {
  border-color: rgba(124,240,194,0.7);
  background: rgba(124,240,194,0.1);
}

.step .e { font-size: 1.3rem; display: block; }
.step .t { font-weight: 800; font-size: 0.88rem; }
.step .h { color: var(--muted); font-size: 0.75rem; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 8px;
}

.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.88rem;
  margin: 4px 4px 0 0;
}

.badge.spring {
  background: rgba(61,184,255,0.15);
  color: #9fdfff;
  border: 1px solid rgba(61,184,255,0.4);
}

.badge.neap {
  background: rgba(196,165,116,0.15);
  color: var(--mud);
  border: 1px solid rgba(196,165,116,0.4);
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.stat {
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 8px;
  text-align: center;
}

.stat .k { color: var(--muted); font-size: 0.78rem; }
.stat .v { font-weight: 900; margin-top: 2px; }

/* Bottom dock for mobile kid mode */
.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 8px 12px calc(8px + var(--safe));
  background: linear-gradient(to top, rgba(7,11,26,0.98), rgba(7,11,26,0.88));
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  gap: 8px;
  justify-content: center;
  z-index: 40;
}

.dock button {
  flex: 1;
  max-width: 200px;
  min-height: var(--tap);
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.dock .primary {
  background: linear-gradient(135deg, #5b8cff, #7cf0c2);
  color: #071018;
}

.dock .ghost {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

footer.note {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 8px;
  padding-bottom: 8px;
}

.parent-only.hidden,
.kid-only.hidden { display: none !important; }
