:root {
  --ink: #161616;
  --muted: #736f68;
  --paper: #f5f1e8;
  --paper-deep: #ebe4d6;
  --red: #c93827;
  --yellow: #f2c64e;
  --line: #d6cec0;
  --max: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: 'DM Sans', sans-serif;
  background-image: radial-gradient(rgba(22,22,22,.06) .7px, transparent .7px);
  background-size: 9px 9px;
}
button, input { font: inherit; }
a { color: inherit; }

.masthead, main, .footer { max-width: var(--max); margin: 0 auto; padding-left: 32px; padding-right: 32px; }
.masthead { border-bottom: 2px solid var(--ink); }
.masthead__topline, .masthead__stamp, .eyebrow, .result-count, .alphabet, .footer, .footer__meta, .searchbox kbd {
  font-family: 'DM Mono', monospace;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-size: 10px;
}
.masthead__topline { display: flex; justify-content: space-between; padding: 18px 0 12px; color: var(--muted); }
.masthead__main { display: flex; align-items: flex-end; justify-content: space-between; padding: 4px 0 26px; }
.wordmark { font-family: 'Playfair Display', serif; font-size: clamp(32px, 7vw, 76px); line-height: .78; letter-spacing: -.06em; text-decoration: none; white-space: nowrap; }
.wordmark em { color: var(--red); font-style: normal; }
.wordmark span { font-size: 1em; letter-spacing: -.06em; }
.masthead__stamp { text-align: right; line-height: 1.6; color: var(--muted); padding-bottom: 3px; }
.masthead__stamp strong { color: var(--ink); font-size: 13px; }

.hero { min-height: 420px; display: grid; grid-template-columns: 1.4fr .6fr; gap: 80px; align-items: center; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 16px; color: var(--red); font-weight: 500; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 740px; margin-bottom: 20px; font-family: 'Playfair Display', serif; font-size: clamp(58px, 10vw, 126px); line-height: .83; letter-spacing: -.07em; }
h1 i { color: var(--red); font-style: normal; }
.hero__intro { max-width: 450px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.55; }
.hero__note { align-self: center; justify-self: end; width: 220px; padding: 30px 25px 25px; background: var(--yellow); transform: rotate(3deg); box-shadow: 7px 8px 0 var(--ink); }
.hero__note-mark { display: block; font-family: 'Playfair Display', serif; font-size: 72px; line-height: .4; }
.hero__note p { margin: 16px 0 25px; font-family: 'Playfair Display', serif; font-size: 27px; line-height: 1.02; letter-spacing: -.04em; }
.hero__note-caption { font-family: 'DM Mono', monospace; font-size: 9px; text-transform: uppercase; letter-spacing: .07em; }

.dictionary { padding: 50px 0 96px; }
.dictionary__toolbar { display: flex; gap: 25px; align-items: center; justify-content: space-between; }
.searchbox { display: flex; align-items: center; width: min(100%, 560px); border-bottom: 2px solid var(--ink); padding: 12px 0; }
.searchbox__icon { margin-right: 12px; color: var(--red); font-size: 30px; line-height: 0; transform: rotate(-20deg); }
.searchbox input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 19px; }
.searchbox input::placeholder { color: #a29c91; }
.searchbox kbd { padding: 3px 6px; border: 1px solid var(--line); color: var(--muted); }
.result-count { color: var(--muted); white-space: nowrap; }
.alphabet { display: flex; flex-wrap: wrap; gap: 9px; padding: 26px 0 38px; border-bottom: 1px solid var(--line); }
.letter { border: 0; padding: 7px 6px; color: var(--muted); background: none; cursor: pointer; }
.letter:hover, .letter.active { color: var(--red); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; }
.letter.active { font-weight: 700; }
.dictionary__heading { display: flex; justify-content: space-between; align-items: end; padding: 44px 0 20px; }
.dictionary__heading .eyebrow { margin-bottom: 9px; }
h2 { margin-bottom: 0; font-family: 'Playfair Display', serif; font-size: clamp(34px, 5vw, 55px); line-height: .9; letter-spacing: -.06em; }
.clear-button { border: 0; color: var(--red); background: none; cursor: pointer; font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.clear-button span { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-left: 5px; border: 1px solid var(--red); border-radius: 50%; font-size: 16px; line-height: 1; }
.entries { display: grid; grid-template-columns: repeat(2, 1fr); border-top: 2px solid var(--ink); }
.entry { display: grid; grid-template-columns: 62px 1fr; gap: 18px; min-height: 170px; padding: 25px 22px 27px 0; border-bottom: 1px solid var(--line); }
.entry:nth-child(odd) { padding-right: 32px; border-right: 1px solid var(--line); }
.entry:nth-child(even) { padding-left: 32px; }
.entry__letter { color: var(--red); font-family: 'Playfair Display', serif; font-size: 42px; line-height: .8; }
.entry__term { margin: 0 0 10px; font-size: 21px; line-height: 1.05; letter-spacing: -.035em; }
.entry__definition { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.empty-state { padding: 70px 0; text-align: center; }
.empty-state__face { margin-bottom: 18px; font-family: 'DM Mono', monospace; font-size: 24px; }
.empty-state p { color: var(--muted); }

.footer { display: flex; align-items: center; gap: 20px; padding-top: 18px; padding-bottom: 26px; border-top: 2px solid var(--ink); color: var(--muted); }
.footer__mark { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; background: var(--red); color: var(--paper); font-family: 'Playfair Display', serif; font-size: 17px; transform: rotate(-5deg); }
.footer p { display: flex; align-items: center; gap: 8px; margin: 0; }
.footer p img { width: 28px; height: 28px; flex: 0 0 auto; object-fit: contain; }
.footer a { color: var(--red); }
.footer__meta { margin-left: auto !important; text-align: right; line-height: 1.5; font-size: 9px; }
.footer__meta a { display: inline-block; margin-top: 8px; color: var(--ink); font-size: 17px; line-height: 1; text-decoration: none; transition: transform .2s ease; }
.footer__meta a:hover { transform: rotate(-10deg) scale(1.15); }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(22, 22, 22, .55); }
.modal__panel { position: relative; width: min(560px, 100%); max-height: min(680px, calc(100vh - 48px)); overflow: auto; padding: 38px 42px 42px; border: 2px solid var(--ink); background: var(--paper); box-shadow: 9px 10px 0 var(--yellow); }
.modal__panel h2 { margin-bottom: 28px; }
.modal__close { position: absolute; top: 13px; right: 16px; width: 30px; height: 30px; border: 1px solid var(--ink); border-radius: 50%; background: transparent; color: var(--ink); font-size: 22px; line-height: 1; cursor: pointer; }
.modal__close:hover { background: var(--yellow); }
.egg-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; border-top: 2px solid var(--ink); }
.egg-list li { display: grid; gap: 5px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.egg-list strong { font-family: 'Playfair Display', serif; font-size: 20px; line-height: 1; }
.egg-list span { color: var(--muted); font-size: 14px; line-height: 1.5; }
.egg-list em { color: var(--ink); font-style: normal; }

.scroll-top {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 52px;
  height: 52px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 10px 20px rgba(22, 22, 22, 0.12);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
  z-index: 20;
}
.scroll-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.scroll-top:hover { background: var(--yellow); }

.egg-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 30;
  max-width: min(440px, calc(100vw - 40px));
  padding: 13px 17px;
  border: 2px solid var(--ink);
  background: var(--yellow);
  box-shadow: 5px 5px 0 var(--ink);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
  text-transform: uppercase;
  transform: translate(-50%, 18px) rotate(-1deg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.egg-toast.is-visible { opacity: 1; transform: translate(-50%, 0) rotate(-1deg); }
.newman-toast { background: var(--red); color: var(--paper); }
.festivus-mode { --red: #7d1d26; --yellow: #c7bda9; }
.festivus-mode .hero__note { transform: rotate(-3deg); }
.festivus-mode .hero__note::after { display: block; margin-top: 18px; padding-top: 12px; border-top: 1px solid currentColor; content: 'Airing of grievances / Feats of strength'; font-family: 'DM Mono', monospace; font-size: 9px; line-height: 1.5; text-transform: uppercase; }
.serenity-mode .hero__note { animation: serenity-pulse .8s ease-in-out 2; }
.theater-mode .hero__note { background: #302735; color: #f8e8bf; box-shadow: 7px 8px 0 var(--red); }
.newman-mode .wordmark em { animation: newman-flash .8s steps(2, end) 2; }
.kramer-mode .wordmark { animation: kramer-slide .7s cubic-bezier(.2, .8, .2, 1); }
.contest-mode .hero { border-bottom-color: var(--red); }
.contest-mode .result-count { color: var(--red); }
.bizarro-mode .dictionary__heading h2::after { content: ' / opposite day'; color: var(--red); font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.empty-state { cursor: pointer; }

@keyframes serenity-pulse {
  50% { transform: scale(1.05) rotate(3deg); }
}
@keyframes newman-flash {
  50% { color: var(--yellow); }
}
@keyframes kramer-slide {
  0% { transform: translateX(110vw) rotate(8deg); }
  100% { transform: translateX(0) rotate(0); }
}

@media (max-width: 700px) {
  .masthead, main, .footer { padding-left: 20px; padding-right: 20px; }
  .masthead__topline span:last-child { display: none; }
  .masthead__main { padding-bottom: 20px; }
  .masthead__stamp { font-size: 8px; }
  .hero { min-height: 0; display: block; padding: 72px 0 62px; }
  h1 { font-size: clamp(62px, 19vw, 100px); }
  .hero__intro { font-size: 15px; }
  .hero__note { margin: 48px 16px 10px auto; }
  .dictionary { padding-top: 38px; }
  .dictionary__toolbar { display: block; }
  .result-count { margin-top: 14px; }
  .alphabet { gap: 4px; padding-bottom: 26px; }
  .letter { padding: 7px 5px; }
  .dictionary__heading { padding-top: 35px; }
  .entries { display: block; }
  .entry, .entry:nth-child(odd), .entry:nth-child(even) { grid-template-columns: 43px 1fr; min-height: 0; padding: 22px 0; border-right: 0; }
  .entry__letter { font-size: 32px; }
  .entry__term { font-size: 19px; }
  .footer { display: grid; grid-template-columns: auto 1fr; gap: 12px; }
  .footer__meta { grid-column: 2; margin: 0 !important; text-align: left; }
  .modal { padding: 18px; }
  .modal__panel { padding: 36px 24px 28px; box-shadow: 6px 7px 0 var(--yellow); }
}
