/* ============================================================
   Living the Grid — Tomodachi Life: Living the Dream style
   Warm cream backgrounds, yellow accents, playful & cozy
   ============================================================ */

:root {
  --yellow:       #FFD600;
  --yellow-dark:  #F5C800;
  --yellow-hover: #FFCC00;
  --yellow-light: #FFF0A0;
  --yellow-pale:  #FFF8D6;

  --cream:        #FFF8E1;
  --cream-dark:   #FFF0C8;
  --cream-deeper: #FFE8A8;
  --bg-pattern:   #F5E6B8;

  --brown:        #4A3728;
  --brown-light:  #6B5744;
  --brown-muted:  #9C8B78;
  --brown-pale:   #B8A898;

  --white:        #FFFFFF;
  --card-bg:      #FFFDF5;
  --border:       #F0DDB0;
  --border-light: #F5E8C8;

  --footer-bg:    #3D3020;

  --radius:       16px;
  --radius-sm:    10px;
  --radius-btn:   50px;
  --nav-h:        60px;
  --font:         'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: Georgia, 'Times New Roman', serif;
  --max-w:        1100px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font);
  color: var(--brown);
  background: var(--cream);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: var(--brown); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 24px; }

/* ============================================================
   BACKGROUND DOODLE PATTERN — subtle warm shapes
   ============================================================ */
.pattern-bg {
  position: relative;
}
.pattern-bg::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle 8px at 10% 20%, transparent 96%, var(--bg-pattern) 100%),
    radial-gradient(circle 6px at 30% 70%, transparent 96%, var(--bg-pattern) 100%),
    radial-gradient(circle 10px at 60% 15%, transparent 96%, var(--bg-pattern) 100%),
    radial-gradient(circle 7px at 80% 60%, transparent 96%, var(--bg-pattern) 100%),
    radial-gradient(circle 5px at 45% 45%, transparent 96%, var(--bg-pattern) 100%),
    radial-gradient(circle 9px at 90% 30%, transparent 96%, var(--bg-pattern) 100%),
    radial-gradient(circle 6px at 15% 85%, transparent 96%, var(--bg-pattern) 100%),
    radial-gradient(circle 8px at 70% 80%, transparent 96%, var(--bg-pattern) 100%);
  opacity: .35;
  pointer-events: none;
  z-index: 0;
}

/* ============================================================
   NAVIGATION — warm cream bar
   ============================================================ */
#topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: rgba(255,248,225,.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  transition: box-shadow .3s;
}
#topnav.scrolled { box-shadow: 0 2px 12px rgba(74,55,40,.08); }

.nav-inner {
  max-width: var(--max-w); margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  height: 100%;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 1.1rem; color: var(--brown);
}
.logo:hover { text-decoration: none; }
.logo-icon-svg {
  flex-shrink: 0;
  filter: drop-shadow(0 1px 3px rgba(74,55,40,.15));
  transition: transform .2s;
}
.logo:hover .logo-icon-svg { transform: rotate(-5deg) scale(1.08); }
.logo-text { color: var(--brown); }

.nav-links { list-style: none; display: flex; gap: 28px; }
.nav-links a {
  font-weight: 700; font-size: .9rem; color: var(--brown-light);
  transition: color .15s;
}
.nav-links a:hover { color: var(--brown); text-decoration: none; }

.menu-toggle {
  display: none;
  flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 4px;
}
.menu-toggle span {
  display: block; width: 22px; height: 2.5px;
  background: var(--brown); border-radius: 2px;
  transition: transform .3s, opacity .3s;
}
.menu-toggle.open span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* ============================================================
   HERO — warm cream with doodle pattern, like the screenshot
   ============================================================ */
#hero {
  position: relative;
  min-height: 90vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--cream);
  padding: calc(var(--nav-h) + 56px) 24px 100px;
  text-align: center;
  overflow: hidden;
}

/* Subtle doodle shapes behind hero */
#hero::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cpath d='M50 80c20-30 60-20 80 0s60 30 80 0' fill='none' stroke='%23F0DDB0' stroke-width='2.5' stroke-linecap='round'/%3E%3Ccircle cx='300' cy='60' r='15' fill='none' stroke='%23F0DDB0' stroke-width='2.5'/%3E%3Cpath d='M320 200c10-20 30-20 40 0s30 20 40 0' fill='none' stroke='%23F0DDB0' stroke-width='2.5' stroke-linecap='round'/%3E%3Ccircle cx='70' cy='250' r='12' fill='none' stroke='%23F0DDB0' stroke-width='2.5'/%3E%3Cpath d='M180 300c15-25 45-25 60 0' fill='none' stroke='%23F0DDB0' stroke-width='2.5' stroke-linecap='round'/%3E%3Crect x='250' y='280' width='25' height='25' rx='5' fill='none' stroke='%23F0DDB0' stroke-width='2.5'/%3E%3Cpath d='M30 160l20 15-20 15' fill='none' stroke='%23F0DDB0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='200' cy='100' r='8' fill='none' stroke='%23F0DDB0' stroke-width='2.5'/%3E%3Cpath d='M100 350c10-15 30-15 40 0s30 15 40 0' fill='none' stroke='%23F0DDB0' stroke-width='2.5' stroke-linecap='round'/%3E%3Cpath d='M350 130l-10 20 10 20' fill='none' stroke='%23F0DDB0' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: 400px 400px;
  opacity: .6;
  pointer-events: none;
  z-index: 0;
}

#hero::after { display: none; }

.hero-inner { max-width: 660px; position: relative; z-index: 1; }

.hero-badge {
  display: inline-block;
  background: var(--yellow);
  color: var(--brown);
  font-weight: 800; font-size: .72rem;
  padding: 6px 16px;
  border-radius: var(--radius-btn);
  margin-bottom: 22px;
  letter-spacing: .03em;
  text-transform: uppercase;
}

#hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4.5vw, 2.8rem);
  font-weight: 700;
  font-style: italic;
  line-height: 1.3;
  margin-bottom: 18px;
  color: var(--brown);
}

.hero-accent {
  color: var(--brown);
  background: none;
  -webkit-text-fill-color: var(--brown);
}

.hero-sub {
  font-size: .95rem; color: var(--brown-light);
  margin-bottom: 36px; line-height: 1.75;
}

.hero-dropzone {
  background: var(--card-bg);
  border: 2.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 42px 28px;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
  margin-bottom: 16px;
}
.hero-dropzone:hover, .hero-dropzone.dragover {
  border-color: var(--yellow-dark);
  background: var(--white);
  transform: translateY(-2px);
}
.dropzone-icon { font-size: 2.4rem; display: block; margin-bottom: 10px; }
.dropzone-content p { font-size: .95rem; margin-bottom: 4px; color: var(--brown-light); }
.dropzone-hint { font-size: .8rem; color: var(--brown-muted); }

.hero-privacy { font-size: .78rem; color: var(--brown-muted); margin-top: 16px; }

.hero-wave {
  position: absolute; bottom: -1px; left: 0; right: 0;
  line-height: 0; z-index: 1;
}
.hero-wave svg { width: 100%; height: 60px; }

/* ============================================================
   BUTTONS — yellow with brown text, like the Tomodachi style
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 28px;
  font-family: var(--font);
  font-weight: 800; font-size: .9rem;
  border: none; border-radius: var(--radius-btn);
  cursor: pointer; transition: all .2s;
  background: var(--yellow); color: var(--brown);
}
.btn:hover {
  background: var(--yellow-dark);
  box-shadow: 0 4px 14px rgba(245,200,0,.35);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--brown-light);
}
.btn-outline:hover {
  border-color: var(--yellow);
  background: var(--yellow-pale);
  color: var(--brown);
  box-shadow: none;
}

.btn-sm { padding: 8px 18px; font-size: .82rem; }
.btn-outline-sm {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--brown-muted);
}
.btn-outline-sm:hover { border-color: var(--yellow); color: var(--brown); background: transparent; }

.btn-icon {
  width: 34px; height: 34px; padding: 0;
  border-radius: 50%; font-size: 1.1rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card-bg); color: var(--brown-light);
  border: 1.5px solid var(--border);
}
.btn-icon:hover { border-color: var(--yellow); color: var(--brown); background: var(--yellow-pale); box-shadow: none; }

.btn-dl {
  background: var(--card-bg); color: var(--brown-light);
  border: 1.5px solid var(--border); font-size: .8rem; padding: 7px 14px;
}
.btn-dl:hover { border-color: var(--yellow); color: var(--brown); background: var(--yellow-pale); box-shadow: none; }

/* ============================================================
   SECTION TITLES — warm serif/italic headlines
   ============================================================ */
.section-title {
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
  font-style: italic;
  margin-bottom: 8px;
  color: var(--brown);
}

.section-sub {
  text-align: center;
  color: var(--brown-muted);
  font-size: .92rem;
  margin-bottom: 48px;
  max-width: 580px; margin-left: auto; margin-right: auto;
}

/* ============================================================
   FEATURES — warm cards with yellow accents
   ============================================================ */
#features { padding: 80px 0; background: var(--cream); }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.feature-card {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px 24px;
  border: 1px solid var(--border-light);
  transition: transform .25s, box-shadow .25s;
  overflow: hidden;
}
.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(74,55,40,.08);
}
.feature-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--yellow);
  opacity: 0; transition: opacity .25s;
}
.feature-card:hover::before { opacity: 1; }

.feature-icon { font-size: 2rem; margin-bottom: 12px; }
.feature-card h3 { font-size: 1rem; font-weight: 800; margin-bottom: 6px; color: var(--brown); }
.feature-card p { color: var(--brown-muted); font-size: .85rem; line-height: 1.65; }

/* ============================================================
   TOOL SECTION — cream background
   ============================================================ */
#tool { padding: 80px 0; background: var(--cream-dark); position: relative; }

.tool-layout {
  display: grid;
  grid-template-columns: 250px 1fr 220px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 960px) {
  .tool-layout { grid-template-columns: 1fr; }
}

.tool-controls {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border-light);
  display: flex; flex-direction: column; gap: 18px;
}

.control-group label {
  display: block;
  font-weight: 700; font-size: .82rem;
  margin-bottom: 6px; color: var(--brown-light);
}

.canvas-size-btns, .toggle-btns, .palette-btns {
  display: flex; flex-wrap: wrap; gap: 5px;
}

.size-btn, .toggle-btn, .pal-btn {
  padding: 5px 12px; font-size: .78rem; font-weight: 700;
  border: 1.5px solid var(--border); border-radius: var(--radius-btn);
  background: var(--white); color: var(--brown-light);
  cursor: pointer; transition: all .15s;
  font-family: var(--font);
}
.size-btn:hover, .toggle-btn:hover, .pal-btn:hover {
  border-color: var(--yellow); color: var(--brown);
}
.size-btn.active, .toggle-btn.active, .pal-btn.active {
  background: var(--yellow); color: var(--brown); border-color: var(--yellow);
}

.display-toggles { display: flex; flex-wrap: wrap; gap: 10px; }

.check-label {
  display: flex; align-items: center; gap: 4px;
  font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--brown-light);
}
.check-label input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--yellow-dark); cursor: pointer;
}

input[type="range"] {
  width: 100%; height: 5px;
  -webkit-appearance: none; appearance: none;
  background: var(--border); border-radius: 3px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px;
  background: var(--yellow); border-radius: 50%;
  cursor: pointer; border: 3px solid var(--white);
  box-shadow: 0 1px 4px rgba(74,55,40,.2);
}

.tool-canvas-area {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}

.canvas-placeholder {
  width: 100%;
  min-height: 400px;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1.5px solid var(--border-light);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  color: var(--brown-muted);
  font-size: .9rem;
}
.canvas-placeholder span { font-size: 2.4rem; }

#pixelCanvas {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--white);
  image-rendering: pixelated;
  max-width: 100%;
}

.canvas-info {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; font-size: .8rem; font-weight: 600; color: var(--brown-muted);
}

.zoom-controls { display: flex; align-items: center; gap: 6px; }
.download-bar { display: flex; flex-wrap: wrap; gap: 6px; }

.tool-palette {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border-light);
}
.tool-palette h3 { font-size: .9rem; font-weight: 800; margin-bottom: 12px; }

.palette-display { min-height: 50px; }
.palette-empty { color: var(--brown-muted); font-size: .82rem; }

.palette-grid { display: flex; flex-wrap: wrap; gap: 3px; }

.palette-swatch {
  width: 26px; height: 26px;
  border-radius: 4px;
  border: 1px solid rgba(74,55,40,.1);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  position: relative;
}
.palette-swatch:hover {
  transform: scale(1.3); z-index: 2;
  box-shadow: 0 2px 8px rgba(74,55,40,.2);
}
.palette-swatch .swatch-tip {
  display: none;
  position: absolute; bottom: calc(100% + 5px); left: 50%; transform: translateX(-50%);
  background: var(--brown); color: var(--yellow-pale); padding: 2px 7px;
  border-radius: 4px; font-size: .65rem; white-space: nowrap; font-weight: 700;
  pointer-events: none;
}
.palette-swatch:hover .swatch-tip { display: block; }

.recipe-card {
  margin-top: 16px;
  padding: 14px;
  background: var(--yellow-pale);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--yellow);
}
.recipe-card h4 { font-size: .85rem; margin-bottom: 6px; font-weight: 800; color: var(--brown); }
.recipe-card p { font-size: .78rem; color: var(--brown-light); line-height: 1.5; }

/* ============================================================
   HOW TO — warm cards with yellow numbered circles
   ============================================================ */
#howto { padding: 80px 0; background: var(--cream); }

.steps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.step-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px 20px;
  border: 1px solid var(--border-light);
  text-align: center;
  transition: transform .25s, box-shadow .25s;
}
.step-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(74,55,40,.08);
}

.step-num {
  width: 48px; height: 48px;
  background: var(--yellow);
  color: var(--brown);
  font-size: 1.2rem; font-weight: 900;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}

.step-card h3 { font-size: .95rem; font-weight: 800; margin-bottom: 8px; }
.step-card p { color: var(--brown-muted); font-size: .85rem; line-height: 1.6; }

/* ============================================================
   CONVERTER — warm card
   ============================================================ */
#converter { padding: 64px 0; background: var(--cream); }

.converter-card {
  max-width: 440px; margin: 0 auto;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 32px;
  border: 1px solid var(--border-light);
  text-align: center;
}
.converter-card h2 {
  font-family: var(--font-display);
  font-size: 1.2rem; margin-bottom: 6px; font-weight: 700; font-style: italic;
}
.converter-card > p { color: var(--brown-muted); font-size: .85rem; margin-bottom: 18px; }

.converter-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 18px; }

#hexInput {
  padding: 9px 14px; font-size: .9rem; font-weight: 700;
  border: 1.5px solid var(--border); border-radius: var(--radius-btn);
  width: 140px; text-align: center;
  font-family: var(--font); outline: none;
  background: var(--white);
  transition: border-color .15s;
}
#hexInput:focus { border-color: var(--yellow); }

.hsb-result {
  display: flex; gap: 28px; justify-content: center;
  font-size: .9rem; color: var(--brown-muted);
  margin-bottom: 8px;
}
.hsb-result strong { color: var(--brown); font-size: 1.15rem; }

.converter-hint { font-size: .72rem; color: var(--brown-pale); }

/* ============================================================
   FAQ — warm accordion
   ============================================================ */
#faq { padding: 80px 0; background: var(--cream-dark); }

.faq-list {
  max-width: 720px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 0;
}

.faq-item {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-bottom: none;
  transition: background .15s;
}
.faq-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.faq-item:last-child { border-bottom: 1px solid var(--border-light); border-radius: 0 0 var(--radius) var(--radius); }

.faq-item summary {
  padding: 16px 20px;
  font-weight: 700; font-size: .9rem;
  cursor: pointer;
  list-style: none;
  display: flex; align-items: center; justify-content: space-between;
  transition: color .15s;
  color: var(--brown-light);
}
.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
  content: '+';
  font-size: 1.2rem; font-weight: 700;
  color: var(--brown-muted);
  transition: color .15s;
  flex-shrink: 0;
  margin-left: 12px;
}
.faq-item[open] summary::after { content: '−'; color: var(--yellow-dark); }
.faq-item[open] summary { color: var(--brown); }
.faq-item[open] { border-left: 3px solid var(--yellow); }

.faq-item p {
  padding: 0 20px 16px;
  color: var(--brown-muted); font-size: .85rem; line-height: 1.7;
}

/* ============================================================
   SEO CONTENT SECTIONS
   ============================================================ */
.seo-section { padding: 72px 0; background: var(--cream); }
.seo-section.alt-bg { background: var(--cream-dark); }

.about-content {
  max-width: 720px; margin: 0 auto;
  font-size: .9rem; color: var(--brown-light); line-height: 1.8;
}
.about-content p { margin-bottom: 14px; }
.about-content strong { color: var(--brown); }

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.info-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border-light);
  transition: transform .25s, box-shadow .25s;
}
.info-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(74,55,40,.08);
}
.info-card h3 { font-size: .95rem; font-weight: 800; margin-bottom: 8px; }
.info-card p { color: var(--brown-muted); font-size: .85rem; line-height: 1.7; }
.info-card strong { color: var(--brown); }

.seo-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  max-width: 960px; margin: 0 auto;
}
.seo-columns article h3 {
  font-size: .95rem; font-weight: 800; margin-bottom: 8px; color: var(--brown);
}
.seo-columns article p { font-size: .85rem; color: var(--brown-muted); line-height: 1.7; }
.seo-columns article strong { color: var(--brown); }
.seo-columns article em { font-style: italic; color: var(--brown-muted); }

/* ============================================================
   FOOTER — warm dark brown
   ============================================================ */
#footer {
  background: var(--footer-bg);
  color: rgba(255,248,225,.5);
  padding: 44px 0;
  text-align: center;
}

.footer-inner {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.footer-logo {
  font-size: 1.05rem; font-weight: 800; color: var(--yellow-pale);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.footer-icon-svg { flex-shrink: 0; }
#footer p { font-size: .8rem; max-width: 500px; }
#footer strong { color: rgba(255,248,225,.65); }
.footer-links a { color: rgba(255,248,225,.4); font-size: .8rem; }
.footer-links a:hover { color: var(--yellow-pale); text-decoration: none; }
.footer-copy { font-size: .72rem; margin-top: 6px; opacity: .5; }

/* ============================================================
   RESPONSIVE — Desktop-first, Tablet, Mobile
   Desktop: >1024px (default)
   Tablet:  768px–1024px
   Mobile:  <768px
   Small:   <480px
   ============================================================ */

/* --- TABLET (768–1024) --- */
@media (max-width: 1024px) {
  .container { padding: 0 20px; }

  .feature-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .steps-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .info-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .seo-columns { grid-template-columns: repeat(2, 1fr); gap: 20px; }

  .tool-layout { grid-template-columns: 220px 1fr 200px; gap: 16px; }

  #hero h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
  .section-title { font-size: clamp(1.3rem, 3vw, 1.8rem); }

  #hero { padding: calc(var(--nav-h) + 44px) 20px 80px; }

  .hero-dropzone { padding: 36px 24px; }
}

/* --- TABLET PORTRAIT / LARGE MOBILE (768) --- */
@media (max-width: 768px) {
  :root { --nav-h: 56px; }

  .menu-toggle { display: flex; }

  .nav-links {
    display: none;
    position: absolute; top: var(--nav-h); left: 0; right: 0;
    background: var(--cream);
    flex-direction: column; gap: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 20px rgba(74,55,40,.08);
    padding: 4px 0;
    z-index: 99;
  }
  .nav-links.open { display: flex; }
  .nav-links li a {
    display: block; padding: 14px 24px;
    border-bottom: 1px solid var(--border-light);
    font-size: .95rem;
  }
  .nav-links li:last-child a { border-bottom: none; }
  .nav-links li a:hover { background: var(--cream-dark); }

  #hero {
    padding: calc(var(--nav-h) + 32px) 16px 60px;
    min-height: auto;
  }
  #hero h1 { font-size: 1.6rem; }
  .hero-sub { font-size: .9rem; }
  .hero-dropzone { padding: 32px 20px; }
  .hero-wave svg { height: 40px; }

  .feature-grid { grid-template-columns: 1fr; }
  .steps-grid { grid-template-columns: repeat(2, 1fr); }
  .info-grid { grid-template-columns: 1fr; }
  .seo-columns { grid-template-columns: 1fr; }

  .tool-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .tool-controls { order: 2; }
  .tool-canvas-area { order: 1; }
  .tool-palette { order: 3; }

  .section-title { font-size: 1.3rem; padding: 0 8px; }
  .section-sub { font-size: .88rem; padding: 0 8px; }

  #features, #howto, .seo-section, #faq { padding: 56px 0; }
  #tool { padding: 56px 0; }
  #converter { padding: 48px 0; }

  .converter-card { padding: 24px 20px; }

  .faq-list { max-width: 100%; }
  .faq-item summary { font-size: .88rem; padding: 14px 16px; }
  .faq-item p { padding: 0 16px 14px; font-size: .83rem; }

  .about-content { font-size: .88rem; }

  .download-bar { justify-content: center; }
  .btn-dl { font-size: .75rem; padding: 6px 12px; }
}

/* --- MOBILE (480) --- */
@media (max-width: 480px) {
  .container { padding: 0 16px; }

  #hero {
    padding: calc(var(--nav-h) + 24px) 16px 48px;
  }
  #hero h1 { font-size: 1.35rem; line-height: 1.35; }
  .hero-sub { font-size: .85rem; margin-bottom: 24px; }
  .hero-badge { font-size: .65rem; padding: 4px 12px; margin-bottom: 16px; }
  .hero-dropzone { padding: 28px 16px; }
  .dropzone-icon { font-size: 2rem; }

  .btn { padding: 10px 22px; font-size: .85rem; }
  .btn-outline { padding: 10px 22px; }

  .section-title { font-size: 1.15rem; }
  .section-sub { font-size: .84rem; margin-bottom: 32px; }

  .feature-card { padding: 22px 18px; }
  .feature-icon { font-size: 1.6rem; margin-bottom: 8px; }
  .feature-card h3 { font-size: .92rem; }
  .feature-card p { font-size: .82rem; }

  .steps-grid { grid-template-columns: 1fr; gap: 14px; }
  .step-card { padding: 22px 16px; }
  .step-num { width: 40px; height: 40px; font-size: 1rem; }
  .step-card h3 { font-size: .9rem; }

  .info-card { padding: 20px 16px; }
  .info-card h3 { font-size: .9rem; }

  .seo-columns { gap: 16px; }

  .converter-card { padding: 22px 16px; max-width: 100%; }
  .converter-row { flex-direction: column; align-items: center; }
  #hexInput { width: 100%; max-width: 200px; }
  .hsb-result { gap: 16px; font-size: .85rem; }
  .hsb-result strong { font-size: 1.05rem; }

  .canvas-placeholder { min-height: 280px; }

  .tool-controls { padding: 16px; gap: 14px; }
  .tool-palette { padding: 16px; }

  .palette-swatch { width: 22px; height: 22px; }

  .back-to-top { width: 38px; height: 38px; bottom: 16px; right: 16px; font-size: 1rem; }

  #footer { padding: 32px 0; }
  .footer-logo { font-size: .95rem; }
  #footer p { font-size: .75rem; }

  .logo-icon-svg { width: 28px; height: 28px; }
  .logo { font-size: 1rem; gap: 8px; }
}

/* --- VERY SMALL (360) --- */
@media (max-width: 360px) {
  #hero h1 { font-size: 1.15rem; }
  .hero-sub { font-size: .8rem; }
  .section-title { font-size: 1.05rem; }
  .btn { padding: 9px 18px; font-size: .8rem; }
  .feature-card h3 { font-size: .88rem; }
  .step-card h3 { font-size: .85rem; }
  .faq-item summary { font-size: .82rem; padding: 12px 14px; }
}

/* --- LARGE DESKTOP (1200+) --- */
@media (min-width: 1200px) {
  .container { max-width: 1140px; }
  #hero h1 { font-size: 2.8rem; }
  .hero-inner { max-width: 700px; }
  .section-title { font-size: 2rem; }
}

/* --- TOUCH DEVICE OPTIMIZATIONS --- */
@media (hover: none) and (pointer: coarse) {
  .feature-card:hover { transform: none; box-shadow: none; }
  .step-card:hover { transform: none; box-shadow: none; }
  .info-card:hover { transform: none; box-shadow: none; }
  .feature-card::before { display: none; }
  .palette-swatch:hover { transform: none; box-shadow: none; }
  .btn:hover { transform: none; box-shadow: none; }

  .hero-dropzone { padding: 36px 20px; }
  .faq-item summary { padding: 16px 18px; }
  .size-btn, .toggle-btn, .pal-btn { padding: 8px 14px; min-height: 40px; }
  .check-label { min-height: 40px; }
  input[type="range"] { height: 8px; }
  input[type="range"]::-webkit-slider-thumb { width: 24px; height: 24px; }
}

/* --- LANDSCAPE MOBILE --- */
@media (max-height: 500px) and (orientation: landscape) {
  #hero {
    min-height: auto;
    padding: calc(var(--nav-h) + 16px) 24px 32px;
  }
  #hero h1 { font-size: 1.4rem; }
  .hero-sub { font-size: .85rem; margin-bottom: 20px; }
  .hero-dropzone { padding: 24px 20px; }
  .hero-wave { display: none; }
}

/* --- PRINT --- */
@media print {
  #topnav, .back-to-top, .hero-wave, .menu-toggle { display: none !important; }
  body { background: #fff; color: #000; }
  #hero { min-height: auto; padding: 24px; }
  .feature-card, .step-card, .info-card, .faq-item { break-inside: avoid; }
}

/* ============================================================
   BACK TO TOP — warm dark, matches footer
   ============================================================ */
.back-to-top {
  position: fixed; bottom: 28px; right: 28px;
  width: 42px; height: 42px;
  border-radius: 50%; border: none;
  background: var(--yellow); color: var(--brown);
  font-size: 1.1rem; font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(74,55,40,.15);
  opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .2s;
  z-index: 90;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { transform: translateY(-2px); background: var(--yellow-dark); }

/* ============================================================
   ACCESSIBILITY — focus states, skip link, reduced motion
   ============================================================ */
*:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; top: -100px; left: 16px;
  background: var(--yellow); color: var(--brown);
  padding: 10px 20px; border-radius: 0 0 8px 8px;
  font-weight: 800; font-size: .85rem; z-index: 200;
  transition: top .2s;
}
.skip-link:focus { top: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .fade-in { opacity: 1; animation: none; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --cream: #2A2418;
    --cream-dark: #221E14;
    --card-bg: #332B1E;
    --brown: #F5E8C8;
    --brown-light: #D4C4A8;
    --brown-muted: #9C8B78;
    --border: #4A3F30;
    --border-light: #3D3428;
    --footer-bg: #1A1510;
    --bg-pattern: #3D3020;
  }
  #topnav { background: rgba(42,36,24,.95); }
  .hero-wave svg path { fill: #221E14; }
  .faq-item { background: var(--card-bg); }
  #pixelCanvas { border-color: var(--border); }
  .menu-toggle span { background: var(--brown); }
}

/* ============================================================
   ANIMATIONS — gentle fade-in
   ============================================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
  opacity: 0;
  animation: fadeInUp .5s ease forwards;
}

.fade-in.d1 { animation-delay: .05s; }
.fade-in.d2 { animation-delay: .1s; }
.fade-in.d3 { animation-delay: .15s; }
.fade-in.d4 { animation-delay: .2s; }
.fade-in.d5 { animation-delay: .25s; }
.fade-in.d6 { animation-delay: .3s; }
