:root {
  --bg: #fff8f1;
  --bg-soft: #ffe9d6;
  --surface: #ffffff;
  --ink: #2a1f3a;
  --ink-soft: #6b5d80;
  --accent: #ff6b8b;
  --accent-strong: #e0467a;
  --accent-soft: #ffd3df;
  --warm: #ffb547;
  --shadow: 0 8px 24px rgba(80, 30, 60, 0.08);
  --shadow-lg: 0 16px 40px rgba(80, 30, 60, 0.12);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at top left, var(--accent-soft), transparent 55%),
    radial-gradient(ellipse at bottom right, #ffe5b8, transparent 60%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button {
  -webkit-tap-highlight-color: transparent;
}

/* ───── Inline / back links ───── */
.ghost-link {
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
.ghost-link:hover {
  text-decoration: underline;
}

.inline-link {
  display: inline-block;
  margin-top: 14px;
}

.back-link {
  display: inline-block;
  margin-bottom: 12px;
}

.change-choice {
  display: inline-block;
  margin-top: 18px;
  font-size: 0.9rem;
  opacity: 0.85;
}

/* ───── Main + screens ───── */
#app {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px;
  width: 100%;
}

.screen {
  display: none;
  animation: fadeIn 0.35s ease;
}
.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ───── Hero / landing ───── */
.hero {
  max-width: 640px;
  margin: 40px auto;
  text-align: center;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin: 0 0 6px;
  font-weight: 600;
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.1;
  margin: 4px 0 18px;
}

.lede {
  font-size: 1.1rem;
  color: var(--ink-soft);
  margin: 0 0 28px;
}

.small-print {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 16px;
}

/* ───── Buttons ───── */
.cta-primary,
.cta-ghost {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  font-weight: 600;
  font-size: 1rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  display: inline-block;
  text-decoration: none;
}

.cta-primary {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow);
}
.cta-primary:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.cta-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 2px solid rgba(0, 0, 0, 0.08);
}
.cta-ghost:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.button-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

/* ───── Tournament ───── */
.round-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 720px;
  margin: 0 auto 24px;
}

.pill {
  background: var(--surface);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-strong);
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.progress {
  flex: 1;
  height: 8px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--warm));
  transition: width 0.4s ease;
}

.round-title {
  text-align: center;
  font-size: 1.8rem;
  margin: 0 0 28px;
}

.versus {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  max-width: 960px;
  margin: 0 auto;
}

.image-card {
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, outline-color 0.2s ease;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 10px;
  outline: 3px solid transparent;
  outline-offset: 4px;
}
.image-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.image-card:active {
  transform: translateY(0);
}

.image-card.is-preselected {
  transform: translateY(-6px) scale(1.06);
  box-shadow: 0 24px 50px rgba(224, 70, 122, 0.28);
  outline-color: var(--accent);
}
.image-card.is-preselected .image-caption {
  color: var(--accent-strong);
  font-weight: 700;
}

.image-card.is-dimmed {
  opacity: 0.55;
  transform: scale(0.97);
}
.image-card.is-dimmed:hover {
  opacity: 0.8;
  transform: scale(0.97) translateY(-2px);
}

.image-card.is-winning {
  animation: winnerPulse 0.42s cubic-bezier(0.34, 1.4, 0.64, 1);
  pointer-events: none;
}
.image-card.is-losing {
  animation: loserExit 0.42s ease-in forwards;
  pointer-events: none;
}
.image-card.is-entering {
  animation: challengerEnter 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

@keyframes winnerPulse {
  0%   { transform: translateY(-6px) scale(1.06); outline-color: var(--accent); }
  45%  {
    transform: translateY(-12px) scale(1.12);
    box-shadow: 0 32px 60px rgba(224, 70, 122, 0.45);
    outline-color: var(--accent-strong);
  }
  100% { transform: translateY(0) scale(1); outline-color: transparent; }
}

@keyframes loserExit {
  0%   { opacity: 0.55; transform: scale(0.97); }
  60%  { opacity: 0.25; transform: scale(0.84) rotate(-3deg); }
  100% { opacity: 0;    transform: scale(0.7)  rotate(-4deg); }
}

@keyframes challengerEnter {
  0%   { opacity: 0; transform: scale(0.82); }
  60%  { opacity: 1; transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}

.image-tile {
  aspect-ratio: 4 / 5;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.4rem;
  color: white;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  background-size: cover;
  background-position: center;
}

.image-caption {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.vs {
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--accent-strong);
  background: var(--surface);
  border-radius: 50%;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

/* ───── Mobile tuning ───── */
@media (max-width: 720px) {
  #app {
    padding: 14px 16px 24px;
  }

  .hero {
    margin: 16px auto 32px;
  }

  .round-meta {
    margin-bottom: 14px;
  }
  .round-title {
    display: none;
  }

  .versus {
    grid-template-columns: 1fr;
    gap: 10px;
    max-width: 480px;
  }
  .image-tile {
    aspect-ratio: auto;
    height: calc(50vh - 115px);
    height: calc(50dvh - 115px);
    min-height: 130px;
    max-height: 320px;
  }
  .image-card {
    padding: 6px;
    gap: 4px;
    border-radius: 14px;
  }
  .image-caption {
    font-size: 0.8rem;
  }
  .vs {
    width: 40px;
    height: 40px;
    font-size: 0.95rem;
    justify-self: center;
    margin: 0;
  }

  .image-card.is-preselected {
    transform: translateY(-3px) scale(1.02);
    outline-offset: 2px;
    outline-width: 2px;
  }

  .champion-tile {
    max-width: 260px;
  }

  .message-form {
    padding: 22px 18px;
    gap: 16px;
  }
  .form-title {
    font-size: 1.6rem;
    margin: 8px 0 22px;
  }

  .rankings-header {
    margin-bottom: 20px;
  }
  .rank-row {
    grid-template-columns: 36px 56px 1fr auto;
    gap: 12px;
    padding: 10px 12px;
  }
  .rank-number {
    font-size: 1.25rem;
  }
  .rank-thumb {
    width: 56px;
  }
  .rank-rate {
    font-size: 1.15rem;
  }
  .rank-meta {
    font-size: 0.85rem;
  }
}

@media (max-width: 380px) {
  .image-caption {
    display: none;
  }
}

/* ───── Champion ───── */
.champion-wrap {
  max-width: 520px;
  margin: 30px auto;
  text-align: center;
}

.champion-tile {
  aspect-ratio: 4 / 5;
  max-width: 320px;
  margin: 24px auto;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.8rem;
  color: white;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  box-shadow: var(--shadow-lg);
  background-size: cover;
  background-position: center;
  position: relative;
}
.champion-tile::after {
  content: "👑";
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.5rem;
}

/* ───── Form ───── */
.form-title {
  text-align: center;
  margin: 20px 0 30px;
  font-size: 2rem;
}

.message-form {
  max-width: 540px;
  margin: 0 auto;
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.field-hint {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.field input[type="text"],
.field textarea {
  font: inherit;
  border: 1.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  padding: 12px;
  transition: border-color 0.15s ease;
  background: var(--bg);
}
.field input[type="text"]:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.field textarea {
  resize: vertical;
  font-family: inherit;
}

.field input[type="file"] {
  font-size: 0.95rem;
}

/* ───── Thanks ───── */
.thanks-wrap {
  text-align: center;
  max-width: 520px;
  margin: 60px auto;
}

.confetti {
  font-size: 4rem;
  margin-bottom: 12px;
}

/* ───── Rankings ───── */
.rankings-screen {
  max-width: 760px;
  margin: 0 auto;
}

.rankings-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.rankings-header h1 {
  margin: 4px 0 12px;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
}

.ranking-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rank-row {
  display: grid;
  grid-template-columns: 48px 72px 1fr auto;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  padding: 14px 18px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.rank-row.is-top {
  background: linear-gradient(135deg, #fff3da, #ffe1c2);
  box-shadow: var(--shadow-lg);
}

.rank-number {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-strong);
  text-align: center;
}

.rank-thumb {
  width: 72px;
  aspect-ratio: 4 / 5;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 0.85rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.rank-meta {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.rank-rate {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--ink);
}

.rank-rate-label {
  display: block;
  font-size: 0.7rem;
  color: var(--ink-soft);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: right;
}

