@font-face {
  font-family: Arcade;
  src: url("/fonts/pixelify-sans.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #19283b;
  --cream: #fff4dd;
  --dim: #d2e3dd;
  --gold: #ffcd6f;
  --shadow: #182b3b;
  font-family: system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  background: #17374a;
  color: var(--cream);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
p, h1, h2 { margin: 0; }
button { color: inherit; font: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid #fff0ae; outline-offset: 3px; }
[hidden] { display: none !important; }

.stadium { min-height: 100dvh; }
.stadium:fullscreen { overflow: auto; }
.duel-side .duel-copy { margin: 9px 0; color: var(--dim); font-size: .86rem; }
.duel-invite, .duel-roster { display: grid; gap: 7px; margin: 10px 0; }
.duel-side label { display: grid; gap: 3px; min-width: 0; color: var(--dim); font-size: .8rem; }
.duel-side :is(input, select) { width: 100%; min-height: 38px; border: 1px solid #719198; background: #163348; color: #fff4dd; padding: 5px 7px; border-radius: 0; font: inherit; }
.duel-invite button { justify-self: start; }
.duel-slot { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: end; gap: 8px; }
.duel-place.secondary { display: grid; place-items: center; min-height: 42px; padding: 4px; }
.duel-place[aria-pressed="true"] { border-color: #ffd276; background: #4a625b; }
.duel-place img { height: 30px; max-width: 34px; object-fit: contain; image-rendering: pixelated; }
.duel-gear { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 8px; }
.duel-arena .guest-side .tile.is-selected { border-color: #ffd276; background: #c9726f72; }
.scoreboard {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 6px clamp(12px, 2.4vw, 34px) 8px;
  background: #18374b;
  border-top: 3px solid #32748a;
  border-bottom: 4px solid #172d3b;
  box-shadow: inset 0 -3px #265264, 0 3px #572d3540;
}
.brand, .record, .lives, .coins { display: flex; align-items: center; }
.brand { gap: 11px; }
.back {
  display: grid;
  place-items: center;
  min-width: 32px;
  min-height: 36px;
  color: var(--dim);
  text-decoration: none;
  font-size: 1.35rem;
}
.back:hover { color: var(--gold); }
h1 {
  font-family: Arcade, system-ui, sans-serif;
  font-size: clamp(1.1rem, 3.2vw, 2.45rem);
  line-height: 1;
  letter-spacing: -.025em;
  text-shadow: 0 3px #121222;
}
h1 span { color: var(--gold); }
.wave { text-align: center; }
.wave h2 { font-size: clamp(1.05rem, 2.15vw, 1.6rem); line-height: .98; }
.label { color: var(--dim); font-size: .91rem; line-height: 1.1; }
.wave .label { margin-bottom: 3px; color: #ffd495; font-weight: 700; }
.record { justify-self: end; justify-content: end; text-align: right; gap: 13px; }
.lives { justify-content: flex-end; gap: 5px; margin: 0 0 4px; }
.life, .coin {
  display: inline-block;
  width: 13px;
  height: 13px;
  background: #ef9c7a;
  clip-path: polygon(25% 0,75% 0,75% 25%,100% 25%,100% 75%,75% 75%,75% 100%,25% 100%,25% 75%,0 75%,0 25%,25% 25%);
  box-shadow: inset 2px 2px #ffd098, inset -2px -2px #9e4b57;
}
.life.spent { background: #556677; box-shadow: none; }
.coin { background: #ebaf56; box-shadow: inset 2px 2px #ffe09b, inset -2px -2px #a46637; flex: none; }

.layout {
  --field: min(calc(100dvh - 178px), calc(100vw - 356px));
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(270px, 25vw, 350px);
  align-items: center;
  gap: clamp(12px, 2vw, 30px);
  min-height: calc(100dvh - 66px);
  padding: 15px clamp(14px, 3vw, 42px) 19px;
  background: #e3a66a;
}
#stadium-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  image-rendering: pixelated;
}
.arena {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  justify-items: center;
  gap: 13px;
}
.board, .action-bar { width: clamp(310px, var(--field), 820px); max-width: 100%; }
.board {
  position: relative;
  isolation: isolate;
}
.board > canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.tiles {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--board-columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--board-rows), minmax(0, 1fr));
  pointer-events: none;
}
.tile { min-width: 0; padding: 0; border: 1px solid transparent; background: none; pointer-events: auto; }
.tile:not(:disabled):hover, .tile.is-selected { border: 2px solid #fff0b5; background: #fff0bc2c; }
.tile:focus-visible { outline-offset: -3px; }
.tiles.placing .tile:not(:disabled) { box-shadow: inset 0 0 0 1px #315c615d; }
.training-arena .layout { align-content: center; --field: min(calc(100dvh - 256px), calc(100vw - 356px)); }
.training-coach {
  order: -2;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 730px);
  justify-self: center;
  padding: 8px 14px;
  background: #192b42;
  border-left: 4px solid #c5a8f7;
  box-shadow: 3px 4px #532e3980;
}
.training-coach img { flex: 0 0 39px; width: 39px; image-rendering: pixelated; }
.training-coach strong { color: #decafa; font-family: Arcade, monospace; font-size: 1.18rem; }
.training-coach span { margin-left: 4px; color: #b8d3d5; font-size: .85rem; }
.training-coach p { color: var(--cream); font-size: .92rem; line-height: 1.35; }
.training-arena .tiles .training-target:not(:disabled) { border: 3px solid #ffda74; background: #ffc76170; }
.training-arena[data-training-step="buy"] .offer:not(:disabled),
.training-arena[data-training-step="gear"] .gear-buy:not(:disabled) { outline: 2px solid #ffd683; outline-offset: -2px; }
.guide-next { position: relative; z-index: 2; }
.guide-next::after {
  content: "";
  position: absolute;
  bottom: calc(100% + 3px);
  left: calc(50% - 11px);
  width: 22px;
  height: 22px;
  background: #ffe69d;
  clip-path: polygon(36% 0, 64% 0, 64% 44%, 100% 44%, 50% 100%, 0 44%, 36% 44%);
  box-shadow: inset 0 -3px #e8a15a;
  pointer-events: none;
  animation: guide-point .85s steps(2, end) infinite alternate;
}
.guide-next.tile::after { bottom: 78%; }
@keyframes guide-point { to { transform: translateY(-5px); } }
.result {
  position: absolute;
  z-index: 1;
  top: 45%;
  left: 50%;
  width: min(86%, 280px);
  transform: translate(-50%, -50%);
  padding: 16px 12px;
  background: #18374b;
  border: 3px solid #ffd486;
  box-shadow: inset 0 -5px #265368, 5px 6px #27374370;
  text-align: center;
}
.result strong { display: block; color: var(--gold); font-size: 2rem; line-height: 1.1; }
.result span { color: var(--dim); font-size: .91rem; }

.action-bar, .section-head, .shop-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.action-bar {
  min-height: 62px;
  padding: 8px 9px 8px 12px;
  border: 2px solid #295369;
  background: #18374b;
  box-shadow: inset 0 2px #37667a, 0 4px #834e3970;
}
.action-bar #phase { display: block; font-size: 1.1rem; line-height: 1.05; margin-bottom: 3px; }
#timer { color: var(--gold); }
.action-bar p, .hint, .inspect p, .tip { font-size: .88rem; color: var(--dim); line-height: 1.22; }
.action-bar .fight-key {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 9px;
  margin-top: 5px;
  font-size: .71rem;
}
.fight-key span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.fight-key i { display: inline-block; width: 9px; height: 9px; }
.fight-key .team-ally { background: #69dcf5; clip-path: polygon(33% 0, 67% 0, 67% 33%, 100% 33%, 100% 67%, 67% 67%, 67% 100%, 33% 100%, 33% 67%, 0 67%, 0 33%, 33% 33%); }
.fight-key .team-enemy { background: #ff786f; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.fight-key .health-key { width: 12px; height: 4px; background: #c4e7ef; }
.fight-key .super-key { width: 14px; height: 4px; background: repeating-linear-gradient(90deg, #ffcd6f 0 2px, transparent 2px 4px); }
#prompt[data-cue="super"] { color: #ffe3a6; }

.primary, .secondary {
  position: relative;
  border-radius: 0;
  min-height: 36px;
  padding: 4px 10px 8px;
  white-space: nowrap;
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid #193340;
  background: #267478;
  box-shadow: inset 2px 2px #4b9990, inset -2px -4px #215b68, 2px 3px var(--shadow);
}
.primary { flex: none; min-height: 43px; padding-inline: 14px; background: #ffc15b; color: var(--ink); box-shadow: inset 2px 2px #ffe5a2, inset -2px -4px #c38040, 2px 3px var(--shadow); }
.primary:not(:disabled):hover { background: #ffd17c; }
.secondary:not(:disabled):hover { background: #318486; }
.primary:disabled, .secondary:disabled { opacity: .58; }
.primary:not(:disabled):active, .secondary:not(:disabled):active { translate: 1px 2px; }
.full-screen { width: 38px; height: 36px; padding: 0; display: grid; place-items: center; }
.full-screen span {
  width: 16px;
  height: 14px;
  background:
    linear-gradient(var(--cream) 0 0) left top / 5px 2px,
    linear-gradient(var(--cream) 0 0) left top / 2px 5px,
    linear-gradient(var(--cream) 0 0) right top / 5px 2px,
    linear-gradient(var(--cream) 0 0) right top / 2px 5px,
    linear-gradient(var(--cream) 0 0) left bottom / 5px 2px,
    linear-gradient(var(--cream) 0 0) left bottom / 2px 5px,
    linear-gradient(var(--cream) 0 0) right bottom / 5px 2px,
    linear-gradient(var(--cream) 0 0) right bottom / 2px 5px;
  background-repeat: no-repeat;
}

.side { min-width: 0; display: grid; gap: 12px; }
.shop, .roster, .catalog {
  border: 2px solid #285369;
  background: #18374b;
  box-shadow: inset 0 2px #316373, 0 4px #834e3970;
}
.shop { border-color: #874648 #874648 #653d42; background: #442e3b; }
.section-head {
  min-height: 35px;
  padding: 5px 10px 7px;
  border-bottom: 3px solid #1d394b;
  background: #226765;
  box-shadow: inset 0 2px #478f83, inset 0 -2px #25535b;
}
.shop .section-head {
  background: repeating-linear-gradient(90deg,#aa514b 0 25px,#98454c 25px 49px);
  box-shadow: inset 0 2px #dc8f75, inset 0 -2px #783b44;
}
h2 { font-size: 1.26rem; line-height: 1; text-shadow: 0 2px #242038; }
.coins { gap: 5px; color: #fff0bd; font-size: .97rem; font-weight: 700; white-space: nowrap; }
.coins strong { font-size: 1.17rem; }
#coins { min-width: 1ch; }

.offers { display: grid; gap: 5px; padding: 8px 8px 6px; }
.offer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 53px;
  padding: 3px 8px 6px 5px;
  text-align: left;
  background: #523a43;
  border: 2px solid #8e5b51;
  box-shadow: inset 0 2px #805451, inset 0 -4px #432e39;
}
.offer:not(:disabled):hover { background: #66464b; border-color: #f9c076; }
.offer:disabled { opacity: .58; }
.offer img, .bench img { width: 38px; height: 38px; object-fit: contain; flex: none; image-rendering: pixelated; }
.offer img { padding: 2px; background: #322c3b; box-shadow: inset 2px 2px #272638, inset -2px -2px #775354; }
.offer strong { display: block; font-size: 1.15rem; line-height: .95; }
.offer small { display: block; color: #d7b9c0; font-size: .8rem; line-height: .99; margin-top: 4px; }
.offer .price { margin-left: auto; }
.shop-counter { min-height: 49px; padding: 4px 8px 8px; }
.gear-shop {
  margin: 2px 8px 6px;
  border: 2px solid #a47654;
  background: #29333e;
  box-shadow: 0 3px #292330, inset 0 -3px #202731;
}
.gear-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 5px;
  border-bottom: 2px solid #252633;
  color: #30253a;
  background: #e3aa6b;
  box-shadow: inset 0 2px #ffd59a, inset 0 -2px #ba8155;
}
.gear-header strong { font-size: .82rem; }
.gear-header span { font-size: .69rem; font-weight: 650; text-align: right; }
.gear-offer { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 7px; padding: 7px; }
.gear-portrait {
  display: grid;
  place-items: center;
  height: 44px;
  border: 2px solid #c2a579;
  box-shadow: inset 0 0 0 2px #263547, 0 2px #202632;
  background: #507384;
}
.gear-portrait[data-kind="trail"] { background: #53795d; }
.gear-portrait[data-kind="fuse"] { background: #8a5a58; }
.gear-portrait[data-kind="launch"] { background: #5e527e; }
.gear-art { display: block; width: 36px; height: 36px; image-rendering: pixelated; }
.gear-info strong { display: block; font-size: .88rem; line-height: 1.12; }
.gear-info p { margin-top: 3px; font-size: .75rem; color: #e0d9d1; line-height: 1.2; }
.gear-buy { min-width: 57px; padding: 3px 6px 5px; font-size: .82rem; }
.gear-buy span, .gear-buy small { display: block; }
.gear-buy small { color: #ffe1a0; font-size: .68rem; }
.gear-equipped { padding: 0 8px 6px; color: #ffda97; font-size: .75rem; }
.hint { color: #dfbdae; }
.bench { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; padding: 8px; }
.slot {
  min-width: 0;
  min-height: 49px;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 3px;
  border: 2px solid #356578;
  background: #163042;
  box-shadow: inset 2px 2px #152b3b, inset -2px -2px #285369;
}
.slot.empty::after { content: ""; width: 11px; height: 11px; background: #436d79; clip-path: polygon(36% 0,64% 0,64% 36%,100% 36%,100% 64%,64% 64%,64% 100%,36% 100%,36% 64%,0 64%,0 36%,36% 36%); }
.slot.is-selected { border-color: var(--gold); background: #28666b; }
.slot .rank { color: var(--gold); font-size: .74rem; line-height: 1; }
.slot img { width: min(32px,100%); height: auto; max-height: 32px; }
.inspect { padding: 0 9px 8px; }
.inspect > strong { font-size: 1.05rem; }
.inspect p { margin-top: 3px; }
.inspect-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.inspect-actions button { margin-top: 7px; padding-inline: 6px; }
.catalog { padding: 5px 9px 7px; }
.catalog summary { cursor: pointer; color: var(--dim); font-weight: 650; }
.catalog-list { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px 4px; margin: 8px 0 0; padding: 0; list-style: none; }
.catalog-list li { display: grid; justify-items: center; align-content: start; gap: 3px; font-size: .84rem; line-height: 1.05; text-align: center; }
.catalog-list img { width: 32px; height: 32px; object-fit: contain; image-rendering: pixelated; }
.super-label { color: var(--gold); }
.tip { color: #342a2a; padding-inline: 2px; font-weight: 650; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 760px) {
  .scoreboard { min-height: 56px; gap: 5px; padding: 4px 7px 6px; }
  .brand { gap: 2px; }
  .back { min-width: 26px; min-height: 34px; }
  .record { gap: 6px; }
  .life { width: 10px; height: 10px; }
  .lives { gap: 3px; }
  .full-screen { width: 31px; height: 32px; min-height: 30px; }
  .layout { --field: min(calc(100vw - 16px), 530px); grid-template-columns: minmax(0,1fr); align-content: start; padding: 7px 8px 14px; gap: 12px; }
  .training-arena .layout { --field: min(calc(100vw - 16px), 530px); align-content: start; }
  .training-arena:is([data-training-step="buy"], [data-training-step="gear"]) #arena-shop { order: -1; }
  .training-arena[data-training-step="buy"] .roster { display: none; }
  .arena { gap: 7px; }
  .action-bar { min-height: 54px; padding: 5px 6px 6px 8px; }
  .action-bar p { font-size: .83rem; }
  .side { width: min(100%, 530px); margin-inline: auto; gap: 8px; }
  .offers { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .offer { flex-direction: column; justify-content: space-between; gap: 3px; padding: 4px 2px 6px; align-items: center; text-align: center; }
  .offer strong { font-size: .99rem; }
  .offer small { margin-top: 2px; }
  .offer img { width: 31px; height: 31px; }
  .offer .price { margin-left: 0; }
  .section-head { min-height: 31px; }
  .bench { padding: 6px; }
}
@media (max-width: 380px) {
  .full-screen { display: none; }
  .scoreboard h1 span { display: block; }
}
