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

:root {
  --bg: #d8d0aa;
  --paper: #f3edd2;
  --panel: #fff8dc;
  --ink: #182118;
  --muted: #5f604f;
  --line: #182118;
  --green: #236b36;
  --green-2: #4f9f31;
  --red: #b53b2f;
  --blue: #244f7d;
  --gold: #b8872c;
  --bad: #a32f2a;
  --radius: 3px;
  --hard-shadow: 4px 4px 0 #182118;
  --display: "Arial Black", Impact, Haettenschweiler, sans-serif;
  --body: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  background: var(--bg) url("assets/solkicks-stadium.png") center top / cover fixed no-repeat;
  color: var(--ink);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.45;
  image-rendering: pixelated;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(216, 208, 170, .78);
}

button,
input {
  font: inherit;
}

h1,
h2,
h3 {
  font-family: var(--display);
  text-transform: uppercase;
  line-height: .95;
  letter-spacing: 0;
}

h2 {
  font-size: 30px;
  margin-bottom: 8px;
}

.tri-stripe {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: 8px;
  border-bottom: 2px solid var(--line);
}

.tri-stripe span:nth-child(1) { background: var(--red); }
.tri-stripe span:nth-child(2) { background: var(--blue); }
.tri-stripe span:nth-child(3) { background: var(--green); }
.tri-stripe.small {
  width: 240px;
  max-width: 100%;
  height: 6px;
  margin: 0 auto 14px;
  border: 2px solid var(--line);
}

.masthead {
  background: var(--paper);
  border-bottom: 3px solid var(--line);
}

.masthead-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 22px 20px 18px;
  text-align: center;
}

.masthead-meta {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.host-chip {
  display: inline-block;
  color: var(--paper);
  background: var(--blue);
  border: 2px solid var(--line);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.host-chip:nth-child(2) { background: var(--red); }
.host-chip:nth-child(3) { background: var(--green); }

.wordmark {
  font-size: clamp(48px, 10vw, 92px);
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--gold);
}

.masthead-sub {
  margin-top: 8px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

main {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.screen[hidden] { display: none !important; }

.card {
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--hard-shadow);
  padding: 24px;
}

.card-tag {
  display: inline-block;
  margin-bottom: 14px;
  padding: 4px 8px;
  color: var(--paper);
  background: var(--green);
  border: 2px solid var(--line);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.gold-tag { background: var(--gold); color: var(--ink); }
.muted { color: var(--muted); }

.error {
  color: var(--paper);
  background: var(--bad);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin: 12px 0 0;
  font-weight: 800;
}

.fineprint {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 2px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.steps-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 800px;
  margin: 0 auto 18px;
}

.step {
  min-width: 0;
  padding: 8px;
  background: var(--paper);
  border: 2px solid var(--line);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.step b { color: var(--green); }
.step.on { background: #dfe9b9; }
.step.gold b { color: var(--gold); }

.signup-card {
  max-width: 590px;
  margin: 0 auto;
}

form label {
  display: block;
  margin: 18px 0 6px;
  font-weight: 900;
  text-transform: uppercase;
}

.label-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

form input[type="text"] {
  width: 100%;
  padding: 12px 11px;
  color: var(--ink);
  background: #fffef0;
  border: 3px solid var(--line);
  border-radius: var(--radius);
}

form input[type="text"]::placeholder { color: #8a8874; }

form input[type="text"]:focus {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin-top: 20px;
  padding: 12px 20px;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 var(--line);
  cursor: pointer;
  font-family: var(--display);
  font-size: 18px;
  text-transform: uppercase;
}

.btn:hover { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--line); }
.btn:active { transform: translate(3px, 3px); box-shadow: none; }
.btn-primary { background: var(--green-2); color: #fffef0; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: not-allowed; transform: none; }
.btn-arrow { display: none; }

.lobby-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 14px;
  color: var(--green);
  font-weight: 900;
  text-transform: uppercase;
}

.status-line::before {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--green-2);
  border: 2px solid var(--line);
}

.player-list {
  list-style: none;
  padding: 0;
}

.player-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin-bottom: 8px;
  padding: 9px 10px;
  background: var(--paper);
  border: 2px solid var(--line);
  font-weight: 800;
}

.player-list li.empty {
  color: var(--muted);
  background: transparent;
  border-style: dashed;
}

.player-list .flag,
.tie-row .flag,
.sb-team .flag {
  font-size: 24px;
  line-height: 1;
}

.player-list .you-tag {
  margin-left: auto;
  padding: 2px 6px;
  color: #fffef0;
  background: var(--blue);
  border: 2px solid var(--line);
  font-size: 11px;
  font-weight: 900;
}

.prize-note {
  margin-top: 16px;
  padding: 12px;
  background: #ead28b;
  border: 2px solid var(--line);
}

.prize-note strong { color: var(--ink); }

#country-groups {
  max-height: 520px;
  overflow-y: auto;
  padding-right: 6px;
}

.group-block { margin-bottom: 14px; }

.group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.group-label::after {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--line);
}

.country-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.country-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 7px 9px;
  color: var(--ink);
  background: #fffef0;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.country-btn:hover:not([disabled]) { background: #dfe9b9; }
.country-btn.selected { background: var(--blue); color: #fffef0; }
.country-btn.taken {
  color: #77725d;
  background: #cfc6a2;
  cursor: not-allowed;
  text-decoration: line-through;
}

.bracket {
  display: flex;
  gap: 18px;
  margin: 20px 0;
}

.bracket-round {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-around;
  gap: 14px;
  min-width: 0;
}

.bracket-round h3 {
  color: var(--muted);
  font-size: 16px;
  text-align: center;
}

.tie {
  overflow: hidden;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius);
}

.tie-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border-bottom: 2px solid var(--line);
  font-weight: 800;
}

.tie-row:last-child { border-bottom: none; }
.tie-row.winner { background: #dfe9b9; }
.tie-row.loser { color: #77725d; }
.tie-row.tbd { color: var(--muted); font-style: italic; }

.scoreboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
  color: #fffef0;
  background: var(--ink);
  border: 3px solid var(--line);
  border-bottom: 0;
}

.sb-team {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  font-family: var(--display);
  font-size: 18px;
  text-transform: uppercase;
}

.sb-team .sub {
  display: block;
  overflow: hidden;
  max-width: 230px;
  color: #d8d0aa;
  font-family: var(--body);
  font-size: 11px;
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
}

.sb-right {
  flex-direction: row-reverse;
  text-align: right;
}

.sb-mid {
  align-self: stretch;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--gold);
  border-left: 3px solid var(--line);
  border-right: 3px solid var(--line);
  text-align: center;
}

.sb-score {
  font-family: var(--display);
  font-size: 34px;
  line-height: 1;
}

.sb-clock {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 900;
}

.pitch-wrap {
  position: relative;
}

#pitch {
  display: block;
  width: 100%;
  background: #6aa4d8;
  border: 3px solid var(--line);
  border-top: 0;
  image-rendering: pixelated;
}

.game-banner {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 28px;
  color: var(--ink);
  background: var(--gold);
  border: 3px solid var(--line);
  box-shadow: var(--hard-shadow);
  font-family: var(--display);
  font-size: 30px;
  text-transform: uppercase;
}

.controls-hint {
  margin-top: 14px;
  color: var(--muted);
  text-align: center;
}

.hint-sep {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 8px;
  background: var(--line);
}

kbd {
  display: inline-block;
  min-width: 23px;
  padding: 1px 5px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--line);
  text-align: center;
}

.champion-card {
  max-width: 620px;
  margin: 26px auto;
  text-align: center;
}

.trophy {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 12px;
  color: var(--gold);
  background: var(--paper);
  border: 3px solid var(--line);
  box-shadow: 3px 3px 0 var(--line);
  font-size: 48px;
  line-height: 1;
  image-rendering: pixelated;
}

.payout-box {
  margin: 20px 0;
  padding: 14px;
  word-break: break-all;
  background: #ead28b;
  border: 2px solid var(--line);
}

.payout-box a {
  display: inline-block;
  margin-top: 8px;
  color: var(--blue);
  font-weight: 900;
  text-transform: uppercase;
}

.payout-box.failed {
  color: #fffef0;
  background: var(--bad);
}

.footer {
  padding: 22px 20px 28px;
  color: var(--muted);
  background: var(--paper);
  border-top: 3px solid var(--line);
  text-align: center;
  font-size: 12px;
}

.footer code { font-size: 11px; }

@media (max-width: 820px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .scoreboard {
    grid-template-columns: 1fr;
  }
  .sb-mid {
    border: 3px solid var(--line);
    border-left: 0;
    border-right: 0;
  }
  .sb-right {
    flex-direction: row;
    text-align: left;
  }
}

@media (max-width: 720px) {
  main { padding: 22px 12px 48px; }
  .masthead-inner { padding-inline: 12px; }
  .steps-strip { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 18px; }
  .bracket { flex-direction: column; }
  .wordmark { font-size: clamp(42px, 17vw, 72px); }
  .game-banner { font-size: 24px; width: max-content; max-width: 90%; }
}

/* Persistent contract-address badge, pinned bottom-right on every screen. */
/* Hidden until the CA is loaded from the server, so no stale value flashes. */
#ca-bubble:not(.ready) { display: none; }
#ca-bubble {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: calc(100vw - 24px);
  padding: 10px 14px;
  border: 2px solid #1c2a4a;
  border-radius: 18px;
  background: #fff8dc;
  color: #1c2a4a;
  font: 700 12px/1.25 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: 0 4px 0 #1c2a4a, 0 8px 18px rgba(0, 0, 0, 0.28);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
#ca-bubble:hover { transform: translateY(-1px); box-shadow: 0 5px 0 #1c2a4a, 0 10px 20px rgba(0, 0, 0, 0.3); }
#ca-bubble:active { transform: translateY(2px); box-shadow: 0 2px 0 #1c2a4a, 0 5px 12px rgba(0, 0, 0, 0.28); }
#ca-bubble .ca-label { color: #c8102e; flex: none; }
#ca-bubble .ca-value {
  /* show the full address; wrap rather than truncate so nothing is cut off */
  min-width: 0;
  word-break: break-all;
  overflow-wrap: anywhere;
}
#ca-bubble .ca-copied {
  display: none;
  color: #0b7a3b;
}
#ca-bubble.copied .ca-label,
#ca-bubble.copied .ca-value { display: none; }
#ca-bubble.copied .ca-copied { display: inline; }

@media (max-width: 600px) {
  #ca-bubble { right: 10px; bottom: 10px; padding: 8px 11px; font-size: 11px; }
}
