:root {
  --wall: #12402E;      /* spray-painted bottle green */
  --wall-deep: #0A2A1D;
  --lime: #B8F03A;      /* the outline glow on the FreeSoul piece */
  --pink: #FF4FA3;
  --gold: #F9B233;      /* FreeSoul logo orange-gold */
  --paper: #F3FAEE;     /* sticker paper */
  --ink: #000;
  --on-wall: #EAF6E2;
  --mute: #4C6356;      /* secondary text on paper */
  --mute-wall: #A9CBB6; /* secondary text on the wall */
  --good: #1FA855;
  --shadow: 5px 5px 0 var(--ink);
  --display: "Bungee", "Arial Black", sans-serif;
  --body: "Rubik", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--wall-deep); }
body {
  margin: 0; min-height: 100vh; color: var(--on-wall); font: 16px/1.5 var(--body);
  overflow-x: hidden;
  background:
    radial-gradient(ellipse 60% 45% at 8% 0%, rgba(184,240,58,.16), transparent 70%),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgba(255,79,163,.14), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='48'%3E%3Cg fill='none' stroke='%23000' stroke-opacity='.22' stroke-width='2'%3E%3Cpath d='M0 1h120M0 25h120M60 1v24M0 25v23M120 25v23'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(var(--wall), var(--wall-deep));
  background-attachment: fixed;
}

/* ---- The wall of tags (fixed, behind everything) ---- */
.wall { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.wall img { position: absolute; height: auto; }
.tag { opacity: .9; }
.piece   { width: min(1150px, 92vw); left: 50%; bottom: -1.5vh; transform: translateX(-50%) rotate(-2deg); opacity: .78; }
.concept { width: 300px; top: 40%; right: -70px; transform: rotate(7deg); }
.fstag   { width: 230px; top: 38%; left: -24px; transform: rotate(-9deg); }
.acn     { width: 104px; top: 26px; left: 47%; transform: rotate(-5deg); opacity: .55; }

/* Badges as peeled stickers: a white die-cut edge and a hard shadow. */
.sticker {
  width: 92px;
  filter: drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff)
          drop-shadow(4px 5px 0 rgba(0,0,0,.4));
}
.sticker.photo { border-radius: 14px; border: 4px solid #fff; filter: drop-shadow(4px 5px 0 rgba(0,0,0,.4)); }
.b0   { top: 17%; left: 2.5%;  transform: rotate(-12deg); }
.b88  { top: 66%; left: 1.5%;  transform: rotate(8deg); width: 104px; }
.b204 { bottom: 9%; left: 7%;  transform: rotate(-6deg); }
.b250 { top: 15%; right: 2.5%; transform: rotate(14deg); }
.b69  { top: 64%; right: 8%;   transform: rotate(-7deg); width: 84px; }
.b19  { top: 80%; right: 2.5%; transform: rotate(10deg); }
.b3   { top: 52%; left: 4%;    transform: rotate(16deg); width: 70px; }
.b51  { bottom: 3%; right: 24%; transform: rotate(-10deg); width: 100px; }

/* ---- Header ---- */
.top {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1080px; margin: 0 auto; padding: 22px 16px 8px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img {
  width: 60px; height: 60px; border-radius: 12px; border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink); transform: rotate(-5deg);
}
/* On the link screen the big icon sits next to the heading instead. */
/* The icon now sits next to each screen's heading, so the header only holds the account bit. */
.brand { visibility: hidden; }

.hero { display: flex; align-items: center; gap: 20px; margin-bottom: 14px; }
.hero h1 { margin: 0; }
.hero-icon {
  width: 128px; height: 128px; flex: none; border-radius: 20px; border: 4px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink); transform: rotate(-5deg);
}
.hero.small { gap: 16px; margin-bottom: 12px; }
.hero.small .hero-icon { width: 76px; height: 76px; border-radius: 14px; border-width: 3px; box-shadow: 4px 4px 0 var(--ink); }
.me { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; font-weight: 500; }
.me .hint { color: var(--mute-wall); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 2px solid var(--ink); margin-right: 6px; vertical-align: -1px; }
.dot.on { background: var(--lime); }
.dot.off { background: var(--pink); }

main { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; padding: 8px 16px 96px; }
.connecting { font-weight: 700; }

/* ---- Building blocks ---- */
.panel {
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); box-shadow: var(--shadow);
  border-radius: 6px; padding: 22px;
}
h1, h2 { font-family: var(--display); font-weight: 400; line-height: 1.05; margin: 0 0 12px; }
h1 { font-size: clamp(30px, 6vw, 52px); color: var(--on-wall); text-shadow: 4px 4px 0 var(--ink); }
h2 { font-size: 22px; }
p { margin: 0 0 12px; max-width: 62ch; }
.hint { color: var(--mute); font-size: 14px; }
.lead { font-size: 18px; font-weight: 500; text-shadow: 0 1px 2px rgba(0,0,0,.5); }

label { display: block; font-weight: 700; margin: 14px 0 6px; }
input[type=text] {
  width: 100%; font: 700 20px var(--body); padding: 10px 12px; color: var(--ink);
  border: 3px solid var(--ink); border-radius: 4px; background: #fff;
}
input::placeholder { color: #8AA596; font-weight: 500; }
input.code { font-family: var(--display); letter-spacing: .25em; text-transform: uppercase; font-size: 28px; max-width: 220px; }

button {
  font: 700 17px var(--body); cursor: pointer; padding: 10px 18px;
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 4px;
  box-shadow: 3px 3px 0 var(--ink); transition: transform .06s, box-shadow .06s;
}
button:hover { background: #E2F5D5; }
button:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
button.go { background: var(--lime); }
button.go:hover { background: #CBFA62; }
button.small { font-size: 14px; padding: 5px 10px; box-shadow: 2px 2px 0 var(--ink); }
button:disabled { opacity: .45; cursor: default; transform: none; box-shadow: 3px 3px 0 var(--ink); }
button.go:disabled { opacity: 1; background: #B9C4BD; color: #5E6B63; }
:focus-visible { outline: 3px solid var(--pink); outline-offset: 3px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 3px solid var(--ink); border-radius: 4px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; box-shadow: none; border-right: 3px solid var(--ink); padding: 6px 14px; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed=true] { background: var(--ink); color: var(--lime); }
.seg.vis { margin-top: 14px; }
.host .seg.vis { margin-top: 0; justify-self: start; }
.seg button:active { transform: none; }

/* ---- Link screen ---- */
.link { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; align-items: start; margin-top: 18px; }
.steps { margin: 0 0 4px; padding-left: 22px; font-weight: 500; }
.steps li { margin-bottom: 8px; }

.shots { position: relative; padding-top: 8px; min-height: 730px; }
.shot { margin: 0; background: #fff; border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); padding: 10px 10px 8px; color: var(--ink); }
.shot img { display: block; width: 100%; height: auto; border: 2px solid var(--ink); }
.shot figcaption { font-weight: 700; font-size: 14px; margin-top: 8px; }
.shot.spot { position: relative; transform: rotate(2deg); }
.shot .photo { position: relative; }
/* Pinned on the photo's bottom edge, a little right of centre (tilts with the photo). */
.shot.spot .pin {
  position: absolute; width: 64px; border: 0; left: 56%; bottom: -18px;
  filter: drop-shadow(3px 4px 0 rgba(0,0,0,.45));
}
.shot.spot { width: 82%; }
.shot.spot figcaption { margin-top: 20px; }
.shot.phone figcaption { font-size: 17px; }
.shot.phone { position: absolute; width: 74%; right: -6px; top: 300px; transform: rotate(-4deg); }

/* ---- Lobby list ---- */
.browse { display: grid; grid-template-columns: 1fr 320px; gap: 28px; align-items: start; margin-top: 18px; }
.lobbies { display: grid; gap: 12px; }
.lob {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: center; color: var(--ink);
  background: var(--paper); border: 3px solid var(--ink); border-radius: 6px; padding: 14px 16px;
  box-shadow: 4px 4px 0 var(--ink);
}
.lob b { font-size: 19px; }
.lob .meta { color: var(--mute); font-size: 14px; }
.empty { padding: 26px; border: 3px dashed var(--lime); border-radius: 6px; font-weight: 500; background: rgba(10,42,29,.75); }
.side { display: grid; gap: 22px; }

/* ---- Lobby / match ---- */
.lobby-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 18px 0 20px; }
.lobby-head .hint { color: var(--mute-wall); }
.lobby-head .code-tag {
  font: 22px var(--display); letter-spacing: .15em; background: var(--lime); color: var(--ink);
  border: 3px solid var(--ink); padding: 4px 12px; border-radius: 4px; display: inline-block; transform: rotate(-2deg);
  box-shadow: 3px 3px 0 var(--ink);
}
.status { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.clock { font: 64px/1 var(--display); color: var(--on-wall); text-shadow: 4px 4px 0 var(--ink); }
.clock.hurry { color: var(--pink); }
.status .what { font-weight: 700; font-size: 18px; }

.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.board li {
  display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 14px; color: var(--ink);
  background: var(--paper); border: 3px solid var(--ink); border-radius: 6px; padding: 10px 16px 10px 10px;
  box-shadow: 4px 4px 0 var(--ink);
}
.board li:nth-child(odd) { transform: rotate(-.4deg); }
.board li:nth-child(even) { transform: rotate(.35deg); }
.board li.you { background: #E4F9C6; }
.board .hint { color: var(--mute); }
.rank {
  font: 26px/1 var(--display); text-align: center; padding: 8px 0; border-radius: 4px;
  background: var(--wall); color: var(--on-wall);
}
.board li:nth-child(1) .rank { background: var(--gold); color: var(--ink); }
.board li:nth-child(2) .rank { background: var(--lime); color: var(--ink); }
.board li:nth-child(3) .rank { background: var(--pink); color: var(--ink); }
.who b { font-size: 19px; }
.who .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; font-size: 13px; font-weight: 700; }
.tag-chip { border: 2px solid var(--ink); border-radius: 3px; padding: 0 6px; }
.tag-chip.guessed { background: var(--good); color: #fff; border-color: var(--good); }
.tag-chip.away { background: #e6ece6; color: var(--mute); border-color: #b9c6bd; }
.total { font: 28px var(--display); }

.match { display: grid; grid-template-columns: 1fr 340px; gap: 28px; align-items: start; }
.results table { width: 100%; border-collapse: collapse; font-size: 15px; }
.results td { padding: 6px 4px; border-bottom: 2px solid #dbe8d6; }
.results td.n { text-align: right; font-weight: 700; white-space: nowrap; }
.results .bonus { color: var(--good); font-weight: 700; }
.results .miss { color: #D0246F; }
.host { display: grid; gap: 14px; }

/* ---- Toast ---- */
.toast {
  visibility: hidden;
  position: fixed; z-index: 5; left: 50%; bottom: 24px; transform: translate(-50%, 140px);
  background: var(--ink); color: #fff; font-weight: 700; padding: 12px 18px; border-radius: 4px;
  box-shadow: 4px 4px 0 var(--lime); max-width: calc(100% - 32px); transition: transform .2s, visibility .2s;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }

/* ---- Smaller screens: the wall steps back so text stays readable ---- */
@media (max-width: 1240px) {
  .sticker, .fstag { opacity: .45; }
  .concept { opacity: .45; }
}
@media (max-width: 900px) {
  .hero-icon { width: 84px; height: 84px; border-radius: 14px; }
  .link, .browse, .match { grid-template-columns: 1fr; }
  .shots { min-height: 0; max-width: 520px; }
  .shot.phone { position: relative; width: 70%; top: 0; right: 0; margin: -40px 0 0 auto; }
  .clock { font-size: 48px; }
  .b3, .b69, .b88, .acn, .fstag { display: none; }
  .sticker { width: 64px; opacity: .35; }
  .concept { width: 220px; top: 70px; right: -40px; opacity: .3; }
  .piece { opacity: .4; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
.host > div:first-child label { margin-top: 0; }
