:root {
  color-scheme: light;
  --ink: #171714;
  --paper: #f8f4ec;
  --surface: #fffdf8;
  --muted: #6d6a62;
  --line: #d8d1c4;
  --red: #e93b2f;
  --red-dark: #bd251d;
  --yellow: #f8c822;
  --teal: #168f94;
  --teal-dark: #0d676b;
  --shadow: 0 16px 50px rgba(27, 25, 20, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
}

button,
select,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

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

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.65rem 0.9rem;
  color: white;
  background: var(--ink);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 72px;
  padding: 0 4vw;
  border-bottom: 1px solid var(--ink);
  background: rgba(248, 244, 236, 0.96);
  backdrop-filter: blur(12px);
}

.brand {
  justify-self: start;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0;
  text-decoration: none;
}

.brand-make {
  text-decoration: underline;
  text-decoration-color: var(--yellow);
  text-decoration-thickness: 0.28rem;
  text-underline-offset: 0.08rem;
}

.brand-ai {
  color: var(--red);
}

.brand-funny {
  color: var(--teal-dark);
}

.view-nav {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 0.25rem;
}

.nav-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 112px;
  padding: 0 1rem;
  border: 0;
  border-bottom: 4px solid transparent;
  color: var(--muted);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 750;
}

.nav-button svg,
.icon-button svg,
.primary-button svg,
.secondary-button svg,
.vote-button svg,
.report-trigger svg,
.minimum-note svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke-width: 2;
}

.nav-button.is-active {
  border-bottom-color: var(--red);
  color: var(--ink);
}

.lock-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
}

.lock-dot.is-unlocked {
  background: var(--teal);
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  background: var(--surface);
  place-items: center;
}

#profile-button {
  justify-self: end;
}

main {
  min-height: calc(100vh - 132px);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

#jokes-view {
  width: min(980px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.control-band {
  display: grid;
  grid-template-columns: minmax(190px, 1.4fr) minmax(210px, 1fr) minmax(210px, 1fr);
  gap: 1rem;
  align-items: end;
  width: min(820px, 100%);
  margin: 0 auto 1rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
}

.select-control,
.segmented-control {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.select-control > span,
.segmented-control legend,
.field-label {
  display: block;
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

select,
input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: 0 0.75rem;
  border: 1px solid var(--ink);
  border-radius: 4px;
  color: var(--ink);
  background: var(--surface);
}

.segmented-control > div,
.tab-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  min-height: 42px;
  padding: 3px;
  border: 1px solid var(--ink);
  border-radius: 5px;
  background: var(--surface);
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control label,
.tab-button {
  display: grid;
  min-width: 0;
  padding: 0.45rem 0.7rem;
  border: 0;
  border-radius: 3px;
  color: var(--muted);
  background: transparent;
  font-size: 0.84rem;
  font-weight: 750;
  text-align: center;
  place-items: center;
}

.segmented-control input:checked + label,
.tab-button.is-active {
  color: white;
  background: var(--ink);
}

.joke-stage {
  display: grid;
  min-height: 480px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  place-items: center;
}

.stage-idle,
.stage-loading {
  display: grid;
  justify-items: center;
  width: 100%;
  padding: 2rem;
  text-align: center;
}

.stage-idle[hidden],
.stage-loading[hidden],
.joke-card[hidden],
.vote-prompt[hidden],
.vote-result[hidden],
.leaderboard-empty[hidden],
#leaderboard-content[hidden] {
  display: none;
}

.stage-idle img {
  width: min(220px, 58vw);
  height: auto;
  margin-bottom: 0.5rem;
}

.stage-idle p,
.stage-loading p {
  margin: 0 0 1.4rem;
  color: var(--muted);
  font-size: 1rem;
}

.primary-button,
.secondary-button,
.vote-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  gap: 0.55rem;
  padding: 0.75rem 1.15rem;
  border: 1px solid var(--ink);
  border-radius: 5px;
  font-weight: 850;
}

.primary-button {
  color: white;
  background: var(--ink);
  box-shadow: 4px 4px 0 var(--yellow);
}

.primary-button:hover:not(:disabled) {
  color: var(--ink);
  background: var(--yellow);
  box-shadow: 4px 4px 0 var(--ink);
}

.secondary-button {
  color: var(--ink);
  background: var(--surface);
}

.loading-mark {
  display: flex;
  align-items: end;
  gap: 8px;
  height: 56px;
  margin-bottom: 1.25rem;
}

.loading-mark span {
  width: 12px;
  height: 24px;
  background: var(--red);
  animation: bounce 0.8s ease-in-out infinite alternate;
}

.loading-mark span:nth-child(2) {
  height: 44px;
  background: var(--yellow);
  animation-delay: 0.15s;
}

.loading-mark span:nth-child(3) {
  height: 32px;
  background: var(--teal);
  animation-delay: 0.3s;
}

@keyframes bounce {
  to {
    transform: scaleY(0.45);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-mark span {
    animation: none;
  }
}

.joke-card {
  width: 100%;
  padding: 2.25rem clamp(1.25rem, 6%, 4.5rem) 1.25rem;
}

.joke-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.mode-badge {
  padding: 0.28rem 0.5rem;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--yellow);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.mode-badge.is-adult {
  color: white;
  background: var(--red);
}

.model-reveal {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.joke-text {
  max-width: 760px;
  min-height: 150px;
  margin: 2.75rem auto;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  line-height: 1.42;
  letter-spacing: 0;
  white-space: pre-line;
}

.vote-prompt {
  display: grid;
  justify-items: center;
  gap: 0.85rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}

.vote-prompt p {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
}

.vote-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: min(460px, 100%);
}

.vote-yes {
  background: #cdecd7;
}

.vote-no {
  background: #ffd2cc;
}

.vote-button:hover:not(:disabled) {
  color: white;
  background: var(--ink);
}

.vote-result {
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  text-align: center;
}

.result-number {
  margin: 0;
  font-size: 2.35rem;
  font-weight: 950;
}

.result-detail {
  margin: 0.3rem 0 1.25rem;
  color: var(--muted);
}

.post-vote-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.report-trigger {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 1.5rem auto 0;
  padding: 0.4rem;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 0.76rem;
  text-decoration: underline;
  text-underline-offset: 0.15rem;
}

.report-trigger svg {
  width: 14px;
  height: 14px;
}

.vote-progress {
  width: min(620px, calc(100% - 2rem));
  margin: 1.25rem auto 0;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border: 1px solid var(--ink);
  background: var(--surface);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--teal);
  transition: width 220ms ease;
}

.leaderboard-view {
  width: min(1060px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3.5rem 0 5rem;
}

.leaderboard-heading-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--ink);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--red-dark);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.leaderboard-heading-row h1 {
  margin: 0;
  font-size: 2.25rem;
  letter-spacing: 0;
}

.minimum-note {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.leaderboard-lock-panel,
.leaderboard-empty {
  display: grid;
  justify-items: center;
  max-width: 540px;
  margin: 4.5rem auto;
  text-align: center;
}

.leaderboard-lock-panel > svg,
.leaderboard-empty > svg {
  width: 52px;
  height: 52px;
  margin-bottom: 1rem;
  color: var(--teal-dark);
}

.leaderboard-lock-panel h2,
.leaderboard-empty h2 {
  margin: 0;
  font-size: 1.4rem;
}

.leaderboard-lock-panel p,
.leaderboard-empty p {
  margin: 0.55rem 0 1.25rem;
  color: var(--muted);
}

.leaderboard-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.25rem 0;
}

.tab-list {
  min-width: 250px;
}

.leaderboard-list {
  border-top: 1px solid var(--ink);
}

.leaderboard-entry {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 1.1rem;
  align-items: start;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--ink);
}

.rank-number {
  display: grid;
  width: 42px;
  height: 42px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
  font-weight: 950;
  place-items: center;
}

.leaderboard-joke {
  margin: 0 0 0.85rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
  line-height: 1.45;
  white-space: pre-line;
}

.leaderboard-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.leaderboard-entry .icon-button {
  flex: 0 0 auto;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  padding: 0 4vw;
  border-top: 1px solid var(--ink);
  color: var(--muted);
  background: var(--paper);
  font-size: 0.78rem;
}

footer nav {
  display: flex;
  gap: 1rem;
}

footer a {
  color: inherit;
}

.modal {
  width: min(520px, calc(100% - 2rem));
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 8px 8px 0 var(--ink);
}

.modal::backdrop {
  background: rgba(23, 23, 20, 0.58);
  backdrop-filter: blur(2px);
}

.modal form {
  position: relative;
  padding: 2rem;
}

.compact-modal {
  width: min(440px, calc(100% - 2rem));
}

.modal h2 {
  margin: 0;
  font-size: 1.65rem;
  letter-spacing: 0;
}

.modal-intro {
  margin: 0.75rem 0 1.6rem;
  color: var(--muted);
  line-height: 1.55;
}

.modal .field-label {
  margin-top: 1rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.text-button {
  min-height: 44px;
  padding: 0.6rem 0.8rem;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-weight: 750;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  background: var(--paper);
  font-weight: 750;
}

.check-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--red);
}

.report-options {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.35rem;
}

.report-options button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 50px;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--ink);
  border-radius: 4px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 750;
  text-align: left;
}

.report-options button:hover {
  color: white;
  background: var(--ink);
}

.report-options svg {
  width: 19px;
  height: 19px;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 80;
  max-width: min(360px, calc(100% - 2rem));
  padding: 0.85rem 1rem;
  border: 1px solid var(--ink);
  border-radius: 4px;
  color: white;
  background: var(--ink);
  box-shadow: 4px 4px 0 var(--yellow);
  font-size: 0.88rem;
  font-weight: 700;
}

.turnstile-container {
  position: fixed;
  right: 0;
  bottom: 4.75rem;
  left: 0;
  z-index: 100;
  width: min(320px, calc(100vw - 1rem));
  margin: auto;
}

.turnstile-container:empty {
  display: none;
}

.legal-page {
  background: var(--paper);
}

.legal-shell {
  width: min(760px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 4rem 0 6rem;
}

.legal-shell h1 {
  margin: 0 0 1.5rem;
  font-size: 2.4rem;
}

.legal-shell h2 {
  margin: 2rem 0 0.5rem;
  font-size: 1.15rem;
}

.legal-shell p,
.legal-shell li {
  color: #4f4d47;
  line-height: 1.65;
}

.legal-shell a {
  color: var(--teal-dark);
}

@media (max-width: 760px) {
  .site-header {
    grid-template-columns: 1fr auto;
    min-height: 64px;
    padding: 0 1rem;
    backdrop-filter: none;
  }

  .view-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 62px;
    border-top: 1px solid var(--ink);
    background: var(--surface);
  }

  .nav-button {
    justify-content: center;
    min-width: 0;
    border-top: 4px solid transparent;
    border-bottom: 0;
  }

  .nav-button.is-active {
    border-top-color: var(--red);
    border-bottom: 0;
  }

  #profile-button {
    grid-column: 2;
  }

  #jokes-view,
  .leaderboard-view {
    width: min(100% - 1rem, 680px);
    padding-top: 1rem;
    padding-bottom: 5rem;
  }

  .control-band {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 0.75rem 0;
  }

  .select-control {
    grid-column: 1 / -1;
  }

  .joke-stage {
    min-height: 450px;
  }

  .joke-card {
    padding: 1.25rem 1rem 1rem;
  }

  .joke-text {
    min-height: 170px;
    margin: 2rem auto;
    font-size: 1.52rem;
  }

  .post-vote-actions {
    align-items: stretch;
  }

  .post-vote-actions > button {
    flex: 1;
  }

  .progress-copy {
    align-items: end;
  }

  .leaderboard-heading-row,
  .leaderboard-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .minimum-note {
    align-self: flex-start;
  }

  .tab-list {
    min-width: 0;
    width: 100%;
  }

  .leaderboard-entry {
    grid-template-columns: 44px minmax(0, 1fr) 38px;
    gap: 0.7rem;
  }

  footer {
    margin-bottom: 62px;
  }
}

@media (max-width: 410px) {
  .brand {
    font-size: 1.12rem;
  }

  .control-band {
    grid-template-columns: 1fr;
  }

  .select-control {
    grid-column: auto;
  }

  .vote-actions,
  .post-vote-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .joke-text {
    font-size: 1.35rem;
  }

  .progress-copy {
    font-size: 0.7rem;
  }

  .leaderboard-entry {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .leaderboard-entry .icon-button {
    grid-column: 2;
  }
}
