:root {
  --iron: #221E1C;
  --gunmetal: #3B4145;
  --cold: #2E4450;
  --rust: #B4592A;
  --amber: #E8A33D;
  --chalk: #EAE3D2;
  --red: #A8302A;
  --brass: #C08B3E;
  --topPad: clamp(104px, 16.1vh, 152px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: #0e0c0b;
  overflow: hidden;
}

body {
  color: var(--chalk);
  font-family: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

img { pointer-events: none; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  isolation: isolate;
  background: #0e0c0b;
}

.room { position: absolute; inset: 0; z-index: 0; overflow: hidden; }

.wall {
  position: absolute;
  inset: 0;
  background: #221E1C url(assets/workshop_wall.webp) no-repeat;
  background-size: cover;
  background-position: 42% 20%;
  filter: brightness(.9) saturate(.96);
}

.floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 58%;
  background: #1b1815 url(assets/brawl_pit_floor.webp) no-repeat;
  background-size: 100% 100%;
  background-position: center bottom;
  filter: brightness(.9) saturate(.95);
  box-shadow: inset 0 22px 30px -12px rgba(10, 8, 7, .75);
}

.roomShade {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 58% 40%, rgba(0, 0, 0, 0) 34%, rgba(7, 6, 5, .58) 100%),
    linear-gradient(90deg, rgba(7, 9, 11, .34), rgba(0, 0, 0, 0) 26%, rgba(0, 0, 0, 0) 74%, rgba(7, 9, 11, .28));
  pointer-events: none;
}

.wallGauge {
  position: absolute;
  top: 6px;
  right: 10px;
  width: clamp(72px, 8.4vw, 126px);
  height: auto;
  z-index: 2;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, .65));
}

.bench {
  position: absolute;
  left: 0;
  bottom: 0;
  width: min(48%, 860px);
  height: auto;
  z-index: 2;
  filter: drop-shadow(0 -10px 18px rgba(0, 0, 0, .55));
}

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px clamp(10px, 1.1vw, 18px) 0;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand {
  position: relative;
  width: clamp(184px, 20vw, 292px);
  transform: rotate(-.7deg);
  filter: drop-shadow(0 16px 22px rgba(0, 0, 0, .62));
}

.brandPlate {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2.25 / 1;
  object-fit: fill;
  border: 1px solid #0a0908;
}

.brandInk {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 7% 8% 8%;
}

.brandInk h1 {
  margin: 0;
  font-family: 'Stardos Stencil', Impact, sans-serif;
  font-weight: 700;
  line-height: .94;
  color: var(--chalk);
  text-shadow: 0 2px 0 #1a1512, 0 0 12px rgba(232, 163, 61, .12);
}

.brandInk .l1 {
  display: block;
  font-size: clamp(11px, 1.32vw, 19px);
  letter-spacing: .06em;
  color: #d8ccb4;
}

.brandInk .l2 {
  display: block;
  font-size: clamp(14px, 1.62vw, 24px);
  letter-spacing: .015em;
}

.brandInk p {
  margin: 5px 0 0;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: clamp(6px, .58vw, 9px);
  letter-spacing: .19em;
  color: #c3b69d;
}

.readouts {
  display: flex;
  align-items: flex-start;
  gap: clamp(5px, .8vw, 12px);
  margin-left: auto;
  padding-right: clamp(76px, 9vw, 136px);
}

.meters {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: clamp(124px, 15vw, 214px);
  padding: 6px 8px;
  background: linear-gradient(180deg, rgba(32, 29, 26, .92), rgba(18, 16, 15, .94));
  border: 1px solid #0a0908;
  box-shadow: inset 0 1px 0 rgba(116, 101, 81, .35), 0 8px 16px rgba(0, 0, 0, .45);
}

.meterTop {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.meterName {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: clamp(8px, .74vw, 11px);
  letter-spacing: .14em;
  color: #cfc3ab;
  white-space: nowrap;
}

.meterNum {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: clamp(9px, .82vw, 12px);
  color: var(--chalk);
}

.chalkTrack {
  height: clamp(5px, .58vw, 8px);
  background: repeating-linear-gradient(90deg, rgba(234, 227, 210, .12) 0 4px, rgba(0, 0, 0, 0) 4px 7px);
  border: 1px solid rgba(234, 227, 210, .18);
}

.chalkFill {
  height: 100%;
  width: 100%;
  background: repeating-linear-gradient(90deg, #EAE3D2 0 20px, #cfc4ad 20px 22px, #EAE3D2 22px 42px);
  transition: width .12s linear;
}

.chalkFill.rival {
  background: repeating-linear-gradient(90deg, #B4592A 0 18px, #8f4320 18px 20px, #B4592A 20px 38px);
}

.miniStats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  background: linear-gradient(180deg, rgba(32, 29, 26, .92), rgba(18, 16, 15, .94));
  border: 1px solid #0a0908;
  box-shadow: inset 0 1px 0 rgba(116, 101, 81, .35), 0 8px 16px rgba(0, 0, 0, .45);
}

.mini {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: clamp(64px, 6.8vw, 88px);
}

.mini span {
  font-size: clamp(7px, .62vw, 9px);
  letter-spacing: .13em;
  color: #cfc3ab;
}

.mini b {
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(9px, .82vw, 12px);
  color: var(--chalk);
}

.soundLever {
  position: relative;
  width: clamp(60px, 7vw, 92px);
  aspect-ratio: 532 / 323;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .55));
}

.soundLever img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.soundLever.off { filter: grayscale(1) brightness(.55) drop-shadow(0 8px 12px rgba(0, 0, 0, .55)); }

.soundWord {
  position: absolute;
  left: 50%;
  bottom: -12px;
  transform: translateX(-50%);
  font-size: clamp(6px, .52vw, 8px);
  letter-spacing: .13em;
  color: #cfc3ab;
  white-space: nowrap;
}

.main {
  position: absolute;
  inset: var(--topPad) 0 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(286px, 34vw) 1fr;
  gap: clamp(4px, .7vw, 12px);
  padding: 0 clamp(8px, 1vw, 16px) max(8px, env(safe-area-inset-bottom));
}

.bay {
  position: relative;
  z-index: 12;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: clamp(4px, .72vh, 8px);
  min-height: 0;
  padding: clamp(7px, .85vw, 12px);
  background:
    linear-gradient(180deg, rgba(18, 16, 14, .68), rgba(14, 12, 11, .8)),
    url(assets/panel_kit_01_bolted_panel.webp) center / 100% 100% no-repeat;
  border: 1px solid #090807;
  box-shadow: inset 0 0 64px rgba(0, 0, 0, .62), 0 18px 34px rgba(0, 0, 0, .42);
  overflow: hidden;
}

.bayTitle {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 0 0 auto;
}

.bayTitle h2 {
  margin: 0;
  font-family: 'Stardos Stencil', Impact, sans-serif;
  font-weight: 700;
  font-size: clamp(15px, 1.55vw, 23px);
  letter-spacing: .08em;
  color: var(--chalk);
  text-shadow: 0 2px 0 #120f0d;
}

.hazardRule {
  display: block;
  width: 100%;
  height: clamp(10px, .95vw, 14px);
  object-fit: fill;
  opacity: .7;
  border: 1px solid rgba(0, 0, 0, .45);
}

.buildView {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: clamp(4px, .72vh, 8px);
  min-height: 0;
  flex: 1;
}

.cradleWrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1024 / 449;
  flex: 0 0 auto;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, .52));
}

.cradleArt {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.slots {
  position: absolute;
  left: 23.5%;
  right: 19.5%;
  top: 29%;
  height: 51%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: 100%;
  gap: 1.5%;
}

.slot {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border: 1px dashed rgba(234, 227, 210, .14);
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.slot img {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  padding: 12% 8% 22%;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .62));
}

.slot.just { animation: seatDrop .34s ease-out; }

@keyframes seatDrop {
  0% { transform: translateY(-5px); }
  55% { transform: translateY(3px); }
  100% { transform: translateY(0); }
}

.slotTag {
  position: absolute;
  left: 50%;
  bottom: -1px;
  transform: translateX(-50%);
  padding: 0 3px;
  font-size: clamp(6px, .5vw, 8px);
  line-height: 1.25;
  letter-spacing: .1em;
  color: var(--chalk);
  background: rgba(11, 9, 8, .82);
  border: 1px solid rgba(234, 227, 210, .18);
  white-space: nowrap;
}

.loadout {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  flex: 0 0 auto;
  padding: 3px 4px;
  background: linear-gradient(180deg, #272320, #151312);
  border: 1px solid #090807;
  box-shadow: inset 0 1px 0 rgba(116, 101, 81, .3);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
  border-right: 1px solid rgba(234, 227, 210, .09);
}

.stat:last-child { border-right: 0; }

.stat span {
  font-size: clamp(6px, .5vw, 8px);
  letter-spacing: .12em;
  color: #b7ab95;
}

.stat b {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: clamp(9px, .8vw, 12px);
  color: var(--chalk);
}

.trayWrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 0 0 auto;
}

.trayHead {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: clamp(6px, .54vw, 9px);
  letter-spacing: .15em;
  color: #b7ab95;
}

.tray {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(2px, .3vw, 5px);
  padding: clamp(3px, .35vw, 5px);
  background: linear-gradient(180deg, #2d2a26, #161413);
  border: 2px solid #090807;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, .8), 0 2px 0 rgba(92, 82, 66, .32);
}

.partBtn {
  position: relative;
  aspect-ratio: 1 / 1;
  min-width: 0;
  padding: 2px;
  background: radial-gradient(ellipse at 50% 38%, #39332d, #1a1816 72%);
  border: 1px solid rgba(234, 227, 210, .11);
  overflow: hidden;
  transition: transform .06s;
}

.partBtn img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .55));
}

.partBtn .partName {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1px 0;
  font-size: clamp(5px, .47vw, 7px);
  letter-spacing: .06em;
  text-align: center;
  color: var(--chalk);
  background: rgba(9, 8, 7, .8);
}

.partBtn.seated {
  outline: 2px solid rgba(232, 163, 61, .62);
  outline-offset: -2px;
  background: radial-gradient(ellipse at 50% 38%, #4a3b29, #1e1915 72%);
}

.partBtn.seated::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 4px;
  height: 4px;
  background: var(--amber);
  border-radius: 50%;
}

.partBtn:active { transform: translateY(2px); }

.sendBtn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  height: clamp(48px, 7vh, 68px);
  padding: 0 12px;
  overflow: hidden;
  background: linear-gradient(180deg, #2b2723, #151312);
  border: 2px solid #090807;
  box-shadow: inset 0 1px 0 rgba(116, 101, 81, .35), 0 10px 16px rgba(0, 0, 0, .45);
  transition: transform .06s;
}

.sendBtn:active { transform: translateY(3px); }

.sendBtn img:first-child {
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  width: clamp(38px, 5.2vh, 54px);
  height: clamp(38px, 5.2vh, 54px);
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .6));
}

.sendWord {
  position: relative;
  z-index: 3;
  flex: 1;
  text-align: center;
  font-family: 'Stardos Stencil', Impact, sans-serif;
  font-weight: 700;
  font-size: clamp(15px, 1.5vw, 23px);
  letter-spacing: .1em;
  color: var(--chalk);
  text-shadow: 0 2px 0 #120f0d;
}

.sendStripe {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 38%;
  object-fit: fill;
  opacity: .26;
  z-index: 1;
}

.sendBtn:disabled { filter: grayscale(.55) brightness(.72); }

.bayHint {
  margin: 0;
  flex: 0 0 auto;
  text-align: center;
  font-size: clamp(7px, .63vw, 10px);
  line-height: 1.2;
  letter-spacing: .05em;
  color: #b7ab95;
}

.battlePanel {
  display: none;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  gap: clamp(4px, .9vh, 10px);
  padding-top: 2px;
}

[data-mode="battle"] .buildView { display: none; }
[data-mode="battle"] .battlePanel { display: flex; }
[data-mode="battle"] .bayHint { display: none; }

.battleTop {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.fightWord {
  font-family: 'Stardos Stencil', Impact, sans-serif;
  font-weight: 700;
  font-size: clamp(28px, 3vw, 44px);
  line-height: .9;
  letter-spacing: .1em;
  color: var(--chalk);
  text-shadow: 0 3px 0 #100d0b;
}

.weaponWord {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: clamp(9px, .92vw, 13px);
  letter-spacing: .13em;
  color: var(--amber);
}

.rivalTag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(8px, .75vw, 11px);
  letter-spacing: .17em;
  color: #c1b49c;
}


.weaponCard {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.2vw, 16px);
  min-height: 0;
  padding: clamp(7px, 1vh, 12px);
  border: 1px solid rgba(234, 227, 210, .14);
  background: linear-gradient(180deg, rgba(31, 28, 25, .62), rgba(12, 11, 10, .46));
  box-shadow: inset 0 1px 0 rgba(116, 101, 81, .22);
}

.weaponDisc {
  flex: 0 0 34%;
  max-width: 130px;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(234, 227, 210, .24);
  border-radius: 50%;
}

.weaponDisc img {
  width: 90%;
  height: 90%;
  object-fit: contain;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .6));
}

.weaponMeta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.weaponNameBig {
  font-family: 'Stardos Stencil', Impact, sans-serif;
  font-weight: 700;
  font-size: clamp(13px, 1.45vw, 19px);
  letter-spacing: .05em;
  line-height: 1;
  color: var(--chalk);
  margin-bottom: 3px;
}

.weaponStat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 1px 0;
  border-bottom: 1px dotted rgba(234, 227, 210, .16);
}

.weaponStat span {
  font-size: clamp(6px, .58vw, 8px);
  letter-spacing: .12em;
  color: #b7ab95;
}

.weaponStat b {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: clamp(8px, .78vw, 11px);
  color: var(--chalk);
}

.tallyReadout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  flex: 0 0 auto;
}

.tallyReadout div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px;
  border: 1px solid rgba(234, 227, 210, .14);
  background: rgba(13, 12, 10, .45);
}

.tallyReadout span {
  font-size: clamp(6px, .54vw, 8px);
  letter-spacing: .1em;
  color: #b7ab95;
}

.tallyReadout b {
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(9px, .82vw, 12px);
  color: var(--amber);
}

[data-mode="battle"] .vsMark,
[data-mode="battle"] .pitNote {
  display: none;
}


.battleLoadout {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  flex: 0 0 auto;
  padding: 4px;
  border: 1px solid rgba(234, 227, 210, .14);
  background: linear-gradient(180deg, rgba(31, 28, 25, .6), rgba(12, 11, 10, .45));
}

.blItem {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: 2px 1px 1px;
  border: 1px solid rgba(234, 227, 210, .12);
  background: radial-gradient(ellipse at 50% 38%, #332e28, #171513 74%);
}

.blItem img {
  display: block;
  width: 100%;
  height: clamp(30px, 5.2vh, 52px);
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .55));
}

.blItem span {
  font-size: clamp(5.5px, .55vw, 8px);
  letter-spacing: .1em;
  color: #b7ab95;
  white-space: nowrap;
}

.weaponLine {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex: 0 0 auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8px;
  letter-spacing: .04em;
  color: var(--amber);
}

.controlRow {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(8px, 1.4vw, 18px);
  margin-top: auto;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  width: clamp(128px, 15vw, 176px);
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
}

.padBtn {
  position: relative;
  background: linear-gradient(180deg, #35312b, #1a1816);
  border: 1px solid #090807;
  box-shadow: inset 0 1px 0 rgba(116, 101, 81, .35), 0 4px 6px rgba(0, 0, 0, .4);
}

.padBtn:active, .padBtn.down {
  transform: translateY(2px);
  box-shadow: inset 0 2px 7px rgba(0, 0, 0, .7);
}

.padBtn.up { grid-column: 2; grid-row: 1; }
.padBtn.left { grid-column: 1; grid-row: 2; }
.padBtn.center { grid-column: 2; grid-row: 2; background: #14120f; box-shadow: inset 0 0 6px rgba(0, 0, 0, .9); pointer-events: none; }
.padBtn.right { grid-column: 3; grid-row: 2; }
.padBtn.down { grid-column: 2; grid-row: 3; }

.padBtn i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 10px solid var(--chalk);
  transform: translate(-50%, -50%);
}

.padBtn.down i { border-bottom: 0; border-top: 10px solid var(--chalk); }
.padBtn.left i { border-bottom: 7px solid transparent; border-top: 7px solid transparent; border-right: 10px solid var(--chalk); border-left: 0; }
.padBtn.right i { border-bottom: 7px solid transparent; border-top: 7px solid transparent; border-left: 10px solid var(--chalk); border-right: 0; }

.padBtn.center i {
  width: 7px;
  height: 7px;
  border: 1px solid rgba(234, 227, 210, .28);
  border-radius: 50%;
  background: #0b0908;
}

.strikeBtn {
  position: relative;
  width: clamp(94px, 11vw, 130px);
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .55));
}

.strikeBtn img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform .06s;
}

.strikeBtn span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: 'Stardos Stencil', Impact, sans-serif;
  font-weight: 700;
  font-size: clamp(12px, 1.2vw, 17px);
  letter-spacing: .05em;
  color: #1b1410;
  text-shadow: 0 1px 0 rgba(255, 220, 160, .3);
}

.strikeBtn:active img, .strikeBtn.down img { transform: translateY(3px) scale(.97); }

.chargeTrack {
  height: 6px;
  flex: 0 0 auto;
  background: rgba(234, 227, 210, .12);
  border: 1px solid rgba(234, 227, 210, .18);
}

.chargeFill {
  height: 100%;
  width: 100%;
  background: repeating-linear-gradient(90deg, #E8A33D 0 14px, #b47a26 14px 16px);
  transition: width .08s linear;
}

.battleHint {
  margin: 0;
  font-size: clamp(7px, .63vw, 10px);
  line-height: 1.2;
  letter-spacing: .05em;
  color: #b7ab95;
}

.pit {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  z-index: 8;
}

#pitCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#pitCanvas canvas { display: block; }

.pitLabel {
  position: absolute;
  left: clamp(10px, 2vw, 28px);
  top: clamp(8px, 2vh, 20px);
  z-index: 3;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  color: var(--chalk);
  text-shadow: 0 2px 3px rgba(0, 0, 0, .75);
}

.pitLabel span {
  font-family: 'Stardos Stencil', Impact, sans-serif;
  font-weight: 700;
  font-size: clamp(14px, 1.6vw, 24px);
  letter-spacing: .12em;
  opacity: .82;
}

.pitLabel b {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
  font-size: clamp(8px, .78vw, 12px);
  letter-spacing: .18em;
  color: #c8bca4;
}

.pitNote {
  position: absolute;
  left: 0;
  right: 0;
  bottom: clamp(8px, 2vh, 18px);
  z-index: 3;
  text-align: center;
  font-family: 'Stardos Stencil', Impact, sans-serif;
  font-weight: 700;
  font-size: clamp(12px, 1.35vw, 22px);
  letter-spacing: .14em;
  color: var(--chalk);
  opacity: .78;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .85);
  pointer-events: none;
  transition: opacity .3s;
}

.vsMark {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%) rotate(-3deg);
  z-index: 2;
  font-family: 'Stardos Stencil', Impact, sans-serif;
  font-weight: 700;
  font-size: clamp(30px, 5vw, 76px);
  color: var(--chalk);
  opacity: .34;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .4);
  pointer-events: none;
  transition: opacity .3s;
}

.endOverlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 7, 6, .76);
}

.endOverlay[hidden] { display: none; }

.endPlate {
  position: relative;
  width: min(92vw, 540px);
  filter: drop-shadow(0 24px 40px rgba(0, 0, 0, .72));
}

.endArt {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: .95;
}

.endInk {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: 90vh;
  overflow-y: auto;
  padding: clamp(18px, 4vw, 32px);
  background: linear-gradient(rgba(20, 18, 16, .66), rgba(15, 13, 12, .76));
}

.endKicker {
  font-size: 9px;
  letter-spacing: .2em;
  color: #c9bda6;
}

.endInk h2 {
  margin: 0;
  font-family: 'Stardos Stencil', Impact, sans-serif;
  font-weight: 700;
  font-size: clamp(28px, 5vw, 46px);
  line-height: .95;
  color: var(--chalk);
  text-shadow: 0 3px 0 #0c0a09;
}

.endInk p {
  margin: 0;
  font-size: clamp(12px, 1.3vw, 16px);
  letter-spacing: .03em;
  color: #c9bda6;
}

.endStats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px 0;
  border-top: 1px solid rgba(234, 227, 210, .2);
  border-bottom: 1px solid rgba(234, 227, 210, .2);
}

.endStats div {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.endStats span {
  font-size: 7px;
  letter-spacing: .14em;
  color: #b7ab95;
}

.endStats b {
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(14px, 1.9vw, 20px);
  color: var(--chalk);
}

.endBoard {
  min-height: 58px;
  font-size: clamp(10px, 1.15vw, 13px);
  letter-spacing: .04em;
  color: #cbbea6;
}

.endBoard h3 {
  margin: 0 0 4px;
  font-family: 'Stardos Stencil', Impact, sans-serif;
  font-weight: 700;
  font-size: clamp(12px, 1.35vw, 16px);
  letter-spacing: .12em;
  color: var(--chalk);
}

.boardNote {
  padding: 3px 0;
  font-size: 9px;
  letter-spacing: .12em;
  color: #968872;
}

.boardRow {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 2px 0;
  border-bottom: 1px dotted rgba(234, 227, 210, .15);
}

.boardRow .rank {
  width: 16px;
  font-family: 'IBM Plex Mono', monospace;
  color: #8f816b;
}

.boardRow .who {
  flex: 1;
  color: var(--chalk);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boardRow .when {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--chalk);
}

.boardRow.mine .who { color: var(--amber); }

.endActions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.steelBtn {
  padding: 10px 16px;
  font-family: 'Stardos Stencil', Impact, sans-serif;
  font-weight: 700;
  font-size: clamp(12px, 1.35vw, 17px);
  letter-spacing: .08em;
  color: var(--chalk);
  background: linear-gradient(180deg, #34302b, #1a1816);
  border: 1px solid #090807;
  box-shadow: inset 0 1px 0 rgba(116, 101, 81, .35), 0 6px 10px rgba(0, 0, 0, .42);
  transition: transform .06s;
}

.steelBtn:active { transform: translateY(2px); }

#againBtn {
  background: linear-gradient(180deg, #4d3622, #291b11);
  color: #f3d9ae;
}

.flash {
  position: fixed;
  inset: 0;
  z-index: 55;
  pointer-events: none;
  background: var(--amber);
  opacity: 0;
}

.flash.on { animation: hitFlash .22s ease-out; }

@keyframes hitFlash {
  0% { opacity: .26; }
  100% { opacity: 0; }
}

@media (max-aspect-ratio: 1.03), (max-width: 560px) {
  :root { --topPad: clamp(84px, 12.2vh, 108px); }

  .topbar {
    padding: 6px 8px 0;
    gap: 6px;
  }

  .brand {
    width: clamp(136px, 43vw, 196px);
    transform: rotate(-.5deg);
  }

  .brandInk { padding: 5% 7% 6%; }
  .brandInk .l1 { font-size: clamp(9px, 2.5vw, 13px); }
  .brandInk .l2 { font-size: clamp(11px, 3vw, 15px); }
  .brandInk p { margin-top: 3px; font-size: 5.5px; letter-spacing: .16em; }

  .wallGauge { display: none; }

  .readouts {
    align-items: center;
    gap: 4px;
    padding-right: 0;
  }

  .meters {
    width: clamp(94px, 27vw, 132px);
    gap: 3px;
    padding: 4px 5px;
  }

  .meterName { font-size: 7px; letter-spacing: .07em; }
  .meterNum { font-size: 9px; }
  .chalkTrack { height: 4px; }
  .miniStats { gap: 2px; padding: 4px 5px; }
  .mini { width: auto; gap: 4px; }
  .mini span { font-size: 6px; }
  .mini b { font-size: 9px; }

  .soundLever {
    width: 40px;
    align-self: flex-start;
    margin-top: 4px;
  }

  .soundWord { bottom: -9px; font-size: 5px; letter-spacing: .08em; }

  .main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(150px, 1fr) auto;
    gap: 3px;
    padding: 0 6px max(6px, env(safe-area-inset-bottom));
  }

  .pit { grid-row: 1; }
  .bay { grid-row: 2; justify-content: flex-start; height: clamp(290px, 44vh, 352px); }
  .floor { height: 76%; }

  .bayTitle h2 { font-size: 14px; }
  .hazardRule { height: 8px; }

  .buildView { gap: 3px; }

  .cradleWrap {
    width: 100%;
    height: 76px;
    aspect-ratio: auto;
    filter: none;
  }

  .cradleArt { display: none; }

  .slots {
    position: static;
    width: 100%;
    height: 100%;
    gap: 4px;
  }

  .slot {
    border: 1px solid rgba(234, 227, 210, .16);
    background: rgba(16, 14, 12, .55);
  }

  .slot img { padding: 8% 8% 18%; }
  .slotTag { font-size: 6.5px; padding: 0 2px; }

  .loadout { padding: 2px; }
  .stat span { font-size: 6px; }
  .stat b { font-size: 9px; }

  .trayWrap { gap: 2px; }
  .trayHead { font-size: 6.5px; }
  .tray { grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 3px; }
  .partBtn { aspect-ratio: auto; height: 48px; }
  .partBtn .partName { font-size: 7px; }

  .sendBtn {
    height: 42px;
    padding: 0 8px;
    gap: 6px;
  }

  .sendBtn img:first-child { width: 32px; height: 32px; }
  .sendWord { font-size: 14px; }
  .bayHint { font-size: 7px; }

  .battlePanel { gap: 4px; }
  .weaponCard { display: none; }
  .battleLoadout { gap: 2px; padding: 3px; }
  .blItem { padding: 1px; }
  .blItem img { height: clamp(26px, 4vh, 38px); }
  .blItem span { font-size: 6px; }
  .weaponLine { display: flex; font-size: 8px; }
  .tallyReadout { display: none; }
  .fightWord { font-size: 26px; }
  .weaponWord { font-size: 9px; }
  .rivalTag { font-size: 8px; }
  .controlRow { gap: 8px; }
  .dpad { width: 128px; }
  .strikeBtn { width: 94px; }
  .strikeBtn span { font-size: 12px; }
  .battleHint { font-size: 7px; }

  .pitLabel { left: 8px; top: 6px; }
  .pitLabel span { font-size: 14px; }
  .pitLabel b { font-size: 7px; }
  .pitNote { bottom: 6px; font-size: 10px; }
  .vsMark { top: 35%; font-size: 34px; }

  .endPlate { width: 94vw; }
  .endInk { padding: 16px; gap: 6px; }
  .endInk h2 { font-size: clamp(26px, 8vw, 38px); }
  .endStats { padding: 6px 0; }
  .endBoard { min-height: 48px; }
  .steelBtn { padding: 9px 13px; font-size: 13px; }
}

@media (max-height: 580px) and (min-aspect-ratio: 1.03) {
  :root { --topPad: 84px; }
  .brand { width: clamp(160px, 18vw, 220px); }
  .brandInk .l1 { font-size: 11px; }
  .brandInk .l2 { font-size: 14px; }
  .wallGauge { width: 70px; }
  .bay { gap: 3px; padding: 6px; }
  .bayTitle h2 { font-size: 14px; }
  .hazardRule { height: 8px; }
  .cradleWrap { max-height: 104px; width: auto; margin: 0 auto; }
  .tray { grid-template-columns: repeat(8, 1fr); }
  .partBtn .partName { display: none; }
  .sendBtn { height: 42px; }
  .sendBtn img:first-child { width: 32px; height: 32px; }
  .sendWord { font-size: 14px; }
  .bayHint { font-size: 7px; }
  .loadout { padding: 2px; }
  .stat span { font-size: 5px; }
  .stat b { font-size: 8px; }
  .trayHead { font-size: 6px; }
  .fightWord { font-size: 28px; }
  .weaponCard { padding: 4px; gap: 6px; }
  .weaponDisc { flex: 0 0 48px; width: 48px; height: 48px; }
  .weaponNameBig { font-size: 10px; margin-bottom: 1px; }
  .weaponStat { padding: 0; }
  .weaponStat span { font-size: 5px; }
  .weaponStat b { font-size: 7px; }
  .tallyReadout { display: none; }
  .battleLoadout { gap: 2px; padding: 2px; }
  .blItem img { height: 24px; }
  .blItem span { font-size: 5px; }
  .dpad { width: 118px; }
  .strikeBtn { width: 86px; }
  .battleHint { font-size: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .flash.on { animation: none; }
  .slot.just { animation: none; }
}

@media (max-width: 380px) {
  .brand { width: 40vw; }
  .readouts { gap: 3px; }
  .meters { width: 88px; padding: 3px 4px; }
  .miniStats { display: none; }
  .soundLever { width: 34px; }
  .brandInk .l1 { font-size: 9px; }
  .brandInk .l2 { font-size: 11px; }
}

@media (max-height: 680px) and (max-aspect-ratio: 1.03) {
  .slots { height: 60px; }
  .cradleWrap { height: 60px; }
  .partBtn { height: 40px; }
  .partBtn .partName { font-size: 6.5px; }
  .stat span { font-size: 6px; }
  .stat b { font-size: 9px; }
  .trayHead { font-size: 6.5px; }
  .bayHint { display: none; }
  .sendBtn { height: 38px; }
  .sendBtn img:first-child { width: 27px; height: 27px; }
  .sendWord { font-size: 12px; }
  .bayTitle h2 { font-size: 12px; }
  .hazardRule { height: 6px; }
  .bayHint { font-size: 6px; }
  .buildView { gap: 2px; }
}

button:focus-visible {
  outline: 2px solid rgba(232, 163, 61, .9);
  outline-offset: 2px;
}

.room.hit {
  animation: roomShake .2s linear;
}

@keyframes roomShake {
  0% { transform: translate(0, 0); }
  22% { transform: translate(-2px, 1px); }
  48% { transform: translate(2px, -1px); }
  72% { transform: translate(-1px, 1px); }
  100% { transform: translate(0, 0); }
}

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

@media (max-height: 560px) and (max-aspect-ratio: 1.03) {
  :root { --topPad: 72px; }
  .topbar { padding-top: 4px; }
  .brand { width: clamp(120px, 40vw, 170px); }
  .brandInk .l1 { font-size: 8px; }
  .brandInk .l2 { font-size: 10px; }
  .brandInk p { display: none; }
  .bay { height: 240px; padding: 5px; gap: 3px; }
  .bayTitle h2 { font-size: 11px; }
  .hazardRule { height: 5px; }
  .buildView { gap: 2px; }
  .cradleWrap { height: 48px; }
  .slots { height: 48px; }
  .loadout { padding: 1px; }
  .stat span { font-size: 5px; }
  .stat b { font-size: 7px; }
  .trayHead { font-size: 5px; }
  .tray { padding: 2px; gap: 1px; }
  .partBtn { height: 32px; }
  .partBtn .partName { font-size: 5px; }
  .sendBtn { height: 34px; padding: 0 6px; gap: 5px; }
  .sendBtn img:first-child { width: 24px; height: 24px; }
  .sendWord { font-size: 11px; }
  .bayHint { display: none; }
  .battlePanel { gap: 3px; }
  .fightWord { font-size: 18px; }
  .weaponWord { font-size: 7px; }
  .rivalTag { font-size: 6px; }
  .weaponCard { display: none; }
  .battleLoadout { gap: 2px; padding: 2px; }
  .blItem img { height: 22px; }
  .blItem span { font-size: 5px; }
  .weaponLine { display: flex; font-size: 6px; }
  .tallyReadout { display: none; }
  .dpad { width: 102px; gap: 3px; }
  .strikeBtn { width: 76px; }
  .strikeBtn span { font-size: 9px; }
  .chargeTrack { height: 4px; }
  .battleHint { font-size: 6px; }
  .pitLabel span { font-size: 11px; }
  .pitLabel b { font-size: 6px; }
  .pitNote { display: none; }
  .vsMark { font-size: 24px; }
}
