:root {
  --ink: #1a1510;
  --paper: #f7f2e9;
  --accent: #c45c26;
  --muted: #5c5348;
  --content-max: min(52rem, 100%);
  --safe-x: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: "Architects Daughter", "Kalam", cursive;
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(196, 92, 38, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(26, 21, 16, 0.04) 0%, transparent 40%);
  color: var(--ink);
  line-height: 1.45;
  padding:
    calc(var(--safe-t) + 0.25rem)
    var(--safe-r)
    calc(var(--safe-b) + 0.5rem)
    var(--safe-x);
  touch-action: manipulation;
}

#scribble-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  width: 100vw;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  pointer-events: none;
  z-index: 9999;
  mix-blend-mode: multiply;
}

main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1rem clamp(1rem, 4vw, 1.65rem) 2rem;
  position: relative;
  z-index: 1;
  width: 100%;
}

.hero-title {
  font-size: clamp(1.35rem, 5.2vw + 0.65rem, 2.35rem);
  font-weight: 400;
  text-align: center;
  margin: 0 0 1.75rem;
  letter-spacing: 0.02em;
  line-height: 1.28;
  text-wrap: balance;
  padding: 0 0.125rem;
  hyphens: auto;
}

.scribble-underline {
  text-decoration: underline;
  text-decoration-style: wavy;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.2em;
}

.nav-scribble,
.chat-section,
.token-card,
.footer-scribble {
  position: relative;
  padding: 0.85rem 1rem;
  margin-bottom: 1.5rem;
  background: rgba(255, 253, 248, 0.85);
}

.nav-scribble {
  margin-bottom: 0.75rem;
  max-width: var(--content-max);
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.nav-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  justify-content: flex-start;
  row-gap: 0.65rem;
  margin-inline: auto;
  padding-inline: clamp(0.65rem, 2vw, 1rem);
}

.ca-line {
  font-size: 0.95rem;
  color: var(--muted);
  margin-left: 0.35rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin: 0 0.35rem 0 0;
  padding: 0.15rem;
  border-radius: 4px;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.brand-mark:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.brand-mark img {
  width: clamp(2.5rem, 9vw, 2.85rem);
  height: auto;
  aspect-ratio: 1 / 1;
  display: block;
}

.ca-blank {
  letter-spacing: 0.04em;
  color: var(--ink);
  font-size: 0.78rem;
  word-break: break-all;
}

.scribble-btn {
  appearance: none;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem 0.95rem;
  min-height: 2.75rem;
  min-width: 2.75rem;
  background: transparent;
  color: var(--ink);
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .scribble-btn {
    padding: 0.45rem 0.95rem;
    min-height: unset;
    min-width: unset;
    display: inline-block;
  }
}

.scribble-btn:hover {
  transform: rotate(-2deg) scale(1.03);
  color: var(--accent);
}

.scribble-btn:active {
  transform: rotate(1deg) scale(0.98);
}

.section-title {
  font-size: 1.55rem;
  font-weight: 400;
  text-align: center;
  margin: 2rem 0 1rem;
}

/* Landing tweet + clickable lore block — paper theme only (no #000 UI) */
.landing-zone {
  margin-bottom: 1.25rem;
}

.lore-giant-link {
  display: block;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: rgba(196, 92, 38, 0.2);
}

.lore-giant-link:focus {
  outline: none;
}

.lore-giant-link:focus-visible {
  outline: 3px dashed var(--accent);
  outline-offset: 6px;
  border-radius: 14px;
}

.landing-tweet-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 28rem;
  margin-inline: auto;
}

.tweet-card {
  position: relative;
  width: 100%;
  padding: 1rem 1.1rem 1.15rem;
  margin: 0;
  background: rgba(255, 253, 248, 0.92);
  border-radius: 12px;
}

.tweet-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.tweet-avatar {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  flex-shrink: 0;
  object-fit: cover;
  border: 2px dashed rgba(92, 83, 72, 0.45);
  background: #fffef9;
}

.tweet-meta {
  min-width: 0;
  flex: 1;
}

.tweet-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.4rem;
  line-height: 1.2;
}

.tweet-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
}

.tweet-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fffef9;
  background: color-mix(in srgb, #3b82f6 88%, var(--ink));
  border-radius: 4px;
}

.tweet-mini-logo {
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.85;
}

.tweet-handle {
  display: block;
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.tweet-text {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  color: var(--ink);
  line-height: 1.4;
}

.tweet-media {
  margin: 0 0 0.85rem;
  padding: 0.65rem;
  background: #fffef9;
  border-radius: 10px;
  border: 2px dashed rgba(92, 83, 72, 0.38);
  display: flex;
  justify-content: center;
  align-items: center;
}

.tweet-media--embed {
  margin: 0 0 0.85rem;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.tweet-logo-frame {
  position: relative;
  width: min(17rem, 80vw);
  max-width: 100%;
  margin: 0 auto;
  aspect-ratio: 1;
  box-sizing: border-box;
  padding: clamp(0.55rem, 2.8vw, 0.9rem);
  background: #fffef9;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tweet-media--embed .tweet-logo-img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: none;
  object-fit: contain;
  filter: none;
  border-radius: 6px;
}

.tweet-logo-img {
  width: clamp(176px, 58vw, 280px);
  height: auto;
  max-height: min(280px, 72vw);
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(26, 21, 16, 0.1));
}

.tweet-media:not(.tweet-media--embed) .tweet-logo-img {
  width: clamp(160px, 56vw, 240px);
  max-height: min(240px, 52vw);
}

.tweet-quote {
  position: relative;
  padding: 0.7rem 0.85rem;
  margin: 0;
  background: rgba(255, 252, 244, 0.95);
  border-radius: 8px;
}

.tweet-quote-top {
  font-size: 0.92rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
  gap: 0.2rem 0.45rem;
  display: flex;
  align-items: baseline;
  color: var(--ink);
}

.tweet-quote-name {
  font-weight: 700;
}

.tweet-quote-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0.95rem;
  height: 0.95rem;
  padding: 0 0.18rem;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(145deg, #f5d78a 0%, #daa520 100%);
  border-radius: 3px;
}

.tweet-quote-handle,
.tweet-quote-time {
  color: var(--muted);
  font-size: 0.9rem;
}

.tweet-quote-body {
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.42;
  color: var(--ink);
}

.tweet-founder {
  display: block;
  font-size: 0.88rem;
  color: var(--accent);
  font-style: italic;
  margin-top: 0.2rem;
  letter-spacing: 0.01em;
}

.nav-lure {
  font-variant: small-caps;
  letter-spacing: 0.06em;
}

.chat-messages {
  min-height: 6rem;
  max-height: 14rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.5rem 0;
  margin-bottom: 0.75rem;
}

.chat-msg {
  margin: 0.5rem 0;
  padding: 0.35rem 0.5rem;
  border-left: 3px solid var(--accent);
  padding-left: 0.65rem;
}

.chat-msg.from-them {
  border-left-color: var(--muted);
  font-style: italic;
}

.chat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: stretch;
}

.chat-row #chat-send {
  flex: 1 1 100%;
  order: 2;
}

@media (min-width: 420px) {
  .chat-row {
    flex-wrap: nowrap;
    align-items: flex-end;
  }

  .chat-row #chat-send {
    flex: 0 0 auto;
    order: unset;
  }

  #chat-input {
    flex: 1 1 auto;
    min-width: 0;
    order: 1;
  }
}

#chat-input {
  flex: 1 1 100%;
  order: 1;
  width: 100%;
  max-width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.65rem 0.8rem;
  border: 2px dashed var(--ink);
  border-radius: 6px;
  background: #fffef9;
  resize: vertical;
  min-height: 3rem;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}

/* iOS avoids auto-zoom when focused inputs stay >= 16px */
@media screen and (max-width: 540px) {
  #chat-input {
    font-size: max(1rem, 16px);
  }
}

#chat-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tokenomics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.25rem), 1fr));
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.token-card {
  text-align: center;
  min-height: 7rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.token-card h4 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
}

.token-card p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.footer-scribble {
  text-align: center;
  max-width: var(--content-max);
  margin: 0 auto 1.5rem;
  padding: 1rem clamp(1rem, 4vw, 1.65rem);
  position: relative;
  z-index: 1;
  width: 100%;
}

.footer-scribble p {
  margin: 0;
  font-size: 1.15rem;
}

[data-scribble-box] canvas.rough-border {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

[data-scribble-box] > *:not(canvas) {
  position: relative;
  z-index: 1;
}

@media (min-width: 640px) {
  .landing-tweet-wrap {
    max-width: min(34rem, 100%);
  }

  .nav-inner {
    justify-content: center;
    gap: 0.6rem 0.95rem;
  }
}

@media (min-width: 900px) {
  :root {
    --content-max: min(58rem, 100%);
  }

  html {
    font-size: clamp(17px, 0.42vw + 16px, 19px);
  }

  .landing-tweet-wrap {
    max-width: min(36rem, 100%);
    gap: 1.25rem;
  }

  .tokenomics {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }

  .chat-messages {
    max-height: 16rem;
  }
}

@media (min-width: 1200px) {
  :root {
    --content-max: min(64rem, calc(100% - 4rem));
  }

  main {
    padding-left: clamp(1.25rem, 5vw, 2.25rem);
    padding-right: clamp(1.25rem, 5vw, 2.25rem);
  }

  .nav-scribble {
    padding-left: clamp(0.95rem, 4vw, 1.85rem);
    padding-right: clamp(0.95rem, 4vw, 1.85rem);
  }
}

@media (max-width: 540px) {
  html {
    font-size: 17px;
  }

  main {
    padding: 0.75rem 0.85rem calc(2rem + var(--safe-b));
  }

  .section-title {
    font-size: 1.4rem;
    margin: 1.5rem 0 0.85rem;
  }

  .hero-title {
    margin-bottom: 1.35rem;
  }

  .nav-scribble,
  .chat-section,
  .footer-scribble {
    padding-left: max(0.75rem, var(--safe-x));
    padding-right: max(0.75rem, var(--safe-r));
  }

  .token-card {
    min-height: 6.25rem;
    padding: 0.35rem;
  }

  .chat-messages {
    max-height: min(36vh, 13rem);
  }

  #chat-send {
    min-height: 2.875rem;
  }
}

@media (max-width: 380px) {
  html {
    font-size: 16px;
  }

  .ca-line {
    flex: 1 1 100%;
    text-align: center;
    margin-left: 0;
  }
}
