/* Terrella, a planet crafter. An example brand made with MALA.
   Paper and ink with solid colours only; the halo behind the planet is two flat discs.
   Glass is blur, tint, an inset highlight and a hairline edge. */
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 200 800; font-display: swap; src: url(fonts/bricolage-grotesque-latin-wght-normal.woff2) format("woff2"); }

:root {
  --bg: #efe8dd;
  --disc: #e7dfd2;
  --disc-2: #ebe4d8;
  --ink: #1f2a2b;
  --ink-2: rgba(31, 42, 43, .68);
  --ink-3: rgba(31, 42, 43, .46);
  --glass: rgba(255, 252, 246, .64);
  --glass-strong: rgba(255, 252, 246, .9);
  --line: rgba(31, 42, 43, .12);
  --hi: rgba(255, 255, 255, .7);
  --press: rgba(31, 42, 43, .07);
  --on-ink: #fbf7f0;
  --coral: #d9603f;
  --sans: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --gap: clamp(14px, 2.2vw, 24px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 450 15px/1.4 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.glass { background: var(--glass); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi), 0 14px 36px rgba(40, 32, 20, .1); backdrop-filter: blur(18px) saturate(1.25); -webkit-backdrop-filter: blur(18px) saturate(1.25); }

/* ------------------------------------------------------------------ the stage */
.stage { position: fixed; inset: 0; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; outline: none; cursor: grab; touch-action: none; }
.embed .stage canvas { touch-action: pan-y; }
.stage canvas:active { cursor: grabbing; }
.stage canvas:focus-visible { outline: none; }
.stage canvas:focus-visible + .halo i:last-child { box-shadow: 0 0 0 2px var(--ink); }
.halo { position: absolute; left: 50%; top: 50%; z-index: 0; --r: 200px; }
.halo i { position: absolute; left: 0; top: 0; border-radius: 50%; transform: translate(-50%, -50%); }
.halo i:first-child { width: calc(var(--r) * 2.9); height: calc(var(--r) * 2.9); background: var(--disc-2); }
.halo i:last-child { width: calc(var(--r) * 2.32); height: calc(var(--r) * 2.32); background: var(--disc); transition: box-shadow .2s ease; }

/* ------------------------------------------------------------------ the header */
.top { position: fixed; z-index: 3; top: max(var(--gap), env(safe-area-inset-top)); left: max(var(--gap), env(safe-area-inset-left)); display: grid; gap: 6px; justify-items: start; max-width: min(46vw, 520px); }
.brand { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; color: var(--ink-2); }
.brand b { font-weight: 750; font-size: 20px; letter-spacing: -.01em; color: var(--ink); }
.naming { margin-top: 8px; }
.name-btn, .name-input { font-size: clamp(34px, 4.2vw, 56px); font-weight: 700; letter-spacing: -.025em; line-height: 1; }
.name-btn { display: inline-flex; align-items: center; gap: 12px; border: 0; background: transparent; padding: 4px 6px; margin: -4px -6px; border-radius: 12px; text-align: left; }
.name-btn svg { color: var(--ink-3); flex: none; transition: color .2s ease; }
.name-btn:hover { background: var(--press); }
.name-btn:hover svg { color: var(--ink); }
.name-input { width: min(12ch, 70vw); border: 0; border-bottom: 2px solid var(--ink); background: transparent; padding: 2px 0; outline: none; border-radius: 0; }
.stats { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.hint { position: fixed; z-index: 3; left: 50%; bottom: calc(max(var(--gap), env(safe-area-inset-bottom)) + 84px); transform: translateX(-50%); margin: 0; padding: 9px 16px; border-radius: 999px; background: var(--glass-strong); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi); font-size: 14px; color: var(--ink-2); white-space: nowrap; transition: opacity .5s ease, transform .5s ease; pointer-events: none; }
.hint.is-gone { opacity: 0; transform: translate(-50%, 8px); }

/* ------------------------------------------------------------------ the ring of things */
.radial { position: fixed; z-index: 6; width: 0; height: 0; }
.radial-item {
  --a: calc(var(--i) * 60deg - 90deg);
  position: absolute; left: 0; top: 0;
  width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--glass-strong);
  box-shadow: inset 0 1px 0 var(--hi), 0 8px 22px rgba(40, 32, 20, .16);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transform: translate(-50%, -50%) rotate(var(--a)) translate(0px) rotate(calc(-1 * var(--a))) scale(.25);
  opacity: 0;
  transition: transform .42s cubic-bezier(.3, 1.55, .5, 1) calc(var(--i) * 26ms), opacity .2s ease calc(var(--i) * 26ms), background-color .15s ease;
}
.radial.is-open .radial-item { transform: translate(-50%, -50%) rotate(var(--a)) translate(86px) rotate(calc(-1 * var(--a))) scale(1); opacity: 1; }
.radial-item span { position: absolute; top: calc(100% + 5px); left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 600; white-space: nowrap; padding: 2px 8px; border-radius: 999px; background: var(--glass-strong); border: 1px solid var(--line); pointer-events: none; }
.radial-item:hover, .radial-item:focus-visible { background: #fff; }
.radial-item:active { transform: translate(-50%, -50%) rotate(var(--a)) translate(86px) rotate(calc(-1 * var(--a))) scale(.92); }
.radial-item svg { transition: transform .2s ease; }
.radial-item:hover svg { transform: scale(1.12); }
.tool-land svg { color: #6d8f3a; } .tool-mountain svg { color: #7c6f60; } .tool-water svg { color: #2f7fa8; }
.tool-trees svg { color: #3f7a3c; } .tool-village svg { color: #c0563a; } .tool-cloud svg { color: #6d7f95; }
.radial-close { position: absolute; left: 0; top: 0; width: 40px; height: 40px; border-radius: 50%; transform: translate(-50%, -50%) scale(.4); opacity: 0; display: grid; place-items: center; border: 1px solid var(--line); background: var(--ink); color: var(--on-ink); transition: transform .3s cubic-bezier(.3, 1.5, .5, 1), opacity .2s ease; }
.radial.is-open .radial-close { transform: translate(-50%, -50%) scale(1); opacity: 1; }

/* ------------------------------------------------------------------ the dock */
.dock { position: fixed; z-index: 4; left: 50%; bottom: max(var(--gap), env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 999px; max-width: calc(100vw - 2 * var(--gap)); }
.dock-btn { display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; font-weight: 600; font-size: 14px; color: var(--ink); transition: background-color .15s ease, transform .15s ease; white-space: nowrap; }
.dock-btn:hover { background: var(--press); }
.dock-btn:active { transform: scale(.96); }
.dock-btn:disabled { opacity: .4; cursor: default; }
.dock-btn[aria-pressed="false"] svg { opacity: .45; }
.dock-order { display: inline-flex; align-items: center; gap: 9px; height: 48px; padding: 0 20px 0 16px; border: 0; border-radius: 999px; background: var(--ink); color: var(--on-ink); font-weight: 650; font-size: 15px; margin-left: 4px; white-space: nowrap; transition: transform .15s ease; }
.dock-order:hover { transform: translateY(-1px); }
.dock-order:active { transform: scale(.97); }

.toast { position: fixed; z-index: 5; left: 50%; bottom: calc(max(var(--gap), env(safe-area-inset-bottom)) + 76px); transform: translate(-50%, 10px); max-width: min(560px, calc(100vw - 32px)); padding: 10px 16px; border-radius: 16px; background: var(--ink); color: var(--on-ink); font-size: 14px; font-weight: 550; text-align: center; opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .35s cubic-bezier(.3, 1.4, .5, 1); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------------ the checkout */
.co-scrim { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: rgba(31, 38, 40, .3); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; } }
.checkout { position: relative; width: min(880px, 100%); max-height: 100%; overflow: auto; border-radius: 28px; padding: 24px; display: grid; gap: 18px; background: var(--glass-strong); animation: rise .38s cubic-bezier(.3, 1.3, .5, 1); outline: none; }
@keyframes rise { from { transform: translateY(18px) scale(.98); opacity: 0; } }
.co-head { display: grid; gap: 4px; padding-right: 44px; }
.co-step { margin: 0; font-size: 13px; color: var(--ink-3); font-weight: 600; }
.co-head h2 { margin: 0; font-size: clamp(24px, 3vw, 32px); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.co-close { position: absolute; top: 18px; right: 18px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--press); display: grid; place-items: center; }
.co-body { display: grid; gap: 16px; }
.co-portrait { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 24px; align-items: start; }
.co-preview { border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: var(--disc); aspect-ratio: 4 / 5; }
.co-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.co-options { display: grid; gap: 18px; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 0; }
legend { font-size: 13px; font-weight: 650; color: var(--ink-2); margin-bottom: 8px; padding: 0; }
.co-format { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, .55); cursor: pointer; transition: border-color .15s ease, background-color .15s ease; }
.co-format:has(input:checked) { border-color: var(--ink); background: #fff; box-shadow: inset 0 0 0 1px var(--ink); }
.co-format input { accent-color: var(--ink); width: 18px; height: 18px; margin: 0; }
.co-format span { display: grid; gap: 2px; }
.co-format b { font-weight: 650; }
.co-format small { font-size: 12.5px; color: var(--ink-3); }
.co-format em { font-style: normal; font-weight: 650; font-variant-numeric: tabular-nums; }
.co-swatches { display: flex; gap: 10px; }
.co-swatch { position: relative; cursor: pointer; }
.co-swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.co-swatch span { display: block; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); }
.co-swatch input:checked + span { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); }
.co-swatch input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 6px; }
.co-field { display: grid; gap: 6px; font-size: 13px; font-weight: 650; color: var(--ink-2); }
.co-field input { height: 46px; border-radius: 14px; border: 1px solid var(--line); background: #fff; padding: 0 14px; font-size: 16px; font-weight: 550; color: var(--ink); }
.co-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.co-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 24px; border-radius: 999px; border: 0; background: var(--ink); color: var(--on-ink); font-weight: 650; font-size: 15px; text-decoration: none; }
.co-primary:disabled { opacity: .85; cursor: default; }
.co-ghost { min-height: 50px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-weight: 600; }
.co-ghost:hover { background: var(--press); }
.co-line { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px; border-radius: 18px; border: 1px solid var(--line); background: rgba(255, 255, 255, .55); }
.co-line img { width: 72px; height: 90px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--disc); }
.co-line div { display: grid; gap: 3px; min-width: 0; }
.co-line small { color: var(--ink-3); font-size: 13px; }
.co-line em { font-style: normal; font-weight: 650; }
.co-sum { margin: 0; display: grid; gap: 0; }
.co-sum div { display: flex; justify-content: space-between; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.co-sum div:last-child { border-bottom: 0; }
.co-sum dt { color: var(--ink-2); }
.co-sum dd { margin: 0; font-weight: 600; text-align: right; }
.co-sum .is-total dt, .co-sum .is-total dd { color: var(--ink); font-weight: 750; font-size: 17px; }
.co-demo { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 12px 14px; border-radius: 14px; background: #f6e7c8; color: #5a4210; font-size: 14px; font-weight: 550; line-height: 1.4; }
.co-demo svg { flex: none; margin-top: 2px; }
.co-done { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 24px; align-items: center; }
.co-final { width: 100%; border-radius: 16px; border: 1px solid var(--line); box-shadow: 0 18px 40px rgba(40, 32, 20, .18); -webkit-touch-callout: default; }
.co-done > div { display: grid; gap: 14px; justify-items: start; }
.co-ok { display: flex; gap: 10px; align-items: flex-start; margin: 0; font-size: 17px; font-weight: 600; line-height: 1.35; }
.co-ok svg { flex: none; color: #2f7a4d; margin-top: 2px; }
.co-note { margin: 0; font-size: 13px; color: var(--ink-3); line-height: 1.45; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(251, 247, 240, .35); border-top-color: var(--on-ink); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.boot { position: fixed; inset: 0; z-index: 2; display: grid; place-items: center; font-size: 28px; font-weight: 700; color: var(--ink-3); transition: opacity .5s ease; pointer-events: none; }
.boot.is-gone { opacity: 0; }
.failed { position: fixed; left: 50%; top: 45%; transform: translate(-50%, -50%); max-width: 320px; text-align: center; color: var(--ink-2); z-index: 3; }

/* ------------------------------------------------------------------ smaller frames */
@media (max-width: 760px) {
  .top { max-width: calc(100vw - 2 * var(--gap)); }
  .brand span { display: none; }
  .dock-btn { padding: 0 13px; }
  .dock-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .co-portrait, .co-done { grid-template-columns: minmax(0, 1fr); }
  .co-preview { max-width: 260px; justify-self: center; width: 100%; }
  .co-final { max-width: 300px; justify-self: center; }
  .co-scrim { place-items: end center; padding: 10px; }
  .checkout { border-radius: 24px; padding: 20px; }
}
@media (max-width: 420px) {
  :root { --gap: 12px; }
  .name-btn, .name-input { font-size: 32px; }
  .dock-order { padding: 0 16px 0 13px; font-size: 14px; }
  .hint { white-space: normal; text-align: center; width: calc(100vw - 32px); border-radius: 16px; }
  .radial-item { width: 52px; height: 52px; }
  .radial.is-open .radial-item { transform: translate(-50%, -50%) rotate(var(--a)) translate(76px) rotate(calc(-1 * var(--a))) scale(1); }
}
@media (max-height: 560px) {
  .name-btn, .name-input { font-size: 30px; }
  .stats { font-size: 13px; }
}
.embed .brand span { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
