:root {
  --bg: #0e0f13;
  --surface: #181a21;
  --surface-2: #22252f;
  --line: #2f3340;
  --text: #f3f1ea;
  --muted: #9a9caa;
  --blue: #2850d8;
  --red: #e63946;
  --gold: #f4c542;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 Inter, system-ui, sans-serif;
}

.tricolore {
  height: 6px;
  background: linear-gradient(90deg, var(--blue) 33.3%, #fff 33.3% 66.6%, var(--red) 66.6%);
}

a { color: var(--gold); }

/* Hero */
.hero {
  text-align: center;
  padding: 48px 16px 24px;
  background: radial-gradient(ellipse at top, rgba(230, 57, 70, 0.18), transparent 60%);
}
.kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  color: var(--gold);
  font-weight: 600;
}
h1 {
  font-family: Anton, Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(48px, 11vw, 112px);
  line-height: 1;
  margin: 8px 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
h1 span { color: var(--red); }
.tagline { margin: 0 auto; max-width: 680px; color: var(--muted); }

/* Tabs: underlined, sticky under the header */
.tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tabs button {
  font: 600 15px Inter, sans-serif;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  padding: 14px 18px 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }

h2 {
  font-family: Anton, Impact, sans-serif;
  font-weight: 400;
  text-transform: uppercase;
  font-size: 32px;
  margin: 8px 0 4px;
  letter-spacing: 0.01em;
}
.hint { color: var(--muted); margin: 0 0 24px; max-width: 640px; }
.hint strong { color: var(--text); }

/* Avatar */
.avatar {
  --c: #444;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: Anton, Impact, sans-serif;
  font-size: 36px;
  color: #fff;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--c) 60%, #fff), var(--c) 70%);
  border: 3px solid rgba(255, 255, 255, 0.85);
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center 25%; }
.avatar.sm { width: 44px; height: 44px; font-size: 17px; border-width: 2px; }

/* Arena */
/* Each fighter is a head (clickable) and a badges block, styled as one card.
   Separate grid cells so mobile can put the tape between them. */
.arena {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "a tape b" "pa tape pb";
  grid-template-rows: auto 1fr;
  column-gap: 16px;
}
#corner-a { grid-area: a; }
#corner-b { grid-area: b; }
#perks-a { grid-area: pa; }
#perks-b { grid-area: pb; }
.corner, .corner-perks { transition: opacity 0.3s, transform 0.3s; }
/* Fade the content only: fading a whole cell would also fade its background and split the card in two. */
.corner-perks.loser .perks, .corner.loser .avatar, .corner.loser .fighter-info { opacity: 0.25; }
.perks, .fighter-info { transition: opacity 0.3s; }
.corner-perks {
  background: var(--surface);
  border: 2px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 0 12px 16px;
}
.corner-perks:empty { padding-bottom: 8px; }
.corner-perks .perks { margin-top: 0; }
.vs {
  text-align: center;
  font-family: Anton, Impact, sans-serif;
  font-size: 44px;
  color: var(--red);
  text-shadow: 0 0 24px rgba(230, 57, 70, 0.6);
}
.fighter {
  width: 100%;
  height: 100%;
  background: var(--surface);
  border: 2px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: transform 0.15s, border-color 0.15s, opacity 0.3s;
}
.fighter:hover, .fighter:focus-visible { outline: none; }
.fighter:hover .avatar, .fighter:focus-visible .avatar { transform: scale(1.06); border-color: var(--gold); }
.fighter:hover .name, .fighter:focus-visible .name { color: var(--gold); }
.avatar { transition: transform 0.15s, border-color 0.15s, opacity 0.3s; }
.fighter .avatar { width: 120px; height: 120px; font-size: 44px; margin-bottom: 8px; }
.fighter .name {
  font-family: Anton, Impact, sans-serif;
  font-size: 26px;
  line-height: 1.1;
  text-transform: uppercase;
}
.fighter .party { color: var(--muted); font-size: 14px; }
.fighter .fighter-info { width: 100%; }

/* Tale of the tape */
.tape { grid-area: tape; align-self: center; width: 250px; }
.tape table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.tape th, .tape td { padding: 9px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tape th {
  font: 600 10px Inter, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-align: center;
}
.tape td { font-family: Anton, Impact, sans-serif; font-size: 18px; width: 40%; }
.tape td.a { text-align: right; }
.tape td.b { text-align: left; }
.tape td.edge { color: var(--gold); }
.tape td:has(.rec) { white-space: normal; }
.tape .rec span { white-space: nowrap; }
.tape td a { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; }
.tape .nc { color: var(--muted); font-size: 14px; }
.tape tr.odds td, .tape tr.odds th { border-bottom: 0; padding-top: 14px; }
.tape tr.odds td { font-size: 26px; color: var(--text); }
.tape tr.odds td.edge { color: var(--gold); }
.tape tr.odds th { color: var(--gold); }
.tape tr.odds-votes td { text-align: center; font: 12px Inter, sans-serif; color: var(--muted); border-bottom: 0; padding-top: 0; }
.winner .fighter, .corner-perks.winner { border-color: var(--gold); }

.arena-actions { text-align: center; margin-top: 20px; }
.ghost {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 16px;
  font: 14px Inter, sans-serif;
  cursor: pointer;
}
.ghost:hover { color: var(--text); border-color: var(--muted); }
.counter { text-align: center; color: var(--muted); font-size: 14px; }

/* K.O. stamp, slammed onto the loser's card */
.corner { position: relative; }
.ko {
  position: absolute;
  top: 38%;
  left: 50%;
  translate: -50% -50%;
  font-family: Anton, Impact, sans-serif;
  font-size: clamp(44px, 9vw, 84px);
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--red);
  padding: 6px 18px 2px;
  border: 5px solid var(--red);
  border-radius: 10px;
  background: rgba(14, 15, 19, 0.55);
  text-shadow: 3px 3px 0 var(--gold);
  box-shadow: 0 0 0 3px var(--gold);
  pointer-events: none;
  rotate: -12deg;
  animation: ko-slam 0.35s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
@keyframes ko-slam {
  0% { opacity: 0; scale: 3; }
  60% { opacity: 1; scale: 0.92; }
  100% { opacity: 1; scale: 1; }
}
/* Head and badges are separate cells styled as one card: shake both in sync. */
.corner.loser .fighter, .corner-perks.loser { animation: ko-shake 0.35s ease-out 0.2s; }
@keyframes ko-shake {
  0%, 100% { translate: 0; }
  20% { translate: -6px 2px; }
  40% { translate: 5px -2px; }
  60% { translate: -3px 1px; }
  80% { translate: 2px 0; }
}

/* Estimates */
.estimates { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.est {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.est-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.est-head .name { font-weight: 800; line-height: 1.2; }
.est-head .party { color: var(--muted); font-size: 13px; }
.est-value {
  margin-left: auto;
  font-family: Anton, Impact, sans-serif;
  font-size: 30px;
  color: var(--gold);
  min-width: 3.2ch;
  text-align: right;
}
.slider-wrap { position: relative; }
input[type="range"] {
  width: 100%;
  accent-color: var(--red);
  margin: 0;
  height: 24px;
}
.avg-mark {
  position: absolute;
  top: -6px;
  width: 2px;
  height: 36px;
  background: var(--gold);
  pointer-events: none;
  transform: translateX(-1px);
}
.est-quip { font-size: 13px; color: var(--text); margin: 8px 0 0; min-height: 1.5em; }
.est-meta { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.est-meta b { color: var(--gold); font-weight: 600; }

/* Ranking */
.rank-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; }
.ranking { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.ranking li {
  counter-increment: r;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.ranking li::before {
  content: counter(r);
  font-family: Anton, Impact, sans-serif;
  font-size: 20px;
  width: 2ch;
  color: var(--muted);
  text-align: right;
}
.ranking li:nth-child(1)::before { color: var(--gold); }
.ranking li:nth-child(2)::before { color: #cfd3dc; }
.ranking li:nth-child(3)::before { color: #cd7f32; }
.ranking .who { flex: 1; min-width: 0; }
.ranking .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranking .who small { color: var(--muted); }
.ranking .score { font-family: Anton, Impact, sans-serif; font-size: 22px; }
.bar { height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--red); border-radius: 2px; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 16px 40px;
  border-top: 1px solid var(--line);
}

@media (max-width: 680px) {
  /* Compact header: the duel should start in the first half of the screen. */
  .hero { padding: 14px 16px 6px; }
  .kicker { font-size: 10px; letter-spacing: 0.15em; }
  h1 { font-size: clamp(40px, 13vw, 64px); margin: 8px 0 0; }
  .tagline { display: none; }
  .tabs { gap: 0; padding: 0 6px; }
  .tabs button { flex: 1 1 auto; padding: 12px 6px 9px; font-size: 13px; white-space: nowrap; }
  main { padding-top: 14px; }
  h2 { font-size: 24px; margin: 0 0 2px; }
  .hint { font-size: 14px; margin-bottom: 14px; }

  .arena {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "a b" "tape tape" "pa pb";
    grid-template-rows: auto;
    column-gap: 10px;
  }
  .fighter { border-bottom: 2px solid var(--line); border-radius: var(--radius); }
  .winner .fighter { border-color: var(--gold); }
  .tape { width: 100%; margin: 4px 0 16px; }
  .corner-perks { border: 0; background: none; padding: 0; }
  .vs { font-size: 32px; }
  .fighter { padding: 14px 8px; }
  .fighter .avatar { width: 72px; height: 72px; }
  .fighter .name { font-size: 18px; }
  .fighter .party { font-size: 12px; }
  .arena .badge { width: 68px; }
  .arena .badge-icon { width: 44px; height: 44px; font-size: 20px; }
  .rank-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) {
  .tab-icon { display: none; }
}

/* Perks: round icon badges, description underneath */
.perks { margin-top: 14px; width: 100%; }
.badges { display: flex; flex-wrap: wrap; gap: 10px 6px; justify-content: center; }
.badge {
  --ring: #c9c3ff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 84px;
  padding: 0;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.badge.plus { --ring: #7ee2a0; }
.badge.minus { --ring: #ff8a8a; }
.badge-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 24px;
  line-height: 1;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--ring) 22%, var(--surface-2)), var(--surface-2) 70%);
  border: 2px solid var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 12%, transparent);
  transition: transform 0.15s, box-shadow 0.15s;
}
.badge-label {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  color: var(--ring);
}
.badge:hover .badge-icon, .badge:focus-visible .badge-icon, .badge.active .badge-icon {
  transform: scale(1.1);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--ring) 28%, transparent);
}
.badge:focus-visible { outline: none; }
.perk-descs { display: grid; margin-top: 12px; }
.perk-desc {
  grid-area: 1 / 1;
  visibility: hidden;
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}
.perk-desc.shown { visibility: visible; }
.perk-desc b { color: var(--text); }
.est .badges, .est .perk-desc { justify-content: flex-start; text-align: left; }


.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  background: var(--red);
  color: #fff;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
