:root {
  --bg:      #F0E0D6;
  --paper:   #FFFDF7;
  --ink:     #222;
  --green:   #789922;
  --scribble: "Patrick Hand", system-ui;
  --sans:    "Inter", ui-sans-serif;
  --radius:  14px;
  --shadow:  0 2px 0 #0001, 0 8px 24px #0002;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  max-width: 100%;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; }

.container {
  width: min(1200px, 92vw);
  margin: 0 auto;
}

.scribble { font-family: var(--scribble); }

/* =====================
   HEADER / NAV
   ===================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar {
  background: var(--paper);
  border-bottom: 4px solid var(--green);
  box-shadow: var(--shadow);
}

.topbar-inner {
  width: min(1200px, 92vw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: .6rem .4rem;
}

.brand {
  font-size: clamp(22px, 3.5vw, 40px);
  text-decoration: none;
  color: var(--ink);
}

.top-links {
  display: grid;
  grid-auto-flow: column;
  gap: .7rem;
}

.nav-link {
  background: var(--bg);
  padding: .85rem 1.2rem;
  border: 3px solid var(--green);
  border-radius: 16px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  box-shadow: 3px 3px 0 #0002;
  font-size: clamp(14px, 1.4vw, 20px);
}

/* =====================
   HERO
   ===================== */
.hero {
  background: var(--paper);
  border-bottom: 4px solid var(--green);
}

.hero-inner {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1.1fr 1fr;
  align-items: center;
  width: min(1200px, 92vw);
  margin: 1.2rem auto;
}

.hero-gif {
  border: 4px solid var(--green);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: #fff;
  width: 100%;
  height: auto;
  max-width: 320px;
}

h1 {
  font-size: clamp(36px, 5.5vw, 62px);
  margin: .2rem 0;
}

.tagline {
  opacity: .9;
  font-size: clamp(15px, 2vw, 21px);
  margin: .3rem 0 1.2rem;
}

/* =====================
   CA BOX
   ===================== */
.ca-box {
  margin: .6rem 0 1rem;
  padding: 1rem;
  background: var(--bg);
  border: 3px solid var(--green);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.ca-label {
  font-weight: 700;
  font-size: .95rem;
}

.ca-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .8rem;
  margin-top: .6rem;
  align-items: center;
}

.ca-input {
  flex: 1;
  padding: 1rem;
  border: 2px dashed var(--green);
  background: #fff;
  border-radius: 12px;
  font-size: clamp(11px, 1.3vw, 15px);
  font-family: monospace;
  user-select: all;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =====================
   BUTTONS
   ===================== */
.btn {
  padding: 1rem 1.25rem;
  border: 3px solid var(--ink);
  border-radius: 16px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  display: inline-block;
  box-shadow: 4px 4px 0 #000;
  background: #fff;
  font-size: clamp(14px, 1.5vw, 20px);
  cursor: pointer;
  font-family: var(--sans);
  transition: background .1s, color .1s;
}

.btn:hover {
  background: var(--ink);
  color: var(--paper);
}

.btn.xl {
  padding: 1.05rem 1.3rem;
  font-size: clamp(14px, 1.5vw, 20px);
  width: 100%;
}

.btn.copy {
  min-width: 100px;
  text-align: center;
  white-space: nowrap;
}

.copy-btn .copy-done { display: none; }
.copy-btn.copied .copy-idle { display: none; }
.copy-btn.copied .copy-done { display: inline; }

/* =====================
   SOCIALS
   ===================== */
.socials {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .9rem;
  margin-top: .4rem;
}

/* =====================
   LORE
   ===================== */
.lore {
  padding: 1.2rem 0 .8rem;
}

.lore .container > h2 {
  font-size: clamp(28px, 4vw, 44px);
  margin: .2rem 0 .6rem;
}

.lore .container > p {
  font-size: clamp(15px, 1.6vw, 18px);
  line-height: 1.7;
  margin: .6rem 0;
  max-width: 740px;
}

.greentext-block {
  font-family: monospace;
  font-size: clamp(15px, 1.6vw, 18px);
  color: var(--green);
  line-height: 1.9;
  border-left: 4px solid var(--green);
  padding: .7rem 1.1rem;
  background: var(--paper);
  margin: 1rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.greentext-block p { margin: 0; }

.kym-cta {
  display: flex;
  gap: .8rem;
  align-items: center;
  flex-wrap: wrap;
  margin: .8rem 0;
}

.kym-text { margin: 0; font-size: clamp(14px, 1.5vw, 17px); }

/* =====================
   PFP GENERATOR
   ===================== */
.pfp {
  padding: .8rem 0 1.6rem;
  border-top: 4px solid var(--green);
  background: var(--paper);
}

.pfp .container > h2 {
  font-size: clamp(28px, 4vw, 44px);
  margin: .2rem 0 .4rem;
}

.pfp-copy {
  margin: 0 0 .8rem;
  font-size: clamp(14px, 1.5vw, 17px);
}

.pfp-container {
  width: min(1200px, 92vw);
}

.pfp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem;
  align-items: start;
}

.pfp-controls {
  background: var(--bg);
  border: 3px solid var(--green);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  user-select: none;
}

.pfp-controls-inner {
  padding: 1rem;
}

.traits-list {
  display: grid;
  gap: .9rem;
}

.trait {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.trait label {
  min-width: 140px;
  font-size: clamp(14px, 1.4vw, 17px);
  font-weight: 700;
}

.trait select {
  flex: 1;
  padding: .9rem;
  border: 2px solid var(--green);
  border-radius: 12px;
  background: #fff;
  font-size: clamp(14px, 1.4vw, 17px);
  width: 100%;
  max-width: 100%;
}

.pfp-actions {
  display: flex;
  gap: .9rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.pfp-tip {
  opacity: .85;
  font-size: .95rem;
  margin: .6rem 0 0;
}

.pfp-preview {
  width: 100%;
  overflow: visible;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  border: 3px dashed var(--green);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

#pfp-canvas {
  width: 100%;
  height: auto;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#pfp-save-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: auto;
  display: none;
  z-index: 9;
  object-fit: contain;
  background: transparent;
}

/* =====================
   GALLERY
   ===================== */
.gallery-section {
  padding: 1.2rem 0 1.6rem;
  border-top: 4px solid var(--green);
  background: var(--paper);
}

.gallery-section .container > h2 {
  font-size: clamp(28px, 4vw, 44px);
  margin: .2rem 0 .3rem;
}

.gallery-sub {
  font-size: clamp(13px, 1.4vw, 16px);
  opacity: .7;
  margin: 0 0 1rem;
  font-family: monospace;
}

.gallery-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .7rem;
}

.gallery-grid li a {
  display: block;
  border: 3px solid var(--green);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  transition: transform .15s, box-shadow .15s;
}

.gallery-grid li a:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px #0003;
}

.gallery-grid li a img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.gallery-grid li a span {
  display: block;
  font-size: .75rem;
  font-family: monospace;
  color: var(--green);
  padding: .3rem .5rem;
  min-height: 1.4rem;
  line-height: 1.4;
}

/* =====================
   IP HOLDER
   ===================== */
.ip {
  padding: 1.2rem 0 1.6rem;
  border-top: 4px solid var(--green);
  background: var(--bg);
}

.ip-badge {
  display: inline-block;
  background: var(--paper);
  border: 2px solid var(--green);
  border-radius: 999px;
  padding: .35rem .9rem;
  font-size: .8rem;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: .6rem;
}

.ip > .container > h2 {
  font-size: clamp(26px, 3.8vw, 42px);
  margin: .2rem 0 1rem;
}

.ip-card {
  background: var(--paper);
  border: 3px solid var(--green);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.2rem;
  max-width: 740px;
}

.ip-sub {
  font-size: clamp(15px, 1.7vw, 19px);
  font-weight: 900;
  margin: 0 0 .7rem;
}

.ip-card p {
  font-size: clamp(14px, 1.5vw, 17px);
  line-height: 1.7;
  margin: 0 0 .8rem;
}

.ip-quote {
  border-left: 4px solid var(--green);
  padding: .6rem 1rem;
  background: var(--bg);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: clamp(14px, 1.5vw, 17px);
  font-style: italic;
  font-weight: 700;
}

.ip-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.ip-item {
  background: var(--paper);
  border: 3px solid var(--green);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
}

.ip-item h3 {
  font-size: clamp(16px, 1.8vw, 22px);
  margin: 0 0 .5rem;
}

.ip-item p {
  font-size: clamp(13px, 1.4vw, 16px);
  line-height: 1.6;
  margin: 0;
}

@media (max-width: 820px) {
  .ip-grid {
    grid-template-columns: 1fr;
  }
}

/* =====================
   COMMUNITY
   ===================== */
.community {
  padding: .8rem 0 1.6rem;
  border-top: 4px solid var(--green);
  background: var(--paper);
}

.community-card {
  background: var(--bg);
  border: 3px solid var(--green);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: .8rem 0;
}

.community-card-inner {
  padding: 1rem;
}

/* =====================
   FOOTER
   ===================== */
.site-footer {
  border-top: 4px solid var(--green);
  padding: 1.2rem 0;
  background: var(--paper);
}

.footer-inner {
  text-align: center;
}

.meme-line {
  font-family: monospace;
  color: var(--green);
  font-size: 1rem;
  margin: 0 0 .3rem;
}

.fine {
  opacity: .6;
  font-size: .9rem;
  margin: 0;
}

/* =====================
   SAVE OVERLAY (iOS)
   ===================== */
.save-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.save-overlay.hidden { display: none; }

.save-overlay img {
  max-width: min(94vw, 1000px);
  max-height: calc(94vh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 32px);
  border-radius: 12px;
  background: #fff;
  margin: auto;
}

.save-close {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  right: 12px;
  z-index: 60;
  background: #000;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .5rem .9rem;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

/* =====================
   SMOOTH SCROLL
   ===================== */
html { scroll-behavior: smooth; }
#token, #links, #lore-top, #pfp, #community { scroll-margin-top: 90px; }

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 820px) {
  .topbar-inner {
    grid-template-columns: 1fr;
  }

  .top-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-flow: row;
  }

  .nav-link {
    text-align: center;
  }

  .brand {
    font-size: 34px;
  }

  .hero-inner {
    grid-template-columns: 1fr;
  }

  .hero-efg {
    max-width: 100%;
    padding: 1.5rem;
  }

  .socials {
    grid-template-columns: 1fr;
  }

  .pfp-grid {
    grid-template-columns: 1fr;
  }

  .pfp-container {
    width: 100%;
    padding: 0 12px;
  }

  .canvas-wrap {
    width: 100%;
    max-width: 100%;
  }

  #pfp-canvas {
    width: 100%;
  }

  .container {
    width: 100%;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
}

@media (min-width: 821px) {
  .pfp-grid {
    grid-template-columns: minmax(0, 520px) minmax(0, 1fr);
  }

  .pfp-preview .canvas-wrap {
    max-width: min(520px, 42vw);
  }
}
