:root {
  --paper: #f4f1e8;
  --surface: #fffdf7;
  --ink: #181b19;
  --muted: #6d716c;
  --line: #d9d7cc;
  --green: #236a4b;
  --green-soft: #dcebdd;
  --yellow: #f2c84b;
  --red: #d95b43;
  --red-soft: #f5dfd9;
  --shadow: 0 14px 34px rgba(42, 44, 38, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
img { display: block; max-width: 100%; }
a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 70px;
  padding: 0 clamp(18px, 3vw, 46px);
  border-bottom: 1px solid var(--line);
  background: rgba(244, 241, 232, .96);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}
.brand {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 900;
  text-decoration: none;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--yellow);
  display: grid;
  place-items: center;
  font-size: 19px;
  transform: rotate(-3deg);
}
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links a {
  padding: 8px 12px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.nav-links a:hover, .nav-links a.active { background: var(--surface); color: var(--ink); }
.account-actions { justify-self: end; display: flex; align-items: center; gap: 7px; }
.user-chip {
  max-width: 110px;
  overflow: hidden;
  color: var(--green);
  font-size: 11px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-button {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}
.account-button:hover { border-color: var(--ink); }
.upload-button {
  min-height: 42px;
  padding: 0 18px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  box-shadow: 4px 4px 0 var(--yellow);
}
.upload-button:hover { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--yellow); }

.arena {
  height: calc(100svh - 70px);
  min-height: 650px;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(190px, 2fr) minmax(270px, 3fr) minmax(270px, 3fr) minmax(190px, 2fr);
  gap: 12px;
}
.rail, .feature-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.rail {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: #a7aaa3 transparent;
}
.rail-head {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 247, .96);
}
.rail-head div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rail-head h2 { margin: 0; font-size: 14px; }
.rail-head span { color: var(--green); font-size: 9px; font-weight: 800; }
.rail-head p { margin: 5px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.rail-list { padding: 10px; display: grid; gap: 10px; }
.rail-empty {
  min-height: 190px;
  padding: 24px 14px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}
.rail-empty img { width: 100%; max-width: 150px; border: 1px solid var(--line); border-radius: 5px; }

.submission-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #d9eef2;
}
.card-media img { width: 100%; height: 100%; object-fit: contain; }
.svg-label {
  position: absolute;
  top: 7px;
  left: 7px;
  z-index: 2;
  padding: 3px 5px;
  border-radius: 3px;
  background: rgba(24, 27, 25, .84);
  color: #fff;
  font-size: 8px;
  font-weight: 900;
}
.card-body { padding: 9px; }
.model-row { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.model-row strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.model-row span { flex: 0 0 auto; color: var(--muted); font-size: 8px; }
.prompt {
  min-height: 30px;
  margin: 6px 0 9px;
  color: var(--muted);
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 9px;
  line-height: 1.55;
}
.vote-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.vote-buttons button {
  min-width: 0;
  height: 30px;
  padding: 0 2px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f7f6f1;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}
.vote-buttons button:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }
.vote-buttons button.selected[data-vote="good"] { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.vote-buttons button.selected[data-vote="mid"] { border-color: #b68a13; background: #fbefbd; color: #735300; }
.vote-buttons button.selected[data-vote="bad"] { border-color: var(--red); background: var(--red-soft); color: #9f3325; }
.vote-result { min-height: 13px; margin: 6px 0 0; color: #8a8d87; font-size: 8px; text-align: center; }

.feature-card {
  position: relative;
  height: 100%;
  padding: 14px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.feature-card.best { background: #f9fbf3; }
.feature-card.worst { background: #fff8f4; }
.feature-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.eyebrow { display: block; margin-bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 850; }
.feature-head h1, .feature-head h2 {
  max-width: 230px;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: clamp(20px, 2vw, 30px);
  line-height: 1.1;
}
.rank-badge {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--yellow);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 950;
}
.worst .rank-badge { background: var(--red-soft); color: #a53a2a; }
.feature-media {
  min-height: 0;
  margin: 14px 0;
  overflow: hidden;
  border: 1px solid rgba(24, 27, 25, .18);
  border-radius: 6px;
  background: #cfe9ef;
  display: grid;
  place-items: center;
}
.feature-media img { width: 100%; height: 100%; object-fit: contain; }
.feature-info { display: grid; gap: 10px; }
.feature-stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.feature-stats div { padding: 9px 4px; border-right: 1px solid var(--line); text-align: center; }
.feature-stats div:last-child { border-right: 0; }
.feature-stats strong { display: block; font-size: 14px; }
.feature-stats span { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.feature-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 10px; }
.feature-meta strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feature-meta span { flex: 0 0 auto; color: var(--muted); }

.second-screen {
  min-height: 100svh;
  padding: 90px clamp(20px, 7vw, 110px);
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.section-title { max-width: 760px; }
.section-title > span, .dialog-kicker { color: var(--green); font-size: 11px; font-weight: 900; }
.section-title h2 { margin: 8px 0 12px; font-size: clamp(34px, 5vw, 66px); line-height: 1; }
.section-title p { margin: 0; color: var(--muted); line-height: 1.7; }
.leaderboard { margin-top: 45px; border-top: 2px solid var(--ink); }
.leader-row {
  min-height: 72px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 130px 90px;
  align-items: center;
  gap: 18px;
}
.leader-row > strong:first-child { font-size: 24px; }
.leader-model { min-width: 0; }
.leader-model strong, .leader-model span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-model span, .leader-row > span { color: var(--muted); font-size: 11px; }
.score-bar { height: 8px; overflow: hidden; border-radius: 99px; background: #e6e3d9; }
.score-bar i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.leader-score { text-align: right; font-size: 20px; }
.leader-empty { padding: 34px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.rules { margin-top: 90px; }

.pelican-guide {
  padding: 96px clamp(20px, 7vw, 110px);
  border-top: 1px solid var(--line);
  background: #edf3ea;
}
.guide-intro { max-width: 980px; }
.guide-intro > span, .guide-language {
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
}
.guide-intro h1 {
  max-width: 920px;
  margin: 10px 0 18px;
  font-size: clamp(36px, 5vw, 68px);
  line-height: 1.05;
}
.guide-intro p {
  max-width: 820px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.8;
}
.guide-intro strong { color: var(--ink); }
.guide-columns {
  margin-top: 52px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.guide-article {
  min-width: 0;
  padding: 38px 42px 44px 0;
}
.guide-article + .guide-article {
  padding-right: 0;
  padding-left: 42px;
  border-left: 1px solid var(--line);
}
.guide-article h2 {
  margin: 9px 0 20px;
  font-size: 30px;
  line-height: 1.2;
}
.guide-article h3 {
  margin: 30px 0 9px;
  font-size: 17px;
  line-height: 1.35;
}
.guide-article p {
  margin: 0;
  color: #4e544f;
  font-size: 14px;
  line-height: 1.9;
}
.guide-checklist {
  margin: 14px 0 18px;
  padding-left: 20px;
  color: #4e544f;
  font-size: 14px;
  line-height: 1.75;
}
.guide-checklist li + li { margin-top: 5px; }
.guide-article blockquote {
  margin: 14px 0 17px;
  padding: 13px 0 13px 18px;
  border-left: 4px solid var(--yellow);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
}
.guide-article code { overflow-wrap: anywhere; }
.guide-sources {
  padding-top: 28px;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 24px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
.guide-sources strong { color: var(--ink); }
.guide-sources ol { margin: 0; padding-left: 20px; }
.guide-sources a { text-underline-offset: 3px; }
.guide-sources a:hover { color: var(--green); }

dialog {
  width: min(540px, calc(100% - 28px));
  max-height: calc(100svh - 28px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 25px 80px rgba(0, 0, 0, .22);
}
dialog::backdrop { background: rgba(20, 22, 20, .58); }
.dialog-head { padding: 20px 22px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.dialog-head h2 { margin: 5px 0 0; font-size: 23px; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--ink); font-size: 20px; }
.auth-tabs { margin: 16px 22px 0; padding: 3px; border: 1px solid var(--line); border-radius: 6px; display: grid; grid-template-columns: 1fr 1fr; }
.auth-tabs button { height: 34px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 850; }
.auth-tabs button.active { background: var(--ink); color: #fff; }
.dialog-form { padding: 18px 22px 22px; display: grid; gap: 14px; }
.field { min-width: 0; display: grid; gap: 6px; }
.field > span { font-size: 11px; font-weight: 800; }
.field small { color: var(--muted); font-size: 9px; }
.field input, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.field input { height: 42px; padding: 0 11px; }
.field textarea { min-height: 86px; padding: 10px 11px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(35, 106, 75, .1); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.file-field {
  min-height: 155px;
  overflow: hidden;
  border: 1px dashed #a7aaa3;
  border-radius: 6px;
  background: #f7f5ee;
  display: grid;
  place-items: center;
  cursor: pointer;
  text-align: center;
}
.file-field:hover { border-color: var(--green); background: #f0f6ec; }
.file-field strong, .file-field small { display: block; }
.file-field strong { max-width: 450px; padding: 0 12px; overflow-wrap: anywhere; font-size: 13px; }
.file-field small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.security-note { margin: -2px 0 0; color: var(--green); font-size: 10px; }
.form-error { min-height: 16px; margin: -4px 0 0; color: #a13426; font-size: 10px; }
.form-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.cancel-button, .submit-button { min-height: 44px; border-radius: 5px; font-weight: 850; }
.cancel-button { border: 1px solid var(--line); background: transparent; color: var(--ink); }
.submit-button { border: 2px solid var(--ink); background: var(--ink); color: #fff; box-shadow: 3px 3px 0 var(--yellow); }
.submit-button:disabled { opacity: .55; box-shadow: none; }
.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 24px;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 5px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity .18s ease, transform .18s ease;
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1060px) {
  .arena { grid-template-columns: minmax(165px, 1fr) minmax(240px, 1.5fr) minmax(240px, 1.5fr) minmax(165px, 1fr); gap: 8px; padding: 8px; }
  .feature-card { padding: 11px; }
  .topbar { padding-inline: 18px; }
  .prompt { min-height: 28px; }
  .vote-buttons button { font-size: 8px; }
}

@media (max-width: 780px) {
  .topbar { height: 62px; grid-template-columns: 1fr auto; }
  .nav-links { display: none; }
  .user-chip { display: none; }
  .upload-button { min-height: 38px; padding: 0 12px; font-size: 12px; }
  .account-button { min-height: 34px; padding: 0 8px; font-size: 11px; }
  .arena {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "best worst" "left right";
    padding: 10px;
  }
  .feature-card { height: min(66svh, 620px); }
  .feature-card.best { grid-area: best; }
  .feature-card.worst { grid-area: worst; }
  .rail { height: 70svh; }
  #left-rail { grid-area: left; }
  #right-rail { grid-area: right; }
  .feature-head h1, .feature-head h2 { font-size: 20px; }
  .leader-row { grid-template-columns: 45px 1fr 80px; }
  .score-bar { display: none; }
  .guide-columns { grid-template-columns: 1fr; }
  .guide-article { padding-right: 0; }
  .guide-article + .guide-article {
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 520px) {
  .brand { font-size: 15px; }
  .brand-mark { width: 30px; height: 30px; }
  .account-actions { gap: 5px; }
  .arena { display: flex; flex-direction: column; }
  .feature-card { height: 72svh; min-height: 520px; }
  .feature-card.worst { order: 2; }
  #left-rail { order: 3; }
  #right-rail { order: 4; }
  .rail { height: auto; max-height: none; overflow: visible; }
  .rail-head { position: static; }
  .rail-list { grid-template-columns: 1fr 1fr; }
  .second-screen { padding: 70px 18px; }
  .pelican-guide { padding: 70px 18px; }
  .guide-intro h1 { font-size: 38px; }
  .guide-intro p { font-size: 15px; }
  .guide-article { padding-block: 30px 34px; }
  .guide-article h2 { font-size: 25px; }
  .guide-sources { grid-template-columns: 1fr; gap: 8px; }
  .leader-row { grid-template-columns: 36px 1fr 60px; gap: 10px; }
  .leader-row > strong:first-child { font-size: 18px; }
  .field-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
