/*
 * Scrap Stars UI.
 *
 * One committed visual world — a lit arcade cabinet in violet — rather than
 * following the viewer's light/dark preference. Nothing here should read as a
 * web page: every panel is a moulded plastic tile with a hard black edge and a
 * thick bottom lip, every label is outlined so it survives on top of art, and
 * buttons physically depress when you press them.
 */

:root {
  --ink: #150b28;
  --edge: #12071f;            /* the hard outline every game element wears */
  --bg: #241546;
  --bg-2: #422284;
  --panel: #3a2170;
  --panel-hi: #573098;
  --line: rgba(190, 160, 255, .22);
  --text: #ffffff;
  --muted: #c9b8f0;
  --gold: #ffc738;
  --gold-2: #f59e0b;
  --gold-lip: #9c5405;
  --sky: #38bdf8;
  --green: #43d17a;

  /* Outlines, faked with shadows so they sit outside the glyph. */
  --stroke:
    2px 0 0 var(--edge), -2px 0 0 var(--edge), 0 2px 0 var(--edge), 0 -2px 0 var(--edge),
    2px 2px 0 var(--edge), -2px 2px 0 var(--edge), 2px -2px 0 var(--edge), -2px -2px 0 var(--edge),
    0 5px 0 rgba(0, 0, 0, .45);
  --stroke-sm:
    1px 0 0 var(--edge), -1px 0 0 var(--edge), 0 1px 0 var(--edge), 0 -1px 0 var(--edge),
    0 2px 0 rgba(0, 0, 0, .4);

  /* Moulded-plastic look: dark rim, glossy top lip, soft drop. */
  --emboss: inset 0 3px 0 rgba(255, 255, 255, .22), inset 0 -6px 12px rgba(0, 0, 0, .3),
            0 6px 0 rgba(0, 0, 0, .32), 0 10px 22px rgba(0, 0, 0, .45);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: ui-rounded, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* Above the menu scenery. Without this the backdrop painted over the whole
     match and the arena was never visible. */
  z-index: 2;
  touch-action: none;
  cursor: crosshair;
}

/* ---------- overlays ---------- */

/* The canyon behind every menu, painted in backdrop.js. */
#backdrop {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  pointer-events: none;
}
/* Taken off the page entirely during a match — it is menu scenery, and even
   underneath the arena it would be a full-screen canvas composited for nothing. */
#backdrop.hidden { display: none !important; }
/* Same reasoning in reverse: a canvas keeps its last frame, so the arena has
   to be taken off the page on the menus or it shows through them. */
#game.hidden { display: none !important; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
  /* Barely a wash — the scene is the point, so let it through. */
  background: rgba(24, 11, 40, .10);
}
/* Screens that are mostly reading get a heavier scrim so text stays crisp. */
#brawlers, #modes, #road, #skins, #quests, #settings, #friends, #result {
  background: rgba(20, 9, 34, .62);
}
.overlay.soft { background: rgba(15, 8, 26, .86); }
.hidden { display: none !important; }

/* ---------- home ---------- */

.home-screen {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto 1fr auto auto;
  grid-template-areas:
    "top    top    top"
    "left   stage  right"
    "bottom bottom bottom"
    "keys   keys   keys";
  gap: 10px;
  padding: 14px;
  place-items: stretch;
}

.topbar { grid-area: top; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.rail.left { grid-area: left; }
.rail.right { grid-area: right; }
.stage { grid-area: stage; display: grid; justify-items: center; align-content: center; gap: 2px; }
.bottombar { grid-area: bottom; display: flex; gap: 14px; align-items: stretch; justify-content: center; }
.keys { grid-area: keys; text-align: center; font-size: 11.5px; color: var(--muted); line-height: 2; }

/* panels ---------------------------------------------------------- */

.plate, .railbtn, .modecard, .pill, .sheet, .ghost {
  background: linear-gradient(180deg, var(--panel-hi), var(--panel) 58%, #2a175a);
  border: 3px solid var(--edge);
  border-radius: 16px;
  box-shadow: var(--emboss);
}

.plate { display: flex; gap: 11px; align-items: center; padding: 9px 16px 9px 9px; }
.rankplate canvas { width: 56px; height: 56px; flex: none; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .5)); }
.plate-body { display: grid; gap: 4px; min-width: 138px; }
.plate-title { font-size: 17px; font-weight: 900; letter-spacing: .02em; text-transform: uppercase; text-shadow: var(--stroke-sm); }
.plate-sub { font-size: 11px; color: var(--muted); font-weight: 800; letter-spacing: .04em; }

.bar {
  height: 11px;
  border-radius: 99px;
  background: #180d2c;
  border: 2px solid var(--edge);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .6);
  overflow: hidden;
}
.bar.wide { width: 160px; margin-top: 5px; }
.bar span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(180deg, #ffe9a8, var(--gold) 60%, var(--gold-2));
  box-shadow: 0 0 10px rgba(255, 199, 56, .7);
}

.topright { display: flex; gap: 9px; align-items: center; }
.pill { display: flex; align-items: center; gap: 8px; padding: 9px 15px; font-size: 13px; font-weight: 900; text-shadow: var(--stroke-sm); }
.pill .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--edge); }
.dot.win { background: var(--green); }
.dot.best { background: var(--gold); }
.dot.coin { background: linear-gradient(180deg, #ffe08a, #e0a11a); }
.dot.credit { background: linear-gradient(180deg, #a5f3fc, #0891b2); }

/* power level chip + upgrade button on a brawler card */
.plevel {
  display: flex; align-items: center; gap: 7px;
  margin-top: 7px; font-size: 11px; font-weight: 900; width: 100%;
}
.plevel .pnum {
  background: linear-gradient(180deg, #ffe08a, var(--gold));
  color: #4a2800; border: 2px solid var(--edge); border-radius: 7px; padding: 1px 8px;
}
.pbar { flex: 1; height: 9px; border-radius: 99px; background: #180d2c; border: 2px solid var(--edge); overflow: hidden; }
.pbar span { display: block; height: 100%; background: linear-gradient(180deg, #a5e8ff, #38bdf8); }
.upbtn {
  margin-top: 8px; width: 100%; padding: 7px 8px;
  font: inherit; font-size: 11.5px; font-weight: 900; letter-spacing: .06em;
  color: #4a2800; background: linear-gradient(180deg, #ffe08a, var(--gold));
  border: 3px solid var(--edge); border-radius: 11px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .6), 0 4px 0 var(--gold-lip);
  cursor: pointer;
}
.upbtn:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .6), 0 1px 0 var(--gold-lip); }
.upbtn[disabled] {
  background: #2a1a4e; color: #7c6aa8;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .5); cursor: default;
}

/* rails ----------------------------------------------------------- */

.rail { display: grid; gap: 11px; align-content: center; }
.railbtn {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 3px;
  width: 92px;
  padding: 10px 6px 8px;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
}
.railbtn canvas { width: 54px; height: 54px; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .45)); }
.railbtn:hover { transform: translateY(-3px); }
.railbtn:active { transform: translateY(3px); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .18), 0 2px 0 rgba(0, 0, 0, .32); }
.railbtn:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.raillabel { font-size: 11px; font-weight: 900; letter-spacing: .09em; color: var(--muted); text-shadow: var(--stroke-sm); }
.railbtn.active, .railbtn.on {
  background: linear-gradient(180deg, #ffe08a, var(--gold) 60%, var(--gold-2));
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .55), 0 6px 0 var(--gold-lip), 0 10px 20px rgba(0, 0, 0, .45);
}
.railbtn.active .raillabel, .railbtn.on .raillabel { color: #4a2800; text-shadow: 0 1px 0 rgba(255, 255, 255, .5); }

/* stage ------------------------------------------------------------ */

.logo {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: clamp(30px, 6vw, 62px);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1;
  margin-bottom: 6px;
  transform: rotate(-2.5deg);
}
/* The shadow lives on the solid half only — a text-shadow behind clipped
   gradient text shows straight through the glyphs and reads as hollow. */
.logo span { color: var(--text); text-shadow: var(--stroke), 0 9px 22px rgba(0, 0, 0, .6); }
.logo em {
  font-style: normal;
  background: linear-gradient(180deg, #fff6d5, #ffd44d 45%, var(--gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter:
    drop-shadow(2px 0 0 var(--edge)) drop-shadow(-2px 0 0 var(--edge))
    drop-shadow(0 2px 0 var(--edge)) drop-shadow(0 -2px 0 var(--edge))
    drop-shadow(0 6px 0 rgba(0, 0, 0, .45)) drop-shadow(0 10px 18px rgba(0, 0, 0, .5));
}

.hero {
  width: min(290px, 38vh); height: min(290px, 38vh);
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .55));
}
.heroname { font-size: 30px; font-weight: 900; letter-spacing: .01em; text-transform: uppercase; text-shadow: var(--stroke); }
.heroclass {
  font-size: 11px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase;
  margin-top: 6px; padding: 4px 12px; border-radius: 99px;
  background: rgba(0, 0, 0, .45); border: 2px solid var(--edge);
}

/* bottom ----------------------------------------------------------- */

.modecard {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 9px 18px 9px 9px;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  min-width: min(360px, 46vw);
  transition: transform .1s ease;
}
.modecard:hover { transform: translateY(-3px); }
.modecard:active { transform: translateY(3px); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .18), 0 2px 0 rgba(0, 0, 0, .32); }
.modecard canvas { width: 58px; height: 58px; flex: none; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .45)); }
.modebody { display: grid; gap: 3px; flex: 1; }
.modename { font-size: 21px; font-weight: 900; text-transform: uppercase; text-shadow: var(--stroke-sm); }
.mapname { font-size: 12.5px; font-weight: 900; color: var(--green); letter-spacing: .03em; }
.modetag {
  font-size: 11px; font-weight: 900; letter-spacing: .08em;
  color: #4a2800; background: linear-gradient(180deg, #ffe08a, var(--gold));
  padding: 5px 11px; border-radius: 99px; border: 2px solid var(--edge);
}

.play {
  padding: 18px 52px;
  font: inherit;
  font-size: clamp(24px, 3.6vw, 38px);
  font-weight: 900;
  letter-spacing: .07em;
  color: #4a2800;
  background: linear-gradient(180deg, #fff2c4, #ffcf4a 48%, var(--gold-2));
  border: 3px solid var(--edge);
  border-radius: 18px;
  cursor: pointer;
  text-shadow: 0 2px 0 rgba(255, 255, 255, .55);
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, .65), 0 8px 0 var(--gold-lip), 0 14px 26px rgba(0, 0, 0, .5);
  transition: transform .08s ease, filter .12s ease, box-shadow .08s ease;
}
.play:hover { filter: brightness(1.06); }
.play:active {
  transform: translateY(6px);
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, .65), 0 2px 0 var(--gold-lip), 0 6px 14px rgba(0, 0, 0, .5);
}
.play.small { font-size: 19px; padding: 14px 28px; }

kbd {
  background: #1d1136;
  border: 2px solid var(--edge);
  border-radius: 7px;
  padding: 2px 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .5);
}

/* ---------- sheets ---------- */

.sheet {
  width: min(980px, 100%);
  padding: 22px;
  border-radius: 24px;
  box-shadow: var(--emboss), 0 30px 90px rgba(0, 0, 0, .6);
}
.sheet.narrow { width: min(520px, 100%); text-align: center; }

.sheethead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
h2 {
  font-size: 32px; font-weight: 900; letter-spacing: .02em; text-transform: uppercase;
  text-shadow: var(--stroke);
}
h2.win { color: var(--green); }
h2.lose { color: #fb7185; }
h2.draw { color: var(--gold); }
.sub { color: var(--muted); margin-top: 8px; font-size: 14px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }

.ghost {
  padding: 12px 22px; font: inherit; font-size: 14px; font-weight: 900;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text);
  cursor: pointer; text-shadow: var(--stroke-sm);
  transition: transform .08s ease;
}
.ghost:active { transform: translateY(3px); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .18), 0 2px 0 rgba(0, 0, 0, .32); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(186px, 1fr)); gap: 12px; max-height: 62vh; overflow-y: auto; padding: 4px; }

.card {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 12px 10px;
  font: inherit;
  text-align: center;
  color: var(--text);
  background: linear-gradient(180deg, var(--panel-hi), var(--panel) 58%, #2a175a);
  border: 3px solid var(--edge);
  border-radius: 18px;
  box-shadow: var(--emboss);
  cursor: pointer;
  transition: transform .1s ease;
}
.card:hover { transform: translateY(-4px); }
.card:active { transform: translateY(2px); }
.card.active {
  background: linear-gradient(180deg, #7a49c8, #4d2b96 58%, #351f6c);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .3), 0 0 0 3px var(--gold),
              0 6px 0 rgba(0, 0, 0, .32), 0 12px 26px rgba(255, 199, 56, .25);
}

.portrait { width: 96px; height: 96px; filter: drop-shadow(0 5px 6px rgba(0, 0, 0, .5)); }
.modeicon { width: 66px; height: 66px; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .5)); }

.cname { font-size: 17px; font-weight: 900; text-transform: uppercase; text-shadow: var(--stroke-sm); }
.cname em { font-style: normal; font-size: 10.5px; color: var(--muted); }
.ccls { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; font-weight: 900; }
.cblurb { font-size: 11.5px; color: var(--muted); line-height: 1.45; margin-top: 5px; }
.ctip { font-size: 10.5px; color: #9d8bcc; line-height: 1.45; margin-top: 5px; font-style: italic; }
.cgadget {
  margin-top: 7px; padding: 6px 8px; width: 100%;
  border-radius: 9px; border: 2px solid var(--edge);
  background: rgba(45, 212, 191, .08);
  display: grid; gap: 2px; text-align: left;
}
.cgadget b { font-size: 9.5px; letter-spacing: .1em; color: #5eead4; }
.cgadget span { font-size: 10.5px; color: var(--muted); line-height: 1.4; }
.cmaps { font-size: 10.5px; color: var(--green); font-weight: 800; margin-top: 5px; }
.cstats { display: flex; gap: 10px; margin-top: 7px; font-size: 11px; font-weight: 800; color: var(--muted); }
.cstats span { display: inline-flex; align-items: center; gap: 5px; }
.cstats i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--edge); }

.modelist { display: grid; gap: 11px; max-height: 62vh; overflow-y: auto; padding: 4px; }
.card.mode { grid-template-columns: 92px 1fr; justify-items: start; text-align: left; align-items: center; gap: 14px; }
.card.mode .mbody { display: grid; gap: 4px; }
.card.mode.ranked { box-shadow: inset 0 3px 0 rgba(255, 255, 255, .25), 0 0 0 3px var(--gold), 0 6px 0 rgba(0, 0, 0, .32); }

/* ---------- result ---------- */

.rankresult {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  margin-top: 18px; padding: 14px;
  background: #1b0f34; border: 3px solid var(--edge); border-radius: 16px;
  box-shadow: inset 0 3px 10px rgba(0, 0, 0, .55);
}
.rankresult canvas { width: 66px; height: 66px; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .5)); }
.rankresult > div { display: grid; justify-items: start; }
.delta { font-size: 30px; font-weight: 900; color: var(--gold); text-shadow: var(--stroke); }
.delta.down { color: #fb7185; }

/* The scoreboard is a stack of team-coloured chips, not a spreadsheet. */
table { width: 100%; margin-top: 18px; border-collapse: separate; border-spacing: 0 6px; font-size: 14px; font-weight: 800; }
th {
  text-align: left; color: var(--muted); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; padding: 2px 12px;
}
td { padding: 9px 12px; text-align: left; background: #2c1a58; border-top: 2px solid var(--edge); border-bottom: 3px solid var(--edge); }
td:first-child { border-left: 3px solid var(--edge); border-radius: 12px 0 0 12px; }
td:last-child { border-right: 3px solid var(--edge); border-radius: 0 12px 12px 0; }
th:last-child, td:last-child, th:nth-child(3), td:nth-child(3) { text-align: right; }
tr.ally td { background: linear-gradient(180deg, #1f4a78, #17355a); }
tr.enemy td { background: linear-gradient(180deg, #6d2440, #4c1a2e); }
tr.ally td:first-child { color: #a5e2ff; }
tr.enemy td:first-child { color: #ffb3c1; }

.row.buttons { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }

.corner-note { position: fixed; right: 12px; bottom: 10px; color: rgba(255, 255, 255, .22); font-size: 11px; z-index: 5; pointer-events: none; }

/* ---------- Starr Drops ---------- */

/* The teaser button on the result screen. */
.dropbtn {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  width: 100%; margin-top: 18px; padding: 10px 20px 10px 10px;
  font: inherit; font-size: 17px; font-weight: 900; letter-spacing: .06em;
  color: #fff; cursor: pointer;
  background: linear-gradient(180deg, #a855f7, #7c2fd4 55%, #5b1ea6);
  border: 3px solid var(--edge); border-radius: 18px;
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, .35), 0 7px 0 #3d1273, 0 12px 26px rgba(168, 85, 247, .35);
  text-shadow: var(--stroke-sm);
  animation: nudge 1.5s ease-in-out infinite;
}
.dropbtn canvas { width: 60px; height: 60px; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .5)); }
.dropbtn:active {
  transform: translateY(5px); animation: none;
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, .35), 0 2px 0 #3d1273;
}
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* The opening itself: takes the whole screen. */
.dropstage {
  position: fixed; inset: 0; z-index: 60;
  cursor: pointer; touch-action: none; overflow: hidden;
  background:
    radial-gradient(700px 700px at 50% 50%, rgba(80, 40, 140, .55), rgba(0, 0, 0, 0) 70%),
    rgba(10, 5, 20, .985);
}
.dropstage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.dropprompt {
  position: absolute; left: 0; right: 0; bottom: 9%;
  text-align: center; font-size: clamp(15px, 2.6vw, 22px);
  font-weight: 900; letter-spacing: .16em; text-transform: uppercase;
  color: #fff; text-shadow: var(--stroke);
  animation: pulse 1.1s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pulse { 0%, 100% { opacity: .55; transform: scale(.98); } 50% { opacity: 1; transform: scale(1.02); } }

@media (prefers-reduced-motion: reduce) {
  .dropbtn, .dropprompt { animation: none; }
}

/* ---------- portrait nudge ---------- */

.rotate { display: none; }

@media (pointer: coarse) and (orientation: portrait) {
  .rotate {
    position: fixed; inset: 0; z-index: 70;
    display: grid; place-items: center;
    background: var(--ink); text-align: center;
  }
  .rotate-inner { display: grid; gap: 16px; justify-items: center; padding: 28px; }
  .rotate p { font-size: 21px; font-weight: 900; text-transform: uppercase; text-shadow: var(--stroke); }
  .rotate span { font-size: 13px; color: var(--muted); font-weight: 800; }
  .phone { width: 54px; height: 96px; border: 4px solid var(--gold); border-radius: 12px; animation: tip 1.8s ease-in-out infinite; }
  @keyframes tip { 0%, 40% { transform: rotate(0deg); } 60%, 100% { transform: rotate(-90deg); } }
}
@media (pointer: coarse) { .corner-note { display: none; } }
@media (prefers-reduced-motion: reduce) { .phone { animation: none; transform: rotate(-90deg); } }

/* Short landscape phones: shed the chrome that does not fit. */
@media (max-height: 460px) {
  .keys { display: none; }
  .hero { width: 158px; height: 158px; }
  .logo { font-size: 26px; }
  .heroname { font-size: 20px; }
  .heroclass { margin-top: 3px; padding: 3px 9px; }
  .railbtn { width: 72px; padding: 7px 5px 6px; }
  .railbtn canvas { width: 40px; height: 40px; }
  .play { padding: 13px 34px; }
}
@media (max-width: 720px) {
  .plate-body { min-width: 100px; }
  .topright { display: none; }
  .modecard { min-width: 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(152px, 1fr)); max-height: 56vh; }
  .row.buttons { flex-direction: column; }
  .row.buttons .play, .row.buttons .ghost { width: 100%; }
}

/* ---------- Starr Road ---------- */

.roadsub { margin-bottom: 14px; }
.roadlist { display: grid; gap: 11px; max-height: 58vh; overflow-y: auto; padding: 4px; }

.roadrow {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px 10px 10px;
  background: linear-gradient(180deg, var(--panel-hi), var(--panel) 58%, #2a175a);
  border: 3px solid var(--edge);
  border-radius: 18px;
  box-shadow: var(--emboss);
  text-align: left;
}
/* The one you are saving for is the only one that should pull the eye. */
.roadrow.next { box-shadow: inset 0 3px 0 rgba(255, 255, 255, .25), 0 0 0 3px var(--gold), 0 6px 0 rgba(0, 0, 0, .32); }
.roadrow.owned { opacity: .62; }
.roadart { width: 74px; height: 74px; }
.roadbody { display: grid; gap: 3px; }
.roadact { display: grid; justify-items: end; }
.roadbtn { margin-top: 0; width: auto; min-width: 132px; }
.ownedtag {
  font-size: 11px; font-weight: 900; letter-spacing: .1em;
  color: var(--green); padding: 6px 12px;
  border: 2px solid var(--edge); border-radius: 99px; background: rgba(0, 0, 0, .35);
}

/* Anything you do not own yet shows as a flat shadow of itself. */
.silhouette { filter: brightness(0) opacity(.42); }
.card.locked { opacity: .8; }
.card.locked .cname { color: var(--muted); }

/* ---------- play with a friend ---------- */

.friendpick { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card.fbig { padding: 22px 20px; gap: 8px; position: relative; }
.fbadge {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 19px; font-weight: 900; color: #4a2800;
  background: linear-gradient(180deg, #ffe08a, var(--gold));
  border: 3px solid var(--edge);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .6);
  margin-bottom: 4px;
}

.fflow { display: grid; gap: 14px; }
.fsteps { display: grid; gap: 16px; list-style: none; }
.fsteps li { display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: start; }
.fsteps b { display: block; font-size: 14px; font-weight: 900; margin-bottom: 8px; letter-spacing: .02em; }
.fstep {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 900; color: #fff;
  background: linear-gradient(180deg, #a855f7, #6d28d9);
  border: 3px solid var(--edge);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35);
}

/* The codes are long. Monospace and a scroll box beat truncation. */
.fcode {
  width: 100%; resize: vertical;
  padding: 11px 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px; line-height: 1.5;
  color: #d9c9ff; background: #150c29;
  border: 3px solid var(--edge); border-radius: 12px;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, .55);
  word-break: break-all;
}
.fcode:focus { outline: 3px solid var(--sky); outline-offset: 2px; }
.fcode::placeholder { color: #6b5b95; }
.fcopy { width: auto; min-width: 190px; margin-top: 9px; }

.fstatus {
  margin-top: 2px; padding: 11px 14px;
  font-size: 13px; font-weight: 800; color: var(--muted);
  background: rgba(0, 0, 0, .32);
  border: 2px solid var(--edge); border-radius: 12px;
  text-align: center;
}

@media (max-width: 720px) {
  .friendpick { grid-template-columns: 1fr; }
  .fcopy { width: 100%; }
}

/* ---------- polish ---------- */

/* Screens arrive rather than blink into place. */
.overlay:not(.hidden) { animation: screenIn .22s ease-out both; }
@keyframes screenIn { from { opacity: 0; } to { opacity: 1; } }
.overlay .sheet { animation: sheetIn .26s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes sheetIn {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* The hero breathes so the menu never looks like a screenshot. */
.hero { animation: heroBob 3.6s ease-in-out infinite; }
@keyframes heroBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-9px); }
}

/* PLAY has a slow sheen crossing it — the one moving thing on the screen. */
.play { position: relative; overflow: hidden; }
.play::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .55) 50%, transparent 62%);
  transform: translateX(-120%);
  animation: sheen 3.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sheen {
  0%, 62% { transform: translateX(-120%); }
  86%, 100% { transform: translateX(120%); }
}

/*
 * Keyboard focus has to be visible on every control, not just the ones I
 * styled. A controller moves focus programmatically, which the browser does
 * not count as a "visible" interaction, so :focus is matched too once a pad
 * has been used — otherwise pad navigation is invisible.
 */
body.usingpad .railbtn:focus, body.usingpad .card:focus, body.usingpad .play:focus,
body.usingpad .ghost:focus, body.usingpad .modecard:focus, body.usingpad .upbtn:focus,
body.usingpad .trybtn:focus, body.usingpad .segbtn:focus, body.usingpad .dropbtn:focus,
.railbtn:focus-visible, .card:focus-visible, .play:focus-visible,
.ghost:focus-visible, .modecard:focus-visible, .upbtn:focus-visible,
.trybtn:focus-visible, .segbtn:focus-visible,
.dropbtn:focus-visible, .roadrow button:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .overlay:not(.hidden), .overlay .sheet, .hero { animation: none; }
  .play::after { animation: none; opacity: 0; }
}

/* ---------- room codes ---------- */

.roombox {
  display: grid; justify-items: center; gap: 10px;
  padding: 22px 18px;
  background: #1b0f34; border: 3px solid var(--edge); border-radius: 18px;
  box-shadow: inset 0 3px 12px rgba(0, 0, 0, .55);
}
.roomlabel {
  font-size: 11px; font-weight: 900; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted);
}
.roomcode {
  font-size: clamp(44px, 9vw, 76px); font-weight: 900; letter-spacing: .14em;
  color: var(--gold); text-shadow: var(--stroke);
  font-variant-numeric: tabular-nums;
}
.roomhint { font-size: 12.5px; font-weight: 700; color: var(--muted); text-align: center; max-width: 42ch; }
.roominput {
  width: min(260px, 80vw); padding: 12px 16px;
  font: inherit; font-size: clamp(32px, 7vw, 52px); font-weight: 900;
  letter-spacing: .22em; text-align: center; text-transform: uppercase;
  color: var(--gold); background: #120a25;
  border: 3px solid var(--edge); border-radius: 14px;
  box-shadow: inset 0 3px 10px rgba(0, 0, 0, .6);
}
.roominput:focus { outline: 3px solid var(--sky); outline-offset: 2px; }
.roominput::placeholder { color: #4b3a75; letter-spacing: .22em; }

.linkbtn {
  justify-self: center;
  background: none; border: none; padding: 6px 4px;
  font: inherit; font-size: 12.5px; font-weight: 800;
  color: var(--muted); text-decoration: underline; cursor: pointer;
}
.linkbtn:hover { color: var(--text); }
.linkbtn:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; border-radius: 6px; }

.sheet.narrowish { width: min(660px, 100%); }
.ordiv { display: flex; align-items: center; gap: 12px; margin: 16px 0 12px; color: var(--muted);
         font-size: 11px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.ordiv::before, .ordiv::after { content: ""; flex: 1; height: 3px; border-radius: 2px; background: rgba(0,0,0,.4); }
.joinrow { display: flex; gap: 12px; align-items: stretch; justify-content: center; }
.joinrow .roominput { width: min(220px, 52vw); }
.joinrow .play { padding: 0 30px; }

.diagbox {
  margin-top: 10px; padding: 8px 14px;
  background: rgba(0,0,0,.3); border: 2px solid var(--edge); border-radius: 12px;
  font-size: 12px; color: var(--muted);
}
.diagbox summary { cursor: pointer; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; font-size: 11px; }
.diagbox summary:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; border-radius: 6px; }
.diaglog {
  margin-top: 8px; padding-left: 20px; max-height: 150px; overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.7;
}

/* Results: damage column lines up, MVP is a badge not a colour. */
table { font-variant-numeric: tabular-nums; }
th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4) { text-align: right; }
.mvp {
  font-style: normal; font-size: 10px; font-weight: 900; letter-spacing: .08em;
  color: #4a2800; background: linear-gradient(180deg, #ffe08a, var(--gold));
  border: 2px solid var(--edge); border-radius: 6px; padding: 1px 6px; margin-right: 6px;
}
.fpane { display: grid; gap: 4px; }
.upbtn.wide { width: 100%; }
.roomline { margin-top: 10px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.roomline b { color: var(--gold); font-size: 17px; letter-spacing: .12em; }

/* ---------- daily quests ---------- */

.questrow { grid-template-columns: 52px 1fr auto; }
.qmark {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 900; color: var(--gold);
  background: rgba(0, 0, 0, .35); border: 3px solid var(--edge);
}
.questrow .pbar { margin-top: 6px; }
.qprog { margin-top: 5px; font-size: 11.5px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }

/* One dot, on the rail, only when something is actually claimable. */
.reddot {
  position: absolute; top: -5px; right: -5px;
  width: 15px; height: 15px; border-radius: 50%;
  background: #ef4444; border: 3px solid var(--edge);
  animation: dotPulse 1.6s ease-in-out infinite;
}
@keyframes dotPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.22); } }
@media (prefers-reduced-motion: reduce) { .reddot { animation: none; } }

/* ---------- settings ---------- */

.setblock { margin-bottom: 20px; }
.setlabel { font-size: 15px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; text-shadow: var(--stroke-sm); }
.setsub { margin: 4px 0 10px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.segrow { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; }
.segbtn {
  display: grid; gap: 3px; padding: 12px 10px;
  font: inherit; color: var(--text); cursor: pointer; text-align: center;
  background: linear-gradient(180deg, var(--panel-hi), var(--panel) 58%, #2a175a);
  border: 3px solid var(--edge); border-radius: 14px;
  box-shadow: var(--emboss);
  transition: transform .08s ease;
}
.segbtn b { font-size: 14.5px; font-weight: 900; letter-spacing: .03em; }
.segbtn span { font-size: 11px; font-weight: 700; color: var(--muted); }
.segbtn:active { transform: translateY(3px); }
.segbtn.on {
  background: linear-gradient(180deg, #ffe08a, var(--gold) 60%, var(--gold-2));
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .55), 0 6px 0 var(--gold-lip);
}
.segbtn.on b { color: #4a2800; text-shadow: 0 1px 0 rgba(255, 255, 255, .5); }
.segbtn.on span { color: #6b4400; }
.segbtn:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
@media (max-width: 620px) { .segrow { grid-auto-flow: row; } }

/* ---------- home screen atmosphere ---------- */

/* Everything on the home screen sits above the painted scene. */
.home-screen > * { position: relative; z-index: 1; }

.herowrap { position: relative; display: grid; place-items: center; }
/* The lighting is scenery, so it must sit behind the fighter — the podium
   comes after the canvas in the DOM and would otherwise wash over their legs. */
.herowrap .hero { position: relative; z-index: 1; }
.herowrap .spot, .herowrap .podium { z-index: 0; }

/* A shaft of light behind the fighter so they are lit rather than pasted on. */
.spot {
  position: absolute;
  width: min(420px, 52vh); height: min(420px, 52vh);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,222,150,.28) 0%, rgba(190,140,255,.14) 42%, rgba(0,0,0,0) 70%);
  animation: breathe 5.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: .85; }
  50%      { transform: scale(1.07); opacity: 1; }
}

/* And something to stand on. */
.podium {
  position: absolute; bottom: 4%;
  width: min(230px, 30vh); height: min(52px, 7vh);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,222,150,.34) 0%, rgba(120,70,190,.22) 55%, rgba(0,0,0,0) 72%);
  box-shadow: 0 0 44px 12px rgba(160,110,255,.18);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .spot { animation: none; }
}

/* ---------- quest progress on the result screen ---------- */

.questgains { display: grid; gap: 7px; margin-top: 16px; }
.gainrow {
  display: grid; grid-template-columns: 1fr 90px auto; gap: 11px; align-items: center;
  padding: 9px 13px;
  background: #1e1140; border: 2px solid var(--edge); border-radius: 12px;
  font-size: 12.5px; font-weight: 800; text-align: left;
}
.gainrow.done { border-color: var(--gold); background: #2c1f10; }
.gaintext { color: var(--muted); }
.gainrow.done .gaintext { color: #fff; }
.gainbar { height: 8px; border-radius: 99px; background: #100a22; border: 2px solid var(--edge); overflow: hidden; }
.gainbar i { display: block; height: 100%; background: linear-gradient(180deg, #a5e8ff, #38bdf8); }
.gainrow.done .gainbar i { background: linear-gradient(180deg, #ffe08a, var(--gold)); }
.gainnum { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.gainrow.done .gainnum { color: var(--gold); }
@media (max-width: 620px) { .gainrow { grid-template-columns: 1fr auto; } .gainbar { display: none; } }

/* ---------- mastery + practice ---------- */

.mastery { display: flex; align-items: center; gap: 7px; width: 100%; margin-top: 7px; font-size: 10.5px; font-weight: 900; }
.mbadge {
  width: 15px; height: 15px; flex: none; border-radius: 4px;
  border: 2px solid var(--edge); transform: rotate(45deg);
}
.mbar { flex: 1; height: 6px; border-radius: 99px; background: rgba(0,0,0,.45); border: 2px solid var(--edge); overflow: hidden; }
.mbar i { display: block; height: 100%; width: 0%; }
.mnum { white-space: nowrap; font-variant-numeric: tabular-nums; }

.trybtn {
  margin-top: 6px; width: 100%; padding: 6px 8px;
  font: inherit; font-size: 10.5px; font-weight: 900; letter-spacing: .08em;
  color: var(--text); background: rgba(255, 255, 255, .07);
  border: 2px solid var(--edge); border-radius: 9px; cursor: pointer;
}
.trybtn:hover { background: rgba(255, 255, 255, .14); }
.trybtn:active { transform: translateY(2px); }
.trybtn:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

/* ---------- first run ---------- */

.tutsheet { width: min(520px, 100%); text-align: center; }
.tutsheet h2 { margin: 12px 0 0; }
.tutstep {
  font-size: 11px; font-weight: 900; letter-spacing: .18em;
  color: var(--muted); margin-bottom: 8px;
}
.tutart {
  display: block; width: 100%; max-width: 420px; height: auto; margin: 0 auto;
  border-radius: 14px; border: 3px solid var(--edge);
  background: linear-gradient(180deg, #23163f, #150c28);
}
.tutbody { margin: 8px auto 4px; max-width: 40ch; line-height: 1.5; }
.tutsheet .row.buttons { justify-content: center; gap: 10px; margin-top: 14px; }
.tutsheet .play.small { padding: 12px 34px; font-size: 17px; }

/* Mastery earned this match, on the result screen. */
.mgain {
  display: flex; align-items: center; gap: 16px;
  margin-top: 14px; padding: 12px 16px;
  background: #1b0f34; border: 3px solid var(--edge); border-radius: 16px;
  box-shadow: inset 0 3px 10px rgba(0, 0, 0, .55);
}
.mgain canvas { width: 56px; height: 56px; flex: none; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .5)); }
.mgain-body { flex: 1; display: grid; justify-items: start; gap: 5px; }
.mgain-body .bar.wide { width: 100%; margin: 0; }
.mgain-title { font-size: 15px; font-weight: 900; text-shadow: var(--stroke); }
.mgain.promoted { border-color: var(--gold); background: #2c1f10; }
.mgain.promoted .mgain-title { color: var(--gold); }
.mgain.promoted canvas { animation: mgpop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes mgpop { from { transform: scale(.2) rotate(-90deg); } to { transform: none; } }
