/* Planet Generator — neumorphism UI. by Wondermayank (wondermayank.in) */
:root {
  --bg: #e0e5ec;
  --sd: #a3b1c6;
  --sl: #ffffff;
  --text: #333b4a;
  --muted: #566073;
  --accent: #5b6cff;
  --accent-2: #4453e6;
  --accent-soft: rgba(91, 108, 255, 0.35);
  --love: #ff5c8a;
  --ok: #1f9d6b;
  --err: #d9434b;
  --info: #5b6cff;
  --focus: #5b6cff;
  --raise: 9px 9px 18px var(--sd), -9px -9px 18px var(--sl);
  --raise-sm: 5px 5px 10px var(--sd), -5px -5px 10px var(--sl);
  --raise-xs: 3px 3px 6px var(--sd), -3px -3px 6px var(--sl);
  --inset: inset 6px 6px 12px var(--sd), inset -6px -6px 12px var(--sl);
  --inset-sm: inset 3px 3px 6px var(--sd), inset -3px -3px 6px var(--sl);
  --font: "Nunito", "Quicksand", ui-rounded, "SF Pro Rounded", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --r: 24px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #2b2f3a;
  --sd: #1c1f27;
  --sl: #3a3f4d;
  --text: #e4e8f2;
  --muted: #a6aec2;
  --accent: #8e9bff;
  --accent-2: #7584ff;
  --accent-soft: rgba(142, 155, 255, 0.4);
  --love: #ff7aa2;
  --ok: #4cd9a0;
  --err: #ff7a80;
  --info: #8e9bff;
  --focus: #a9b4ff;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s, color 0.25s;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
body.walking { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 200; background: var(--bg); padding: 10px 16px; border-radius: 12px; box-shadow: var(--raise-sm); transition: top 0.15s; }
.skip:focus { top: 10px; }

/* ---------------------------------------------------------------- header */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: max(14px, env(safe-area-inset-top)) 18px 6px; padding: 12px 18px;
  border-radius: var(--r); background: var(--bg); box-shadow: var(--raise);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo { width: 44px; height: 44px; border-radius: 50%; box-shadow: var(--raise-xs); flex: none; background: #0a0f1e; }
.brand h1 { font-size: 1.25rem; font-weight: 800; letter-spacing: 0.1px; line-height: 1.15; }
.brand p { font-size: 0.86rem; color: var(--muted); }
.top-actions { display: flex; gap: 12px; flex: none; }

/* ---------------------------------------------------------------- buttons */
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700; color: var(--text);
  min-height: 46px; padding: 0 20px; border-radius: 16px; background: var(--bg); box-shadow: var(--raise-sm);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: box-shadow 0.15s, transform 0.15s, color 0.15s; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:hover { color: var(--accent); }
.btn:active, .btn[aria-pressed="true"] { box-shadow: var(--inset-sm); transform: translateY(1px); }
.btn.icon { width: 46px; padding: 0; border-radius: 50%; flex: none; }
.btn.wide { width: 100%; }
.btn.primary { color: #fff; background: linear-gradient(145deg, #6f7dff, #4a5aee); box-shadow: 6px 6px 14px var(--sd), -6px -6px 14px var(--sl); }
:root[data-theme="dark"] .btn.primary { color: #121528; background: linear-gradient(145deg, #a0abff, #7c8aff); }
.btn.primary:hover { color: #fff; filter: brightness(1.06); }
:root[data-theme="dark"] .btn.primary:hover { color: #121528; }
.btn.primary:active { box-shadow: inset 3px 3px 8px rgba(0, 0, 0, 0.3), inset -2px -2px 6px rgba(255, 255, 255, 0.15); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
#btnTheme .i-sun { display: none; }
:root[data-theme="dark"] #btnTheme .i-sun { display: block; }
:root[data-theme="dark"] #btnTheme .i-moon { display: none; }

/* ---------------------------------------------------------------- layout */
.layout {
  flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 28px; align-items: start;
  padding: 18px 18px 8px; width: 100%; max-width: 1600px; margin: 0 auto;
}

/* ---------------------------------------------------------------- stage */
.stage {
  position: sticky; top: 16px; height: calc(100dvh - 150px); min-height: 480px;
  border-radius: 34px; background: var(--bg); box-shadow: var(--inset); overflow: hidden;
}
.stage canvas {
  position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px);
  border-radius: 24px; background: #05070f; display: block; touch-action: none; cursor: grab; outline-offset: -4px;
}
.stage canvas:active { cursor: grabbing; }
.hud {
  position: absolute; z-index: 3; color: #eaf0ff; background: rgba(12, 16, 30, 0.55);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-radius: 16px; padding: 10px 16px; font-size: 0.88rem; pointer-events: none;
}
.hud-tl { left: 28px; top: 28px; display: flex; flex-direction: column; gap: 1px; max-width: calc(100% - 200px); }
.hud-tl strong { font-size: 1rem; overflow-wrap: anywhere; }
.hud-tl span { color: #b9c4e6; font-size: 0.82rem; }
.hud-bc { left: 50%; transform: translateX(-50%); bottom: 28px; text-align: center; width: max-content; max-width: calc(100% - 56px); }
.overlay {
  position: absolute; inset: 12px; z-index: 6; border-radius: 24px; background: rgba(5, 7, 15, 0.78); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.overlay.on { opacity: 1; pointer-events: auto; }
.overlay-error { opacity: 1; pointer-events: auto; background: var(--bg); color: var(--text); box-shadow: var(--inset); }
.overlay-error h2 { font-size: 1.3rem; }
.overlay-error p { max-width: 44ch; color: var(--muted); }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 5px solid rgba(255, 255, 255, 0.18); border-top-color: #fff; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.walk-exit { position: absolute; z-index: 8; right: 28px; top: 28px; }
.joystick {
  position: absolute; z-index: 8; left: 30px; bottom: 80px; width: 128px; height: 128px; border-radius: 50%;
  background: var(--bg); box-shadow: var(--inset); touch-action: none; display: grid; place-items: center;
}
.joy-knob { width: 58px; height: 58px; border-radius: 50%; background: var(--bg); box-shadow: var(--raise-sm); pointer-events: none; transition: transform 0.05s; }
.joy-knob::after { content: ""; display: block; width: 14px; height: 14px; margin: 22px; border-radius: 50%; background: var(--accent); }

/* ---------------------------------------------------------------- panel */
.panel { display: flex; flex-direction: column; gap: 24px; padding: 4px 4px 8px; min-width: 0; }
.card { background: var(--bg); border-radius: var(--r); padding: 20px 20px 22px; box-shadow: var(--raise); display: flex; flex-direction: column; gap: 16px; }
.card h2 { font-size: 1.05rem; font-weight: 800; }
.note { font-size: 0.86rem; color: var(--muted); margin-top: -6px; }

.field {
  width: 100%; min-height: 48px; padding: 0 16px; border: 0; border-radius: 16px; background: var(--bg); color: var(--text);
  font: inherit; font-weight: 600; box-shadow: var(--inset-sm);
}
.field::placeholder { color: var(--muted); opacity: 0.8; font-weight: 500; }
.seed-row { display: flex; gap: 14px; align-items: center; }
select.field {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23808a9e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 18px;
}
select.field option, select.field optgroup { background: var(--bg); color: var(--text); }
.select-wrap { display: flex; flex-direction: column; gap: 8px; }
.select-wrap label { font-size: 0.88rem; color: var(--muted); font-weight: 600; }

/* sliders */
.slider { display: flex; flex-direction: column; gap: 8px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; font-size: 0.95rem; }
.slider-head output { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 800; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; margin: 0; cursor: pointer; touch-action: pan-y; --p: 50%; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 14px; border-radius: 10px; box-shadow: var(--inset-sm);
  background: linear-gradient(90deg, var(--accent) var(--p), transparent var(--p)), var(--bg);
}
input[type="range"]::-moz-range-track {
  height: 14px; border-radius: 10px; box-shadow: var(--inset-sm);
  background: linear-gradient(90deg, var(--accent) var(--p), transparent var(--p)), var(--bg);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 28px; height: 28px; margin-top: -7px; border-radius: 50%; border: 0;
  background: radial-gradient(circle, var(--accent) 0 5px, transparent 6px), var(--bg); box-shadow: var(--raise-xs);
}
input[type="range"]::-moz-range-thumb {
  width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: radial-gradient(circle, var(--accent) 0 5px, transparent 6px), var(--bg); box-shadow: var(--raise-xs);
}
input[type="range"].hue-range::-webkit-slider-runnable-track { background: linear-gradient(90deg, #ff6b6b, #ffd36b, #6bff9a, #6bd5ff, #8a6bff, #ff6bd5, #ff6b6b); opacity: 0.9; }
input[type="range"].hue-range::-moz-range-track { background: linear-gradient(90deg, #ff6b6b, #ffd36b, #6bff9a, #6bd5ff, #8a6bff, #ff6bd5, #ff6b6b); opacity: 0.9; }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--focus); outline-offset: 3px; }
input[type="range"]:focus-visible::-moz-range-thumb { outline: 3px solid var(--focus); outline-offset: 3px; }

/* chips */
.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding-top: 4px; }
.chip {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 0.84rem; color: var(--text);
  padding: 10px 0; text-align: center; border-radius: 14px; background: var(--bg); box-shadow: var(--raise-xs); transition: box-shadow 0.15s, color 0.15s;
}
.chip:hover { color: var(--accent); }
.chip[aria-checked="true"] { box-shadow: var(--inset-sm); color: var(--accent); }

.actions .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* about */
.about { gap: 6px; }
.about details { border-radius: 14px; }
.about summary { cursor: pointer; font-weight: 800; padding: 8px 2px; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.about summary::-webkit-details-marker { display: none; }
.about summary::after { content: "+"; font-size: 1.3rem; color: var(--accent); line-height: 1; }
.about details[open] > summary::after { content: "–"; }
.about details p { color: var(--muted); font-size: 0.92rem; margin: 4px 0 10px; }
.species-list h3 { font-size: 0.9rem; margin: 8px 0 4px; }
.species-list ul { margin: 0 0 8px; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.species-list li { font-size: 0.8rem; padding: 4px 10px; border-radius: 10px; box-shadow: var(--inset-sm); color: var(--muted); }

/* ---------------------------------------------------------------- credit */
.credit {
  margin: 18px auto max(22px, env(safe-area-inset-bottom)); padding: 9px 22px; border-radius: 999px; background: var(--bg);
  box-shadow: var(--raise-sm); display: flex; gap: 12px; align-items: center; justify-content: center; font-size: 0.9rem; color: var(--muted); font-weight: 600;
}
.credit a { color: var(--text); text-decoration: none; font-weight: 800; }
.credit a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.credit .domain { color: var(--muted); font-weight: 600; }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; z-index: 500; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(94vw, 440px); display: flex; flex-direction: column; gap: 12px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 14px 14px; border-radius: 20px; background: var(--bg);
  box-shadow: var(--raise); animation: toast-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2); border-left: 5px solid var(--info);
}
.toast.out { opacity: 0; transform: translateY(-8px); transition: opacity 0.2s, transform 0.2s; }
.toast-error { border-left-color: var(--err); }
.toast-success { border-left-color: var(--ok); }
.toast-ic { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; box-shadow: var(--inset-sm); color: var(--info); flex: none; }
.toast-error .toast-ic { color: var(--err); }
.toast-success .toast-ic { color: var(--ok); }
.toast-body { display: flex; flex-direction: column; flex: 1; min-width: 0; font-size: 0.93rem; line-height: 1.4; padding-top: 2px; }
.toast-body strong { font-weight: 800; }
.toast-body span { color: var(--muted); overflow-wrap: anywhere; }
.toast-x { appearance: none; border: 0; background: transparent; color: var(--muted); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; flex: none; }
.toast-x:hover { color: var(--text); box-shadow: var(--inset-sm); }
.toast-x svg { width: 16px; height: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(0.96); } to { opacity: 1; transform: none; } }

.noscript { position: fixed; inset: 0; z-index: 900; background: var(--bg); padding: 40px; text-align: center; font-weight: 700; }

/* ---------------------------------------------------------------- walk mode */
body.walking .topbar, body.walking .panel { visibility: hidden; }
body.walking .layout { display: block; padding: 0; }
body.walking .stage { position: fixed; inset: 0; z-index: 60; width: 100%; height: 100dvh; border-radius: 0; box-shadow: none; }
body.walking .stage canvas:focus-visible { outline: none; }
body.walking .stage canvas { inset: 0; width: 100%; height: 100%; border-radius: 0; cursor: crosshair; }
body.walking .overlay { inset: 0; border-radius: 0; }
body.walking .hud-tl { top: max(18px, env(safe-area-inset-top)); left: 18px; }
body.walking .walk-exit { top: max(18px, env(safe-area-inset-top)); right: 18px; }
body.walking .credit {
  position: fixed; z-index: 70; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); margin: 0; padding: 6px 16px;
  background: rgba(12, 16, 30, 0.55); box-shadow: none; color: #cdd6f2; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); font-size: 0.82rem; white-space: nowrap;
}
body.walking .credit a { color: #fff; }
body.walking .credit .domain { color: #cdd6f2; }
body.walking .hud-bc { bottom: 58px; }
body.walking .joystick { left: max(24px, env(safe-area-inset-left)); bottom: 96px; background: rgba(12, 16, 30, 0.45); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25); }
body.walking .joy-knob { background: rgba(255, 255, 255, 0.85); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); }

/* ---------------------------------------------------------------- guided tour (intro.js) */
.introjs-tooltip.neu-tour { background: var(--bg); color: var(--text); border-radius: 22px; box-shadow: var(--raise); font-family: var(--font); min-width: 270px; max-width: min(340px, 92vw); padding: 4px; }
.neu-tour .introjs-tooltip-header { padding: 14px 16px 0 18px; }
.neu-tour .introjs-tooltip-title { color: var(--text); font-weight: 800; font-size: 1.05rem; }
.neu-tour .introjs-tooltiptext { color: var(--muted); line-height: 1.55; padding: 10px 18px 14px; font-size: 0.95rem; }
.neu-tour .introjs-skipbutton { color: var(--muted); }
.neu-tour .introjs-skipbutton:hover { color: var(--text); }
.neu-tour .introjs-bullets { display: none; }
.neu-tour .introjs-progress { background: var(--bg); box-shadow: var(--inset-sm); height: 8px; border-radius: 8px; margin: 0 18px; }
.neu-tour .introjs-progressbar { background: var(--accent); border-radius: 8px; }
.neu-tour .introjs-tooltipbuttons { border-top: 0; padding: 8px 14px 14px; display: flex; gap: 10px; justify-content: flex-end; }
.neu-tour .introjs-button { background: var(--bg); color: var(--text); border: 0; border-radius: 14px; text-shadow: none; box-shadow: var(--raise-xs); padding: 9px 16px; font: 700 0.92rem var(--font); }
.neu-tour .introjs-button:hover, .neu-tour .introjs-button:focus { background: var(--bg); color: var(--accent); box-shadow: var(--raise-xs); outline: none; }
.neu-tour .introjs-button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.neu-tour .introjs-nextbutton, .neu-tour .introjs-donebutton { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .neu-tour .introjs-nextbutton, :root[data-theme="dark"] .neu-tour .introjs-donebutton { color: #121528; }
.neu-tour .introjs-nextbutton:hover, .neu-tour .introjs-donebutton:hover { background: var(--accent-2); color: #fff; }
.neu-tour .introjs-arrow.top { border-bottom-color: var(--bg); }
.neu-tour .introjs-arrow.bottom { border-top-color: var(--bg); }
.neu-tour .introjs-arrow.left { border-right-color: var(--bg); }
.neu-tour .introjs-arrow.right { border-left-color: var(--bg); }
.introjs-helperLayer { border-radius: 22px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 22px; padding: 12px 14px 4px; }
  .stage { position: relative; top: 0; height: min(70dvh, 620px); min-height: 360px; border-radius: 28px; }
  .topbar { margin: max(10px, env(safe-area-inset-top)) 14px 4px; padding: 10px 14px; }
  .brand p { display: none; }
  .brand h1 { font-size: 1.1rem; }
  .hud-tl { max-width: calc(100% - 60px); }
}
@media (max-width: 520px) {
  .card { padding: 18px 16px 20px; }
  .btn { padding: 0 16px; }
  .credit { font-size: 0.84rem; gap: 8px; padding: 8px 16px; }
  .hud-bc { font-size: 0.8rem; bottom: 22px; }
  .stage canvas, .overlay { inset: 8px; }
  .stage canvas { width: calc(100% - 16px); height: calc(100% - 16px); border-radius: 20px; }
  .hud-tl { left: 20px; top: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .spinner { animation: spin 2.4s linear infinite !important; animation-duration: 2.4s !important; animation-iteration-count: infinite !important; }
}
