@font-face {
  font-family: "Plank";
  src: url("assets/fonts/alfaslabone-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Kampung";
  src: url("assets/fonts/baloo2-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Kampung";
  src: url("assets/fonts/baloo2-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f6e7c8;
  --gold: #e8a73c;
  --terra: #c9522c;
  --leaf: #4c7a3b;
  --teal: #1e4a4c;
  --sky: #8fc6d8;
  --ink: #2b211c;
  --ochre: #8a5a2b;
  --cream: #fff4dc;
  --disp: "Plank", "Arial Black", Impact, sans-serif;
  --body: "Kampung", "Trebuchet MS", system-ui, sans-serif;
  --hud-h: 90px;
  --fighter-h: 210px;
  --baseline-offset: 46px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 600;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

button {
  font-family: var(--body);
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
button:focus { outline: none; }
button:focus-visible {
  outline: 3px dashed var(--paper);
  outline-offset: 3px;
}

img { max-width: 100%; }

[hidden] { display: none !important; }

#grain {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  background-image: url("assets/art/paper-grain.png");
  background-size: 260px 260px;
  opacity: 0.62;
  mix-blend-mode: multiply;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s;
}
.screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.scene-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 55%;
  display: block;
}

/* ============ TITLE ============ */

.screen--title {
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

.title-scene {
  position: relative;
  flex: 1 1 auto;
  min-height: 180px;
  overflow: hidden;
}

.title-scene::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18%;
  background: rgba(120, 74, 31, 0.11);
  pointer-events: none;
}

.title-scene .scene-bg { object-position: 50% 57%; }

.title-sign-wrap {
  position: absolute;
  top: 2%;
  left: 50%;
  width: min(86vw, 62vh, 640px);
  height: 56%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  transform: translateX(-50%) rotate(-1.8deg);
  transform-origin: 50% 0;
  animation: signSway 7s ease-in-out infinite alternate;
  z-index: 3;
}
.title-sign {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  display: block;
  filter: drop-shadow(5px 7px 0 rgba(43, 33, 28, 0.22));
}

@keyframes signSway {
  from { transform: translateX(-50%) rotate(-2.2deg); }
  to   { transform: translateX(-50%) rotate(-0.7deg); }
}

.title-duo {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2.5%;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 4%;
  pointer-events: none;
  z-index: 4;
}

.duo {
  position: relative;
  height: clamp(82px, 19vh, 190px);
  width: auto;
}
.duo--rooster { transform: scaleX(-1); }

.duo img {
  position: relative;
  display: block;
  height: 100%;
  width: auto;
  animation: idleBob 2.6s ease-in-out infinite;
  transform-origin: 50% 100%;
  z-index: 2;
}
.duo--rooster img { animation-delay: -1.3s; }

.duo-shadow {
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 66%;
  height: 11%;
  transform: translateX(-50%);
  background: rgba(107, 69, 33, 0.38);
  border-radius: 50%;
  z-index: 1;
}

@keyframes idleBob {
  0%, 100% { transform: translateY(0) scaleY(1); }
  40% { transform: translateY(-2%) scaleY(1.006); }
  60% { transform: translateY(-1.2%) scaleY(0.997); }
}

.title-stamp {
  position: absolute;
  left: 50%;
  bottom: 2%;
  transform: translateX(-50%) rotate(-0.6deg);
  margin: 0;
  z-index: 5;
  color: var(--cream);
  font-size: clamp(8px, 1.7vw, 12px);
  font-weight: 700;
  letter-spacing: 0.18em;
  white-space: nowrap;
  text-shadow: 1px 2px 0 var(--ink);
  opacity: 0.95;
}

.motes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.motes i {
  position: absolute;
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(43, 33, 28, 0.22);
  animation: moteFloat 13s linear infinite;
}
.motes i:nth-child(1) { left: 14%; top: 72%; animation-delay: -2s; }
.motes i:nth-child(2) { left: 28%; top: 58%; width: 3px; height: 3px; animation-delay: -7s; }
.motes i:nth-child(3) { left: 47%; top: 80%; animation-delay: -4s; }
.motes i:nth-child(4) { left: 61%; top: 52%; width: 4px; height: 4px; animation-delay: -9s; }
.motes i:nth-child(5) { left: 74%; top: 70%; animation-delay: -1s; }
.motes i:nth-child(6) { left: 88%; top: 63%; width: 3px; height: 3px; animation-delay: -6s; }

@keyframes moteFloat {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: 0.75; }
  70% { opacity: 0.55; }
  100% { transform: translate(34px, -90px); opacity: 0; }
}

.title-below {
  flex: 0 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 3px solid var(--ink);
  z-index: 6;
}
.title-below::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  height: 6px;
  background: var(--paper);
  clip-path: polygon(0 60%, 4% 35%, 9% 70%, 15% 40%, 22% 72%, 30% 38%, 38% 68%, 47% 42%, 56% 73%, 64% 40%, 72% 68%, 81% 36%, 89% 70%, 96% 40%, 100% 62%, 100% 100%, 0 100%);
}

.start-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  padding: 2px 18px;
  cursor: pointer;
  transform: rotate(-0.5deg);
  transition: transform 0.12s ease;
}
.start-btn:hover { transform: rotate(-0.5deg) scale(1.03); }
.start-btn:active { transform: rotate(-0.5deg) scale(0.97); }

.start-disc {
  display: block;
  width: clamp(46px, 12vw, 70px);
  animation: discBounce 2.2s ease-in-out infinite;
}
.start-disc img { display: block; width: 100%; height: auto; }

@keyframes discBounce {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-4px) rotate(1.5deg); }
}

.start-word {
  font-family: var(--disp);
  font-size: clamp(28px, 7vw, 46px);
  line-height: 0.95;
  color: var(--gold);
  letter-spacing: 0.02em;
  text-shadow: 3px 3px 0 var(--teal), 5px 5px 0 rgba(43, 33, 28, 0.22);
}

.title-line {
  margin: 0;
  font-size: clamp(9px, 2.2vw, 12px);
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--teal);
  text-align: center;
}
.title-record {
  margin: 0;
  min-height: 13px;
  font-size: clamp(9px, 2vw, 11px);
  letter-spacing: 0.06em;
  color: var(--leaf);
  text-align: center;
}

.icon-btn {
  border: 0;
  background: transparent;
  padding: 0;
  width: 42px;
  height: 42px;
  cursor: pointer;
  position: relative;
  display: inline-block;
  border-radius: 50%;
  flex: 0 0 auto;
}
.icon-btn img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.icon-btn:hover img { transform: scale(1.08) rotate(-2deg); }
.icon-btn:active img { transform: scale(0.94); }

.sound-toggle { position: absolute; top: max(8px, env(safe-area-inset-top)); right: 8px; z-index: 20; }
.mute-slash {
  display: none;
  position: absolute;
  left: 16%;
  right: 16%;
  top: 49%;
  height: 3px;
  background: var(--terra);
  border: 1px solid var(--ink);
  transform: rotate(-38deg);
  border-radius: 2px;
}
.sound-toggle[aria-pressed="false"] .mute-slash { display: block; }
.sound-toggle[aria-pressed="false"] img { opacity: 0.68; }

/* ============ SELECT ============ */

.screen--select {
  background: var(--teal);
  overflow: hidden;
}
.select-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 55%;
  filter: brightness(0.68) saturate(0.82);
}
.dusk-wash {
  position: absolute;
  inset: 0;
  background: rgba(30, 74, 76, 0.52);
  mix-blend-mode: multiply;
  pointer-events: none;
}

.select-content {
  position: relative;
  z-index: 3;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) clamp(10px, 3vw, 30px) calc(10px + env(safe-area-inset-bottom));
}

.select-head {
  flex: 0 0 auto;
  text-align: center;
  padding-top: 2px;
}
.kicker {
  margin: 0 0 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.32em;
  color: var(--gold);
  text-shadow: 1px 2px 0 var(--ink);
}
.sign-plank {
  display: inline-block;
  background: var(--terra);
  padding: 5px 16px 8px;
  border: 3px solid var(--ink);
  border-radius: 12px 18px 9px 14px / 16px 8px 15px 10px;
  box-shadow: 4px 5px 0 rgba(43, 33, 28, 0.42);
  transform: rotate(-0.8deg);
  max-width: 94vw;
}
.sign-plank h1 {
  margin: 0;
  font-family: var(--disp);
  font-weight: 400;
  font-size: clamp(20px, 5.4vw, 42px);
  line-height: 1;
  letter-spacing: 0.015em;
  color: var(--gold);
  text-shadow: 2px 3px 0 var(--teal), 4px 4px 0 rgba(43, 33, 28, 0.25);
  white-space: nowrap;
}
.select-sub {
  margin: 6px 0 0;
  color: var(--cream);
  font-size: clamp(9px, 2.3vw, 12px);
  letter-spacing: 0.04em;
  text-shadow: 1px 2px 0 rgba(43, 33, 28, 0.7);
}

.roster-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) rgba(43, 33, 28, 0.2);
  padding: 2px 2px 8px;
  -webkit-overflow-scrolling: touch;
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(2px, 0.8vh, 8px) clamp(4px, 1.8vw, 14px);
  justify-items: center;
  align-items: start;
  max-width: 900px;
  margin: 0 auto;
}

.roster-card {
  position: relative;
  width: 100%;
  max-width: 168px;
  border: 0;
  background: transparent;
  padding: 0 0 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease;
  color: var(--ink);
  touch-action: manipulation;
}
.roster-card:nth-child(odd) .tag { transform: rotate(-1.3deg); }
.roster-card:nth-child(even) .tag { transform: rotate(1.2deg); }
.roster-card:hover { transform: translateY(-3px); }
.roster-card:active { transform: scale(0.97); }

.medal {
  position: relative;
  width: min(100%, clamp(70px, 12vh, 140px));
  display: block;
  filter: saturate(0.82) brightness(0.94);
  transition: filter 0.18s ease, transform 0.18s ease;
  transform-origin: 50% 100%;
  z-index: 2;
}
.medal img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  transform: rotate(var(--sway, 0deg));
  animation: medalSway 4.8s ease-in-out infinite alternate;
}
.roster-card:nth-child(3n) .medal img { animation-delay: -1.6s; }
.roster-card:nth-child(3n+1) .medal img { animation-delay: -3.2s; }

@keyframes medalSway {
  from { transform: rotate(-0.9deg); }
  to   { transform: rotate(1deg); }
}

.roster-card.is-selected { transform: translateY(-4px); }
.roster-card.is-selected .medal {
  filter: saturate(1.05) brightness(1.03);
  transform: scale(1.06);
}
.roster-card.is-selected .tag {
  background: var(--gold);
  color: var(--ink);
  box-shadow: 3px 3px 0 rgba(43, 33, 28, 0.45);
}

.chalk-ring {
  position: absolute;
  left: 50%;
  bottom: -3%;
  width: 112%;
  aspect-ratio: 1;
  height: auto;
  transform: translateX(-50%) rotate(-8deg);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  z-index: 3;
  overflow: visible;
}
.roster-card.is-selected .chalk-ring { opacity: 1; }
.chalk-ring path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chalk-ring .ring-back {
  stroke: var(--ink);
  stroke-width: 5.6;
  stroke-dasharray: 7 3.5;
  opacity: 0.5;
}
.chalk-ring .ring-front {
  stroke: var(--cream);
  stroke-width: 3;
  stroke-dasharray: 7 3.5;
}

.tag {
  position: relative;
  z-index: 4;
  margin-top: -8px;
  background: var(--paper);
  color: var(--teal);
  border: 2px solid var(--ink);
  border-radius: 7px 10px 6px 9px / 9px 6px 8px 7px;
  padding: 3px 7px 4px;
  min-width: 74%;
  text-align: center;
  box-shadow: 2px 2px 0 rgba(43, 33, 28, 0.36);
  transition: background 0.16s ease, color 0.16s ease;
}
.tag::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 5px;
  height: 5px;
  background: var(--ink);
  border-radius: 50%;
  transform: translateX(-50%);
}
.tag-name {
  display: block;
  font-weight: 700;
  font-size: clamp(9px, 2.3vw, 12px);
  line-height: 1.08;
  letter-spacing: 0.055em;
  white-space: nowrap;
}
.tag-role {
  display: block;
  font-size: clamp(7px, 1.7vw, 9px);
  line-height: 1.1;
  letter-spacing: 0.03em;
  opacity: 0.75;
  white-space: nowrap;
}

.picked {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2.4vw, 20px);
  padding: 5px 12px 6px;
  background: rgba(246, 231, 200, 0.95);
  border: 2px solid var(--ink);
  border-radius: 10px 14px 8px 12px / 12px 7px 11px 8px;
  box-shadow: 3px 4px 0 rgba(43, 33, 28, 0.38);
  color: var(--teal);
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}
.picked-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.picked-name {
  margin: 0;
  font-family: var(--disp);
  font-weight: 400;
  font-size: clamp(16px, 4.2vw, 28px);
  line-height: 1;
  color: var(--terra);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.picked-tag {
  margin: 0;
  font-size: clamp(9px, 2.2vw, 12px);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--teal);
  white-space: nowrap;
}
.picked-stats {
  display: flex;
  gap: clamp(6px, 2vw, 16px);
  align-items: center;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}
.stat b {
  font-size: clamp(6px, 1.6vw, 8px);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--teal);
  line-height: 1;
}
.pips { display: flex; gap: 2px; }
.pips i {
  display: block;
  width: clamp(6px, 1.7vw, 9px);
  height: clamp(6px, 1.7vw, 9px);
  border: 1.5px solid var(--ink);
  background: transparent;
  transform: rotate(3deg);
}
.pips i.on { background: var(--terra); }

.select-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 1px;
}
.plank-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 7px 14px 8px;
  border: 2px solid var(--ink);
  border-radius: 8px 12px 7px 10px / 10px 6px 9px 7px;
  background: var(--paper);
  color: var(--teal);
  font-family: var(--body);
  font-weight: 700;
  font-size: clamp(10px, 2.5vw, 13px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(43, 33, 28, 0.45);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
}
.plank-btn:hover { transform: translateY(-2px) rotate(-0.4deg); }
.plank-btn:active { transform: translateY(1px); box-shadow: 1px 1px 0 rgba(43, 33, 28, 0.45); }
.plank-btn--go {
  background: var(--terra);
  color: var(--gold);
  text-shadow: 1px 2px 0 var(--teal);
  padding-left: 10px;
}
.plank-btn--back { background: var(--paper); }
.btn-disc { display: inline-block; width: 26px; height: 26px; }
.btn-disc img { display: block; width: 100%; height: 100%; object-fit: contain; }

#selectSound { top: max(8px, env(safe-area-inset-top)); right: 8px; }

/* ============ FIGHT ============ */

.screen--fight { background: var(--ink); overflow: hidden; }

.fight-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #1b2d2e;
}

.fight-stage .stage-slide,
.fight-scene { display: none; }

.stage-slot {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.camera {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transform-origin: 50% 70%;
  transition: transform 0.9s cubic-bezier(0.22, 0.72, 0.28, 1);
}
.stage-world {
  position: absolute;
  inset: 0;
  will-change: transform;
}
.stage-world .scene-bg {
  object-position: 50% 58%;
}
.arena {
  position: absolute;
  bottom: 0;
  left: 0;
  height: auto;
  z-index: 2;
  pointer-events: none;
  transform-origin: 50% 100%;
}
.arena img { display: block; width: 100%; height: 100%; }

.fighter {
  position: absolute;
  bottom: var(--baseline-offset);
  transform: translateX(-50%);
  z-index: 6;
  height: var(--fighter-h);
  will-change: transform, left;
}
.fighter .sprite {
  position: relative;
  height: 100%;
  transform-origin: 50% 100%;
  will-change: transform;
}
.fighter .sprite img {
  display: block;
  height: 100%;
  width: auto;
  transform-origin: 50% 100%;
  -webkit-user-drag: none;
}
.fighter[data-side="ai"] .sprite img { transform: scaleX(-1); }
.fighter .shadow {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 62%;
  height: 8%;
  transform: translateX(-50%);
  background: rgba(112, 68, 27, 0.42);
  border-radius: 50%;
  z-index: -1;
}
.fighter.is-ko { z-index: 5; }

.fx-layer {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  overflow: hidden;
}
.fx {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  will-change: transform, opacity;
}
.fx img { display: block; width: 100%; height: auto; }
.fx--spark { animation: sparkPop 0.48s ease-out forwards; }
.fx--spark-small { animation: sparkPop 0.32s ease-out forwards; }
.fx--dust { animation: dustPuff 0.55s ease-out forwards; }
.fx--sweat { animation: sweatFly 0.7s ease-out forwards; }
.fx--skid { animation: skidFade 0.6s ease-out forwards; }
.fx--leaf { animation: leafDrift 2.2s ease-out forwards; }
.fx--star { }

@keyframes sparkPop {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(-14deg); opacity: 0; }
  22% { transform: translate(-50%, -50%) scale(1.18) rotate(3deg); opacity: 1; }
  55% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.18) rotate(6deg); opacity: 0; }
}
@keyframes sparkPopSmall {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(0.8); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.1); opacity: 0; }
}
@keyframes dustPuff {
  0% { transform: translate(-50%, -50%) scale(0.3) translateY(8px); opacity: 0; }
  25% { opacity: 0.95; }
  100% { transform: translate(-50%, -50%) scale(1.25) translateY(-4px); opacity: 0; }
}
@keyframes sweatFly {
  0% { transform: translate(-50%, -50%) scale(0.4) rotate(0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--sx, 60px)), calc(-50% - var(--sy, 34px))) scale(0.9) rotate(24deg); opacity: 0; }
}
@keyframes skidFade {
  0% { transform: translate(-50%, -50%) scaleX(0.4); opacity: 0; }
  30% { opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scaleX(1.05); opacity: 0; }
}
@keyframes leafDrift {
  0% { transform: translate(-50%, -50%) scale(0.5) rotate(-8deg); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 10px)), -180%) scale(1.1) rotate(28deg); opacity: 0; }
}

.decal-layer {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.decal {
  width: min(54vw, 520px);
  display: block;
  animation: decalSlam 0.72s cubic-bezier(0.2, 1.2, 0.3, 1) forwards;
  filter: drop-shadow(4px 6px 0 rgba(43, 33, 28, 0.28));
}
.decal.decal--small { width: min(42vw, 410px); }
@keyframes decalSlam {
  0% { transform: scale(2.2) rotate(-8deg); opacity: 0; }
  38% { transform: scale(0.94) rotate(var(--rot, 2deg)); opacity: 1; }
  62% { transform: scale(1.03) rotate(var(--rot, 2deg)); opacity: 1; }
  100% { transform: scale(1) rotate(var(--rot, 2deg)); opacity: 1; }
}
.decal.is-out { animation: decalOut 0.35s ease-in forwards; }
@keyframes decalOut {
  0% { transform: scale(1) rotate(var(--rot, 2deg)); opacity: 1; }
  100% { transform: scale(1.14) rotate(var(--rot, 2deg)); opacity: 0; }
}

/* HUD */
.fight-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 24;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  gap: clamp(4px, 1.2vw, 16px);
  padding: max(6px, env(safe-area-inset-top)) clamp(8px, 2vw, 24px) 0;
  pointer-events: none;
}

.hp-side {
  display: flex;
  align-items: flex-start;
  gap: clamp(4px, 1vw, 9px);
  min-width: 0;
}
.hp-side--ai { justify-content: flex-end; }

.hud-portrait {
  width: clamp(42px, 6.2vw, 80px);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
  transform: rotate(-1.5deg);
}
.hp-side--ai .hud-portrait { transform: rotate(1.5deg); }
.hud-portrait img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}
.win-pips {
  display: flex;
  gap: 3px;
  justify-content: center;
  margin-top: -2px;
  min-height: 7px;
}
.pip {
  display: block;
  width: clamp(5px, 1.2vw, 8px);
  height: clamp(5px, 1.2vw, 8px);
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: transparent;
}
.pip.on { background: var(--gold); }

.hp-block {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-top: clamp(6px, 1.4vh, 16px);
}
.hp-side--ai .hp-block { align-items: flex-end; }

.hp-plank {
  position: relative;
  width: 100%;
  max-width: clamp(150px, 34vw, 430px);
  aspect-ratio: 556 / 204;
  flex: 0 1 auto;
}
.hp-plank .plank {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}
.hp-plank--ai .plank { transform: scaleX(-1); }

.hp-slot {
  position: absolute;
  left: 17.2%;
  right: 15.4%;
  top: 34.5%;
  height: 27%;
  overflow: hidden;
  border-radius: 5px;
}
.hp-fill, .hp-ghost {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  display: block;
  transition: width 0.5s cubic-bezier(0.2, 0.72, 0.3, 1) 0.16s;
}
.hp-side--player .hp-fill, .hp-side--player .hp-ghost { right: 0; }
.hp-side--ai .hp-fill, .hp-side--ai .hp-ghost { left: 0; }
.hp-ghost {
  background: var(--gold);
  opacity: 0.72;
  z-index: 1;
}
.hp-fill {
  background: var(--terra);
  z-index: 2;
  transition: width 0.1s linear;
  clip-path: polygon(0.5% 5%, 98.5% 0, 100% 28%, 99% 52%, 100% 82%, 96% 100%, 3% 97%, 0 68%, 1% 36%);
}
.hp-fill::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 21%;
  background: #a53e1f;
  opacity: 0.8;
}
.hp-slot.is-instant .hp-fill,
.hp-slot.is-instant .hp-ghost { transition: none; }

.hp-name {
  margin-top: 1px;
  font-size: clamp(8px, 2vw, 12px);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--paper);
  text-shadow: 1px 2px 0 var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.hp-side--ai .hp-name { text-align: right; }

.timer-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding-top: clamp(0px, 0.6vh, 5px);
  z-index: 3;
}
.round-tag {
  font-size: clamp(7px, 1.7vw, 10px);
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--teal);
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 5px 7px 4px 6px / 6px 4px 6px 5px;
  padding: 1px 6px 2px;
  transform: rotate(-2deg);
  white-space: nowrap;
  box-shadow: 1px 2px 0 rgba(43, 33, 28, 0.28);
}
.timer-disc {
  position: relative;
  width: clamp(46px, 8.5vw, 90px);
  line-height: 0;
}
.timer-disc img { display: block; width: 100%; height: auto; }
.timer-num {
  position: absolute;
  left: 50%;
  top: 51%;
  transform: translate(-50%, -50%);
  font-family: var(--disp);
  font-weight: 400;
  font-size: clamp(19px, 3.6vw, 36px);
  line-height: 1;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.timer-num.is-low { color: var(--terra); animation: lowTick 0.65s ease-in-out infinite; }
@keyframes lowTick {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.1); }
}

.hud-buttons {
  position: absolute;
  top: calc(var(--hud-h) + 6px);
  right: 8px;
  z-index: 26;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fight-icon {
  width: clamp(34px, 5vw, 44px);
  height: clamp(34px, 5vw, 44px);
  background: rgba(246, 231, 200, 0.88);
  border: 2px solid var(--ink);
  border-radius: 50%;
  padding: 2px;
  box-shadow: 2px 2px 0 rgba(43, 33, 28, 0.32);
}
.fight-icon img { border-radius: 50%; }
.hud-buttons .sound-toggle { position: relative; top: auto; right: auto; z-index: auto; }

/* controls */
.fight-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 25;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  padding: 10px clamp(10px, 2.5vw, 26px) calc(16px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.move-pad, .action-pad, .key-hint { pointer-events: auto; }

.move-pad {
  display: flex;
  gap: clamp(5px, 1.6vw, 10px);
  align-items: flex-end;
}
.action-pad {
  position: relative;
  width: clamp(132px, 18vh, 210px);
  height: clamp(160px, 24vh, 230px);
  flex: 0 0 auto;
}

.fight-btn {
  border: 0;
  background: transparent;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  width: clamp(48px, 6.5vh, 72px);
}
.fight-btn img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.08s ease, filter 0.08s ease;
}
.fight-btn span {
  font-size: clamp(7px, 1.7vw, 9px);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--paper);
  text-shadow: 1px 1px 0 var(--ink);
  line-height: 1;
}
.fight-btn:active img, .fight-btn.is-down img { transform: scale(0.92) rotate(-3deg); filter: brightness(1.08); }
.fight-btn--strike {
  position: absolute;
  right: 0;
  bottom: 0;
  width: clamp(62px, 9vh, 96px);
}
.fight-btn--kick {
  position: absolute;
  right: clamp(66px, 9.5vh, 100px);
  bottom: 2px;
  width: clamp(48px, 6.6vh, 72px);
}
.fight-btn--block {
  position: absolute;
  right: 2px;
  bottom: clamp(88px, 13.5vh, 124px);
  width: clamp(48px, 6.6vh, 72px);
}

.key-hint {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--paper);
  text-shadow: 1px 1px 0 var(--ink);
  white-space: nowrap;
  opacity: 0.85;
  display: none;
}
@media (hover: hover) and (pointer: fine) {
  .key-hint { display: block; }
}

/* versus */
.versus {
  position: absolute;
  inset: 0;
  z-index: 34;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 2vw, 24px);
  background: rgba(30, 74, 76, 0.72);
  padding: 16px;
}
.versus.is-in { animation: vsIn 0.3s ease both; }
.versus.is-out { animation: vsOut 0.28s ease both; }
@keyframes vsIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes vsOut { from { opacity: 1; } to { opacity: 0; } }
.vs-portrait {
  width: min(26vw, 180px);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(4px 5px 0 rgba(43, 33, 28, 0.36));
}
.vs-portrait img { width: 100%; height: 100%; object-fit: contain; }
.vs-portrait--a { }
.vs-banner { width: min(38vw, 280px); }
.vs-banner img { display: block; width: 100%; height: auto; }
.vs-names {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 68%;
  display: flex;
  justify-content: space-between;
  font-family: var(--disp);
  font-size: clamp(14px, 3.5vw, 28px);
  color: var(--gold);
  text-shadow: 2px 3px 0 var(--teal);
  letter-spacing: 0.02em;
  pointer-events: none;
}

/* overlays */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(22, 52, 54, 0.68);
}
.overlay--result { z-index: 42; }

/* Round and match results sit on top of the sky, never over the fighters:
   the winner must still be readable in the arena at full size. */
#restOverlay,
#resultOverlay {
  align-items: flex-start;
  justify-content: center;
  background: transparent;
  padding: calc(var(--hud-h, 90px) + 6px) 10px 10px;
  pointer-events: auto;
}
#restOverlay .board,
#resultOverlay .board {
  width: min(92vw, 520px);
  border-width: 18px;
  border-image-width: 18px;
  padding: 7px 10px;
  gap: 3px;
  filter: drop-shadow(5px 7px 0 rgba(43, 33, 28, 0.44));
}
#restOverlay .board-title { font-size: clamp(26px, 7vw, 40px); }
#restOverlay .board-copy { font-size: clamp(9px, 2.4vw, 12px); }
#restOverlay .rest-round { font-size: 8px; }
#restOverlay .rest-count { font-size: clamp(30px, 8vw, 48px); }
#restOverlay .plank-btn { min-height: 38px; padding: 5px 12px; }
#resultOverlay .result-wrap {
  width: min(94vw, 540px);
  flex-direction: column;
  align-items: center;
  gap: 0;
}
#resultOverlay .result-decal {
  width: min(50vw, 260px);
  margin-bottom: -6px;
}
#resultOverlay .board-title { font-size: clamp(20px, 5.2vw, 32px); }
#resultOverlay .board-copy {
  font-size: clamp(9px, 2.4vw, 12px);
  max-width: 44ch;
}
#resultOverlay .result-kicker { font-size: 7px; }
#resultOverlay .result-score { font-size: clamp(16px, 4vw, 24px); }
#resultOverlay .board-buttons { gap: 5px; }
#resultOverlay .board-buttons .plank-btn {
  min-height: 38px;
  padding: 5px 7px;
  font-size: clamp(9px, 2.2vw, 11px);
  flex: 1 1 0;
  min-width: 0;
}

body[data-layout="wide"] #restOverlay,
body[data-layout="wide"] #resultOverlay {
  padding-top: calc(var(--hud-h, 90px) + 4px);
}
body[data-layout="wide"] #resultOverlay .result-wrap {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: min(94vw, 1000px);
  gap: 10px;
}
body[data-layout="wide"] #resultOverlay .result-decal { width: min(22vw, 250px); }
body[data-layout="wide"] #resultOverlay .board { width: min(58vw, 620px); }

/* The controls stay in the picture but step back while a round is resting. */
.fight-stage.is-end .fight-controls,
.fight-stage.is-end .hud-buttons {
  opacity: 0.34;
  pointer-events: none;
}

.board {
  position: relative;
  width: min(92vw, 460px);
  border: 30px solid transparent;
  border-image: url("assets/art/ui_plates_05_select_frame.webp") 46 fill / 30px stretch;
  padding: clamp(8px, 2.4vw, 18px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  text-align: center;
  color: var(--paper);
  filter: drop-shadow(6px 8px 0 rgba(43, 33, 28, 0.35));
}
.board-knot {
  width: clamp(32px, 8vw, 48px);
  margin-top: -4px;
  animation: knotSway 3.6s ease-in-out infinite alternate;
}
.board-knot img { display: block; width: 100%; height: auto; }
@keyframes knotSway {
  from { transform: rotate(-5deg); }
  to { transform: rotate(5deg); }
}
.board-title {
  margin: 0;
  font-family: var(--disp);
  font-weight: 400;
  font-size: clamp(30px, 8vw, 52px);
  line-height: 0.95;
  color: var(--gold);
  text-shadow: 3px 4px 0 var(--teal), 5px 5px 0 rgba(43, 33, 28, 0.3);
  letter-spacing: 0.01em;
}
.board-title--small { font-size: clamp(22px, 6vw, 38px); }
.board-hint {
  display: none;
  margin: 0;
  font-size: 9px;
  line-height: 1.3;
  letter-spacing: 0.03em;
  color: rgba(246, 231, 200, 0.8);
}
@media (hover: hover) and (pointer: fine) {
  .board-hint { display: block; }
}
.board-copy {
  margin: 0;
  font-size: clamp(10px, 2.6vw, 13px);
  line-height: 1.25;
  letter-spacing: 0.02em;
  color: var(--cream);
  max-width: 34ch;
}
.board-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-top: 3px;
  width: 100%;
}
.board-buttons .plank-btn { flex: 1 1 auto; min-width: 100px; }
.board-sound {
  position: absolute;
  top: -12px;
  right: -6px;
  width: 38px;
  height: 38px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 50%;
  padding: 2px;
}

.rest-round {
  font-size: clamp(8px, 2vw, 10px);
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--gold);
  border-bottom: 2px solid rgba(246, 231, 200, 0.45);
  padding-bottom: 2px;
}
.rest-count {
  font-family: var(--disp);
  font-weight: 400;
  font-size: clamp(38px, 10vw, 64px);
  line-height: 0.9;
  color: var(--paper);
  text-shadow: 2px 3px 0 var(--teal);
}
.rest-count.is-pulse { animation: countPulse 0.5s ease-out; }
@keyframes countPulse {
  0% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.overlay--result .result-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(94vw, 540px);
}
.result-decal {
  width: min(62vw, 380px);
  margin-bottom: -12px;
  z-index: 2;
  filter: drop-shadow(4px 6px 0 rgba(43, 33, 28, 0.3));
  pointer-events: none;
}
.result-decal img { display: block; width: 100%; height: auto; }
.result-decal:empty { display: none; }
.result-kicker {
  margin: 0;
  font-size: clamp(7px, 1.9vw, 9px);
  letter-spacing: 0.22em;
  color: var(--gold);
}
.result-score {
  font-family: var(--disp);
  font-weight: 400;
  font-size: clamp(18px, 5vw, 30px);
  color: var(--paper);
  letter-spacing: 0.08em;
  line-height: 1;
  text-shadow: 2px 2px 0 var(--teal);
}
.board--result { width: min(92vw, 420px); }
.board--result .board-buttons { margin-top: 2px; }
.board--result .plank-btn { flex: 1 1 28%; }

.match-toast {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%) rotate(-1.5deg) scale(0.9);
  z-index: 22;
  padding: 8px 20px 10px;
  background: var(--terra);
  border: 3px solid var(--ink);
  border-radius: 10px 16px 9px 13px / 14px 8px 12px 9px;
  box-shadow: 4px 5px 0 rgba(43, 33, 28, 0.35);
  color: var(--gold);
  font-family: var(--disp);
  font-size: clamp(20px, 5vw, 36px);
  line-height: 1;
  letter-spacing: 0.02em;
  text-shadow: 2px 2px 0 var(--teal);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  white-space: nowrap;
}
.match-toast.is-show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) rotate(-1.5deg) scale(1);
}

/* ============ TALL FIGHT LAYOUT ============ */
body[data-layout="tall"] .fight-stage {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: relative;
}
body[data-layout="tall"] .fight-hud {
  position: relative;
  order: 1;
  flex: 0 0 auto;
  background: var(--paper);
  border-bottom: 3px solid var(--ink);
  padding-bottom: 4px;
}
body[data-layout="tall"] .stage-slot {
  position: relative;
  order: 2;
  flex: 1 1 auto;
  min-height: 0;
  border-top: 0;
  border-bottom: 0;
}
body[data-layout="tall"] .fight-controls {
  position: relative;
  order: 3;
  flex: 0 0 auto;
  background: var(--paper);
  border-top: 3px solid var(--ink);
  padding-top: 7px;
}
body[data-layout="tall"] .hud-buttons {
  top: 6px;
  right: 6px;
}
body[data-layout="tall"] .fight-icon {
  background: rgba(246, 231, 200, 0.94);
}
body[data-layout="tall"] .fight-btn span {
  color: var(--teal);
  text-shadow: none;
}
body[data-layout="tall"] .hp-name {
  color: var(--teal);
  text-shadow: none;
}
body[data-layout="tall"] .hp-slot { top: 34%; height: 28%; }
body[data-layout="tall"] .fight-controls .key-hint {
  color: var(--teal);
  text-shadow: none;
  display: none;
}
body[data-layout="tall"] .action-pad {
  width: clamp(146px, 34vw, 210px);
  height: clamp(176px, 42vw, 205px);
}
body[data-layout="tall"] .fight-btn--strike { width: clamp(68px, 18vw, 100px); }
body[data-layout="tall"] .fight-btn--kick { width: clamp(54px, 13.4vw, 78px); right: clamp(80px, 18.5vw, 104px); }
body[data-layout="tall"] .fight-btn--block { width: clamp(54px, 13.4vw, 78px); bottom: clamp(100px, 23vw, 118px); }
body[data-layout="tall"] .move-pad .fight-btn { width: clamp(56px, 14vw, 82px); }

body[data-layout="tall"] .fight-hud {
  gap: 4px;
  padding-left: 6px;
  padding-right: 6px;
}
body[data-layout="tall"] .hud-portrait { width: clamp(42px, 11.5vw, 66px); }
body[data-layout="tall"] .hp-plank { max-width: clamp(120px, 36vw, 340px); }
body[data-layout="tall"] .hp-block { margin-top: 4px; }
body[data-layout="tall"] .timer-disc { width: clamp(44px, 11.5vw, 60px); }
body[data-layout="tall"] .timer-num { font-size: clamp(17px, 4.4vw, 26px); }
body[data-layout="tall"] .round-tag { font-size: clamp(6px, 1.7vw, 8px); padding: 0 4px 1px; }
body[data-layout="tall"] .hp-name { font-size: clamp(7px, 1.9vw, 10px); }
body[data-layout="tall"] .win-pips { margin-top: 0; }

/* ============ SELECT WIDE / SHORT ============ */
@media (min-width: 620px) {
  .roster-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .roster-card { max-width: 190px; }
  .roster-grid .roster-card:nth-child(10) { grid-column: auto; }
}
@media (max-width: 619px) {
  .roster-grid .roster-card:nth-child(10) { grid-column: 2; }
}

body[data-layout="wide"] .screen--select .select-content {
  gap: 6px;
  padding-left: clamp(16px, 4vw, 60px);
  padding-right: clamp(16px, 4vw, 60px);
}
body[data-layout="wide"] .roster-wrap { padding-top: 0; padding-bottom: 2px; }
body[data-layout="wide"] .roster-grid { gap: 2px clamp(8px, 2.4vw, 28px); max-width: 1180px; }
body[data-layout="wide"] .roster-card { max-width: 176px; }
body[data-layout="wide"] .medal { width: clamp(80px, 17vh, 150px); }
body[data-layout="wide"] .picked { max-width: 760px; }
body[data-layout="wide"] .select-head { padding-top: 0; }
body[data-layout="wide"] .select-foot { max-width: 1180px; margin: 0 auto; width: 100%; }

/* title adjustments for short screens */
@media (max-height: 640px) and (orientation: landscape) {
  #restOverlay,
  #resultOverlay { padding-top: calc(var(--hud-h, 70px) + 2px); }
  #resultOverlay .result-wrap,
  body[data-layout="wide"] #resultOverlay .result-wrap {
    flex-direction: row;
    width: min(96vw, 900px);
    gap: 4px;
  }
  #resultOverlay .result-decal,
  body[data-layout="wide"] #resultOverlay .result-decal { width: 104px; margin: 0; }
  #resultOverlay .board,
  body[data-layout="wide"] #resultOverlay .board {
    width: min(70vw, 620px);
    border-width: 10px;
    border-image-width: 10px;
    padding: 2px 6px;
    gap: 2px;
  }
  #resultOverlay .result-kicker,
  #resultOverlay .board-copy { display: none; }
  #resultOverlay .board-title { font-size: 18px; }
  #resultOverlay .result-score { font-size: 13px; }
  #resultOverlay .board-buttons { gap: 4px; }
  #resultOverlay .board-buttons .plank-btn {
    min-height: 28px;
    padding: 2px 5px;
    font-size: 9px;
  }
  #restOverlay .board {
    width: min(70vw, 520px);
    border-width: 10px;
    border-image-width: 10px;
    padding: 2px 8px;
    gap: 1px;
  }
  #restOverlay .board-title { font-size: 22px; }
  #restOverlay .board-copy { display: none; }
  #restOverlay .rest-count { font-size: 24px; }
  #restOverlay .plank-btn { min-height: 26px; padding: 2px 8px; font-size: 9px; }
}

@media (max-height: 560px) {
  .title-sign-wrap { height: 52%; }
  .title-stamp { display: none; }
  .title-below { padding-top: 4px; padding-bottom: 4px; }
  .start-disc { width: 40px; }
  .start-word { font-size: clamp(24px, 5vw, 34px); }
  .duo { height: min(20vw, 22vh, 130px); }
  .title-line { display: none; }
  .select-sub { display: none; }
  .kicker { display: none; }
  .picked { padding: 3px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .title-sign-wrap { transform: translateX(-50%) rotate(-1.8deg); }
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  padding: 24px;
  text-align: center;
}
