:root{
  --bg:#0b0912;
  --panel:#1c1640;
  --panel-2:#241c4d;
  --line:#3d2f8f;
  --line-soft:#2a2260;
  --ink:#e9e5f7;
  --muted:#9c93c9;
  --accent:#7fc4d1;
  --accent-ink:#04222a;
  --warm:#c7d27e;
  --warm-ink:#1c210a;
  --danger:#c26b68;
  --danger-ink:#2a0d0c;
  --checker-a:#241c4d;
  --checker-b:#191436;
  color-scheme: dark;
}

/* Sizing note: real, literal values (not zoom/transform) — see git history
   for why. Went small -> 2x -> ~1.4x -> back down close to the original
   scale: 1.4x still read as oversized once viewed as its own full page
   rather than embedded/linked from elsewhere. */

*{box-sizing:border-box;}
html,body{ height:100%; }
body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font-family:'VT323', ui-monospace, monospace;
  font-size:17px;
  line-height:1.35;
  padding-inline:18px;
  padding-block:20px 32px;
  background-image:
    radial-gradient(ellipse 900px 500px at 20% -10%, rgba(111,61,134,0.25), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 0%, rgba(112,164,178,0.12), transparent 55%);
  background-attachment:fixed;
}

h1,h2,h3{ margin:0; }
h1{ font-family:'Press Start 2P', 'VT323', monospace; }
button, select, input{ font-family:inherit; }

.wrap{ max-width:1200px; width:100%; margin:0 auto; }

header.top{
  display:flex; align-items:flex-end; justify-content:space-between; gap:16px;
  flex-wrap:wrap;
  padding-bottom:18px; margin-bottom:18px;
  border-bottom:2px solid var(--line);
}
.brand h1{ font-size:22px; color:var(--warm); letter-spacing:1.2px; margin-bottom:8px; }
.brand p{ margin:0; color:var(--muted); font-size:16px; max-width:52ch; }
.brand p a{ color:var(--accent); }
.brand .tag{ display:inline-block; font-size:12px; letter-spacing:1.8px; text-transform:uppercase;
  color:var(--accent); border:1px solid var(--line); background:var(--panel);
  padding:3px 8px; border-radius:4px; margin-bottom:9px; }

#downloadBtn{
  flex-shrink:0;
  background:var(--warm); color:var(--warm-ink); border:2px solid #8b9451;
  padding:11px 18px; font-size:16px; border-radius:6px; cursor:pointer;
  box-shadow: 0 3px 0 #6f7940;
}
#downloadBtn:active{ transform:translateY(2px); box-shadow:0 1px 0 #6f7940; }

.grid{
  display:grid;
  grid-template-columns: minmax(0,1.1fr) minmax(280px,0.9fr);
  gap:17px;
  align-items:start;
}
@media (max-width:1100px){
  .grid{ grid-template-columns: 1fr; }
}

.panel{
  background:var(--panel);
  border:2px solid var(--line);
  border-radius:7px;
  padding:14px;
}
.panel + .panel{ margin-top:14px; }

.eyebrow{
  font-size:12px; letter-spacing:2px; text-transform:uppercase;
  color:var(--muted); margin-bottom:9px; display:block;
}

.stage-scroll{ overflow-x:auto; padding-bottom:6px; }
.stage{
  display:flex; justify-content:center; padding:11px;
  background:var(--panel-2); border-radius:7px; border:1px solid var(--line-soft);
}
canvas#pixels{
  image-rendering:pixelated;
  touch-action:none;
  cursor:crosshair;
  border-radius:3px;
  box-shadow: 0 0 0 1px var(--line);
}
canvas#sideView{
  image-rendering:pixelated;
  border-radius:3px;
  box-shadow: 0 0 0 1px var(--line);
}

.toolbar{
  display:flex; flex-wrap:wrap; gap:9px; align-items:center;
  margin-top:12px;
}
.btn-row{ display:flex; gap:7px; flex-wrap:wrap; }
.tbtn{
  background:var(--panel-2); color:var(--ink); border:1px solid var(--line);
  border-radius:6px; padding:7px 11px; font-size:14px; cursor:pointer;
  display:flex; align-items:center; gap:6px;
}
.tbtn[aria-pressed="true"]{ background:var(--accent); color:var(--accent-ink); border-color:var(--accent); }
.tbtn:hover{ filter:brightness(1.1); }

.field{ display:flex; align-items:center; gap:8px; font-size:13px; color:var(--muted); }
.field input[type=range]{ width:110px; accent-color:var(--accent); }
.field input[type=checkbox]{ width:16px; height:16px; accent-color:var(--accent); }

.swatches{ display:flex; flex-wrap:wrap; gap:8px; margin-top:9px; }
.swatch{
  width:30px; height:30px; border-radius:6px; border:2px solid var(--line-soft);
  cursor:pointer; padding:0; position:relative;
}
.swatch[aria-pressed="true"]{ border-color:var(--warm); box-shadow:0 0 0 2px var(--warm-ink) inset, 0 0 0 1px var(--warm); }
.swatch.checker{
  background-image: linear-gradient(45deg,#3a3355 25%,transparent 25%,transparent 75%,#3a3355 75%),
                     linear-gradient(45deg,#3a3355 25%,transparent 25%,transparent 75%,#3a3355 75%);
  background-size:13px 13px; background-position:0 0, 6.5px 6.5px; background-color:#221c40;
}
input[type=color]{
  width:30px; height:30px; padding:0; border:2px solid var(--line-soft); border-radius:6px;
  background:none; cursor:pointer;
}

label.lbl{ font-size:13px; color:var(--muted); display:block; margin-bottom:5px; letter-spacing:.5px; }
select{
  width:100%; background:var(--panel-2); color:var(--ink); border:1px solid var(--line);
  border-radius:6px; padding:8px 10px; font-size:15px; margin-bottom:9px;
}

.palette-preview{ display:flex; gap:5px; margin:-2px 0 11px; }
.palette-chip{
  width:20px; height:20px; border-radius:5px; flex-shrink:0;
  border:1px solid var(--line-soft);
}

.gen-actions{ display:flex; gap:8px; flex-wrap:wrap; margin-top:5px; }
.gen-actions button{ flex:1; min-width:130px; }
.primary{
  background:var(--accent); color:var(--accent-ink); border:1px solid #4f8f9c;
  padding:10px 12px; border-radius:6px; font-size:15px; cursor:pointer;
}
.secondary{
  background:var(--panel-2); color:var(--ink); border:1px solid var(--line);
  padding:10px 12px; border-radius:6px; font-size:13px; cursor:pointer;
}
.secondary:hover, .primary:hover{ filter:brightness(1.12); }

.gallery-strip{ display:flex; gap:9px; overflow-x:auto; padding:6px 3px 12px; }
.gallery-item{ position:relative; flex:0 0 auto; }
.gallery-item button.thumb{
  width:70px; height:109px; padding:0; border:2px solid var(--line-soft); border-radius:6px;
  background:var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Crect width='4' height='4' fill='%23241c4d'/%3E%3Crect x='4' y='4' width='4' height='4' fill='%23241c4d'/%3E%3Crect x='4' width='4' height='4' fill='%231b1634'/%3E%3Crect y='4' width='4' height='4' fill='%231b1634'/%3E%3C/svg%3E");
  cursor:pointer;
}
.gallery-item button.thumb img{ width:100%; height:100%; image-rendering:pixelated; display:block; }
.gallery-item .del{
  position:absolute; top:-8px; right:-8px; width:20px; height:20px; border-radius:50%;
  background:var(--danger); color:var(--danger-ink); border:none; font-size:13px; line-height:1;
  cursor:pointer; display:flex; align-items:center; justify-content:center;
}
.empty-note{ color:var(--muted); font-size:14px; }

.toast{
  position:fixed; left:50%; bottom:24px; transform:translateX(-50%) translateY(20px);
  background:var(--panel); border:1px solid var(--line); color:var(--ink);
  padding:10px 14px; border-radius:7px; font-size:14px; opacity:0; pointer-events:none;
  transition:opacity .2s, transform .2s;
  z-index:20;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

footer.note{ margin-top:20px; color:var(--muted); font-size:13px; text-align:center; }
footer.note a{ color:var(--accent); }

.modal-backdrop{
  position:fixed; inset:0; background:rgba(6,4,12,0.72);
  display:flex; align-items:center; justify-content:center;
  padding:16px; z-index:30;
}
.modal-backdrop[hidden]{ display:none; }
.modal{
  background:var(--panel); border:2px solid var(--line); border-radius:10px;
  padding:14px; max-width:100%; max-height:90vh;
  display:flex; flex-direction:column; gap:10px;
}
.modal-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.pose-preview-wrap{
  overflow:auto; background:var(--panel-2); border:1px solid var(--line-soft);
  border-radius:7px; padding:9px; max-width:calc(100vw - 64px); max-height:60vh;
}
#poseModalCanvas{ image-rendering:pixelated; display:block; }
.modal-actions{ display:flex; gap:8px; justify-content:flex-end; flex-wrap:wrap; }

/* ---- phone --------------------------------------------------------------
   Everything above already reflows at 1100px (two columns -> one). This
   tunes the parts that only actually break on a real phone: the canvas can
   still exceed the screen width once the zoom slider is pushed up, the two
   Recolour/Reshape buttons don't fit side by side at their desktop
   min-width, and text/controls sized for a mouse are a bit small for a
   thumb. */
@media (max-width:480px){
  body{ font-size:16px; padding-inline:14px; }
  .brand h1{ font-size:21px; }
  #downloadBtn{ padding:10px 16px; font-size:15px; }
  .panel{ padding:12px; }
  .stage{ padding:9px; }
  /* let the canvas shrink to fit instead of forcing horizontal scroll on
     first load; pointer math in app.js already reads canvas.width/rect.width,
     so a CSS-scaled canvas still maps clicks to the right pixel. */
  canvas#pixels{ max-width:100%; height:auto; display:block; }
  .tbtn{ padding:7px 10px; font-size:13px; }
  .gen-actions{ flex-direction:column; }
  .gen-actions button{ min-width:0; width:100%; }
  .swatch, input[type=color]{ width:30px; height:30px; }
  .field{ font-size:13px; }
  .field input[type=range]{ width:90px; }
  .gallery-item button.thumb{ width:64px; height:100px; }
  .pose-preview-wrap{ max-width:calc(100vw - 40px); padding:7px; }
  .modal{ padding:11px; }
}
