:root {
  --bg: #faf8f5;
  --fg: #1c1a17;
  --muted: #69645d;
  --card-bg: #fff;
  --line: rgba(0, 0, 0, 0.08);
  --check: #27b95f;
  --cross: #e5273a;
  --accent: #ffb84d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --fg: #f2efe9;
    --muted: #8a857d;
    --card-bg: #1f1d1a;
    --line: rgba(255, 255, 255, 0.1);
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.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;
}

html,
body {
  height: 100%;
}

body {
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* --- title bar: just the name, nothing else --- */
.bar {
  display: flex;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
}
.title {
  color: var(--fg);
  text-decoration: none;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
}

/* --- the core loop: two pets, tap the cuter one --- */
.arena {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.8vw, 24px);
  padding: 8px clamp(8px, 2vw, 24px) calc(env(safe-area-inset-bottom) + 84px);
  flex-direction: column;
  overflow: hidden;
}

.card {
  position: relative;
  border: none;
  padding: 0;
  background: var(--card-bg);
  border-radius: 22px;
  overflow: hidden;
  cursor: pointer;
  width: min(calc(100vw - 32px), calc((100dvh - 180px) / 2), 520px);
  aspect-ratio: 1;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.1);
  transition: transform 0.12s ease;
  touch-action: manipulation;
}
@media (min-aspect-ratio: 1/1) {
  .arena {
    flex-direction: row;
  }
  .card {
    width: min(calc((100vw - 64px) / 2), 60dvh, 520px);
  }
}
@media (hover: hover) {
  .card:hover:not(:disabled) {
    transform: scale(1.015);
  }
}
.card:active:not(:disabled) {
  transform: scale(0.985);
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.vs {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: lowercase;
}

/* --- vote feedback: fast check on the winner, cruel X on the loser --- */
.card.lost img {
  filter: grayscale(0.9) brightness(0.72);
  transition: filter 0.18s ease;
}
.card.lost {
  animation: shake 0.32s ease;
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0) rotate(0);
  }
  25% {
    transform: translateX(-6px) rotate(-1deg);
  }
  55% {
    transform: translateX(5px) rotate(1deg);
  }
  80% {
    transform: translateX(-3px) rotate(0);
  }
}

.mark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.mark.check {
  background: rgba(39, 185, 95, 0.16);
}
.mark.cross {
  background: rgba(229, 39, 58, 0.2);
}

.mark-svg {
  width: 56%;
  height: 56%;
}
.mark-svg path {
  fill: none;
  stroke-width: 15;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
}
.mark.check path {
  stroke: var(--check);
  animation: draw 0.26s cubic-bezier(0.3, 0.9, 0.4, 1) forwards;
}
.mark.cross path {
  stroke: var(--cross);
  animation: draw 0.18s ease-out forwards;
}
.mark.cross path:nth-child(2) {
  animation-delay: 0.1s;
}
.mark.check .mark-svg {
  animation: stamp 0.26s ease-out;
}
.mark.cross .mark-svg {
  animation: stamp 0.2s ease-out;
}
@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}
@keyframes stamp {
  from {
    transform: scale(1.5);
    opacity: 0.4;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .card.lost img {
    transition: none;
  }
  .card.lost {
    animation: none;
  }
  .mark-svg,
  .mark path {
    animation: none !important;
  }
  .mark-svg path {
    stroke-dashoffset: 0;
  }
}

.empty {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--muted);
}
.empty a {
  color: var(--fg);
  font-weight: 700;
}

/* --- bottom nav: two small buttons --- */
.tabs {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
}
.tabs a {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  text-decoration: none;
  font-size: 18px;
  color: var(--fg);
}
.tabs a:focus-visible,
.card:focus-visible,
.button:focus-visible,
.text-button:focus-visible,
.drop:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.text-button {
  border: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.codec-notice {
  max-width: 38rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: center;
}
.codec-notice a,
.legal a {
  color: var(--fg);
  text-decoration: underline;
}
.legal {
  align-items: flex-start;
  line-height: 1.55;
  padding-bottom: calc(env(safe-area-inset-bottom) + 32px);
}
.legal h1 {
  font-size: 1.45rem;
}
.legal ul {
  padding-left: 1.4rem;
}
.legal code {
  overflow-wrap: anywhere;
}

/* --- leaderboard: one long quiet scroll of cute pets --- */
.feed {
  width: min(94vw, 520px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: calc(env(safe-area-inset-bottom) + 84px);
}
.item {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
}
.item img {
  width: 100%;
  display: block;
}
.chip {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}
.load-error {
  padding: 24px;
  text-align: center;
}
.image-retry {
  width: 100%;
  min-height: 160px;
}

/* --- upload --- */
.panel {
  flex: 1;
  width: min(94vw, 440px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 12px 0 calc(env(safe-area-inset-bottom) + 96px);
}
.drop {
  width: 100%;
  aspect-ratio: 1;
  border: 2px dashed var(--line);
  border-radius: 22px;
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
  background: var(--card-bg);
  color: var(--muted);
  position: relative;
}
.drop-hint,
#drop-hint {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: clamp(18px, 8vw, 48px);
  line-height: 1.5;
  overflow-wrap: anywhere;
  text-align: center;
}
#drop-hint[hidden] {
  display: none;
}
.drop.dragover {
  border-color: var(--accent);
}
.drop[aria-disabled="true"] {
  opacity: 0.6;
  cursor: progress;
}
.drop img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.drop.upload-failed img {
  filter: grayscale(0.35) brightness(0.42);
}
.drop.upload-succeeded img {
  filter: brightness(0.58);
}
.upload-failure {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 5vw, 28px);
  padding: clamp(20px, 8vw, 48px);
  background: rgba(25, 3, 6, 0.72);
  color: #fff;
  pointer-events: none;
  text-align: center;
}
.upload-failure[hidden] {
  display: none;
}
.upload-failure-x {
  color: #ff4054;
  font-size: clamp(7rem, 42vw, 12rem);
  font-weight: 900;
  line-height: 0.55;
  text-shadow:
    0 2px 0 #fff,
    0 0 18px rgba(0, 0, 0, 0.85);
}
.upload-failure-copy {
  max-width: 19rem;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.78);
  font-size: clamp(1rem, 4.5vw, 1.25rem);
  font-weight: 800;
  line-height: 1.3;
}
.upload-success {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 5vw, 28px);
  padding: clamp(20px, 8vw, 48px);
  background: rgba(2, 35, 15, 0.62);
  color: #fff;
  pointer-events: none;
  text-align: center;
}
.upload-success[hidden] {
  display: none;
}
.upload-success-check {
  color: #35e477;
  font-size: clamp(7rem, 42vw, 12rem);
  font-weight: 900;
  line-height: 0.55;
  text-shadow:
    0 2px 0 #fff,
    0 0 18px rgba(0, 0, 0, 0.85);
}
.upload-success-copy {
  max-width: 19rem;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.78);
  font-size: clamp(1rem, 4.5vw, 1.25rem);
  font-weight: 800;
  line-height: 1.3;
}
.button {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 14px;
  background: var(--fg);
  color: var(--bg);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.button:disabled {
  opacity: 0.4;
  cursor: default;
}
.status {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  min-height: 1.4em;
}
.status a {
  color: var(--fg);
}
