/* The duels: the tally and the selection above, the two cards and their
   VS, each item over its actions, the bar of undo, tie and skip below, and
   what shows once no duel is left. The duel a cell opens shares the cards. */

body.duels-active {
  overflow: hidden;
}
/* The height a poster may take beside another, in the duels and in a
   duel's sheet. */
:root {
  --art-h: max(120px, calc(100dvh - var(--header-h) - 290px));
}
.duels {
  height: calc(100dvh - var(--header-h) - env(safe-area-inset-bottom));
  /* Two posters of 2:3 at that height, with their cards, the gap and the
     margins around. */
  max-width: min(760px, calc(var(--art-h) * 4 / 3 + 82px));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 10px 14px 8px;
  gap: 8px;
}
.duels-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.duels-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.arena {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.duel-card {
  --tilt: 0deg;
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 8px 12px;
  border-radius: 24px;
  background: var(--card);
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.28s var(--ease-out),
    opacity 0.28s ease,
    box-shadow 0.28s ease;
  animation: card-in 0.5s var(--spring) both;
}
.duel-card.side-a {
  --tilt: -2.5deg;
}
.duel-card.side-b {
  --tilt: 2.5deg;
  animation-delay: 0.06s;
}
@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.9) rotate(calc(var(--tilt) * 3));
  }
}
/* On the duels, a card is the item, which a tap votes for, over its
   actions, which never vote. Under the pointer it stays still, so that its
   buttons stay where they are aimed at, and only what votes lights up. */
.duels .duel-card {
  padding: 0;
  cursor: default;
}
.card-vote {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 8px 10px;
  border-radius: 24px 24px 0 0;
  cursor: pointer;
  transition: background 0.18s ease;
}
.card-vote:only-child {
  border-radius: 24px;
}
@media (hover: hover) {
  .card-vote:hover,
  .duel-sheet .duel-card:hover {
    background: var(--vote-bg);
  }
}
.card-vote:active,
.duel-sheet .duel-card:active {
  background: var(--vote-bg);
}
.duel-card:has(> .card-vote:active) {
  transform: scale(0.97);
}
.duel-card.won {
  z-index: 2;
  transform: scale(1.06) rotate(var(--tilt));
  box-shadow:
    0 0 0 4px var(--gold),
    0 18px 50px rgb(245 180 54 / 55%);
  animation: none;
}
.duel-card.won::after {
  content: "\2764";
  position: absolute;
  top: -14px;
  right: -10px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--pink);
  color: #fff;
  font-size: 20px;
  box-shadow: 0 6px 16px rgb(255 107 154 / 50%);
  animation: heart-pop 0.4s var(--spring);
}
@keyframes heart-pop {
  from {
    transform: scale(0) rotate(-30deg);
  }
}
.duels .duel-card.tied {
  z-index: 2;
  transform: scale(1.03) rotate(var(--tilt));
  box-shadow:
    0 0 0 4px var(--matrix-tie),
    0 14px 40px rgb(111 96 128 / 40%);
  animation: none;
}
.duel-card.lost {
  opacity: 0;
  transform: translateY(40px) scale(0.85) rotate(calc(var(--tilt) * -2));
  animation: none;
}
.duel-card.skipped {
  opacity: 0;
  transform: translateY(46px) scale(0.92);
  animation: none;
}
.duel-card.gone {
  opacity: 0;
  transform: perspective(600px) rotateY(80deg) scale(0.9);
  animation: none;
}
.card-art {
  position: relative;
  display: flex;
  align-items: center;
  max-height: var(--art-h);
  border-radius: 17px;
  overflow: hidden;
}
.card-text {
  min-width: 0;
  padding: 10px 4px 0;
}
.card-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 15.5px;
  font-weight: 850;
  line-height: 1.2;
  color: var(--text-strong);
}
.card-meta {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* A site without images: the card is its words. */
.card-text-only {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 190px;
  padding: 24px 12px;
}
/* The VS badge sits between the cards: their words keep clear of it. */
#card-a .card-text-only {
  padding-right: 30px;
}
#card-b .card-text-only {
  padding-left: 30px;
}
.card-text-only .card-title {
  -webkit-line-clamp: 4;
  font-size: clamp(17px, 4.6vw, 22px);
}
.card-text-only .card-meta {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  margin-top: 10px;
  font-size: 13.5px;
  line-height: 1.4;
  white-space: normal;
}
/* Under the item, its actions: its video, which the ranking's badge asks
   for when it is missing, its form, and taking it out of the selection. */
.card-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px;
  border-top: 1.5px solid var(--border);
}
.card-watch,
.card-act {
  flex-shrink: 0;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--card-alt);
  color: var(--purple);
  transition:
    box-shadow 0.15s ease,
    background 0.15s ease;
}
.card-watch {
  flex: 1 1 auto;
  min-width: 0;
  gap: 5px;
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 850;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
}
.card-watch .icon {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  fill: currentColor;
}
.card-missing {
  background: var(--accent-bg);
  color: #8a5a00;
}
.card-act {
  width: 32px;
  color: var(--text-muted);
}
.card-act .icon {
  width: 16px;
  height: 16px;
}
@media (hover: hover) {
  .card-watch:hover,
  .card-act:hover {
    box-shadow: 0 0 0 2px var(--accent);
    color: var(--text-strong);
  }
}
.card-watch:active,
.card-act:active {
  background: var(--vote-bg);
}
@media (max-width: 400px) {
  .card-actions {
    gap: 4px;
    padding: 6px;
  }
  .card-watch {
    padding: 4px 8px;
    font-size: 11.5px;
  }
  .card-act {
    width: 30px;
    min-height: 30px;
  }
}
.vs {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 3;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe28f, var(--gold) 58%, #e39a10);
  color: var(--purple-deep);
  font-weight: 900;
  font-size: 19px;
  letter-spacing: -0.03em;
  transform: translate(-50%, -50%) rotate(-10deg);
  box-shadow:
    0 0 0 5px var(--bg),
    0 8px 22px rgb(245 180 54 / 55%);
  pointer-events: none;
  animation: vs-pop 0.55s var(--spring) 0.12s both;
}
@keyframes vs-pop {
  from {
    transform: translate(-50%, -50%) scale(0) rotate(-120deg);
  }
}
.tie-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 50px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 800;
  box-shadow: var(--shadow-s);
}
@media (hover: hover) {
  .tie-btn:hover {
    color: var(--text-strong);
    border-color: var(--matrix-tie);
  }
}
.tie-btn:active {
  transform: scale(0.95);
}
.tie-btn.on {
  color: var(--text-strong);
  border-color: var(--matrix-tie);
  background: var(--matrix-tie-bg);
}
.tie-btn .icon {
  width: 17px;
  height: 17px;
}
.arena-loading .ghost {
  min-height: 320px;
  background: linear-gradient(100deg, var(--card) 40%, var(--card-alt) 50%, var(--card) 60%) 0 0 / 200% 100%;
  box-shadow: var(--shadow-s);
  animation: shimmer 1.3s linear infinite;
  cursor: default;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* Undo, tie and skip, one pill of three. */
.duels-bar {
  align-self: center;
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-s);
  overflow: hidden;
}
.duels-bar button {
  height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 18px;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 800;
  transition: background 0.15s ease;
}
.duels-bar button + button {
  border-left: 1.5px solid var(--border);
}
.duels-bar .icon {
  width: 18px;
  height: 18px;
}
@media (hover: hover) {
  .duels-bar button:hover:not(:disabled) {
    background: var(--card-alt);
    color: var(--text-strong);
  }
}
.duels-bar button:active:not(:disabled) {
  background: var(--vote-bg);
}
.duels-bar button:disabled {
  color: var(--border);
}
/* With no duel left, only undo stays. */
.duels-bar.idle .duels-tie,
.duels-bar.idle .duels-skip {
  display: none;
}
/* How far the viewer is, the votes cast written over. */
.tally {
  position: relative;
  flex: 1;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-s);
  overflow: hidden;
}
.tally i {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--purple) 30%, transparent),
    color-mix(in srgb, var(--pink) 32%, transparent),
    color-mix(in srgb, var(--gold) 42%, transparent)
  );
  transition: width 0.6s var(--ease-out);
}
.tally-count {
  position: relative;
  font-size: 13.5px;
  font-weight: 750;
  color: var(--text-muted);
}
.tally-count b {
  font-weight: 900;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.done {
  padding: 20px;
  text-align: center;
  animation: pop-in 0.5s var(--spring);
}
.done-emoji {
  margin-bottom: 14px;
  font-size: 76px;
  line-height: 1;
  animation: wiggle 2.6s ease-in-out infinite;
}
.done h2 {
  margin-bottom: 8px;
  font-size: 26px;
  font-weight: 900;
  color: var(--text-strong);
  letter-spacing: -0.02em;
}
.done p {
  margin-bottom: 22px;
  font-size: 16px;
  color: var(--text-muted);
}
.done .cta {
  margin-top: 6px;
}

@media (min-width: 720px) {
  .duels {
    padding-top: 16px;
  }
  .arena {
    gap: 22px;
  }
  .card-title {
    font-size: 17px;
  }
}
