:root {
  --cream: #FFF7E6;
  --cream2: #FFE2A8;
  --paper: #FFE9BE;
  --sand: #FFA400;
  --ochre: #E85D04;
  --rust: #FF3B30;
  --red: #E0002A;
  --green: #00A86B;
  --slate: #24303A;
  --ink: #0E1A2B;
  --gold: #FFD000;
  --blue: #0057FF;
  --pink: #FF2E93;
  --teal: #00D6C2;
  --display: 'Rye', 'Georgia', serif;
  --text: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --num: 'Bebas Neue', 'Impact', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--ink); }
body {
  font-family: var(--text);
  color: var(--cream);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: default;
}
button { font-family: var(--text); color: var(--ink); cursor: pointer; }

#stage { position: fixed; inset: 0; overflow: hidden; background: var(--ink); }
.scene { position: absolute; inset: 0; }

/* ---------------- open world ---------------- */

#world-scene { background: var(--ink); }
#camera { position: absolute; inset: 0; overflow: hidden; }
#world {
  position: absolute;
  left: 0; top: 0;
  width: 1536px; height: 1024px;
  transform-origin: 0 0;
  will-change: transform;
}
#map { position: absolute; inset: 0; width: 1536px; height: 1024px; display: block; }
#world-ink {
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(36, 28, 22, .5) .7px, transparent 1px);
  background-size: 5px 5px;
  opacity: .11;
  mix-blend-mode: multiply;
  pointer-events: none;
}
#world-static { position: absolute; inset: 0; pointer-events: none; }
#markers, #pickups { position: absolute; inset: 0; pointer-events: none; }

#ring-world {
  position: absolute;
  transform: translate(-50%, -50%);
  filter: drop-shadow(8px 12px 0 rgba(36, 28, 22, .35));
  z-index: 3;
}
#ring-world img { display: block; width: 100%; height: auto; }
#world-skyline {
  position: absolute;
  left: 50%;
  bottom: 167%;
  width: 150%;
  height: 26%;
  transform: translateX(-50%);
  z-index: -3;
  overflow: hidden;
  background: linear-gradient(180deg, #b9c9c4 0%, #b9c9c4 42%, #efe3c4 42%, #efe3c4 100%);
  clip-path: polygon(0 0, 100% 0, 100% 88%, 96% 92%, 91% 89%, 87% 94%, 81% 90%, 76% 95%, 70% 91%, 64% 96%, 58% 92%, 52% 96%, 46% 92%, 40% 96%, 34% 91%, 28% 95%, 22% 90%, 16% 95%, 10% 91%, 5% 95%, 0 90%);
  pointer-events: none;
}
#world-skyline svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#world-skyline::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0; height: 30%;
  background-image: radial-gradient(rgba(36,28,22,.22) 1px, transparent 1.4px);
  background-size: 5px 5px;
}
#ring-world .ring-crowd {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  width: 130%;
  height: auto;
  transform: translateX(-50%);
  z-index: -1;
  opacity: .95;
  filter: drop-shadow(4px 6px 0 rgba(36, 28, 22, .35));
  pointer-events: none;
}

.wrestler-token {
  position: absolute;
  display: block;
  transform: translate(-50%, -100%);
  transform-origin: 50% 100%;
  pointer-events: none;
  image-rendering: auto;
}
#player { z-index: 8; }
#player-tag {
  position: absolute;
  transform: translate(-50%, -100%);
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--cream);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  color: var(--ink);
  font: 700 10px/1 var(--text);
  letter-spacing: .06em;
  padding: 3px 6px 2px;
  white-space: nowrap;
  pointer-events: none;
}
#player-tag b { font: 400 13px/1 var(--num); }
#world.live-mode #player,
#world.live-mode #player-tag,
#world.live-mode #markers,
#world.live-mode #pickups { display: none; }
#player.shadow-box { filter: drop-shadow(3px 4px 0 rgba(36, 28, 22, .45)); }

.district-label {
  position: absolute;
  transform: translate(-50%, -50%) rotate(var(--rot, -2deg));
  font-family: var(--display);
  font-size: 25px;
  line-height: 1;
  color: var(--cream);
  text-shadow:
    -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink),
    -2px 0 0 var(--ink), 2px 0 0 var(--ink), 0 -2px 0 var(--ink), 0 2px 0 var(--ink),
    4px 4px 0 rgba(36, 28, 22, .55);
  white-space: nowrap;
  opacity: .95;
  pointer-events: none;
  z-index: 2;
}
.district-label.small { font-size: 18px; opacity: .8; }
.district-label.hud-hidden { opacity: 0 !important; }

.rival-marker {
  position: absolute;
  width: 0; height: 0;
  z-index: 6;
  pointer-events: auto;
}
.rival-figure {
  position: absolute;
  left: 0; bottom: -2px;
  width: 106px;
  transform: translate(-50%, 0);
  filter: drop-shadow(3px 4px 0 rgba(36, 28, 22, .55));
  pointer-events: none;
}
.rival-pin {
  position: absolute;
  left: 0; bottom: 128px;
  width: 58px;
  transform: translate(-50%, 0);
  filter: drop-shadow(3px 4px 0 rgba(36, 28, 22, .55));
  transition: transform .09s steps(2);
}
.rival-pin img {
  width: 100%;
  display: block;
  border-radius: 50%;
}
.rival-name {
  position: absolute;
  left: 0; bottom: 190px;
  transform: translate(-50%, 0);
  font: 700 13px/1 var(--text);
  letter-spacing: .03em;
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .1s;
}
.rival-marker.near .rival-name { opacity: 1; }
.rival-marker.near .rival-pin { transform: translate(-50%, -4px); }
.rival-marker.edge { visibility: hidden; }
.rival-marker.beaten { opacity: .55; }
.rival-marker.beaten .rival-pin { filter: grayscale(.85) drop-shadow(3px 4px 0 rgba(36, 28, 22, .45)); }
.rival-marker.beaten::after {
  content: 'KO';
  position: absolute;
  left: 0; top: -38px;
  transform: translateX(-50%) rotate(-12deg);
  font: 400 26px/1 var(--num);
  color: var(--red);
  text-shadow: 2px 2px 0 var(--cream);
  letter-spacing: .02em;
}
.challenge-ring {
  position: absolute;
  left: 0; bottom: -8px;
  width: 96px; height: 24px;
  transform: translateX(-50%);
  border: 3px solid var(--gold);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
.rival-marker.near .challenge-ring { opacity: .9; animation: ringPulse .6s steps(2) infinite; }
@keyframes ringPulse { 50% { transform: translateX(-50%) scale(1.08); } }

.pickup {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 5;
  pointer-events: none;
  animation: pickupBob 1.8s steps(2) infinite;
}
.pickup img { display: block; width: 100%; filter: drop-shadow(3px 3px 0 rgba(36, 28, 22, .45)); }
.pickup.taken { display: none; }
@keyframes pickupBob { 50% { transform: translate(-50%, -58%); } }
.pickup::after {
  content: '';
  position: absolute;
  left: 50%; bottom: -10px;
  width: 70%; height: 10px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(36, 28, 22, .28);
}

.challenge-beam {
  position: absolute;
  left: 50%; bottom: 100%;
  width: 3px; height: 46px;
  background: repeating-linear-gradient(to top, var(--gold) 0 6px, transparent 6px 11px);
  transform: translateX(-50%);
  margin-bottom: 4px;
}

#world-live { position: absolute; inset: 0; pointer-events: none; z-index: 7; }
#live-wait {
  position: absolute;
  transform: translate(-50%, -100%);
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  text-align: center;
}
#live-wait .lw-ring {
  display: block;
  width: 76px;
  height: 106px;
  border: 3px dashed var(--pink);
  border-radius: 40% 40% 30% 30%;
  background: rgba(255, 46, 147, .16);
  box-shadow: inset 0 0 0 5px rgba(0, 87, 255, .18);
  animation: lwPulse 1.1s steps(2) infinite;
}
#live-wait .lw-label {
  font: 700 10px/1 var(--text);
  letter-spacing: .06em;
  color: var(--ink);
  background: var(--gold);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  padding: 3px 6px 2px;
  white-space: nowrap;
  margin-top: 4px;
}
#live-wait .lw-sub {
  font: 400 14px/1 var(--num);
  letter-spacing: .08em;
  color: var(--pink);
  text-shadow: 2px 2px 0 var(--ink);
}
@keyframes lwPulse { 50% { transform: scale(1.06); opacity: .72; } }
.live-avatar {
  position: absolute;
  transform: translate(-50%, -100%);
  transform-origin: 50% 100%;
  pointer-events: none;
}
.live-avatar img { display: block; filter: drop-shadow(3px 4px 0 rgba(36, 28, 22, .5)); }
.live-tag {
  text-transform: uppercase;
  position: absolute;
  left: 50%; bottom: 100%;
  transform: translate(-50%, -6px);
  font: 700 13px/1 var(--text);
  letter-spacing: .05em;
  color: var(--ink);
  background: var(--cream);
  border: 2px solid var(--ink);
  padding: 3px 7px 2px;
  white-space: nowrap;
  box-shadow: 2px 2px 0 var(--ink);
}
.live-tag.me { background: var(--gold); }

/* ---------------- printed hud ---------------- */

#hud { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
#hud button, #lobby { pointer-events: auto; }

#brand {
  position: absolute;
  top: calc(var(--safe-t) + 16px);
  left: 10px;
  width: min(54vw, 780px);
  z-index: 2;
}
#brand::before {
  content: '';
  position: absolute;
  inset: -18px -60px -12px -10px;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 26% 32%, rgba(14,26,43,.94) 0%, rgba(14,26,43,.78) 52%, rgba(14,26,43,0) 82%);
}
#brand > * { position: relative; z-index: 1; }
#logo { display: block; width: 100%; height: auto; filter: drop-shadow(1px 1px 0 rgba(0,0,0,.15)); }
#subtitle {
  margin: 2px 0 0 6px;
  font: 700 clamp(10px, 1.4vw, 16px)/1 var(--text);
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
}
#crest-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 6px; }
.plate { position: relative; display: block; }
.plate img { display: block; width: 100%; }

#tally-plate { width: clamp(126px, 15vw, 205px); }
#tally-plate > img { width: 100%; }
.tally-patch {
  position: absolute; inset: 14% 6% 16% 6%;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  background-image: radial-gradient(rgba(36,28,22,.14) .6px, transparent 1px);
  background-size: 4px 4px;
}
.tally-label {
  font: 700 clamp(6px, .72vw, 9px)/1 var(--text);
  letter-spacing: .04em;
  color: var(--ink);
  opacity: .75;
  white-space: nowrap;
}
.tally-count {
  font: 400 clamp(16px, 2.1vw, 30px)/1 var(--num);
  color: var(--ink);
  letter-spacing: .02em;
}
.tally-count b { font-weight: 400; }
#district-badge { width: clamp(34px, 4.4vw, 56px); display: flex; flex-direction: column; align-items: center; }
.shield-wrap { position: relative; display: block; width: 100%; aspect-ratio: 240 / 322; isolation: isolate; }
.shield-wrap img { width: 100%; display: block; }
.shield-tint {
  position: absolute;
  inset: 0;
  background: var(--tint, #FF3B30);
  mix-blend-mode: color;
  opacity: .82;
  -webkit-mask-image: url('assets/plates/plate_shield.webp');
  mask-image: url('assets/plates/plate_shield.webp');
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  pointer-events: none;
}
#district-name {
  font: 700 clamp(7px, .8vw, 10px)/1.1 var(--text);
  letter-spacing: .05em;
  color: var(--cream);
  text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
  text-align: center;
  margin-top: 2px;
  max-width: 72px;
}
#belt-crest { width: clamp(58px, 7vw, 110px); display: flex; flex-direction: column; align-items: center; }
#belt-crest img { width: 100%; filter: drop-shadow(2px 2px 0 rgba(36,28,22,.55)); transition: filter .2s; }
#belt-crest.won img { filter: none; }
#belt-state {
  font: 700 clamp(6px, .7vw, 9px)/1 var(--text);
  letter-spacing: .05em;
  color: var(--cream);
  text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
  margin-top: 2px;
  white-space: nowrap;
}

#live-slot {
  position: absolute;
  top: calc(var(--safe-t) + 8px);
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 3;
}
.ink-btn {
  background: var(--cream2);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  color: var(--ink);
  padding: 5px 9px;
  font: 700 12px/1.05 var(--text);
  letter-spacing: .05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}
.ink-btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.ink-btn.round {
  width: 34px; height: 34px;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
  font: 700 18px/1 var(--display);
}
#live-btn { background: var(--blue); color: var(--cream); max-width: min(190px, 31vw); text-align: left; }
#live-btn .live-dot { background: var(--gold); }
.live-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--red);
  border: 1px solid var(--ink);
  flex: 0 0 auto;
}
.live-label { font-size: clamp(9px, 1vw, 12px); }

#roster {
  position: absolute;
  top: calc(var(--safe-t) + 108px);
  right: 18px;
  width: min(24vw, 172px);
  z-index: 2;
}
.roster-head {
  font: 700 10px/1 var(--text);
  letter-spacing: .03em;
  text-align: right;
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--ink);
  margin-bottom: 4px;
}
.roster-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.badge {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  background: none;
  padding: 0;
  filter: drop-shadow(3px 4px 0 rgba(36, 28, 22, .5));
}
.badge img { width: 100%; height: 100%; display: block; border-radius: 50%; }
.badge .bnum {
  position: absolute;
  left: -3px; top: -3px;
  width: 18px; height: 18px;
  display: grid;
  place-items: center;
  font: 400 13px/1 var(--num);
  color: var(--cream);
  background: var(--ink);
  border: 2px solid var(--cream);
  border-radius: 50%;
}
.badge.ko img { filter: grayscale(.85) brightness(.8); }
.badge.ko::after {
  content: 'KO';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 400 clamp(18px, 2.4vw, 34px)/1 var(--num);
  color: var(--red);
  transform: rotate(-12deg);
  text-shadow: 2px 2px 0 var(--cream), -1px -1px 0 var(--cream);
}
.badge.pulse { animation: badgePulse .5s steps(2) infinite; }
@keyframes badgePulse { 50% { transform: scale(1.06); } }

.shared-portal {
  position: absolute;
  transform: translate(-50%, -50%) rotate(-2deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--cream);
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  color: var(--ink);
  padding: 8px 14px 7px;
  pointer-events: auto;
  z-index: 7;
  cursor: pointer;
  white-space: nowrap;
}
.shared-portal .live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); border: 1px solid var(--ink); }
.shared-portal .sp-faces { display: flex; align-items: flex-end; justify-content: center; height: 42px; margin-top: 2px; }
.shared-portal .sp-faces img { height: 52px; width: auto; display: block; filter: drop-shadow(2px 2px 0 rgba(14,26,43,.45)); }
.shared-portal .sp-faces img + img { margin-left: -12px; transform: scaleX(-1); }
.shared-portal .sp-label { font: 700 14px/1 var(--text); letter-spacing: .05em; color: var(--pink); }
.shared-portal .sp-action { font: 400 28px/1 var(--num); letter-spacing: .02em; color: var(--blue); }
.shared-portal:active { transform: translate(-50%, -50%) rotate(-2deg) translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }

#live-card {
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 7px;
  text-align: center;
  background-image: radial-gradient(rgba(36,28,22,.12) .6px, transparent 1px);
  background-size: 4px 4px;
}
.live-card-label { font: 700 9px/1 var(--text); letter-spacing: .04em; color: var(--rust); }
#live-opponent { font: 400 19px/1.05 var(--num); letter-spacing: .03em; color: var(--ink); margin-top: 3px; word-break: break-word; }
#live-leave {
  margin-top: 5px;
  width: 100%;
  border: 2px solid var(--ink);
  background: var(--cream);
  box-shadow: 2px 2px 0 var(--ink);
  font: 700 9px/1 var(--text);
  letter-spacing: .06em;
  padding: 4px 3px;
  color: var(--ink);
}
#live-leave:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }

#lobby {
  position: absolute;
  bottom: calc(var(--safe-b) + 178px);
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, 82vw);
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  color: var(--ink);
  padding: 8px 10px 9px;
  z-index: 6;
  background-image: radial-gradient(rgba(36,28,22,.1) .6px, transparent 1px);
  background-size: 4px 4px;
}
.lobby-top { display: flex; justify-content: space-between; align-items: center; }
.lobby-kicker { font: 700 10px/1 var(--text); letter-spacing: .05em; color: var(--rust); }
#lobby-close { border: 0; background: none; font: 700 16px/1 var(--text); padding: 0 2px; }
#lobby-status { font: 700 clamp(12px, 1.6vw, 16px)/1.1 var(--text); letter-spacing: .03em; margin: 4px 0 7px; }
.lobby-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.lobby-actions button {
  border: 2px solid var(--ink);
  background: var(--sand);
  box-shadow: 2px 2px 0 var(--ink);
  font: 700 11px/1 var(--text);
  letter-spacing: .05em;
  padding: 5px 7px;
}
.lobby-actions button:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
#lobby-link {
  margin-top: 6px;
  font: 400 10px/1.2 var(--text);
  word-break: break-all;
  opacity: .7;
  max-height: 30px;
  overflow: hidden;
  user-select: text;
  -webkit-user-select: text;
}
#mini-live {
  position: absolute;
  bottom: calc(var(--safe-b) + 186px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  color: var(--ink);
  font: 700 10px/1 var(--text);
  letter-spacing: .12em;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  pointer-events: auto;
}

#hint-line {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-b) + 14px);
  transform: translateX(-50%);
  width: min(64vw, 760px);
  text-align: center;
  font: 700 clamp(8px, 1vw, 11px)/1.2 var(--text);
  letter-spacing: .08em;
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
  opacity: .9;
  pointer-events: none;
}

#toast-stack {
  position: absolute;
  top: calc(var(--safe-t) + 64px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: min(420px, 78vw);
  pointer-events: none;
  z-index: 8;
}
.toast {
  background: var(--cream);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  color: var(--ink);
  font: 700 clamp(10px, 1.1vw, 13px)/1.15 var(--text);
  letter-spacing: .04em;
  padding: 5px 10px;
  text-align: center;
  animation: toastIn .12s steps(2);
}
.toast.gold { background: var(--gold); }
.toast.red { background: var(--rust); color: var(--cream); }
@keyframes toastOut { to { opacity: 0; } }

/* ---------------- controls ---------------- */

#controls {
  position: absolute; inset: 0;
  z-index: 40;
  pointer-events: none;
}
#stick {
  position: absolute;
  left: max(14px, env(safe-area-inset-left, 0px));
  bottom: calc(var(--safe-b) + 16px);
  width: 126px; height: 126px;
  pointer-events: auto;
  touch-action: none;
  z-index: 2;
}
.stick-base {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 4px solid var(--ink);
  background: var(--slate);
  box-shadow: 4px 4px 0 rgba(36, 28, 22, .55), inset 0 0 0 7px #22303f, inset 0 0 0 10px var(--gold), inset 0 0 0 13px var(--ink);
  background-image: radial-gradient(rgba(243,231,211,.22) 1px, transparent 1.6px);
  background-size: 6px 6px;
}
.stick-base::after {
  content: '';
  position: absolute; inset: 16px;
  border-radius: 50%;
  border: 2px dashed rgba(243, 231, 211, .28);
}
.rivet { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--cream2); border: 1px solid var(--ink); opacity: .8; }
.rivet.r1 { left: 9px; top: 50%; transform: translateY(-50%); }
.rivet.r2 { right: 9px; top: 50%; transform: translateY(-50%); }
.rivet.r3 { top: 9px; left: 50%; transform: translateX(-50%); }
.rivet.r4 { bottom: 9px; left: 50%; transform: translateX(-50%); }
.stick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 54px; height: 52px;
  margin: -26px 0 0 -27px;
  border-radius: 50%;
  background: var(--red);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(36,28,22,.55);
  display: grid;
  place-items: center;
  transition: transform .04s linear;
}
.stick-knob i {
  display: block; width: 18px; height: 18px;
  background: var(--cream);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 94%, 50% 72%, 21% 94%, 32% 57%, 2% 35%, 39% 35%);
}
.control-label {
  position: absolute;
  left: 50%; bottom: calc(100% + 5px);
  transform: translate(-50%, 0);
  font: 700 9px/1 var(--text);
  letter-spacing: .06em;
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
  white-space: nowrap;
}

#fight-buttons {
  position: absolute;
  right: max(14px, env(safe-area-inset-right, 0px));
  bottom: calc(var(--safe-b) + 18px);
  width: 214px;
  height: 206px;
  pointer-events: none;
}
.fight-btn {
  position: absolute;
  width: 94px; height: 94px;
  border: 0; padding: 0; background: none;
  pointer-events: auto;
  touch-action: none;
  filter: drop-shadow(4px 4px 0 rgba(36, 28, 22, .6));
}
.fight-btn:active, .fight-btn.hit { transform: translate(3px, 3px); filter: drop-shadow(1px 1px 0 rgba(36,28,22,.6)); }
.fight-btn img { width: 100%; height: 100%; display: block; object-fit: contain; }
.fight-btn span {
  position: absolute;
  left: 50%; bottom: calc(100% + 4px);
  transform: translate(-50%, 0);
  background: var(--cream);
  border: 2px solid var(--ink);
  padding: 2px 6px 1px;
  font: 400 13px/1 var(--num);
  letter-spacing: .06em;
  color: var(--ink);
  white-space: nowrap;
  box-shadow: 2px 2px 0 var(--ink);
}
#btn-main { right: 0; bottom: 0; }
#btn-guard { right: 104px; bottom: 0; width: 66px; height: 66px; }
#btn-guard span { font-size: 11px; }
#btn-guard.holding { transform: translate(2px, 2px) scale(.94); filter: drop-shadow(0 0 0 transparent) brightness(1.22); }
#btn-guard.holding span { background: var(--gold); }

/* ---------------- fight scene ---------------- */

#fight-scene { background: var(--ink); z-index: 10; }
#fight-map {
  position: absolute; inset: -2%;
  background-image: url('assets/map_bold.webp');
  background-size: cover;
  background-position: center 62%;
}
#fight-wash { position: absolute; inset: 0; background: linear-gradient(160deg, rgba(176,104,44,.16), rgba(120,62,28,.12) 55%, rgba(18,12,9,.46)); }
#skyline {
  position: absolute;
  top: 6vh; left: 0; right: 0;
  height: 9vh;
  z-index: 1;
  background: linear-gradient(180deg, #b9c9c4 0%, #b9c9c4 42%, #efe3c4 42%, #efe3c4 100%);
  clip-path: polygon(0 0, 100% 0, 100% 88%, 96% 92%, 91% 89%, 87% 94%, 81% 90%, 76% 95%, 70% 91%, 64% 96%, 58% 92%, 52% 96%, 46% 92%, 40% 96%, 34% 91%, 28% 95%, 22% 90%, 16% 95%, 10% 91%, 5% 95%, 0 90%);
}
#skyline::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0; height: 30%;
  background-image: radial-gradient(rgba(36,28,22,.22) 1px, transparent 1.4px);
  background-size: 5px 5px;
}
#skyline svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#crowd-band {
  position: absolute;
  top: 15vh; left: 50%;
  width: 100vw; height: 35vh;
  transform: translateX(-50%);
  z-index: 2;
  overflow: hidden;
  background: transparent;
  background-image: radial-gradient(rgba(14, 26, 43, .17) 1px, transparent 1.4px);
  background-size: 5px 5px;
}
#crowd-band::after {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(36, 28, 22, .13) 1px, transparent 1.5px);
  background-size: 7px 7px;
  pointer-events: none;
}
#crowd-band img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  animation: crowdBob 1.1s steps(2) infinite;
  transform-origin: 50% 100%;
}
@keyframes crowdBob { 50% { transform: translateY(-5px) scaleY(.995); } }

#ring-wrap {
  position: absolute;
  left: 50%;
  bottom: -2vh;
  transform: translateX(-50%);
  z-index: 4;
}
#ring { width: 100%; display: block; }
#fighters { position: absolute; inset: 0; }
#limbs { position: absolute; inset: 0; pointer-events: none; z-index: 40; }
.limb {
  position: absolute;
  left: 0; top: 0;
  width: 0; height: 0;
  background: url(assets/wrestler/punch_arm.webp) left center / 100% 100% no-repeat;
  transform-origin: 0 50%;
  opacity: 0;
  filter: none;
  will-change: transform, opacity;
}
.limb.rival {
  filter: hue-rotate(75deg) saturate(.9) brightness(1.02);
}
.fighter {
  position: absolute;
  width: 0; height: 0;
  will-change: transform;
}
.fighter img {
  position: absolute;
  left: 0; bottom: 0;
  display: block;
  transform-origin: 50% 100%;
  pointer-events: none;
}
.fighter.hit img { filter: drop-shadow(6px 0 0 rgba(193, 39, 45, .75)); }
.fighter.flash img { filter: brightness(1.35) saturate(1.2) drop-shadow(4px 4px 0 rgba(36,28,22,.55)); }

#fx { position: absolute; inset: 0; pointer-events: none; z-index: 9; overflow: visible; }
.burst {
  position: absolute;
  width: 90px; height: 90px;
  margin: -45px 0 0 -45px;
  background-image: radial-gradient(var(--ink) 2px, transparent 2.4px);
  background-size: 7px 7px;
  clip-path: polygon(50% 0, 61% 29%, 88% 12%, 79% 39%, 100% 50%, 79% 61%, 88% 88%, 61% 71%, 50% 100%, 39% 71%, 12% 88%, 21% 61%, 0 50%, 21% 39%, 12% 12%, 39% 29%);
  animation: burstPop .24s steps(3) forwards;
}
.burst.red { background-image: radial-gradient(var(--red) 2px, transparent 2.4px); }
.burst.cream { background-image: radial-gradient(var(--cream) 2px, transparent 2.4px); }
@keyframes burstPop { from { transform: scale(.4) rotate(0); opacity: 1; } to { transform: scale(1.7) rotate(20deg); opacity: 0; } }
.dmg-num {
  position: absolute;
  transform: translate(-50%, -50%);
  font: 400 34px/1 var(--num);
  color: var(--gold);
  text-shadow: 3px 3px 0 var(--ink), -2px -2px 0 var(--ink);
  animation: dmgUp .55s steps(4) forwards;
  z-index: 7;
  pointer-events: none;
}
.dmg-num.miss { color: var(--cream); font-size: 20px; letter-spacing: .04em; }
@keyframes dmgUp { to { transform: translate(-50%, -170%); opacity: 0; } }
.dust {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ochre);
  border: 2px solid var(--ink);
  animation: dustFly .5s steps(4) forwards;
}
@keyframes dustFly { to { transform: translate(var(--dx), var(--dy)) scale(.4); opacity: 0; } }

#guard-call {
  position: absolute;
  z-index: 20;
  transform: translate(-50%, -100%) rotate(-4deg);
  font: 400 clamp(18px, 2.4vw, 32px)/1 var(--num);
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 3px 10px 1px;
  letter-spacing: .05em;
  pointer-events: none;
  white-space: nowrap;
}

#fight-hud {
  position: absolute;
  left: 0; right: 0;
  top: calc(var(--safe-t) + 8px);
  z-index: 8;
}
.corner-hud {
  position: absolute;
  top: 0;
  left: max(10px, env(safe-area-inset-left, 0px));
  width: min(37vw, 380px);
}
.corner-hud.right { left: auto; right: max(10px, env(safe-area-inset-right, 0px)); text-align: right; }
#hud-b .hud-name { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
#rival-portrait {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--cream);
  box-shadow: 3px 3px 0 var(--ink);
  object-fit: cover;
  display: block;
  filter: saturate(.9) contrast(1.05);
}
.hud-name {
  text-transform: uppercase;
  font: 700 clamp(11px, 1.5vw, 16px)/1 var(--text);
  letter-spacing: .06em;
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar {
  position: relative;
  height: 24px;
  border: 3px solid var(--ink);
  background: var(--cream2);
  box-shadow: 3px 3px 0 rgba(36, 28, 22, .65);
  overflow: hidden;
  clip-path: polygon(0 8%, 3% 0, 30% 4%, 55% 0, 78% 5%, 97% 0, 100% 20%, 98% 55%, 100% 92%, 96% 100%, 72% 96%, 48% 100%, 24% 95%, 4% 100%, 0 76%);
}
.bar i {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 100%;
  background: var(--red);
  background-image: radial-gradient(rgba(36,28,22,.25) 1px, transparent 1.4px);
  background-size: 5px 5px;
  transition: width .1s steps(3);
}
.corner-hud.right .bar i { left: auto; right: 0; }
.bar-label {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  font: 400 10px/1 var(--num);
  letter-spacing: .08em;
  color: var(--ink);
  opacity: .55;
}
.corner-hud.right .bar-label { right: auto; left: 6px; }
.bar.stam { height: 7px; margin-top: 3px; border-width: 2px; box-shadow: 2px 2px 0 rgba(36,28,22,.55); }
.bar.stam i { background: var(--gold); background-image: none; }

#timer-plate {
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: clamp(58px, 7.6vw, 96px);
  z-index: 2;
}
#timer-plate img { width: 100%; display: block; filter: drop-shadow(3px 3px 0 rgba(36,28,22,.6)); }
.timer-slate {
  position: absolute;
  left: 19%; right: 19%; top: 19%; bottom: 21%;
  background: var(--ink);
  display: grid;
  place-items: center;
  border: 1px solid rgba(217,169,60,.4);
  box-shadow: inset 0 0 0 2px rgba(36,28,22,.7);
  background-image: radial-gradient(rgba(243,231,211,.08) .6px, transparent 1px);
  background-size: 3px 3px;
}
.timer-slate span {
  font: 400 clamp(17px, 2.4vw, 31px)/1 var(--num);
  color: var(--cream);
  letter-spacing: .03em;
  text-shadow: 2px 2px 0 var(--ink);
}

#fight-caption {
  display: block;
  position: absolute;
  left: 50%;
  top: calc(var(--safe-t) + 62px);
  transform: translateX(-50%);
  text-align: center;
  z-index: 9;
  pointer-events: none;
  z-index: 3;
  pointer-events: none;
  white-space: nowrap;
}
#caption-main {
  display: block;
  font: 400 clamp(20px, 2.6vw, 34px)/1 var(--display);
  color: var(--cream);
  text-shadow: 3px 3px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink);
}
#caption-sub {
  display: block;
  font: 700 10px/1.2 var(--text);
  letter-spacing: .16em;
  color: var(--sand);
  text-shadow: 2px 2px 0 var(--ink);
}

#combo-shot {
  position: absolute;
  right: 9%;
  top: 26%;
  transform: rotate(6deg);
  z-index: 8;
  text-align: center;
  pointer-events: none;
}
#combo-shot b {
  display: block;
  font: 400 clamp(30px, 5vw, 64px)/1 var(--num);
  color: var(--gold);
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 3px 3px 0 var(--ink);
}
#combo-shot span {
  font: 700 clamp(9px, 1.1vw, 13px)/1 var(--text);
  letter-spacing: .1em;
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--ink);
}

/* ---------------- modal cards ---------------- */

#help, #result, #champ {
  position: absolute; inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: rgba(36, 28, 22, .55);
  padding: 14px;
}
.help-card, .result-card, .champ-card {
  position: relative;
  touch-action: pan-y;
  width: min(560px, 92vw);
  max-height: 88vh;
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  border: 4px solid var(--ink);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, .45);
  padding: clamp(16px, 3vw, 28px);
  background-image: radial-gradient(rgba(36,28,22,.12) .6px, transparent 1px);
  background-size: 4px 4px;
  clip-path: polygon(0 1%, 4% 0, 14% 1.2%, 29% 0, 45% 1%, 61% 0, 78% 1.2%, 92% 0, 100% 1.5%, 99% 22%, 100% 44%, 99% 67%, 100% 87%, 99% 100%, 84% 99%, 68% 100%, 51% 99%, 34% 100%, 17% 99%, 0 100%, 1% 74%, 0 50%, 1% 25%);
}
.help-kicker, .result-kicker, .champ-kicker {
  font: 700 11px/1 var(--text);
  letter-spacing: .05em;
  color: var(--rust);
  text-transform: uppercase;
}
.help-card h2, .result-card h2, .champ-card h2 {
  font: 400 clamp(24px, 4vw, 40px)/1 var(--display);
  margin: 6px 0 12px;
  color: var(--ink);
}
.help-card p {
  font: 400 clamp(13px, 1.5vw, 16px)/1.35 var(--text);
  margin: 0 0 9px;
  letter-spacing: .015em;
}
.help-card p b { font-weight: 700; letter-spacing: .05em; }
.help-card button, .result-card button, .champ-card button {
  margin-top: 10px;
  border: 3px solid var(--ink);
  background: var(--gold);
  box-shadow: 4px 4px 0 var(--ink);
  font: 700 14px/1 var(--text);
  letter-spacing: .08em;
  padding: 9px 16px;
  text-transform: uppercase;
}
.help-card button:active, .result-card button:active, .champ-card button:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }

.result-card { text-align: center; }
.result-card h2 { font-size: clamp(38px, 6vw, 66px); margin: 4px 0 2px; color: var(--red); -webkit-text-stroke: 1px var(--ink); }
#result-winner { font: 400 clamp(20px, 2.6vw, 30px)/1 var(--num); letter-spacing: .04em; margin: 2px 0 10px; }
.result-stats {
  display: flex; justify-content: center; gap: 14px; flex-wrap: wrap;
  border-top: 3px solid var(--ink); border-bottom: 3px solid var(--ink);
  padding: 8px 0; margin: 8px 0;
  font: 700 12px/1.2 var(--text); letter-spacing: .05em;
}
.result-stats b { font: 400 20px/1 var(--num); display: block; letter-spacing: .03em; }

.champ-card { text-align: center; background: #101828; color: var(--cream); border-color: var(--gold); }
.champ-card h2 { color: var(--gold); text-shadow: 3px 3px 0 var(--ink); }
#champ-belt { width: min(440px, 84%); display: block; margin: 8px auto 2px; filter: drop-shadow(6px 8px 0 rgba(0,0,0,.45)); }
#champ-name { font: 400 clamp(19px, 2.4vw, 28px)/1 var(--num); letter-spacing: .06em; margin: 2px 0 4px; color: var(--cream); }
.champ-kicker { color: var(--gold); }

/* ---------------- splash, grain, transition ---------------- */

#splash {
  position: absolute; inset: 0;
  z-index: 80;
  background: var(--rust);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  transition: opacity .2s steps(2);
}
#splash img { width: min(760px, 82vw); display: block; filter: drop-shadow(6px 8px 0 rgba(36,28,22,.5)); }
.splash-line {
  font: 700 13px/1 var(--text);
  letter-spacing: .06em;
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--ink);
}
#splash.gone { opacity: 0; pointer-events: none; }

#transition {
  position: absolute; inset: 0;
  z-index: 55;
  pointer-events: none;
  background: var(--ink);
  transform: translateX(-110%);
  clip-path: polygon(0 0, 96% 0, 100% 22%, 97% 46%, 100% 74%, 95% 100%, 0 100%);
}
#transition.run { animation: wipe .34s steps(6) forwards; }
@keyframes wipe {
  0% { transform: translateX(-110%); }
  45% { transform: translateX(0); }
  55% { transform: translateX(0); }
  100% { transform: translateX(110%); }
}

#paper {
  position: absolute; inset: 0;
  z-index: 49;
  pointer-events: none;
  background-image: url('assets/paper_grain.webp');
  background-size: cover;
  background-position: center;
  mix-blend-mode: multiply;
  opacity: .26;
}
#grain {
  position: absolute; inset: 0;
  z-index: 50;
  pointer-events: none;
  background-image:
    radial-gradient(rgba(36,28,22,.22) .5px, transparent .9px),
    repeating-linear-gradient(91deg, rgba(36,28,22,.035) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(0deg, rgba(243,231,211,.05) 0 1px, transparent 1px 9px);
  background-size: 4px 4px, 100% 100%, 100% 100%;
  opacity: .45;
  mix-blend-mode: multiply;
}
#grain::after {
  content: '';
  position: absolute; inset: 0;
  box-shadow: inset 0 0 0 12px rgba(0, 87, 255, .18), inset 0 0 0 34px rgba(255, 46, 147, .10);
}


/* mode switches */
body.in-bout #brand,
body.in-bout #live-slot,
body.in-bout #roster,
body.in-bout #lobby,
body.in-bout #mini-live,
body.in-bout #hint-line { display: none !important; }
body.in-bout #btn-guard { display: flex; }
body.live-mode #live-btn { display: none; }
body.live-mode #brand { width: min(30vw, 360px); top: calc(var(--safe-t) + 8px); }
body.live-mode #brand #subtitle { display: none; }

.corner-hud.you .hud-name { color: var(--gold); }

#splash img { max-width: 92vw; }

/* ---------------- responsive ---------------- */


@media (max-width: 760px) {
  #brand { width: 88vw; }
  #crest-row { margin-top: 4px; gap: 6px; }
  #tally-plate { width: 122px; }
  .tally-label { font-size: 6px; }
  .tally-count { font-size: 17px; }
  #district-badge { width: 40px; }
  #district-name { font-size: 8px; max-width: 66px; }
  #belt-crest { width: 84px; }
  #belt-state { display: block; font-size: 6px; margin-top: 1px; }
  #live-btn { max-width: 34vw; }
  #live-slot { top: calc(var(--safe-t) + 86px); }
  #live-btn { max-width: 40vw; }
  #roster { top: calc(var(--safe-t) + 196px); width: auto; }
  .roster-head { display: none; }
  .roster-grid { grid-template-columns: 1fr 1fr; gap: 4px; }
  .badge { width: 34px; }
  .badge .bnum { width: 14px; height: 14px; font-size: 10px; border-width: 1px; }
  .badge.ko::after { font-size: 17px; }
  #lobby { width: 82vw; }
  #hint-line {
    display: block;
    bottom: calc(var(--safe-b) + 150px);
    width: auto;
    max-width: 88vw;
    white-space: normal;
    background: var(--cream);
    border: 2px solid var(--ink);
    box-shadow: 2px 2px 0 var(--ink);
    color: var(--ink);
    text-shadow: none;
    padding: 3px 7px;
    font: 700 9.5px/1.15 var(--text);
    letter-spacing: .04em;
  }
  #stick { width: 112px; height: 112px; left: 10px; bottom: calc(var(--safe-b) + 12px); }
  .stick-knob { width: 48px; height: 46px; margin: -23px 0 0 -24px; }
  .control-label { font-size: 8px; }
  #fight-buttons { right: 10px; bottom: calc(var(--safe-b) + 14px); width: 186px; height: 182px; }
  .fight-btn { width: 82px; height: 82px; }
  #btn-main { right: 0; bottom: 0; width: 82px; height: 82px; }
  #btn-guard { right: 88px; bottom: 0; width: 58px; height: 58px; }
  .fight-btn span { font-size: 11px; padding: 2px 5px 1px; }
  #btn-guard span { font-size: 9px; }
  .corner-hud { width: 39vw; }
  .bar { height: 20px; }
  .hud-name { font-size: 10px; }
  #fight-caption { top: calc(var(--safe-t) + 62px); bottom: auto; }
  #caption-main { font-size: 18px; }
  #toast-stack { top: calc(var(--safe-t) + 100px); }
}

@media (max-aspect-ratio: 1 / 1) {
  #crowd-band { top: 12vh; height: 46vh; }
  #ring-wrap { bottom: 25vh; }
}

@media (max-width: 760px) and (max-height: 680px) {
  #roster { top: calc(var(--safe-t) + 170px); }
  .badge { width: 30px; }
  .roster-grid { gap: 3px; }
  .badge .bnum { width: 12px; height: 12px; font-size: 9px; border-width: 1px; }
}

@media (max-width: 420px) {
  #live-btn { max-width: 44vw; }
  #crest-row { gap: 4px; }
  #tally-plate { width: 104px; }
  #district-badge { width: 36px; }
  #belt-crest { width: 96px; }
  #district-name { font-size: 7.5px; }
  #fight-hud .corner-hud { width: 40vw; }
  #timer-plate { width: 52px; }
  .timer-slate span { font-size: 16px; }
}

@media (min-width: 1100px) {
  #roster { top: calc(var(--safe-t) + 110px); width: min(21vw, 180px); }
  .badge .bnum { width: 20px; height: 20px; font-size: 14px; }
}

@media (max-height: 520px) {
  #ring-world .ring-crowd { display: none; }
  #hint-line {
    bottom: calc(var(--safe-b) + 4px);
    width: min(72vw, 700px);
    white-space: normal;
  }
  #skyline { top: 10vh; height: 8vh; }
  #crowd-band { top: 18vh; height: 30vh; }
  #brand { width: min(46vw, 520px); top: calc(var(--safe-t) + 18px); }
  #crest-row { margin-top: 2px; }
  #roster { top: calc(var(--safe-t) + 88px); width: min(13vw, 88px); }
  .badge .bnum { width: 14px; height: 14px; font-size: 10px; border-width: 1px; }
  .badge.ko::after { font-size: 16px; }
  .roster-grid { gap: 4px; }
  .roster-head { display: none; }
  #stick { width: 100px; height: 100px; }
  .stick-knob { width: 42px; height: 40px; margin: -20px 0 0 -21px; }
  #fight-buttons { width: 168px; height: 176px; }
  #fight-buttons .fight-btn { width: 76px; height: 76px; }
  #btn-main { right: 0; bottom: 0; width: 78px; height: 78px; }
  #btn-guard { right: 84px; bottom: 0; width: 52px; height: 52px; }
  #lobby { width: min(330px, 56vw); }
  #toast-stack { top: calc(var(--safe-t) + 52px); }
}
