:root {
  color-scheme: dark;
  --ink: #fff7e8;
  --muted: #d7dccd;
  --panel: rgba(17, 28, 22, 0.78);
  --panel-strong: rgba(25, 35, 29, 0.9);
  --line: rgba(255, 247, 232, 0.18);
  --accent: #f5c96a;
  --accent-strong: #ffdd86;
  --mint: #8dd8c1;
  --coral: #ff9b80;
  --danger: #ffb3a8;
  --radius: 8px;
  --visual-viewport-height: 100dvh;
  --visual-viewport-top: 0px;
  --keyboard-inset: 0px;
  font-family:
    "Pretendard",
    "Noto Sans KR",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  overflow-x: hidden;
  color: var(--ink);
  background: #05070d;
}

body.is-loading {
  overflow: hidden;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 18%, rgba(245, 201, 106, 0.12), transparent 25%),
    radial-gradient(circle at 82% 72%, rgba(141, 216, 193, 0.1), transparent 28%),
    linear-gradient(160deg, #07101c 0%, #03070d 58%, #07100f 100%);
  opacity: 1;
  visibility: visible;
  transition: opacity 520ms ease, visibility 0s linear 520ms;
}

.loading-screen::before {
  content: "";
  position: absolute;
  inset: -40px;
  opacity: 0.74;
  background-image:
    radial-gradient(circle, rgba(255, 247, 232, 0.94) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(141, 216, 193, 0.78) 0 1px, transparent 1.6px),
    radial-gradient(circle, rgba(245, 201, 106, 0.62) 0 1px, transparent 1.7px);
  background-position: 9px 13px, 37px 61px, 81px 29px;
  background-size: 93px 91px, 137px 131px, 181px 173px;
  animation: loadingSkyDrift 18s linear infinite;
}

.loading-screen.is-leaving {
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.loading-card {
  position: relative;
  z-index: 1;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 36px);
  padding: clamp(20px, 4vw, 30px);
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid rgba(255, 247, 232, 0.2);
  border-radius: 16px;
  background: linear-gradient(155deg, rgba(18, 32, 31, 0.97), rgba(9, 17, 24, 0.97));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.52), inset 0 1px rgba(255, 255, 255, 0.05);
  animation: loadingCardIn 620ms cubic-bezier(0.2, 0.78, 0.28, 1) both;
}

.loading-card::before {
  content: "";
  position: absolute;
  top: -120px;
  right: -110px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(141, 216, 193, 0.14), transparent 68%);
  pointer-events: none;
}

.loading-kicker {
  margin: 0 0 6px;
  color: var(--mint);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.loading-card h2 {
  position: relative;
  margin: 0;
  color: #fff8dc;
  font-size: clamp(1.75rem, 5vw, 2.35rem);
  letter-spacing: -0.035em;
}

.loading-subtitle {
  margin: 8px 0 0;
  color: #e5ede6;
  font-size: clamp(0.95rem, 2.3vw, 1.08rem);
}

.loading-lightyear {
  --light-travel-distance: calc(min(540px, 100vw - 68px) - 184px);
  height: 170px;
  margin: 20px 0 18px;
}

.loading-lightyear .distance-bubble {
  left: 50%;
  transform: translateX(-50%);
}

.loading-copy {
  margin: 0;
  color: #e7eee8;
  font-size: 0.95rem;
  line-height: 1.65;
  word-break: keep-all;
}

.loading-copy strong {
  color: var(--accent-strong);
}

.loading-meter {
  height: 4px;
  margin-top: 20px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 247, 232, 0.1);
}

.loading-meter span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #fff4b4 52%, var(--mint));
  box-shadow: 0 0 18px rgba(245, 201, 106, 0.5);
  animation: loadingMeter 1.25s ease-in-out infinite;
}

.loading-screen.ready .loading-meter span {
  width: 100%;
  animation: none;
}

.loading-status {
  min-height: 1.35em;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

@keyframes loadingSkyDrift {
  to {
    transform: translate3d(40px, 28px, 0);
  }
}

@keyframes loadingCardIn {
  from {
    transform: translateY(12px) scale(0.985);
    opacity: 0;
  }
}

@keyframes loadingMeter {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(245%);
  }
}

button,
input,
select {
  font: inherit;
}

button {
  text-align: center;
}

#skyCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100dvh;
  cursor: grab;
  touch-action: none;
}

#skyCanvas.dragging {
  cursor: grabbing;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  padding: clamp(16px, 3vw, 36px);
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(260px, 350px);
  gap: clamp(14px, 3vw, 42px);
  align-items: end;
  justify-content: space-between;
}

.control-panel,
.result-panel {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  overflow-wrap: anywhere;
}

body:not(.has-result) .result-panel {
  display: none;
}

.control-panel {
  width: min(350px, 100%);
  padding: 12px;
  border-radius: var(--radius);
}

.result-panel {
  grid-column: 2;
  align-self: end;
  padding: 12px;
  border-radius: var(--radius);
}

.input-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.input-panel-header h1 {
  margin: 2px 0 0;
  font-size: clamp(1.45rem, 2.4vw, 1.9rem);
  line-height: 1.05;
  word-break: keep-all;
}

.input-panel-eyebrow {
  margin: 0;
  color: var(--mint);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.input-panel-close {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 247, 232, 0.2);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.control-panel:not(.hidden) {
  animation: inputPanelIn 240ms cubic-bezier(0.2, 0.76, 0.3, 1) both;
}

.entry-actions {
  position: fixed;
  left: calc(clamp(16px, 3vw, 36px) + env(safe-area-inset-left));
  bottom: calc(clamp(16px, 3vw, 36px) + env(safe-area-inset-bottom));
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(2, minmax(122px, 146px));
  gap: 8px;
}

.entry-action {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 70px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 247, 232, 0.22);
  border-radius: 10px;
  color: var(--ink);
  background: linear-gradient(145deg, rgba(20, 37, 32, 0.92), rgba(8, 18, 23, 0.9));
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.3), inset 0 1px rgba(255, 255, 255, 0.04);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.entry-action:hover {
  border-color: rgba(245, 201, 106, 0.62);
  background: linear-gradient(145deg, rgba(31, 48, 37, 0.96), rgba(13, 27, 30, 0.94));
  transform: translateY(-2px);
}

.entry-action-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 247, 232, 0.22);
  border-radius: 11px;
  color: #18140a;
  background: linear-gradient(180deg, #fff0a4, var(--accent));
  box-shadow: 0 0 20px rgba(245, 201, 106, 0.18);
  font-weight: 950;
}

.birthday-icon {
  padding-top: 5px;
  font-size: 0.72rem;
}

.birthday-icon::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 7px;
  right: 7px;
  height: 3px;
  border-radius: 999px;
  background: rgba(32, 25, 8, 0.48);
}

.age-icon {
  color: #09201d;
  background: linear-gradient(180deg, #c8f1df, var(--mint));
  box-shadow: 0 0 20px rgba(141, 216, 193, 0.2);
  font-size: 1.15rem;
}

.entry-action-copy {
  display: grid;
  gap: 3px;
}

.entry-action-copy strong {
  color: #fff8dc;
  font-size: 1rem;
  line-height: 1;
}

.entry-action-copy small {
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}

@keyframes inputPanelIn {
  from {
    transform: translateY(10px) scale(0.985);
    opacity: 0;
  }
}

.brand-row,
.live-sky,
.privacy-note,
.eyebrow,
.science-note {
  color: var(--muted);
}

.brand-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 18px var(--mint);
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 6px 0 8px;
  max-width: none;
  font-size: clamp(1.45rem, 1.8vw, 1.75rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.lead {
  display: none;
  margin: 0 0 12px;
  color: #edf1e9;
  font-size: 0.86rem;
  line-height: 1.45;
}

.lead-full,
.privacy-full {
  display: none;
}

.lead-compact,
.privacy-compact {
  display: inline;
}

.friend-form {
  display: grid;
  gap: 10px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
}

.mode-button,
.primary-action,
.secondary-action {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  white-space: normal;
}

.mode-button {
  color: var(--muted);
  background: transparent;
}

.mode-button.active {
  color: #14120c;
  background: var(--accent);
}

.field {
  display: grid;
  gap: 6px;
  color: #f8edd5;
}

.field span {
  font-weight: 700;
}

.birth-input-panel {
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid rgba(255, 247, 232, 0.18);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
}

.birth-input-row {
  display: grid;
  grid-template-columns: minmax(86px, 1.18fr) minmax(56px, 0.72fr) minmax(56px, 0.72fr);
  gap: 6px;
  align-items: end;
  min-width: 0;
}

.birth-input {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.birth-input span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.birth-input input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 247, 232, 0.28);
  border-radius: 6px;
  padding: 0 8px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.34);
  font-size: 1rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.birth-input input::placeholder {
  color: rgba(248, 237, 213, 0.42);
}

.birth-date-preview {
  display: block;
  min-height: 28px;
  border-top: 1px solid rgba(255, 247, 232, 0.14);
  padding-top: 7px;
  color: #fff8dc;
  font-size: 0.9rem;
  font-weight: 800;
}
.field input:not([type="range"]),
.field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(255, 247, 232, 0.28);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.34);
}
.field .birth-input input {
  min-height: 42px;
  padding: 0 8px;
  font-size: 1rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  text-align: center;
}


.field input:focus,
.field select:focus,
button:focus-visible {
  outline: 3px solid rgba(141, 216, 193, 0.78);
  outline-offset: 2px;
}

.hidden {
  display: none;
}

.privacy-note {
  display: none;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
}

.input-error {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid rgba(255, 179, 168, 0.4);
  border-radius: 6px;
  color: #ffd4cd;
  background: rgba(92, 28, 25, 0.38);
  font-size: 0.8rem;
  line-height: 1.4;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #15120b;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  font-weight: 800;
}

.secondary-action {
  width: 100%;
  margin-top: 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 247, 232, 0.09);
}

.live-sky {
  display: none;
  gap: 4px;
  margin-top: 10px;
  font-size: 0.78rem;
}


.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

#resultSummary,
.science-note {
  line-height: 1.65;
}

.result-panel.friend-result .fact-grid,
.result-panel.friend-result .science-note {
  display: none;
}
.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 0;
}
.candidate-list {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
}

.candidate-card {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 0;
  padding: 8px;
  border: 1px solid rgba(255, 247, 232, 0.2);
  border-left: 3px solid rgba(141, 216, 193, 0.7);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 247, 232, 0.06);
  text-align: left;
  cursor: pointer;
}

.candidate-card-button {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.candidate-card-button:focus-visible {
  outline: 3px solid rgba(141, 216, 193, 0.78);
  outline-offset: 3px;
}
.candidate-card.active {
  border-color: rgba(141, 216, 193, 0.72);
  border-left-color: var(--accent);
  background: rgba(141, 216, 193, 0.12);
}

.candidate-card strong {
  color: #fff8dc;
  font-size: 0.96rem;
  line-height: 1.2;
}

.candidate-badge,
.candidate-meta {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.candidate-inline-details {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 247, 232, 0.16);
}

.candidate-inline-summary {
  margin: 0;
  color: #fff8dc;
  font-size: 0.82rem;
  line-height: 1.45;
}

.candidate-inline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.candidate-inline-grid div {
  min-width: 0;
  padding: 7px;
  border: 1px solid rgba(255, 247, 232, 0.12);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.14);
}

.candidate-inline-grid dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.candidate-inline-grid dd {
  color: #fff8dc;
  font-size: 0.78rem;
  line-height: 1.35;
}
.candidate-badge {
  color: var(--accent-strong);
  font-weight: 800;
}

.fact-grid div {
  min-width: 0;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  background: transparent;
}

dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

dd {
  margin: 0;
  color: #fff8dc;
  font-weight: 800;
  line-height: 1.35;
  white-space: pre-line;
}

.science-note {
  margin: 12px 0 0;
  font-size: 0.84rem;
}

.sky-tools {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  right: calc(14px + env(safe-area-inset-right));
  z-index: 5;
  display: grid;
  gap: 6px;
}

.sky-toggle {
  display: grid;
  grid-template-columns: 32px minmax(52px, 1fr) 28px;
  align-items: center;
  gap: 8px;
  min-width: 150px;
  min-height: 44px;
  padding: 0 11px;
  border: 1px solid rgba(255, 247, 232, 0.22);
  border-radius: 6px;
  color: rgba(255, 247, 232, 0.88);
  background: rgba(8, 17, 23, 0.72);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

.sky-toggle.active {
  border-color: rgba(141, 216, 193, 0.52);
  background: rgba(10, 28, 31, 0.82);
}

.sky-background-toggle.auto-dimmed {
  border-color: rgba(245, 201, 106, 0.58);
  background: rgba(34, 29, 18, 0.84);
}

.sky-toggle-state {
  min-width: 28px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  text-align: right;
}

.sky-toggle.active .sky-toggle-state {
  color: var(--mint);
}

.sky-background-toggle.auto-dimmed .sky-toggle-state {
  color: var(--accent-strong);
}

.sky-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.sky-toggle-switch {
  position: relative;
  flex: 0 0 auto;
  width: 32px;
  height: 18px;
  border: 1px solid rgba(255, 247, 232, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  transition: background 160ms ease, border-color 160ms ease;
}

.sky-toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 247, 232, 0.72);
  transition: transform 160ms ease, background 160ms ease;
}

.sky-toggle input:checked + .sky-toggle-switch {
  border-color: rgba(141, 216, 193, 0.72);
  background: rgba(141, 216, 193, 0.22);
}

.sky-toggle input:checked + .sky-toggle-switch::after {
  background: var(--mint);
  transform: translateX(14px);
}

.sky-toggle input:focus-visible + .sky-toggle-switch {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
}

.top-actions {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: calc(14px + env(safe-area-inset-left));
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-action {
  min-height: 44px;
  border: 1px solid rgba(255, 247, 232, 0.28);
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  transition: transform 160ms ease, border-color 160ms ease;
}

.home-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 84px;
  padding: 0 12px;
  border-radius: 999px;
  color: #f8f3e6;
  background: rgba(8, 17, 23, 0.78);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.home-symbol {
  color: var(--mint);
  font-size: 1.22rem;
  line-height: 1;
}

.help-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #15120b;
  background: linear-gradient(180deg, #fff2a8, var(--accent));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28), 0 0 26px rgba(245, 201, 106, 0.28);
  font-size: 1.38rem;
  font-weight: 950;
  line-height: 1;
}

.top-action:hover {
  border-color: rgba(245, 201, 106, 0.58);
  transform: translateY(-1px);
}

.help-overlay.hidden {
  display: none;
  pointer-events: none;
}
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  align-items: start;
  justify-items: start;
  padding: calc(66px + env(safe-area-inset-top)) 16px 16px calc(16px + env(safe-area-inset-left));
}

.help-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 5, 10, 0.5);
  backdrop-filter: blur(3px);
}

.help-panel {
  position: relative;
  width: min(430px, calc(100vw - 32px));
  max-height: calc(100svh - 86px);
  overflow-y: auto;
  border: 1px solid rgba(255, 247, 232, 0.22);
  border-radius: 8px;
  padding: 16px;
  color: var(--ink);
  background: rgba(15, 27, 24, 0.94);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

.help-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 247, 232, 0.22);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.2rem;
  cursor: pointer;
}

.help-eyebrow {
  margin: 0 42px 6px 0;
  color: var(--mint);
  font-size: 0.8rem;
  font-weight: 900;
}

.help-panel h2 {
  margin-right: 42px;
  color: #fff8dc;
}

.lightyear-animation {
  position: relative;
  height: 150px;
  margin: 14px 0;
  overflow: hidden;
  border: 1px solid rgba(255, 247, 232, 0.18);
  border-radius: 8px;
  background:
    radial-gradient(circle at 15% 35%, rgba(255, 235, 156, 0.24), transparent 18%),
    radial-gradient(circle at 80% 62%, rgba(141, 216, 193, 0.2), transparent 20%),
    linear-gradient(180deg, rgba(10, 19, 34, 0.98), rgba(4, 8, 16, 0.98));
}

.lightyear-animation::before,
.lightyear-animation::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 247, 232, 0.9);
  box-shadow: 44px 22px rgba(255, 247, 232, 0.58), 112px 18px rgba(245, 201, 106, 0.6), 210px 34px rgba(255, 247, 232, 0.72), 304px 20px rgba(141, 216, 193, 0.64);
}

.lightyear-animation::before {
  top: 22px;
  left: 34px;
}

.lightyear-animation::after {
  right: 56px;
  bottom: 28px;
}

.space-star,
.space-earth {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.space-star {
  top: 38px;
  left: 28px;
  width: 54px;
  height: 54px;
  color: #241902;
  background: radial-gradient(circle, #fff8c8 0 28%, #ffd66f 52%, #f59a4f 100%);
  box-shadow: 0 0 34px rgba(255, 214, 111, 0.72);
  animation: helpStarGlow 2.6s ease-in-out infinite;
}

.space-earth {
  right: 28px;
  bottom: 30px;
  width: 58px;
  height: 58px;
  color: #eafff6;
  background: radial-gradient(circle at 35% 30%, #8dd8c1 0 18%, #2f91c8 44%, #143b73 100%);
  box-shadow: 0 0 28px rgba(141, 216, 193, 0.48);
}

.space-star span,
.space-earth span {
  position: absolute;
  bottom: -22px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.space-track {
  position: absolute;
  left: 76px;
  right: 82px;
  top: 74px;
  height: 2px;
  background: linear-gradient(90deg, rgba(255, 214, 111, 0.12), rgba(255, 214, 111, 0.9), rgba(141, 216, 193, 0.2));
  transform: rotate(7deg);
  transform-origin: left center;
}

.light-pulse {
  position: absolute;
  top: -5px;
  left: -8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff7a8;
  box-shadow: 0 0 20px #fff1a0, 0 0 42px rgba(245, 201, 106, 0.7);
  animation: lightTravel 2.8s linear infinite;
}

.light-pulse.two {
  animation-delay: 0.9s;
}

.light-pulse.three {
  animation-delay: 1.8s;
}

.age-bubble,
.distance-bubble,
.now-bubble {
  position: absolute;
  z-index: 3;
  border: 1px solid rgba(255, 247, 232, 0.2);
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 0.76rem;
  font-weight: 900;
  background: rgba(0, 0, 0, 0.36);
}

.age-bubble {
  left: 82px;
  top: 22px;
  color: var(--accent-strong);
}


.distance-bubble {
  left: 138px;
  bottom: 18px;
  color: #fff8dc;
}
.now-bubble {
  right: 70px;
  top: 78px;
  color: var(--mint);
}

.help-copy {
  display: grid;
  gap: 10px;
}

.help-copy p {
  margin: 0;
  color: #edf1e9;
  font-size: 0.92rem;
  line-height: 1.55;
}

.help-copy strong {
  color: #fff8dc;
}

.help-action {
  width: 100%;
  min-height: 42px;
  margin-top: 14px;
  border: 0;
  border-radius: 6px;
  color: #15120b;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  font-weight: 900;
  cursor: pointer;
}

@keyframes lightTravel {
  0% {
    transform: translateX(0) scale(0.65);
    opacity: 0;
  }

  12% {
    opacity: 1;
  }

  86% {
    opacity: 1;
  }

  100% {
    transform: translateX(var(--light-travel-distance, calc(min(430px, 100vw) - 184px))) scale(1.05);
    opacity: 0;
  }
}

@keyframes helpStarGlow {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }
}

@media (max-width: 820px) {
  body {
    overflow-y: auto;
  }

  .app-shell {
    min-height: 100svh;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 16px;
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
  }

  .control-panel {
    margin-top: clamp(84px, 18svh, 150px);
  }

  .result-panel {
    grid-column: 1;
  }

  h1 {
    max-width: none;
    font-size: clamp(1.85rem, 6.6vw, 2.45rem);
    line-height: 1.04;
    word-break: keep-all;
  }


  .lead {
    margin-bottom: 14px;
    font-size: 0.95rem;
    line-height: 1.5;
  }
  h2 {
    font-size: 1.45rem;
  }

  .fact-grid {
    grid-template-columns: 1fr;
  }
}


@media (max-width: 640px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    display: block;
    min-height: 100svh;
    padding: 0;
  }

  .entry-actions {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .entry-action {
    min-width: 0;
    min-height: 68px;
  }

  .control-panel,
  .result-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 2;
    width: auto;
    height: 34svh;
    min-height: 220px;
    max-height: 300px;
    margin: 0;
    padding: 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    background: rgba(17, 28, 22, 0.88);
    backdrop-filter: blur(12px);
    box-shadow: 0 -10px 36px rgba(0, 0, 0, 0.3);
  }

  .control-panel::before,
  .result-panel::before {
    content: "";
    display: block;
    width: 42px;
    height: 3px;
    margin: 0 auto 8px;
    border-radius: 999px;
    background: rgba(255, 247, 232, 0.28);
  }

  .result-panel {
    display: none;
  }

  body.has-result .control-panel {
    display: none;
  }

  body.has-result .result-panel {
    display: block;
  }

  .brand-row {
    gap: 6px;
    font-size: 0.72rem;
  }

  .brand-mark {
    width: 8px;
    height: 8px;
  }

  h1 {
    margin: 4px 0 6px;
    font-size: clamp(1.3rem, 5.6vw, 1.62rem);
    line-height: 1.06;
  }

  .lead,
  .privacy-note,
  .live-sky {
    display: none;
  }

  .friend-form {
    gap: 8px;
  }

  .mode-switch {
    gap: 3px;
    padding: 3px;
  }

  .mode-button,
  .primary-action,
  .secondary-action {
    min-height: 38px;
  }

  .field {
    gap: 5px;
  }

  .field > span {
    font-size: 0.8rem;
  }

  .birth-input-panel {
    gap: 6px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .birth-input-row {
    grid-template-columns: minmax(82px, 1.18fr) minmax(54px, 0.72fr) minmax(54px, 0.72fr);
    gap: 5px;
  }

  .birth-input span {
    font-size: 0.74rem;
  }

  .field .birth-input input {
    min-height: 38px;
    padding: 0 6px;
    font-size: 0.95rem;
  }

  .birth-date-preview {
    min-height: auto;
    padding: 6px 0 0;
    font-size: 0.84rem;
  }
  .primary-action {
    position: static;
    bottom: auto;
  }

  .eyebrow {
    margin-bottom: 6px;
  }

  h2 {
    font-size: 1.2rem;
  }

  #resultSummary,
  .science-note {
    line-height: 1.45;
  }

  .fact-grid {
    gap: 6px;
    margin-top: 10px;
  }

  .fact-grid div {
    padding: 8px 0;
  }

  .science-note {
    margin-top: 10px;
    font-size: 0.82rem;
  }

  .secondary-action {
    margin-top: 10px;
  }
}

@media (max-width: 430px) {
  .candidate-inline-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding: 12px 12px calc(28px + env(safe-area-inset-bottom));
    gap: 12px;
  }

  .top-actions {
    top: calc(10px + env(safe-area-inset-top));
    left: calc(10px + env(safe-area-inset-left));
    gap: 6px;
  }

  .top-action {
    min-height: 42px;
  }

  .home-button {
    min-width: 78px;
    padding: 0 10px;
  }

  .help-button {
    width: 42px;
    height: 42px;
  }

  .sky-tools {
    top: calc(10px + env(safe-area-inset-top));
    right: calc(10px + env(safe-area-inset-right));
  }

  .entry-action {
    grid-template-columns: 34px 1fr;
    gap: 8px;
    padding: 9px 10px;
  }

  .entry-action-icon {
    width: 34px;
    height: 34px;
  }

  .control-panel,
  .result-panel {
    padding: 12px;
    background: rgba(17, 28, 22, 0.86);
    backdrop-filter: blur(10px);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
  }


  .brand-row {
    gap: 7px;
    font-size: 0.78rem;
  }

  .brand-mark {
    width: 9px;
    height: 9px;
    box-shadow: 0 0 16px var(--mint);
  }

  h1 {
    margin: 4px 0 6px;
    font-size: clamp(1.12rem, 5vw, 1.35rem);
    line-height: 1.08;
  }

  .lead {
    margin-bottom: 10px;
    font-size: 0.88rem;
    line-height: 1.45;
  }

  .lead-full,
  .privacy-full {
    display: none;
  }

  .lead-compact,
  .privacy-compact {
    display: inline;
  }

  .friend-form {
    gap: 6px;
  }

  .mode-switch {
    gap: 4px;
    padding: 3px;
  }

  .mode-button,
  .primary-action,
  .secondary-action {
    min-height: 38px;
  }

  .field {
    gap: 6px;
  }

  .field > span {
    font-size: 0.78rem;
  }

  .birth-input-panel {
    gap: 7px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .birth-input-row {
    grid-template-columns: minmax(90px, 1.2fr) minmax(58px, 0.72fr) minmax(58px, 0.72fr);
    gap: 6px;
  }

  .birth-input span {
    font-size: 0.76rem;
  }

  .field .birth-input input {
    min-height: 40px;
    font-size: 0.98rem;
  }

  .birth-date-preview {
    min-height: auto;
    padding: 7px 0 0;
    border-top: 1px solid rgba(255, 247, 232, 0.14);
    font-size: 0.88rem;
  }
  .privacy-note {
    font-size: 0.78rem;
    line-height: 1.35;
  }

  .primary-action {
    margin-top: 0;
  }

  .live-sky {
    gap: 3px;
    margin-top: 10px;
    font-size: 0.78rem;
  }

  #timeStatus,
  #locationText {
    display: none;
  }
  .brand-row {
    display: none;
  }

  h1 {
    margin: 2px 0 5px;
    font-size: clamp(1.08rem, 4.8vw, 1.28rem);
  }

  .friend-form {
    gap: 6px;
  }

  .mode-button,
  .primary-action,
  .secondary-action {
    min-height: 36px;
  }

  .birth-input-panel {
    gap: 5px;
  }

  .birth-input-row {
    grid-template-columns: minmax(84px, 1.2fr) minmax(54px, 0.72fr) minmax(54px, 0.72fr);
    gap: 5px;
  }

  .birth-input span {
    font-size: 0.72rem;
  }

  .field .birth-input input {
    min-height: 36px;
    padding: 0 6px;
    font-size: 0.92rem;
  }

  .birth-date-preview {
    display: block;
    padding: 5px 0 0;
    font-size: 0.78rem;
    line-height: 1.2;
  }

  .primary-action {
    position: static;
    bottom: auto;
    margin-top: 0;
  }
}

@media (max-width: 820px) {
  .field input:not([type="range"]),
  .field .birth-input input {
    font-size: 16px;
    scroll-margin-block: 12px;
  }
}

body.keyboard-open {
  overflow: hidden;
}

body.keyboard-open .control-panel:not(.hidden) {
  position: fixed;
  left: calc(10px + env(safe-area-inset-left));
  right: calc(10px + env(safe-area-inset-right));
  bottom: calc(var(--keyboard-inset, 0px) + max(8px, env(safe-area-inset-bottom)));
  z-index: 8;
  width: auto;
  height: auto;
  min-height: 0;
  max-width: 420px;
  max-height: calc(var(--visual-viewport-height, 100dvh) - 20px);
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 12px;
  animation: none;
}

@media (max-width: 360px) {
  .home-button {
    width: 42px;
    min-width: 42px;
    padding: 0;
    border-radius: 50%;
  }

  .home-button > span:last-child,
  .sky-toggle-label,
  .entry-action-copy small {
    display: none;
  }

  .sky-toggle {
    grid-template-columns: 32px 28px;
    gap: 6px;
    min-width: 82px;
    padding: 0 8px;
  }

  .entry-action-copy strong {
    font-size: 0.92rem;
  }
}

@media (max-width: 520px) {
  .loading-screen {
    align-items: center;
    padding: 12px;
  }

  .loading-card {
    width: min(100%, 390px);
    padding: 18px 16px;
    border-radius: 12px;
  }

  .loading-card h2 {
    font-size: clamp(1.55rem, 8vw, 1.95rem);
  }

  .loading-subtitle {
    font-size: 0.9rem;
  }

  .loading-lightyear {
    --light-travel-distance: calc(100vw - 252px);
    height: 156px;
    margin: 16px 0 14px;
  }

  .loading-copy {
    font-size: 0.86rem;
    line-height: 1.55;
  }

  .loading-meter {
    margin-top: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }

  .loading-screen,
  .loading-screen::before,
  .loading-card,
  .loading-meter span,
  .control-panel:not(.hidden),
  .entry-action,
  .space-star,
  .light-pulse {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .control-panel,
  .result-panel,
  .entry-action,
  .top-action,
  .sky-toggle,
  .mode-switch,
  .field input,
  .field select,
  .birth-input-panel,
  .secondary-action,
  .fact-grid div {
    border-color: CanvasText;
  }

  .primary-action,
  .mode-button.active {
    border: 1px solid ButtonText;
  }
}
