:root {
  --accent: #e0336f;
  --accent-dark: #b81f55;
  --accent-soft: #fde8ef;
  --ink: #1f1d24;
  --muted: #6b6774;
  --bg: #f6f2ec;
  --card: #fff;
  --line: #e4ddd3;
  --radius: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* Only the current view shows; body[data-view] is set before first paint (see index.html). */
body:not([data-view=landing]) #landing,
body:not([data-view=create]) #create,
body:not([data-view=sheet]) #sheet { display: none !important; }
html, body { margin: 0; }
body {
  font-family: 'Avenir Next', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

:root { --bar-h: 66px; } /* header and footer share one height (18px padding around the 30px logo), so the page between them centres evenly */
.top, .foot { min-height: var(--bar-h); padding: 18px 20px; display: flex; justify-content: center; align-items: center; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--accent); text-decoration: none; }
.brand svg { color: var(--accent); transition: transform .6s cubic-bezier(.3, 1.6, .5, 1); }
/* Logo hover: the hexagon spins a third of a turn with a springy overshoot, like the toy flipping to its next face. */
.brand:hover svg, .brand:focus-visible svg { transform: rotate(120deg) scale(1.12); }
.brand:active svg { transform: rotate(120deg) scale(.94); transition-duration: .15s; }

main { flex: 1; width: 100%; max-width: 1060px; margin: 0 auto; padding: 32px 16px; display: flex; flex-direction: column; }

/* ---------- Big playful call to action ---------- */
.cta {
  font: inherit; font-weight: 800; font-size: clamp(1.15rem, 2.6vw, 1.4rem); letter-spacing: -.01em;
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  padding: 18px 34px; border: 0; border-radius: 999px; cursor: pointer; text-decoration: none;
  background: var(--accent); color: #fff;
  box-shadow: 0 6px 0 var(--accent-dark), 0 14px 30px rgba(224, 51, 111, .28);
  transform: translateY(0) rotate(0);
  transition: transform .15s cubic-bezier(.3, 1.6, .5, 1), box-shadow .15s, background .15s;
}
.cta:hover { transform: translateY(-2px) rotate(-1.5deg); box-shadow: 0 8px 0 var(--accent-dark), 0 18px 36px rgba(224, 51, 111, .32); }
.cta:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--accent-dark), 0 6px 14px rgba(224, 51, 111, .25); }
.cta:focus-visible { outline: 4px solid #f6a5c1; outline-offset: 4px; }
.cta:disabled { background: #d8d0c5; color: #fff; box-shadow: 0 6px 0 #c2b9ad; cursor: not-allowed; transform: none; }
.cta.alt { background: #fff; color: var(--ink); box-shadow: 0 6px 0 var(--line), 0 14px 30px rgba(60, 40, 20, .10); }
.cta.alt:active { box-shadow: 0 1px 0 var(--line); }
.cta-hex { display: inline-flex; width: 1.5em; height: 1.5em; }
.cta-hex svg { width: 100%; height: 100%; color: #fff; transition: transform .5s cubic-bezier(.3, 1.4, .5, 1); }
.cta:hover .cta-hex svg { transform: rotate(120deg); }

/* ---------- 1. Landing ---------- */
.landing { text-align: center; padding: 0 0 40px; display: flex; flex-direction: column; align-items: center; }
.hero-art { position: relative; width: clamp(180px, 30vw, 260px); aspect-ratio: 1; margin-bottom: 18px; }
.hero-hex { width: 100%; height: 100%; animation: bob 4s ease-in-out infinite; filter: drop-shadow(0 14px 18px rgba(60, 40, 20, .18)); overflow: visible; }
.bubble { position: absolute; border-radius: 50%; animation: bob 3.2s ease-in-out infinite; }
.b1 { width: 16px; height: 16px; background: #ffc93c; top: 6%; left: -6%; animation-delay: -.8s; }
.b2 { width: 11px; height: 11px; background: #2ec4a6; bottom: 10%; right: -8%; animation-delay: -1.6s; }
.b3 { width: 8px; height: 8px; background: #3a86ff; top: 0; right: 4%; animation-delay: -2.2s; }
@keyframes bob { 50% { transform: translateY(-8px); } }

.landing h1 { font-size: clamp(3.2rem, 11vw, 6.5rem); line-height: .95; letter-spacing: -.04em; font-weight: 800; margin: 0 0 16px; max-width: 16ch; text-wrap: balance; }
.lede { color: var(--muted); font-size: clamp(1.05rem, 2.2vw, 1.25rem); max-width: 48ch; margin: 0 0 32px; text-wrap: pretty; }
.lede:has(+ .lede) { margin-bottom: 14px; }

/* ---------- Footer ---------- */
.foot { gap: 10px; color: var(--muted); font-size: .88rem; } /* layout shared with .top above */
.foot a { color: var(--muted); text-decoration: none; font-weight: 600; }
.foot a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.agree { color: var(--muted); font-size: .85rem; margin: 33px 0 0; } /* looks the same as the 30px above the button, once the button's 6px edge and the text's leading are counted */
.agree a { color: inherit; text-underline-offset: 2px; }

/* ---------- Privacy & terms (public/privacy.html, public/terms.html) ---------- */
.legal { width: 100%; max-width: 680px; margin: 0 auto; background: var(--card); border-radius: 28px; padding: clamp(24px, 5vw, 48px); box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 16px 50px rgba(60, 40, 20, .10); }
.legal h1 { font-size: clamp(2rem, 5vw, 2.8rem); letter-spacing: -.03em; line-height: 1.05; margin: 0 0 6px; }
.legal .updated { color: var(--muted); font-size: .9rem; margin: 0 0 22px; }
.legal .intro { font-size: 1.1rem; }
.legal h2 { font-size: 1.15rem; margin: 30px 0 6px; }
.legal p, .legal li { color: #3b3842; }
.legal ul { padding-left: 1.2em; }
.legal li { margin: 6px 0; }
.legal a:not(.link) { color: var(--accent-dark); text-underline-offset: 2px; }
.legal code { background: #f1ece5; padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.legal-back { margin-top: 34px; text-align: center; }

/* ---------- 404 (public/404.html) ---------- */
.notfound { padding-top: clamp(20px, 8vh, 80px); }
.notfound h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); max-width: 14ch; }
.nf-hex { width: clamp(130px, 20vw, 170px); margin-bottom: 22px; animation: bob 4s ease-in-out infinite; filter: drop-shadow(0 14px 18px rgba(60, 40, 20, .16)); overflow: visible; }
.nf-home { margin: 22px 0 0; }

/* ---------- 2. Upload ---------- */
.create { position: relative; width: 100%; max-width: 820px; margin: 0 auto; flex: 1; display: flex; flex-direction: column; justify-content: center; } /* card sits in the middle of the screen */
.create-card { background: var(--card); border-radius: 28px; padding: clamp(20px, 4vw, 40px); box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 16px 50px rgba(60, 40, 20, .10); }
.back { color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem; }
.back:hover { color: var(--ink); }
.create h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); letter-spacing: -.02em; line-height: 1.1; margin: 12px 0 6px; }
.sub { color: var(--muted); margin: 0 0 24px; }

.slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 760px) { .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.slot {
  position: relative; display: flex; flex-direction: column;
  background: #fbf8f4; border: 2.5px dashed var(--line); border-radius: var(--radius);
  cursor: pointer; transition: border-color .15s, background .15s, transform .2s cubic-bezier(.3, 1.6, .5, 1);
}
.slot:hover { border-color: #f2a3bf; background: #fff; }
.slot.filled { border-style: solid; border-color: var(--line); background: #fff; }
.slot.drop { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.03); }
.slot.busy { opacity: .5; pointer-events: none; }
.slot-main {
  font: inherit; color: inherit; background: none; border: 0; cursor: pointer; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px 10px 14px; width: 100%;
}
.slot-main:focus-visible { outline: 3px solid #f6a5c1; outline-offset: 2px; }
/* fixed square box, so the card is its final size before app.js draws into it (no layout shift) */
.slot .hex { display: block; width: min(140px, 100%); aspect-ratio: 1; color: #d3c9bc; line-height: 0; transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); }
.slot:hover .hex { transform: rotate(-6deg) scale(1.04); }
.slot.filled .hex { color: var(--ink); }
.slot .hex svg { display: block; width: 100%; height: 100%; }
.slot-name { font-weight: 700; }
.slot-hint { color: var(--muted); font-size: .85rem; }
.slot:not(.filled) .slot-hint::before { content: '+ '; color: var(--accent); font-weight: 800; }
.slot-actions { display: flex; gap: 6px; justify-content: center; padding: 0 10px 14px; margin-top: -4px; }
.chip { font: inherit; font-size: .82rem; font-weight: 600; padding: 4px 11px; border-radius: 999px; border: 0; cursor: pointer; background: #f1ece5; color: var(--ink); }
.chip:hover { background: #e8e1d8; }
.chip:focus-visible { outline: 3px solid #f6a5c1; outline-offset: 1px; }


.make-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 30px; }
.message { background: var(--accent-soft); color: var(--accent-dark); padding: 10px 14px; border-radius: 12px; margin: 20px 0 0; }


.drop-overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; pointer-events: none;
  background: rgba(224, 51, 111, .10); border: 4px dashed var(--accent); opacity: 0; transition: opacity .15s;
}
.drop-overlay span { background: var(--accent); color: #fff; font-weight: 800; font-size: 1.3rem; padding: 14px 26px; border-radius: 999px; box-shadow: 0 10px 30px rgba(224, 51, 111, .3); }
body.dragging .drop-overlay { opacity: 1; }

/* ---------- 3. Sheet ---------- */
.sheet-head { text-align: center; padding: 10px 0 30px; display: flex; flex-direction: column; align-items: center; }
.sheet-head h1 { font-size: clamp(1.9rem, 5vw, 3rem); letter-spacing: -.03em; line-height: 1.05; margin: 0 0 24px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }
.sheet-more { margin-top: 22px; display: flex; justify-content: center; gap: 10px; color: var(--muted); }
.link { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--ink); }

.paper { background: #fff; border-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 30px rgba(60,40,20,.10); padding: 2.5%; overflow: hidden; }
.paper svg { display: block; width: 100%; height: auto; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.noscript { max-width: 520px; margin: 0 auto 40px; padding: 14px 18px; text-align: center; background: var(--accent-soft); color: var(--accent-dark); border-radius: 12px; }

/* ---------- Small buttons (editor dialog) ---------- */
.btn {
  font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; border-radius: 999px; border: 0; cursor: pointer; text-decoration: none;
  background: var(--accent); color: #fff; transition: background .15s;
}
.btn:hover { background: var(--accent-dark); }
.btn:focus-visible { outline: 3px solid #f6a5c1; outline-offset: 2px; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.ghost:hover { background: #fff; }

/* Editor dialog */
#editor { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; }
#editor::backdrop { background: rgba(25, 20, 30, .55); }
.ed-head { padding: 18px 20px 6px; }
.ed-head h2 { margin: 0 0 4px; font-size: 1.2rem; }
.ed-head p { margin: 0; color: var(--muted); font-size: .9rem; }
.stage { display: block; width: 100%; aspect-ratio: 1; touch-action: none; cursor: grab; margin-top: 10px; user-select: none; }
.stage:active { cursor: grabbing; }
.ed-controls { display: grid; gap: 10px; padding: 14px 20px 4px; }
.ed-controls label { display: grid; grid-template-columns: 50px 1fr; align-items: center; gap: 10px; font-weight: 600; font-size: .92rem; }
.ed-controls label.check { display: flex; font-weight: 400; color: var(--muted); }
.ed-controls input[type=range] { width: 100%; accent-color: var(--accent); }
.ed-controls input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; }
.ed-foot { display: flex; justify-content: space-between; padding: 12px 20px 18px; }

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  .slots { grid-template-columns: 1fr; gap: 10px; }
  .slot { flex-direction: row; align-items: center; }
  .slot-main { flex-direction: row; justify-content: flex-start; text-align: left; gap: 4px 14px; padding: 12px 14px; flex: 1; display: grid; grid-template-columns: auto 1fr; }
  .slot .hex { grid-row: span 2; }
  .slot .hex { width: 64px; }
  .slot-name { align-self: end; }
  .slot-hint { align-self: start; }
  .slot-actions { flex-direction: column; padding: 0 12px 0 0; margin: 0; }
  .cta { width: 100%; padding: 17px 24px; }
  .sheet-actions { width: 100%; flex-direction: column; }
}

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

/* Printing: only the sheet, at real size */
@page { size: landscape; margin: 8mm; }
@media print {
  body { background: #fff; }
  .top, .foot, .sheet-head, .sheet-more, #landing, #create, #editor { display: none !important; }
  main { padding: 0; max-width: none; }
  .paper { box-shadow: none; padding: 0; border-radius: 0; }
  .paper svg { width: 263mm; height: 192mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
