:root {
    --paper: #f8edda;
    --paper-deep: #ead7ba;
    --ink: #272129;
    --berry: #762c67;
    --berry-dark: #4c1745;
    --mint: #46b88a;
    --yellow: #f2bd45;
    --line: #342b34;
    --white: #fffaf0;
    --shadow: 5px 6px 0 rgba(52, 43, 52, .16);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 14% 12%, rgba(255,255,255,.8) 0 2px, transparent 3px),
        linear-gradient(115deg, rgba(118,44,103,.04), transparent 32%),
        var(--paper);
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    min-height: 100vh;
}
button, input { font: inherit; }
button { color: inherit; }

.paper-noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .15;
    z-index: 20;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.19'/%3E%3C/svg%3E");
    mix-blend-mode: multiply;
}

.site-head {
    min-height: 76px;
    padding: 13px clamp(18px, 4vw, 64px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--line);
    position: relative;
    z-index: 2;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-stamp {
    width: 48px; height: 48px; border: 2px solid var(--line); border-radius: 50% 45% 48% 42%;
    display: grid; place-items: center; background: var(--berry); color: white;
    font: 900 17px/1 Georgia, serif; transform: rotate(-6deg); box-shadow: 2px 3px 0 var(--line);
}
.brand b { display: block; font: 900 18px/1 "Arial Black", sans-serif; letter-spacing: .06em; }
.brand small { display: block; margin-top: 4px; font: italic 12px Georgia, serif; color: #625763; }
.privacy-note { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.privacy-note span { display: inline-block; width: 8px; height: 8px; background: var(--mint); border-radius: 50%; margin-right: 7px; box-shadow: 0 0 0 3px rgba(70,184,138,.18); }

main { width: min(1500px, 100%); margin: auto; padding: 34px clamp(16px, 4vw, 62px) 54px; }
.intro { display: grid; grid-template-columns: auto 1fr; column-gap: 42px; align-items: end; margin-bottom: 30px; }
.eyebrow { grid-row: 1 / span 2; margin: 7px 0; writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; letter-spacing: .2em; font-weight: 900; color: var(--berry); }
.intro h1 { margin: 0; font: 900 clamp(38px, 5vw, 72px)/.86 "Arial Black", "Cooper Black", sans-serif; letter-spacing: -.055em; text-transform: uppercase; }
.intro h1 em { color: var(--berry); font-family: Georgia, serif; text-transform: none; font-weight: 700; letter-spacing: -.045em; }
.intro-copy { margin: 18px 0 0; max-width: 610px; color: #655b65; font: 16px/1.5 Georgia, serif; }

.maker { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr) 260px; gap: 18px; align-items: stretch; }
.panel, .export-card { border: 2px solid var(--line); background: rgba(255,250,240,.72); box-shadow: var(--shadow); border-radius: 18px 15px 20px 14px; overflow: hidden; }
.panel-heading { min-height: 74px; display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 2px solid var(--line); }
.panel-heading h2 { margin: 0; font: 900 20px/1 "Arial Black", sans-serif; text-transform: uppercase; letter-spacing: -.03em; }
.panel-heading p { margin: 5px 0 0; font: italic 12px Georgia, serif; color: #746a74; }
.step { flex: 0 0 40px; height: 40px; border: 2px solid var(--line); border-radius: 50%; display: grid; place-items: center; color: white; background: var(--berry); font-weight: 900; transform: rotate(-5deg); }
.icon-button { margin-left: auto; border: 1px solid var(--line); background: transparent; border-radius: 20px; padding: 7px 11px; font-size: 10px; font-weight: 900; cursor: pointer; }
.icon-button:hover { color: white; background: var(--berry); }

.canvas-wrap, .preview-stage {
    position: relative; min-height: 350px; display: grid; place-items: center; overflow: hidden;
    background-color: #e9d8bd;
    background-image: linear-gradient(45deg, rgba(255,255,255,.34) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.34) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.34) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.34) 75%);
    background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0;
    border-bottom: 2px solid var(--line);
}
.canvas-wrap canvas, .preview-stage canvas { width: min(100%, 400px); height: auto; display: block; position: relative; z-index: 2; }
#paintCanvas { touch-action: none; cursor: crosshair; }
.canvas-hint { position: absolute; left: 17px; bottom: 15px; border: 1px solid var(--line); background: var(--yellow); padding: 5px 9px; border-radius: 7px; font: 800 10px/1 sans-serif; text-transform: uppercase; transform: rotate(-3deg); transition: opacity .2s; }
.canvas-hint.hidden { opacity: 0; }

.paint-controls { padding: 14px 16px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 13px 16px; }
.control-block label, .outline-row label { display: block; margin-bottom: 7px; font-size: 10px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.coat-control, .size-control { grid-column: 1 / -1; }
.swatches { display: flex; gap: 8px; align-items: center; }
.swatch, .custom-color { width: 31px; height: 31px; border: 2px solid var(--line); border-radius: 50%; background: var(--swatch); cursor: pointer; position: relative; }
.swatch.active::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--line); font-weight: 900; text-shadow: 0 1px white; }
.custom-color { overflow: hidden; border-style: dashed; display: grid; place-items: center; }
.custom-color input { position: absolute; inset: -10px; width: 50px; height: 50px; opacity: 0; cursor: pointer; }
.custom-color b { pointer-events: none; }
.brush-row { display: flex; align-items: center; gap: 6px; }
#brushColor, #outlineColor { width: 34px; height: 30px; padding: 0; border: 1px solid var(--line); background: none; border-radius: 7px; cursor: pointer; }
.tool-button { border: 1px solid var(--line); background: transparent; border-radius: 7px; padding: 7px 8px; font-size: 9px; font-weight: 900; cursor: pointer; }
.tool-button.active { background: var(--line); color: white; }
.size-control label { display: flex; justify-content: space-between; }
.size-control input { width: 100%; accent-color: var(--berry); }

.preview-stage { background-color: #ccead9; min-height: 350px; }
.preview-stage::before { content: ""; width: 78%; height: 78%; border: 2px dashed rgba(39,33,41,.18); border-radius: 50%; position: absolute; }
.shadow { position: absolute; z-index: 1; bottom: 17%; width: 36%; height: 7%; border-radius: 50%; background: rgba(39,33,41,.16); filter: blur(5px); }
.spark { position: absolute; z-index: 3; color: var(--berry); font-size: 27px; animation: twinkle 1.2s ease-in-out infinite alternate; }
.spark-a { left: 15%; top: 19%; }
.spark-b { right: 14%; bottom: 22%; animation-delay: .5s; }
@keyframes twinkle { to { transform: rotate(30deg) scale(.55); opacity: .35; } }
.loading { position: absolute; z-index: 4; background: var(--paper); border: 1px solid var(--line); padding: 7px 11px; border-radius: 20px; font: italic 12px Georgia, serif; }
.loading.hidden { display: none; }
.accessory-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px; border-bottom: 2px solid var(--line); }
.accessory-list button { min-height: 52px; border: 1px solid var(--line); border-radius: 9px; background: var(--white); font-size: 10px; font-weight: 900; cursor: pointer; text-transform: uppercase; transition: transform .12s, background .12s; }
.accessory-list button span { display: block; height: 20px; font: 20px/1 Georgia, serif; text-transform: none; }
.accessory-list button:hover { transform: translateY(-2px) rotate(-1deg); }
.accessory-list button.active { background: var(--yellow); box-shadow: 2px 2px 0 var(--line); transform: translate(-1px,-1px); }
.outline-row { min-height: 64px; padding: 12px 15px; display: flex; align-items: center; gap: 10px; }
.outline-row label { margin: 0; }
.reset-button { margin-left: auto; border: 0; border-bottom: 1px solid currentColor; background: none; padding: 3px; font-size: 9px; font-weight: 900; cursor: pointer; }

.export-card { background: var(--berry); color: white; padding: 18px; display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; }
.export-card::before { content: ""; position: absolute; inset: 8px; border: 1px dashed rgba(255,255,255,.4); border-radius: 12px; pointer-events: none; }
.export-kicker { align-self: stretch; padding: 7px; background: var(--yellow); color: var(--ink); border: 2px solid var(--line); border-radius: 6px; font: 900 10px/1 sans-serif; letter-spacing: .1em; transform: rotate(1.5deg); position: relative; z-index: 2; }
.mini-preview { width: 170px; height: 170px; margin: 20px 0 4px; display: grid; place-items: center; background: #ccead9; border: 2px solid var(--line); border-radius: 50%; box-shadow: 3px 4px 0 var(--line); overflow: hidden; z-index: 2; }
.mini-preview canvas { width: 160px; height: 160px; }
.export-card h2 { font: italic 700 25px/1 Georgia, serif; margin: 15px 0 8px; z-index: 2; }
.export-card p { font-size: 11px; line-height: 1.55; opacity: .82; margin: 0 0 16px; z-index: 2; }
.download-button { width: 100%; padding: 13px 12px; border: 2px solid var(--line); border-radius: 9px; background: var(--mint); box-shadow: 3px 4px 0 var(--line); display: flex; justify-content: space-between; cursor: pointer; font-weight: 900; font-size: 12px; z-index: 2; transition: transform .12s, box-shadow .12s; }
.download-button:hover { transform: translate(2px,2px); box-shadow: 1px 2px 0 var(--line); }
.download-button:disabled { cursor: wait; opacity: .65; }
.download-button b { font-size: 18px; line-height: 12px; }
.export-status { min-height: 34px; margin: 14px 4px; font: italic 10px/1.45 Georgia, serif; opacity: .75; z-index: 2; }
.vrcpop-link { margin-top: auto; color: white; font-size: 10px; line-height: 1.5; z-index: 2; }

footer { border-top: 2px solid var(--line); min-height: 52px; padding: 0 clamp(18px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; font-size: 10px; text-transform: uppercase; letter-spacing: .12em; font-weight: 900; }

@media (max-width: 1100px) {
    .maker { grid-template-columns: 1fr 1fr; }
    .export-card { grid-column: 1 / -1; display: grid; grid-template-columns: auto 170px 1fr 230px; gap: 15px; text-align: left; align-items: center; }
    .export-kicker { display: none; }
    .mini-preview { margin: 0; grid-row: 1 / span 3; }
    .export-card h2, .export-card p, .export-status { margin: 0; }
    .download-button { grid-column: 4; grid-row: 1 / span 2; }
    .vrcpop-link { grid-column: 4; margin: 0; }
}

@media (max-width: 760px) {
    .privacy-note { font-size: 9px; }
    main { padding-top: 24px; }
    .intro { column-gap: 15px; }
    .intro-copy { font-size: 14px; }
    .maker { grid-template-columns: 1fr; }
    .export-card { grid-column: auto; display: flex; text-align: center; }
    .export-kicker { display: block; }
    .mini-preview { margin: 18px 0 2px; }
    .download-button { grid-column: auto; }
    .canvas-wrap, .preview-stage { min-height: 320px; }
}

@media (max-width: 430px) {
    .site-head { min-height: 66px; }
    .brand small { display: none; }
    .brand b { font-size: 15px; }
    .brand-stamp { width: 40px; height: 40px; }
    .intro h1 { font-size: 38px; }
    .intro-copy { margin-top: 12px; }
    .panel-heading h2 { font-size: 17px; }
    .canvas-wrap, .preview-stage { min-height: 290px; }
    .paint-controls { grid-template-columns: 1fr; }
    .coat-control, .size-control { grid-column: auto; }
    .swatches { flex-wrap: wrap; }
    footer { flex-direction: column; justify-content: center; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
    .spark { animation: none; }
    * { scroll-behavior: auto !important; }
}
