:root {
  color-scheme: light;
  --ink: #2d504d;
  --muted: #6b817d;
  --paper: #fffdf7;
  --cream: #fff6dc;
  --line: #ddd5b9;
  --green: #3e9875;
  --blue: #62acd6;
  --purple: #8b73bd;
  --gold: #f3c34f;
  --shadow: 0 18px 42px rgba(55, 74, 68, .12);
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
  color: var(--ink);
  background: #f8f3e8;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 0; min-height: 100%; background: #f8f3e8; }
body { min-width: 0; min-height: 100%; margin: 0; overflow-x: hidden; background: radial-gradient(circle at 8% 11%, rgba(98,172,214,.18) 0 115px, transparent 116px), radial-gradient(circle at 94% 18%, rgba(233,139,181,.15) 0 120px, transparent 121px), linear-gradient(135deg,#faf6ea,#fffaf3 58%,#f8f1f5); }
button { font: inherit; }
button:focus-visible { outline: 4px solid rgba(78,119,200,.35); outline-offset: 3px; }
button:disabled { cursor: default; opacity: .45; box-shadow: none; transform: none; }

.app { width: min(1120px, calc(100% - 32px)); min-height: 100vh; margin: 0 auto; padding: 22px 0 48px; }
.topbar,.topbar-actions,.studio-head,.canvas-label,.control-heading,.history-actions,.tools-row,.option-section,.studio-actions,.feedback,.feedback>div,.hero-actions,.art-meta { display: flex; align-items: center; }
.topbar { min-height: 64px; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.brand,.gallery-button,.sound-button { color: var(--ink); border: 0; cursor: pointer; }
.brand { display: flex; min-width: 0; align-items: center; gap: 12px; padding: 0; text-align: left; background: transparent; }
.brand-mark { display: grid; flex: 0 0 auto; width: 54px; height: 54px; place-items: center; padding-top: 1px; color: #4e77c8; font-size: 27px; font-weight: 1000; background: #eef4ff; border: 2px solid #bfd0eb; border-radius: 18px; box-shadow: 0 7px 15px rgba(47,74,68,.11); }
.brand strong,.brand small,.gallery-button strong,.gallery-button small { display: block; }
.brand strong { font-size: 22px; letter-spacing: -.02em; }
.brand small { margin-top: 2px; color: #71837f; font-family: Georgia, serif; font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.topbar-actions { gap: 10px; }
.gallery-button,.sound-button { display: flex; min-height: 50px; align-items: center; gap: 9px; padding: 0 15px; background: rgba(255,253,247,.9); border: 2px solid var(--line); border-radius: 17px; box-shadow: 0 6px 15px rgba(59,77,70,.08); }
.gallery-button>span,.sound-button>span:first-child { font-size: 21px; }
.gallery-button strong { font-size: 12px; }
.gallery-button small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.sound-button>span:last-child { font-size: 11px; font-weight: 900; }

.eyebrow { margin: 0 0 8px; color: #456f66; font-family: Georgia, serif; font-size: 12px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.primary-button,.secondary-button,.save-button,.idea-button { display: inline-flex; min-height: 53px; align-items: center; justify-content: center; gap: 8px; padding: 0 21px; font-weight: 1000; border-radius: 17px; cursor: pointer; transition: transform 150ms ease, box-shadow 150ms ease; }
.primary-button,.save-button { color: white; background: var(--green); border: 2px solid #337f64; box-shadow: 0 7px 0 #2e7d60; }
.secondary-button { color: var(--ink); background: var(--paper); border: 2px solid var(--line); box-shadow: 0 5px 0 #cfc7aa; }
.idea-button { color: #69551b; background: #fff2bd; border: 2px solid #ddb84e; box-shadow: 0 5px 0 #cba438; }
.compact { min-height: 45px; padding: 0 14px; font-size: 12px; }
.primary-button:not(:disabled):hover,.secondary-button:not(:disabled):hover,.save-button:not(:disabled):hover,.idea-button:not(:disabled):hover,.gallery-button:hover,.sound-button:hover { transform: translateY(-2px); }
.primary-button:not(:disabled):active,.secondary-button:not(:disabled):active,.save-button:not(:disabled):active,.idea-button:not(:disabled):active { transform: translateY(3px); box-shadow: none; }

.hero { position: relative; display: grid; min-height: 424px; align-items: center; grid-template-columns: minmax(0,1fr) minmax(390px,.9fr); gap: 35px; overflow: hidden; padding: 48px 51px; background: linear-gradient(105deg,#fffdf7 0 53%,#f0edfb 53% 100%); border: 3px solid var(--line); border-radius: 42px; box-shadow: var(--shadow); }
.hero::before,.hero::after { position: absolute; border-radius: 16px; content: ''; transform: rotate(12deg); }
.hero::before { top: -34px; right: 220px; width: 108px; height: 108px; background: rgba(98,172,214,.16); }
.hero::after { right: -35px; bottom: -38px; width: 130px; height: 130px; background: rgba(233,139,181,.16); }
.hero-copy { position: relative; z-index: 2; }
.hero h1 { margin: 0 0 18px; font-size: clamp(48px,6vw,70px); font-weight: 1000; line-height: .92; letter-spacing: -.05em; }
.hero h1 span { color: #7460ae; }
.hero-copy>p:not(.eyebrow) { max-width: 560px; margin: 0 0 25px; color: var(--muted); font-size: 17px; font-weight: 700; line-height: 1.55; }
.hero-actions { align-items: stretch; flex-wrap: wrap; gap: 12px; }
.resume-button { max-width: 260px; }
.hero-pixels { position: relative; z-index: 2; display: grid; min-height: 310px; place-items: center; }
.hero-board { width: min(300px,100%); padding: 18px; background: rgba(255,255,255,.94); border: 3px solid #cfc6e3; border-radius: 26px; box-shadow: 0 18px 28px rgba(65,62,94,.17); transform: rotate(2deg); }
.hero-board small { display: block; margin-bottom: 10px; color: var(--muted); font-size: 10px; font-weight: 900; text-align: center; text-transform: uppercase; }
.pixel-preview { display: grid; grid-template-columns: repeat(var(--size),minmax(0,1fr)); gap: 3px; padding: 7px; background: #e8e5dc; border-radius: 14px; }
.pixel-preview span { min-width: 0; aspect-ratio: 1; background: var(--pixel); border-radius: 2px; box-shadow: inset 0 2px 0 rgba(255,255,255,.22); }
.pixel-preview span.is-empty { background: #f7f5ef; box-shadow: inset 0 1px 0 white; }
.floating-pixel { position: absolute; width: 44px; height: 44px; border: 4px solid rgba(45,80,77,.14); border-radius: 10px; box-shadow: 0 9px 13px rgba(48,64,60,.13); animation: float 1.4s ease-in-out infinite alternate; }
.pixel-one { top: 18px; right: 18px; background: #f3c34f; transform: rotate(12deg); }
.pixel-two { bottom: 19px; left: 22px; width: 35px; height: 35px; background: #62acd6; transform: rotate(-9deg); animation-delay: -.5s; }
.pixel-three { right: 3px; bottom: 60px; width: 29px; height: 29px; background: #ef7468; transform: rotate(6deg); animation-delay: -.9s; }

.how-section,.modes-section,.gallery-section { margin-top: 50px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 20px; }
.section-heading h1,.section-heading h2 { margin: 0; font-size: 39px; font-weight: 1000; letter-spacing: -.035em; }
.section-heading>p { max-width: 440px; margin: 0; color: var(--muted); font-size: 13px; font-weight: 800; line-height: 1.45; text-align: right; }
.steps-grid,.modes-grid,.gallery-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 15px; }
.step-card { display: grid; min-height: 128px; align-items: center; grid-template-columns: 62px 1fr; gap: 16px; padding: 21px; background: rgba(255,253,247,.9); border: 2px solid var(--line); border-radius: 27px; box-shadow: var(--shadow); }
.step-number { display: grid; width: 58px; height: 58px; place-items: center; padding-top: 1px; color: white; font-family: Georgia, serif; font-size: 25px; font-weight: 900; background: var(--blue); border: 7px solid #dff2f8; border-radius: 18px; }
.step-card:nth-child(2) .step-number { background: var(--gold); border-color: #fff0bf; }
.step-card:nth-child(3) .step-number { background: var(--purple); border-color: #eee7fa; }
.step-card strong,.step-card small { display: block; }
.step-card strong { margin-bottom: 6px; font-size: 18px; }
.step-card small { color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1.45; }
.mode-card { min-width: 0; padding: 22px; background: var(--paper); border: 2px solid var(--line); border-radius: 29px; box-shadow: var(--shadow); }
.mode-top { display: flex; align-items: center; gap: 13px; }
.mode-icon { display: grid; flex: 0 0 auto; width: 54px; height: 54px; place-items: center; color: var(--accent); font-size: 28px; background: color-mix(in srgb,var(--accent),white 84%); border: 2px solid color-mix(in srgb,var(--accent),white 57%); border-radius: 15px; }
.mode-card h3 { margin: 0; font-size: 21px; }
.mode-card .eyebrow { margin-bottom: 3px; }
.mode-card>p { min-height: 52px; margin: 14px 0 17px; color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1.45; }
.mode-preview { width: 140px; margin: 18px auto; padding: 6px; background: color-mix(in srgb,var(--accent),white 88%); }
.mode-card .secondary-button { width: 100%; }
.adult-note { display: flex; align-items: center; gap: 14px; margin-top: 17px; padding: 18px 21px; color: #496d60; background: #eef8ee; border: 2px solid #c9dec9; border-radius: 24px; }
.adult-note span { display: grid; flex: 0 0 auto; width: 46px; height: 46px; place-items: center; font-size: 24px; background: white; border-radius: 15px; }
.adult-note p { margin: 0; font-size: 12px; font-weight: 800; line-height: 1.45; }

.studio-shell { min-height: 760px; padding: 27px; background: rgba(255,253,247,.97); border: 3px solid var(--line); border-radius: 38px; box-shadow: var(--shadow); }
.studio-head { justify-content: space-between; gap: 22px; margin-bottom: 18px; }
.studio-head h1 { margin: 0 0 5px; font-size: 40px; font-weight: 1000; letter-spacing: -.04em; }
.studio-head>div>p:last-child { margin: 0; color: var(--muted); font-size: 13px; font-weight: 800; }
.studio-layout { display: grid; align-items: start; grid-template-columns: minmax(430px,1.2fr) minmax(330px,.8fr); gap: 17px; }
.canvas-card,.control-panel { min-width: 0; padding: 18px; background: #f7fbf8; border: 2px solid #d7e2d9; border-radius: 28px; }
.control-panel { background: #f8f5fd; border-color: #dcd3ea; }
.canvas-label { gap: 11px; margin-bottom: 14px; }
.canvas-label>span { display: grid; flex: 0 0 auto; width: 42px; height: 42px; place-items: center; color: white; font-size: 20px; background: var(--accent); border-radius: 13px; }
.canvas-label strong,.canvas-label small { display: block; }
.canvas-label strong { font-size: 16px; }
.canvas-label small { margin-top: 2px; color: var(--muted); font-size: 10px; font-weight: 800; }
.pixel-grid { display: grid; width: min(100%,560px); margin: 0 auto; overflow: hidden; grid-template-columns: repeat(var(--size),minmax(0,1fr)); touch-action: none; background: #c7c8c1; border: 8px solid white; border-radius: 20px; box-shadow: 0 0 0 2px #d5d0c4,0 16px 24px rgba(51,68,63,.13); }
.pixel-cell { min-width: 0; aspect-ratio: 1; padding: 0; cursor: crosshair; background: var(--pixel); border: 1px solid rgba(45,80,77,.2); border-radius: 0; box-shadow: inset 0 2px 0 rgba(255,255,255,.17); }
.pixel-cell.is-empty { background: #f8f7f1; }
.pixel-grid.no-grid .pixel-cell { border-color: transparent; }
.control-section { padding: 14px; background: rgba(255,255,255,.75); border: 2px solid #e1d9ec; border-radius: 22px; }
.control-section+.control-section { margin-top: 11px; }
.control-heading { justify-content: space-between; gap: 12px; }
.control-heading .eyebrow,.control-section>.eyebrow { margin-bottom: 4px; font-size: 10px; }
.control-heading strong { font-size: 15px; }
.history-actions { gap: 7px; }
.history-actions button { display: grid; width: 43px; height: 43px; place-items: center; padding: 0; color: var(--ink); font-size: 21px; font-weight: 1000; background: white; border: 2px solid #d8d1e3; border-radius: 13px; cursor: pointer; }
.tools-row { align-items: stretch; gap: 7px; margin-top: 12px; }
.tool-button { display: grid; min-height: 61px; flex: 1 1 0; place-items: center; gap: 3px; padding: 7px 5px; color: var(--ink); font-size: 10px; font-weight: 900; background: #f8f6fb; border: 2px solid #dcd6e5; border-radius: 14px; cursor: pointer; }
.tool-button span { font-size: 21px; }
.tool-button.is-selected { color: #574587; background: #eee8fa; border-color: #8b73bd; box-shadow: 0 0 0 3px rgba(139,115,189,.16); }
.palette { display: grid; grid-template-columns: repeat(6,1fr); gap: 7px; margin-top: 11px; }
.color-button { display: grid; min-width: 0; aspect-ratio: 1; place-items: center; padding: 4px; background: white; border: 2px solid #d9d6c7; border-radius: 12px; cursor: pointer; box-shadow: 0 3px 0 #cbc5af; }
.color-button span { display: block; width: 100%; aspect-ratio: 1; background: var(--swatch); border: 2px solid rgba(45,80,77,.17); border-radius: 7px; }
.color-button.is-selected { border-color: #315f55; box-shadow: 0 0 0 4px rgba(98,180,134,.19),0 3px 0 #315f55; transform: translateY(-1px); }
.option-section { align-items: stretch; gap: 8px; }
.option-button { display: flex; min-height: 57px; min-width: 0; flex: 1 1 0; align-items: center; gap: 8px; padding: 7px 9px; color: var(--ink); text-align: left; background: #faf9fc; border: 2px solid #ded8e8; border-radius: 14px; cursor: pointer; }
.option-button>span { display: grid; flex: 0 0 auto; width: 32px; height: 32px; place-items: center; font-size: 17px; font-weight: 1000; background: white; border-radius: 9px; }
.option-button strong,.option-button small { display: block; }
.option-button strong { font-size: 11px; }
.option-button small { margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 800; }
.option-button.is-selected { background: #eef7f4; border-color: #85baa8; }
.studio-actions { align-items: stretch; flex-direction: column; gap: 9px; margin-top: 12px; }
.studio-actions button { width: 100%; }
.feedback { justify-content: space-between; gap: 18px; min-height: 83px; margin-top: 15px; padding: 14px 18px; background: #f2f7f3; border: 2px solid #cadcd1; border-radius: 23px; }
.feedback>div { gap: 12px; }
.feedback-icon { display: grid; flex: 0 0 auto; width: 49px; height: 49px; place-items: center; font-size: 24px; background: white; border-radius: 15px; box-shadow: 0 5px 12px rgba(59,77,70,.08); }
.feedback p { margin: 0; }
.feedback strong,.feedback small { display: block; }
.feedback strong { margin-bottom: 4px; font-size: 15px; }
.feedback small { color: var(--muted); font-size: 11px; font-weight: 700; }
.feedback.is-error { background: #fff0ec; border-color: #edb2a9; }
.feedback.is-idea { background: #fff7d9; border-color: #e7ca72; }
.feedback.is-success { background: #eaf8ed; border-color: #9fd2ad; }

.gallery-summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; padding: 19px 23px; background: #eee9f8; border: 2px solid #c7b9df; border-radius: 25px; }
.gallery-summary p { margin: 0; color: #5f5374; font-size: 13px; font-weight: 800; line-height: 1.45; }
.gallery-summary b { flex: 0 0 auto; font-size: 28px; }
.art-card { min-width: 0; padding: 15px; background: var(--paper); border: 2px solid var(--line); border-radius: 25px; box-shadow: var(--shadow); }
.art-preview { display: grid; min-height: 225px; place-items: center; background: linear-gradient(135deg,#edf8f4,#f5effa); border-radius: 18px; }
.gallery-preview { width: min(180px,80%); padding: 6px; }
.art-meta { justify-content: space-between; gap: 10px; margin-top: 12px; }
.art-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.art-meta strong,.art-meta small { display: block; }
.art-meta strong { font-size: 15px; }
.art-meta small { margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 800; }
.empty-gallery { display: grid; min-height: 480px; place-items: center; align-content: center; gap: 10px; padding: 40px; text-align: center; background: rgba(255,253,247,.9); border: 3px dashed #cfc5df; border-radius: 34px; }
.empty-gallery>span { display: grid; width: 90px; height: 90px; place-items: center; color: var(--purple); font-size: 49px; background: #eee8fa; border-radius: 26px; }
.empty-gallery h2 { margin: 10px 0 0; font-size: 31px; }
.empty-gallery p { max-width: 520px; margin: 0 0 15px; color: var(--muted); font-weight: 700; line-height: 1.5; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; max-width: calc(100% - 32px); padding: 12px 18px; color: white; font-size: 13px; font-weight: 900; text-align: center; background: #315f55; border-radius: 14px; box-shadow: 0 10px 25px rgba(36,66,59,.25); opacity: 0; pointer-events: none; transform: translate(-50%,18px); transition: opacity .2s ease,transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%,0); }
.loading-card { display: grid; min-height: 70vh; place-items: center; align-content: center; gap: 12px; color: var(--muted); font-weight: 900; }
.loading-card span { font-size: 52px; }

@keyframes float { to { transform: translateY(-9px) rotate(4deg); } }

@media (max-width:900px) {
  .hero { grid-template-columns: 1fr; padding: 39px; }
  .hero-copy { max-width: 680px; }
  .hero-pixels { min-height: 280px; }
  .steps-grid { grid-template-columns: 1fr; }
  .step-card { min-height: 104px; }
  .modes-grid,.gallery-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .studio-layout { grid-template-columns: 1fr; }
  .control-panel { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 11px; }
  .control-section+.control-section { margin-top: 0; }
  .option-section,.studio-actions { margin-top: 0; }
  .studio-actions { justify-content: center; }
}

@media (max-width:650px) {
  .app { width: min(100% - 20px,1120px); padding-top: 12px; }
  .topbar { min-height: 57px; margin-bottom: 13px; }
  .brand { flex: 1 1 auto; overflow: hidden; }
  .brand>span:last-child { min-width: 0; }
  .brand-mark { width: 49px; height: 49px; font-size: 25px; border-radius: 15px; }
  .brand strong { overflow: hidden; max-width: 154px; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
  .brand small { display: none; }
  .gallery-button,.sound-button { width: 48px; justify-content: center; padding: 0; }
  .gallery-button div,.sound-button>span:last-child { display: none; }
  .hero { min-height: 0; gap: 18px; padding: 30px 22px 25px; border-radius: 31px; }
  .hero h1 { font-size: clamp(39px,12vw,54px); }
  .hero-copy>p:not(.eyebrow) { font-size: 15px; }
  .hero-actions { flex-direction: column; }
  .hero-actions button { width: 100%; max-width: none; }
  .hero-pixels { min-height: 235px; }
  .hero-board { width: 215px; padding: 12px; }
  .floating-pixel { width: 34px; height: 34px; }
  .pixel-three { width: 25px; height: 25px; }
  .how-section,.modes-section,.gallery-section { margin-top: 38px; }
  .section-heading { display: block; }
  .section-heading h1,.section-heading h2 { font-size: 32px; }
  .section-heading>p { margin-top: 9px; text-align: left; }
  .modes-grid,.gallery-grid { grid-template-columns: 1fr; }
  .mode-card>p { min-height: 0; }
  .adult-note { align-items: flex-start; }
  .studio-shell { padding: 8px; border-radius: 28px; }
  .studio-head { align-items: flex-start; gap: 10px; padding: 5px; }
  .studio-head h1 { font-size: 27px; }
  .studio-head>div>p:last-child { font-size: 11px; line-height: 1.35; }
  .idea-button { flex: 0 0 auto; width: 48px; min-height: 48px; padding: 0; font-size: 0; }
  .idea-button span { font-size: 20px; }
  .studio-layout { gap: 9px; }
  .canvas-card { padding: 7px; border-radius: 22px; }
  .canvas-label { margin: 4px 4px 10px; }
  .canvas-label>span { width: 38px; height: 38px; }
  .pixel-grid { width: 100%; border-width: 3px; border-radius: 14px; }
  .pixel-cell { border-width: .5px; }
  .control-panel { display: block; padding: 8px; border-radius: 22px; }
  .control-section { padding: 10px; }
  .control-section+.control-section { margin-top: 8px; }
  .history-actions button { width: 46px; height: 46px; }
  .tool-button { min-height: 61px; }
  .palette { grid-template-columns: repeat(6,1fr); gap: 6px; }
  .color-button { min-height: 44px; }
  .option-section { display: flex; }
  .option-button { min-height: 58px; }
  .studio-actions { margin-top: 9px; }
  .feedback { align-items: stretch; flex-direction: column; min-height: 105px; }
  .feedback .primary-button { width: 100%; }
  .gallery-summary { align-items: flex-start; flex-direction: column; }
  .art-preview { min-height: 210px; }
  .empty-gallery { min-height: 420px; padding: 25px 18px; }
}

@media (max-width:390px) {
  .brand strong { max-width: 137px; font-size: 16px; }
  .studio-head .eyebrow { font-size: 10px; }
  .tools-row { gap: 5px; }
  .tool-button { font-size: 9px; }
  .option-button { padding: 6px; }
}

@media (prefers-reduced-motion:reduce) {
  *,*::before,*::after { scroll-behavior: auto!important; animation-duration: .01ms!important; animation-iteration-count: 1!important; transition-duration: .01ms!important; }
}

.print-sheet { display: none; }
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body > * { display: none !important; }
  body > .print-sheet { display: grid !important; width: 100%; height: 100%; place-items: center; align-content: center; gap: 8mm; color: #2d504d; background: #fff; }
  .print-sheet__art { width: min(165mm, 100%); }
  .print-sheet .print-preview { width: 100%; aspect-ratio: 1; padding: 0; border: 2mm solid #fff; box-shadow: 0 0 0 .6mm #d5d0c4; }
  .print-sheet h1 { margin: 0; font-size: 18pt; text-align: center; }
}
