:root {
  color-scheme: light;
  --paper: #f9f7ee;
  --white: #fffefa;
  --ink: #182d45;
  --muted: #486078;
  --blue: #214dc3;
  --pale-blue: #eaf1ff;
  --line: #d9dfdb;
  --cream-line: #e2ded1;
  --yellow: #ffcd52;
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }

.wrap, .workbench { width: min(1240px, calc(100% - 88px)); margin-inline: auto; }
.topbar { background: var(--white); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; min-height: 69px; gap: 38px; }
.brand { align-items: center; display: inline-flex; gap: 10px; white-space: nowrap; font-size: 18px; font-weight: 800; letter-spacing: -.045em; }
.brand-mark { position: relative; display: inline-block; width: 31px; height: 31px; border-radius: 8px; background: var(--blue); }
.brand-mark i { position: absolute; width: 7px; height: 7px; left: 7px; bottom: 7px; background: var(--yellow); }
.brand-mark i:nth-child(2) { left: 16px; }
.brand-mark i:nth-child(3) { left: 16px; bottom: 16px; }
nav { display: flex; gap: 25px; font-size: 14px; font-weight: 650; }
nav a { color: var(--muted); }
nav a:hover, nav a[aria-current] { color: var(--blue); }
.history-link { margin-left: auto; white-space: nowrap; }
#history-count { margin-left: 6px; color: var(--blue); font-variant-numeric: tabular-nums; }

.hero { background: var(--pale-blue); border-bottom: 1px solid #cedbf0; padding: 54px 0; }
.workbench { display: grid; grid-template-columns: minmax(340px, .83fr) minmax(0, 1.17fr); align-items: center; gap: clamp(25px, 4vw, 60px); }
.create, .editor, .viewer { min-width: 0; }
.hero h1, .section-head h2 {
  font-family: ui-rounded, "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-weight: 850;
  letter-spacing: -.055em;
  line-height: 1.04;
}
.hero h1 { font-size: clamp(2.7rem, 4.55vw, 4.35rem); }
.hero em { display: block; color: var(--blue); font-style: normal; }
.intro { margin-top: 14px; max-width: 385px; font-size: 1.06rem; line-height: 1.55; color: #364e6b; }

.editor { margin-top: 22px; padding: 16px; border: 1px solid #c7d4eb; border-radius: 16px; background: var(--white); box-shadow: 0 4px 0 #d6e1f5; }
label { display: block; font-weight: 700; font-size: .88rem; }
textarea, select, input { width: 100%; border-radius: 8px; border: 1px solid #c6d1de; background: #fff; color: var(--ink); padding: 9px 11px; }
textarea { display: block; margin-top: 7px; resize: vertical; min-height: 71px; line-height: 1.4; }
textarea::placeholder { color: var(--muted); }
.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.example { display: inline-flex; align-items: center; gap: 6px; min-height: 31px; padding: 3px 8px; border: 1px solid var(--cream-line); border-radius: 6px; background: #f9f6ed; color: var(--ink); font-weight: 650; font-size: .76rem; }
.example:hover { background: #eaf1ff; border-color: #9cb3da; }
.example::before { display: inline-block; width: 9px; height: 9px; border-radius: 2px; transform: rotate(-12deg); background: var(--swatch, var(--blue)); content: ""; }
.editor-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 13px; }
#character-count { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.quiet-button, .view-tools button, .primary { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 8px 11px; min-height: 37px; border: 1px solid #cbd5de; border-radius: 8px; background: #fff; color: var(--ink); font-size: .82rem; font-weight: 700; white-space: nowrap; }
.quiet-button:hover, .view-tools button:hover { background: #eef4ff; border-color: #9cb3da; }
.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.primary:hover { background: #183ca0; }
.build-button { padding-inline: 16px; min-height: 45px; gap: 12px; background: var(--yellow); border-color: #daad39; box-shadow: 0 3px 0 #e4ad40; color: var(--ink); font-size: .98rem; font-weight: 800; }
.build-button:hover { background: #ffda73; }
.refine { margin-top: 13px; padding-top: 10px; border-top: 1px solid var(--cream-line); }
.refine summary { cursor: pointer; color: var(--muted); font-size: .82rem; font-weight: 700; }
.refine[open] summary { margin-bottom: 10px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.fields select, .fields input { margin-top: 4px; min-height: 37px; font-size: .85rem; font-weight: 500; }
.edit-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.status { color: var(--muted); font-size: .82rem; line-height: 1.4; }
.status:not(:empty) { margin-top: 10px; }
.status[data-error="true"] { color: #a32327; }

.viewer { background: var(--white); border: 1px solid #bacbe6; border-radius: 17px; padding: 10px; box-shadow: 0 5px 0 #d1dff2; }
.viewer-head, .viewer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 1px 4px 10px; }
.viewer h2 { letter-spacing: -.035em; font-size: 1.18rem; font-weight: 800; }
.view-tools { display: flex; gap: 4px; }
.view-tools button { width: 34px; min-height: 34px; padding: 0; font-size: 17px; }
.viewport { position: relative; border-radius: 10px; background: #cbddf3; }
#arena { display: block; width: 100%; height: auto; aspect-ratio: 15 / 8; border-radius: inherit; cursor: crosshair; touch-action: manipulation; }
.hud, .map-key { position: absolute; display: flex; pointer-events: none; gap: 5px; }
.hud { top: 10px; left: 10px; flex-wrap: wrap; max-width: calc(100% - 20px); }
.hud span, .hud strong, .hud time, .map-key { font-size: .73rem; padding: 5px 8px; border: 1px solid #fff; border-radius: 5px; background: #fffffff0; color: var(--ink); font-variant-numeric: tabular-nums; }
.hud span { font-weight: 650; }
.hud time { color: var(--blue); font-weight: 750; }
.map-key { right: 10px; bottom: 10px; gap: 8px; }
.map-key span { display: flex; align-items: center; gap: 4px; }
.map-key i { width: 8px; height: 8px; border-radius: 2px; background: #347bcc; }
.map-key .legend-exit { background: #287456; }
.viewer-foot { padding: 12px 4px 2px; align-items: flex-start; flex-direction: column; }
.viewer-foot p { font-size: .84rem; font-weight: 700; line-height: 1.4; }
#play-instructions { color: var(--muted); font-weight: 500; }
.viewer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; }
#download { margin-left: auto; }

.section { margin-top: 38px; }
.section + .section { border-top: 1px solid var(--cream-line); padding-top: 27px; }
.section-head { margin-bottom: 16px; }
.section-head h2 { font-size: clamp(1.9rem, 3.3vw, 2.65rem); }
.section-head p { margin-top: 7px; line-height: 1.45; color: var(--muted); }
.worlds { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.world-card { display: flex; flex-direction: column; min-width: 0; padding: 5px; border: 1px solid var(--cream-line); border-radius: 12px; background: var(--white); color: var(--ink); text-align: left; }
.world-card:hover { border-color: var(--blue); }
.world-card canvas { display: block; width: 100%; height: auto; aspect-ratio: 15 / 8; border-radius: 7px; background: #dbe6f4; }
.world-card>span { display: flex; flex: 1; flex-direction: column; align-items: flex-start; padding: 8px 7px 6px; font-weight: 800; }
.world-card small { display: block; margin: 4px 0 10px; color: var(--muted); font-weight: 550; font-size: .81rem; line-height: 1.35; }
.world-mode { margin-top: auto; padding: 3px 6px; border-radius: 4px; background: var(--pale-blue); color: var(--blue); font-size: .72rem; font-weight: 700; }
.history-list { display: grid; gap: 7px; color: var(--muted); }
.history-list>p, .history-row { padding: 10px; border: 1px solid var(--cream-line); border-radius: 8px; background: var(--white); }
.history-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 7px; }
.history-row strong, .history-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-row strong { color: var(--ink); font-size: .92rem; }
.history-row small { font-size: .82rem; margin-top: 3px; }
.guide ol { color: var(--muted); padding-left: 22px; line-height: 1.75; }
.guide code { color: var(--blue); }
.footer { display: flex; gap: 10px 18px; flex-wrap: wrap; justify-content: space-between; color: var(--muted); padding-block: 18px; margin-top: 40px; border-top: 1px solid var(--cream-line); font-size: .85rem; }
.footer-links { display: flex; gap: 12px; }
.footer a:hover { color: var(--blue); }
.legal { max-width: 760px; padding-block: 40px; }
.legal h1 { font-size: clamp(2.3rem, 7vw, 4.5rem); letter-spacing: -.05em; margin-bottom: 22px; }
.legal p { margin-block: 15px; color: var(--muted); line-height: 1.65; }

@media (max-width: 1000px) {
  .wrap, .workbench { width: calc(100% - 48px); }
  .topbar-inner, .workbench { gap: 22px; }
  .workbench { grid-template-columns: minmax(290px, .9fr) minmax(0, 1.1fr); }
}
@media (max-width: 760px) {
  .wrap, .workbench { width: calc(100% - 28px); }
  .topbar-inner { min-height: 57px; gap: 9px; }
  .topbar nav { display: none; }
  .brand { font-size: 16px; }
  .hero { padding-block: 27px 31px; }
  .workbench { grid-template-columns: 1fr; gap: 22px; }
  .hero h1 { font-size: clamp(2.5rem, 7.7vw, 3.6rem); }
  .intro { margin-top: 10px; }
  .editor { margin-top: 16px; padding: 12px; }
  .worlds { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .hud { top: 7px; left: 7px; }
  .hud span, .hud strong, .hud time, .map-key { padding: 3px 5px; font-size: .7rem; }
  .map-key { right: 7px; bottom: 6px; }
}
@media (max-width: 380px) {
  .brand { gap: 7px; font-size: 14px; }
  .history-link { padding-inline: 7px; font-size: .75rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

.maker-directory { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:14px; }
.maker-card { display:block; padding:6px 6px 11px; border:1px solid var(--cream-line); border-radius:12px; background:var(--white); }
.maker-card:hover { border-color:var(--blue); }
.maker-card canvas { display:block; width:100%; height:auto; border-radius:7px; background:var(--pale-blue); }
.maker-card strong,.maker-card>span { display:block; margin:8px 5px 0; }
.maker-card>span { margin-top:3px; color:var(--muted); font-size:.85rem; line-height:1.4; }

.maker-hero { background:#eaf1ff; border-bottom:1px solid #cedbf0; padding:22px 0 40px; }
.maker-path { display:flex; flex-wrap:wrap; gap:7px; color:var(--muted); font-size:.83rem; }
.maker-path a:hover,.maker-related a:hover { color:var(--blue); text-decoration:underline; }
.maker-hero h1 { margin-top:12px; font-family:ui-rounded,"Avenir Next","Segoe UI",system-ui,sans-serif; font-size:clamp(2.12rem,5vw,4rem); font-weight:850; letter-spacing:-.06em; line-height:1.04; }
.maker-intro { margin:10px 0 22px; font-size:1.03rem; line-height:1.5; color:var(--muted); max-width:710px; }
.maker-workspace { display:grid; grid-template-columns:minmax(0,1fr) minmax(234px,300px); align-items:start; gap:18px; }
.maker-preview,.maker-settings { min-width:0; background:var(--white); border:1px solid #c4d0e2; border-radius:15px; box-shadow:0 4px 0 #d6e1f5; }
.maker-preview { padding:10px; }
.maker-preview-head { display:flex; align-items:baseline; justify-content:space-between; gap:8px 16px; flex-wrap:wrap; padding:3px 4px 9px; }
.maker-preview-head h2,.maker-settings h2 { font-size:1.13rem; font-weight:800; letter-spacing:-.032em; }
#maker-stats { font-weight:720; color:var(--muted); font-size:.83rem; font-variant-numeric:tabular-nums; }
#maker-canvas { display:block; width:100%; height:auto; aspect-ratio:36/19; border-radius:9px; background:var(--pale-blue); }
[data-maker="pets"] #maker-canvas,[data-maker="defense"] #maker-canvas { cursor:crosshair; touch-action:manipulation; }
#maker-instruction { margin:10px 3px 7px; color:var(--muted); font-size:.86rem; line-height:1.4; }
.maker-controls,.pad-buttons { display:flex; flex-wrap:wrap; gap:6px; }
.maker-controls { align-items:center; margin:0 3px; }
.pad-buttons { flex-basis:100%; }
.pad-buttons button { min-width:33px; }
.maker-controls button:disabled,.maker-settings button:disabled { cursor:default; opacity:.53; }
.maker-controls .quiet-button[aria-pressed="true"] { background:var(--pale-blue); border-color:#748fc6; }
[data-motion] { touch-action:none; user-select:none; min-width:43px; }
.maker-notice { margin-inline:3px; }
.maker-settings { padding:16px; }
#maker-settings { display:grid; gap:10px; margin-top:13px; }
#maker-settings select { display:block; margin-top:5px; font-size:.88rem; font-weight:500; }
#maker-settings .build-button { margin-top:3px; justify-content:space-between; }
.maker-file { display:grid; gap:8px; margin-top:18px; padding-top:14px; border-top:1px solid var(--cream-line); }
.maker-file p { color:var(--muted); font-size:.85rem; line-height:1.45; }
.maker-features { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; }
.maker-features article { padding:14px; background:var(--white); border:1px solid var(--cream-line); border-radius:10px; }
.maker-features h3 { font-size:1.03rem; }
.maker-features p,.maker-faq details p { margin-top:7px; color:var(--muted); line-height:1.5; }
.maker-faq details { border-bottom:1px solid var(--cream-line); padding:11px 3px; }
.maker-faq summary { cursor:pointer; font-weight:700; }
.maker-related a { display:inline-flex; margin:0 14px 9px 0; color:var(--blue); font-weight:680; }

@media(max-width:920px) {
  .topbar-inner { gap:16px; }
  nav { gap:16px; }
  .maker-directory { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media(max-width:760px) {
  .topbar-inner { gap:9px; }
  .maker-workspace,.maker-features { grid-template-columns:1fr; }
  .maker-hero { padding-block:18px 25px; }
  .maker-intro { font-size:.96rem; }
  .maker-settings { min-width:0; }
  .maker-directory { gap:8px; }
  .maker-card strong { font-size:.95rem; overflow-wrap:anywhere; }
}

.quick-card { text-align:left; color:var(--ink); cursor:pointer; }
.quick-card>strong { margin-top:3px; }
.quick-card>.quick-kind { margin-top:9px; color:var(--blue); font-weight:750; font-size:.76rem; }
.starter-heading { margin:25px 0 10px; font-size:1.16rem; letter-spacing:-.025em; }
.quick-dialog { width:min(768px,calc(100% - 22px)); max-height:calc(100% - 24px); padding:14px; border:1px solid #b8c8e0; border-radius:16px; background:var(--white); color:var(--ink); box-shadow:0 12px 45px #182d4545; overflow:auto; }
.quick-dialog::backdrop { background:#16273988; }
.quick-top { display:flex; justify-content:space-between; align-items:flex-start; gap:8px; margin-bottom:9px; }
.quick-top h2 { font-size:clamp(1.17rem,3.4vw,1.57rem); font-weight:840; letter-spacing:-.032em; }
#quick-stats { margin-top:2px; color:var(--muted); font-size:.85rem; font-weight:700; font-variant-numeric:tabular-nums; }
#quick-canvas { width:100%; height:auto; display:block; background:var(--pale-blue); border-radius:9px; cursor:pointer; touch-action:manipulation; }
#quick-help { margin:10px 0; color:var(--muted); font-size:.88rem; line-height:1.45; }
.quick-controls,.quick-controls>div,.quick-plots { display:flex; align-items:center; flex-wrap:wrap; gap:6px; }
.quick-controls [aria-pressed="true"] { background:var(--pale-blue); border-color:#859cc6; }
.quick-controls .quiet-button { min-width:36px; }
.quick-plots button { min-width:31px !important; padding-inline:6px; }
.quick-dialog button:focus-visible,.quick-dialog canvas:focus-visible { outline-offset:2px; }
body:has(.quick-dialog[open]) { overflow:hidden; }
@media(max-width:420px) {
  .quick-dialog { padding:10px; }
  .quick-controls { gap:8px; }
  .quick-controls>div,.quick-plots { gap:4px; }
  .quick-plots { flex-basis:100%; }
}

#quick-journal { margin:-4px 0 10px; color:var(--muted); font-size:.8rem; }
