:root {
  color-scheme: dark;
  font: 16px system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #eef1ed;
  background: #101316;
  --muted: #a6b0ad;
  --line: #343c3e;
  --go: #d0ee9f;
  --gold: #f4d45c;
  --arena-size: 530px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scrollbar-gutter: stable; }
body { margin: 0; }
button, summary { cursor: pointer; }
button { font: inherit; color: inherit; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--go); outline-offset: 3px; }
.tournament { width: min(100% - 32px, 872px); margin: 20px auto 10px; }
.masthead { text-align: center; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.86rem, 4vw, 2.8rem); line-height: 1; letter-spacing: -.055em; font-weight: 850; }
h1 span { color: var(--go); }
.masthead p { margin-top: 7px; color: var(--muted); font-size: .9rem; }

.country { width: min(100%, 290px); position: relative; margin: 16px auto 12px; z-index: 4; }
#country-label { display: block; font-size: .74rem; margin-bottom: 5px; font-weight: 650; }
.optional { color: var(--muted); font-weight: 400; }
#country-toggle {
  display: grid; grid-template-columns: 21px 1fr 10px; align-items: center; gap: 9px;
  width: 100%; height: 44px; padding: 0 12px; text-align: left;
  border: 1px solid #465052; background: #191f21; border-radius: 9px;
  font-size: .87rem; font-weight: 650;
}
#country-toggle:hover:not(:disabled), #country-toggle[aria-expanded=true] { border-color: var(--go); }
#country-toggle:disabled { color: var(--muted); }
.country-flag { width: 21px; height: 16px; border-radius: 2px; background: #30393b; }
.country-flag img, .side-name img, .country-option img { display: block; width: 100%; height: 100%; border-radius: 2px; object-fit: cover; }
.chevron { width: 7px; height: 7px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
#country-toggle[aria-expanded=true] .chevron { transform: rotate(225deg); }
#country-toggle:disabled .chevron { visibility: hidden; }
#country-options {
  position: absolute; inset: calc(100% + 6px) 0 auto; max-height: min(320px, var(--country-room, 320px)); overflow: auto;
  margin: 0; padding: 5px; list-style: none; overscroll-behavior: contain;
  border: 1px solid #53605e; border-radius: 10px; background: #192122; box-shadow: 0 10px 24px #0008;
}
.country-option {
  display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: center; width: 100%; text-align: left;
  min-height: 42px; border: 0; border-radius: 5px; padding: 0 9px; background: transparent; font-size: .87rem;
}
.country-option img { height: 18px; }
.country-option:hover, .country-option:focus-visible, .country-option[aria-selected=true] { background: #304039; }
.country-option:focus-visible { outline-offset: -2px; }
#country-dismiss { position: fixed; inset: 0; z-index: 3; }

.progress {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; list-style: none;
  width: min(100%, 330px); margin: 0 auto; padding: 0; height: 30px;
}
.progress li {
  position: relative; height: 100%; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); font-size: .79rem; font-weight: 800; font-variant-numeric: tabular-nums;
}
.progress li[data-state=current] { background: var(--go); color: #192315; border-color: var(--go); }
.progress li[data-state=complete] { color: var(--go); border-color: #708868; }
.progress li[data-state=complete] span::after { content: "✓"; position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); font-size: .68rem; }
.round-heading { text-align: center; margin: 10px auto 8px; height: 43px; }
#round-number { color: var(--muted); font-size: .68rem; line-height: 15px; letter-spacing: .12em; text-transform: uppercase; }
#stage { font-size: clamp(1.11rem, 2.4vw, 1.46rem); line-height: 28px; letter-spacing: -.025em; }

.play-layout {
  display: grid; grid-template-columns: 145px minmax(0, var(--arena-size)) 145px;
  gap: 10px 14px; justify-content: center; align-items: center;
  grid-template-areas: "favorite arena qualification" ". slots .";
}
.arena-frame {
  position: relative; isolation: isolate; overflow: hidden;
  width: 100%; aspect-ratio: 1; grid-area: arena;
  border: 1px solid #303a35; border-radius: 17px; background: #171e1c;
}
.arena-frame:focus { outline: none; }
canvas { display: block; width: 100%; height: 100%; }
.phase, .arena-caption {
  position: absolute; left: 7px; right: 7px; text-align: center; pointer-events: none;
  color: #d3ded7; font-size: .73rem; font-weight: 650; line-height: 16px;
}
.phase { top: 8px; }
.arena-caption { bottom: 7px; color: var(--muted); }
#go {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  min-width: 92px; min-height: 64px; touch-action: manipulation;
  border: 2px solid #e6ffc7; border-radius: 12px; box-shadow: 0 0 0 3px #101316d9;
  background: var(--go); color: #182216; font-size: 1.55rem; font-weight: 900;
}
#go:disabled { background: #293d32; color: #dce8df; border-color: #87988d; }

.side { border-top: 1px solid var(--line); padding: 11px 0 0; min-width: 0; height: 91px; }
.favorite-panel { grid-area: favorite; }
.qualification-panel { grid-area: qualification; text-align: right; }
.side h3 { font-size: .73rem; font-weight: 650; color: var(--muted); }
.side-name { display: flex; align-items: center; gap: 7px; height: 29px; font-size: .94rem; line-height: 1; }
.side-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-name > span:has(img) { flex: 0 0 19px; height: 14px; }
.qualification-panel .side-name { justify-content: flex-end; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
#qualified-count { display: grid; grid-template-columns: 2ch 1ch 2ch; column-gap: .12em; text-align: center; }
.side > p:last-child { color: var(--muted); font-size: .74rem; line-height: 1.25; }
#favorite-status[data-active=true] { color: var(--gold); }
.qualification-slots { grid-area: slots; }
#slots {
  display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 4px; min-height: 28px;
  margin: 0; padding: 0; list-style: none;
}
#slots li {
  height: 28px; display: grid; place-items: center; border: 1px dashed #475650;
  border-radius: 4px; background: #181e1e; overflow: hidden;
}
#slots li[data-unused=true] { visibility: hidden; }
#slots li[data-filled=true] { border-style: solid; border-color: #6b8371; animation: slot-in .22s ease-out; }
#slots li[data-last=true] { border-color: var(--go); animation: slot-in .35s ease-out; }
#slots li[data-favorite=true] { outline: 2px solid var(--gold); outline-offset: -2px; }
#slots img { display: block; width: 100%; height: 100%; object-fit: cover; }
@keyframes slot-in { from { opacity: .48; } to { opacity: 1; } }

.champion {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 9px;
  padding: 16px; text-align: center; background: #1b2b23;
}
.champion-flag img { display: block; width: clamp(65px, 16vw, 112px); aspect-ratio: 4 / 3; border-radius: 8px; }
.arena-frame:has(.champion:not([hidden])) > :is(canvas, .phase, .arena-caption) { visibility: hidden; }
.champion-flag { animation: champion-in .5s ease-out; margin-bottom: 5px; box-shadow: 0 0 0 2px #d0ee9f77, 0 0 32px #d0ee9f38; border-radius: 8px; }
.champion-label { color: var(--go); font-size: .73rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.champion h2 { font-size: clamp(1.55rem, 5vw, 3rem); line-height: 1.02; letter-spacing: -.05em; }
.champion p { color: #ced9d0; font-size: clamp(.74rem, 2vw, .89rem); }
.champion-actions { display: flex; justify-content: center; gap: 8px; margin-top: 4px; }
.champion-actions button { padding: 0 19px; min-height: 44px; border: 0; border-radius: 8px; background: var(--go); color: #192315; font-weight: 800; }
@keyframes champion-in { from { opacity: .72; } to { opacity: 1; } }

.actions {
  position: relative; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  max-width: var(--arena-size); margin: 6px auto 0; height: 44px;
}
.actions button {
  min-height: 44px; padding: 0 8px; border: 0; background: transparent;
  font-size: .82rem; color: var(--muted);
}
.actions button:hover { color: #eef1ed; }
.actions #restart {
  display: inline-flex; align-items: center; gap: 8px; padding: 0 12px;
  border: 1px solid #53605e; border-radius: 8px; background: #192122;
  color: #eef1ed; font-weight: 650;
}
.actions #restart:hover { border-color: #9baa9d; background: #222c2c; }
#help-dialog {
  width: min(320px, 100% - 24px); padding: 17px;
  border: 1px solid #53605e; border-radius: 10px; background: #192122; color: #eef1ed;
  cursor: pointer;
}
#help-dialog::backdrop { background: #1013168c; }
#help-dialog h2 { font-size: 1rem; }
#help-dialog p { margin-top: 8px; color: #d7dfdc; font-size: .84rem; line-height: 1.45; }
#help-dialog .help-dismiss { color: var(--muted); font-size: .75rem; }

@media (max-width: 845px) {
  .tournament { width: min(100% - 24px, var(--arena-size)); margin-top: 14px; }
  .play-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px;
    grid-template-areas: "arena arena" "favorite qualification" "slots slots"; }
  .side { height: 62px; padding-top: 6px; }
}
@media (max-width: 530px) {
  .country { margin: 10px auto 8px; }
  .masthead p { margin-top: 5px; font-size: .79rem; }
  .progress { height: 27px; }
  .round-heading { margin: 5px auto; height: 36px; }
  #stage { line-height: 21px; }
  .arena-frame { border-radius: 12px; }
  .phase { top: 3px; }
  .arena-caption { bottom: 3px; }
  #slots { grid-template-columns: repeat(8, minmax(0, 1fr)); min-height: 54px; }
  #slots li { height: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  #slots li[data-filled=true], .champion-flag { animation: none; }
}

.champion-actions { position: relative; }
.champion-actions #share-result { background: transparent; color: var(--go); border: 1px solid #75946a; }
.share-status { position: absolute; top: calc(100% + 4px); inset-inline: 0; color: var(--go); font-size: .73rem; }
.privacy-settings { max-width: var(--arena-size); margin: 0 auto; color: var(--muted); font-size: .78rem; }
.privacy-settings > summary { width: fit-content; min-height: 36px; line-height: 36px; padding-inline: 4px; }
.privacy-content { padding: 8px 4px 12px; }
.privacy-content p { margin-bottom: 8px; line-height: 1.5; }
.privacy-decisions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.privacy-decisions button, #share-dialog button {
  min-height: 44px; padding: 3px 8px; border: 1px solid #53605e; border-radius: 6px; background: #192122;
}
.privacy-decisions button:disabled { opacity: .55; }
#share-dialog { width: min(440px, 100% - 24px); padding: 18px; border: 1px solid #53605e; border-radius: 10px; background: #192122; color: #eef1ed; }
#share-dialog::backdrop { background: #101316b8; }
#share-dialog p { margin: 6px 0 12px; color: var(--muted); }
#share-dialog textarea { display: block; width: 100%; padding: 8px; border: 1px solid #53605e; background: #101316; color: inherit; font: inherit; }
#share-dialog form { display: flex; justify-content: flex-end; margin-top: 10px; }
@media (max-width: 360px) {
  .champion-actions button { padding-inline: 11px; }
}


.author-wordmark {
  display: inline-block; margin-inline-start: .55em; padding-inline-start: .55em;
  border-inline-start: 1px solid var(--line); font-size: .88em; font-weight: 650;
}
.privacy-content a { color: var(--go); }
