:root {
  --ink: #16324a;
  --deep: #1a6ea8;
  --foam: #f4f9fd;
  --paper: #ffffff;
  --sand: #1c7ed6;
  --water: #5eb3e0;
  --alert: #c45a3a;
  --ok: #2f7a5a;
  --line: rgba(22, 50, 74, 0.12);
  --pad: clamp(0.75rem, 3vw, 1.5rem);
}

* { box-sizing: border-box; }
html { overflow-x: clip; }
body {
  margin: 0;
  font-family: Onest, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 92% -8%, rgba(94, 179, 224, 0.28), transparent 52%),
    radial-gradient(700px 380px at -8% 108%, rgba(26, 110, 168, 0.1), transparent 48%),
    var(--foam);
  min-height: 100dvh;
  line-height: 1.5;
  overflow-x: clip;
}

a { color: var(--deep); }
img { max-width: 100%; height: auto; display: block; }

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem var(--pad);
  position: relative;
}
.home .nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
}
.nav-brand {
  font-family: Unbounded, sans-serif;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--deep);
  text-decoration: none;
  font-size: clamp(0.92rem, 2.1vw, 1.15rem);
  white-space: nowrap;
}
.nav-links {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.nav-user { opacity: 0.65; font-size: 0.82rem; }
.nav-out {
  text-decoration: none;
  color: var(--ink);
  font-size: 0.86rem;
}
.nav-btn,
.vote-go,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 0;
  font-family: Onest, sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.2;
  text-decoration: none;
  border: 0;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.nav-btn-fill,
.btn-primary,
.vote-go {
  background: var(--sand);
  color: var(--paper);
}
.nav-btn-fill:hover,
.btn-primary:hover,
.vote-go:hover {
  background: #155fad;
  color: var(--paper);
}
.nav-btn-ghost,
.btn-ghost {
  background: var(--paper);
  color: var(--deep);
  box-shadow: inset 0 0 0 1.5px var(--deep);
}
.nav-btn-ghost:hover,
.btn-ghost:hover {
  background: rgba(26, 110, 168, 0.08);
}
.vote-go.is-on {
  background: var(--paper);
  color: var(--deep);
  box-shadow: inset 0 0 0 1.5px var(--deep);
}
.vote-go.is-on:hover {
  background: rgba(26, 110, 168, 0.08);
  color: var(--deep);
}
.vote-go:disabled { opacity: 0.55; }
.stage .nav {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  padding-top: calc(0.7rem + var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)));
}
.browser-gate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin: 0;
  padding: 0.75rem var(--pad);
  background: #e8f3fb;
  font-size: 0.9rem;
}
.browser-gate[hidden],
.need-app[hidden] { display: none; }
body.is-tg .browser-gate { display: none; }
.need-app {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin: 0;
  padding: 0.75rem var(--pad);
  background: #e8f3fb;
  font-size: 0.9rem;
}
.stage .nav::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--water), var(--deep), var(--water), transparent);
  animation: drift 18s linear infinite;
}

.empty-stage,
.stage-hint {
  padding: 1.4rem var(--pad) 2.4rem;
  max-width: 38rem;
}
.empty-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 0;
}

.ladder {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px var(--pad) 2rem;
}
.piece {
  min-width: 0;
  display: flex;
  flex-direction: column;
  color: inherit;
  background: var(--paper);
}
.piece.is-lead { grid-column: span 4; }
.piece.is-high { grid-column: span 2; }
.piece.is-mid { grid-column: span 2; }
.piece.is-rest { grid-column: span 1; }
.piece-pic {
  display: block;
  overflow: hidden;
  background: #d7ebf5;
  aspect-ratio: 4 / 5;
  width: 100%;
  padding: 0;
  border: 0;
  cursor: pointer;
}
.piece.is-lead .piece-pic {
  aspect-ratio: auto;
  height: auto;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(600px 280px at 50% 0%, rgba(94, 179, 224, 0.28), transparent 70%),
    #eaf5fb;
}
.piece.is-high .piece-pic { aspect-ratio: 5 / 4; }
.piece.is-mid .piece-pic { aspect-ratio: 4 / 5; }
.piece-pic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.65s ease;
}
.piece.is-lead .piece-pic img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(88vh, 1100px);
  object-fit: contain;
}
.piece:hover .piece-pic img { transform: scale(1.035); }
.piece.is-lead:hover .piece-pic img { transform: none; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(-24px); }
}
.piece-foot {
  padding: 0.55rem 0.65rem 0.75rem;
}
.piece.is-lead .piece-foot {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.2fr);
  gap: 1rem 1.5rem;
  padding: 1rem 1.1rem 1.25rem;
  align-items: start;
}
.piece-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.piece-rank {
  font-family: Unbounded, sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  min-width: 1.1rem;
  letter-spacing: -0.04em;
  color: var(--deep);
}
.piece.is-lead .piece-rank { font-size: 1.35rem; }
.piece-who {
  flex: 1;
  min-width: 4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 500;
}
.piece-votes {
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
  font-size: 0.8rem;
}
.piece-cap {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: pre-wrap;
}
.piece.is-lead .piece-cap {
  margin: 0;
  font-size: 0.98rem;
}
.piece:not(.is-lead) .piece-cap {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
}
.vote-form { margin: 0; }
.piece .vote-go {
  padding: 0.42rem 0.8rem;
  font-size: 0.78rem;
}
.login-box { max-width: 28rem; }
.login-box .btn { margin-bottom: 0.85rem; }
.login-alt { opacity: 0.8; font-size: 0.92rem; }

.hero {
  min-height: 100dvh;
  padding: 4.2rem var(--pad) 2rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -8% -12% auto -12%;
  height: 70%;
  background: repeating-linear-gradient(
    112deg,
    transparent 0 22px,
    rgba(26, 110, 168, 0.06) 22px 23px
  );
  pointer-events: none;
  animation: drift 28s linear infinite;
}
.hero-copy { position: relative; z-index: 1; max-width: 38rem; }
.hero-brand {
  font-family: Unbounded, sans-serif;
  font-size: clamp(1.55rem, 6.2vw, 3.1rem);
  font-weight: 800;
  line-height: 1.05;
  margin: 0 0 0.45rem;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  text-wrap: balance;
  color: var(--deep);
}
.hero h1 {
  font-family: Unbounded, sans-serif;
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  font-weight: 500;
  margin: 0 0 0.7rem;
}
.hero-lead {
  margin: 0 0 1.15rem;
  font-size: 0.98rem;
  max-width: 34rem;
}
.hero-cta { display: flex; gap: 0.65rem; flex-wrap: wrap; }

.block,
.page-head {
  padding: 2rem var(--pad) 0;
  max-width: 40rem;
}
.block:last-of-type { padding-bottom: 3rem; }
.rules { padding-bottom: 1rem; }
.want, .nope {
  margin: 0.4rem 0 1rem;
  padding-left: 1.15rem;
}
.want li, .nope li { margin: 0 0 0.55rem; }
.nope { opacity: 0.9; }
.prizes {
  margin: 0;
  padding: 0;
  list-style: none;
}
.prizes li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  max-width: 22rem;
}
.prizes span { opacity: 0.75; }
.note {
  padding: 0.85rem 0 0;
  border-top: 1px solid var(--line);
}
.block h2,
.page-head h1 {
  font-family: Unbounded, sans-serif;
  font-size: 1.15rem;
  margin: 0 0 0.5rem;
  color: var(--deep);
}
.block-lead,
.page-head p { margin: 0 0 0.75rem; }
.deadline { margin: 1rem 0 0; opacity: 0.75; }
.empty,
.login-hint,
.pad {
  padding: 0 var(--pad) 2rem;
  max-width: 40rem;
}

.masonry {
  padding: 0.5rem var(--pad) 3rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.tile { color: inherit; text-decoration: none; }
.tile img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: #d7ebf5;
}
.tile-meta { display: block; margin-top: 0.35rem; font-size: 0.82rem; opacity: 0.8; }

.work { padding: 0.6rem var(--pad) 2.5rem; }
.work-img {
  width: 100%;
  max-height: min(64vh, 640px);
  object-fit: contain;
  background: #eaf5fb;
}
.work-copy { max-width: 38rem; padding-top: 0.85rem; }
.work-author { font-family: Unbounded, sans-serif; color: var(--deep); }
.work-caption { white-space: pre-wrap; }
.work .vote-form { margin-top: 0.85rem; }

.submit-form,
.admin-list {
  padding: 0 var(--pad) 3rem;
  max-width: 38rem;
}
.submit-form label,
.submit-form p { display: block; margin: 0 0 0.9rem; }
.submit-form input[type="file"],
.submit-form textarea,
.submit-form input[type="password"],
.submit-form input[type="text"] {
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.5rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  font: inherit;
}
.check { display: flex; gap: 0.5rem; align-items: flex-start; }
.consent-copy {
  margin: 0 0 0.9rem;
  font-size: 0.92rem;
  opacity: 0.88;
}

.flash {
  margin: 0;
  padding: 0.65rem var(--pad);
  background: var(--alert);
  color: #fff;
}
.flash-ok { background: var(--ok); }

.admin-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.85rem;
  margin: 0 0 1.2rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--line);
}
.admin-row img { width: 120px; height: 120px; object-fit: cover; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.admin-actions button {
  font: inherit;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 0.3rem 0.55rem;
  cursor: pointer;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(22, 50, 74, 0.42);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.sheet[hidden] { display: none; }
.sheet-card {
  position: relative;
  background: var(--paper);
  padding-bottom: calc(0.9rem + var(--tg-safe-area-inset-bottom, 0px));
}
.sheet-img {
  width: 100%;
  max-height: 48vh;
  object-fit: contain;
  background: #eaf5fb;
}
.sheet-who,
.sheet-cap,
.sheet .work-votes {
  margin: 0;
  padding: 0.45rem var(--pad) 0;
}
.sheet-who {
  font-family: Unbounded, sans-serif;
  color: var(--deep);
  padding-top: 0.85rem;
}
.sheet-cap {
  white-space: pre-wrap;
  font-size: 0.92rem;
}
.sheet .vote-go { margin: 0.75rem var(--pad) 0; }
.sheet-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 900px) {
  .ladder { grid-template-columns: repeat(2, 1fr); }
  .piece.is-lead { grid-column: span 2; }
  .piece.is-high,
  .piece.is-mid,
  .piece.is-rest { grid-column: span 1; }
  .piece.is-lead .piece-foot { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .hero { min-height: 100dvh; padding-bottom: 1.5rem; }
  .admin-row { grid-template-columns: 1fr; }
  .masonry { grid-template-columns: 1fr 1fr; gap: 8px; }
  .nav { align-items: flex-start; }
  .nav-btn { font-size: 0.76rem; padding: 0.48rem 0.72rem; }
}
