/* Pueblo Commit — an original GBA-era pixel RPG world fused with MMA.
   Palette: deep navy night, warm paper boxes, fight-poster red and gold. */
:root {
  --night: #1a1c2c;
  --night-2: #29366f;
  --paper: #f4f4f4;
  --ink: #1a1c2c;
  --red: #b13e53;
  --red-2: #ef7d57;
  --gold: #ffcd75;
  --green: #38b764;
  --lime: #a7f070;
  --blue: #3b5dc9;
  --sky: #41a6f6;
  --grey: #94b0c2;
  --pixel: "Pixelify Sans", system-ui, sans-serif;
  --arcade: "Press Start 2P", "Pixelify Sans", monospace;
  --s: 3;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { overflow-x: clip; -webkit-text-size-adjust: 100%; }
body {
  min-height: 100svh;
  background: var(--night);
  background-image: radial-gradient(circle at 50% 0%, #333c57 0, transparent 60%);
  color: var(--paper);
  font: 400 18px/1.45 var(--pixel);
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* ------------------------------------------------------------------ top bar */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap;
  padding: 14px clamp(16px, 3vw, 32px);
}
.bar__name { font: 400 14px/1 var(--arcade); text-decoration: none; color: var(--gold); letter-spacing: .02em; }
.styles { display: flex; gap: 6px 14px; align-items: center; font-size: 16px; color: var(--grey); flex-wrap: wrap; }
.styles a { text-decoration: none; padding: 8px 2px; color: var(--grey); }
.styles a[aria-current] { color: var(--paper); box-shadow: inset 0 -3px 0 var(--gold); }
.bar__end { display: flex; align-items: center; gap: 14px; }
.lang { display: flex; gap: 2px; }
.lang button { background: none; border: 0; cursor: pointer; padding: 8px 6px; color: var(--grey); font-size: 16px; }
.lang button[aria-pressed="true"] { color: var(--paper); }

.cta {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  font: 400 12px/1.2 var(--arcade); letter-spacing: .02em; text-decoration: none;
  color: var(--ink); background: var(--gold); border: 0; cursor: pointer;
  box-shadow: inset -4px -4px 0 #d99c3c, 0 0 0 3px var(--ink), 0 0 0 6px var(--gold);
  transition: scale 150ms var(--ease), translate 150ms var(--ease);
  animation: beckon 2.6s steps(1, end) infinite;
}
.cta:active { scale: .96; }
@media (hover: hover) and (pointer: fine) { .cta:hover { translate: 0 -2px; } }
@keyframes beckon { 0%, 86% { filter: none; } 88%, 92% { filter: brightness(1.25); } 90%, 94% { filter: none; } }
.cta--big { min-height: 56px; padding: 0 24px; font-size: 13px; animation: none; }

.ghost { background: none; border: 0; cursor: pointer; color: var(--grey); font-size: 17px; padding: 10px 6px; text-decoration: underline; text-underline-offset: 4px; }
.ghost--small { font-size: 15px; }
@media (hover: hover) and (pointer: fine) { .ghost:hover { color: var(--paper); } }

/* ------------------------------------------------------------------ the world */
.screen { display: grid; justify-items: center; gap: 10px; padding: 4px 12px 24px; }
.frame {
  position: relative;
  width: calc(384px * var(--s));
  box-shadow: 0 0 0 4px var(--ink), 0 0 0 8px #5d6b8a, 0 0 0 12px var(--ink), 0 30px 60px rgb(0 0 0 / .45);
  animation: boot 700ms steps(7, end) both;
}
@keyframes boot { from { filter: brightness(3) saturate(0); } to { filter: none; } }
.view { position: relative; height: calc(240px * var(--s)); }
#world { display: block; width: 100%; height: 100%; image-rendering: pixelated; cursor: pointer; outline-offset: 10px; }

.labels { position: absolute; inset: 0; pointer-events: none; }
.label {
  position: absolute; translate: -50% -100%;
  font: 700 clamp(11px, calc(var(--s) * 3.6px), 16px)/1 var(--pixel); letter-spacing: .04em;
  padding: 4px 7px 3px; background: var(--ink); color: var(--paper); white-space: nowrap;
  box-shadow: 0 0 0 2px var(--paper);
}
.label--hero { background: var(--red); color: var(--paper); animation: bob 1.2s steps(2, end) infinite; }
@keyframes bob { 50% { translate: -50% calc(-100% - 3px); } }

.place {
  position: absolute; left: 3%; top: 4%;
  font: 400 clamp(9px, calc(var(--s) * 3px), 14px)/1 var(--arcade);
  padding: 10px 12px; background: var(--paper); color: var(--ink);
  box-shadow: 0 0 0 3px var(--ink), inset 0 -4px 0 #c2c3c7;
  animation: place 3.4s var(--ease) 500ms both;
}
@keyframes place { 0% { translate: 0 -160%; } 12%, 84% { translate: 0 0; } 100% { translate: 0 -160%; } }

/* dialogue box */
.box {
  position: absolute; left: 2.5%; right: 2.5%; bottom: 3%;
  min-height: 0;
  padding: clamp(10px, calc(var(--s) * 4px), 18px) clamp(14px, calc(var(--s) * 6px), 26px);
  background: var(--paper); color: var(--ink);
  box-shadow: 0 0 0 4px var(--ink), inset 0 0 0 3px #c2c3c7, inset 0 0 0 6px var(--paper), inset 0 0 0 9px var(--blue);
  font-size: clamp(16px, calc(var(--s) * 7px), 26px); line-height: 1.35;
  animation: pop 180ms var(--ease) both;
}
@keyframes pop { from { scale: .98 .9; opacity: 0; } to { scale: 1; opacity: 1; } }
.box__who { margin: 0 0 4px; font: 700 clamp(13px, calc(var(--s) * 4.2px), 18px)/1.2 var(--pixel); letter-spacing: .06em; color: var(--red); }
.box__text { margin: 0; min-height: 2.7em; max-width: 64ch; }
.box__next { position: absolute; right: 18px; bottom: 10px; color: var(--red); animation: blink 700ms steps(1, end) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.box__choices { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 22px; }
.box__choices a, .box__choices button {
  display: inline-flex; gap: 8px; align-items: center; min-height: 40px;
  background: none; border: 0; padding: 0 4px; cursor: pointer; text-decoration: none;
  font-size: inherit; color: var(--ink);
}
.box__choices :is(a, button)::before { content: "▶"; color: var(--red); visibility: hidden; font-size: .7em; }
.box__choices :is(a, button):is(:hover, :focus-visible, .is-on)::before { visibility: visible; }
.box__choices :is(a, button):focus-visible { outline: none; }

.help { margin: 14px 0 0; font-size: 16px; color: var(--grey); text-align: center; }

/* ------------------------------------------------------------------ the fight */
.fight {
  position: fixed; inset: 0; z-index: 30;
  display: grid; align-content: center; justify-items: center; gap: 0;
  padding: 16px; background: var(--night);
  overflow-y: auto;
}
.fight[hidden] { display: none; }
.fight__wipe {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  background: repeating-linear-gradient(0deg, var(--ink) 0 24px, var(--paper) 24px 48px);
  animation: wipe 900ms steps(9, end) both;
}
@keyframes wipe { 0% { clip-path: inset(0 100% 0 0); } 45% { clip-path: inset(0 0 0 0); } 100% { clip-path: inset(0 0 0 100%); } }

.fight__arena {
  position: relative; width: min(960px, 100%); aspect-ratio: 2 / 1;
  box-shadow: 0 0 0 4px var(--ink), 0 0 0 8px #5d6b8a, 0 0 0 12px var(--ink);
  overflow: hidden;
}
.fight__bg { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.fighter { position: absolute; image-rendering: pixelated; }
.fighter--hero { left: 16%; bottom: 9%; width: 24%; animation: enter-l 700ms steps(7, end) 500ms both; }
.fighter--foe { right: 14%; bottom: 9%; width: 27%; animation: enter-r 700ms steps(7, end) 500ms both; }
@keyframes enter-l { from { translate: -260% 0; } to { translate: 0 0; } }
@keyframes enter-r { from { translate: 260% 0; } to { translate: 0 0; } }
.fighter--hero.is-hit-move { animation: lunge 420ms steps(6, end) both; }
@keyframes lunge { 40% { translate: 70% -4%; } 100% { translate: 0 0; } }
.fighter--foe.is-hurt { animation: hurt 480ms steps(8, end) both; }
@keyframes hurt { 0%, 25%, 50%, 75% { translate: 6% 0; filter: brightness(4); } 12%, 37%, 62%, 87% { translate: -6% 0; filter: none; } 100% { translate: 0 0; } }
.fighter--foe.is-down { animation: down 1.1s steps(10, end) both; }
@keyframes down { to { translate: 0 30%; opacity: 0; filter: grayscale(1); } }
.fighter--foe.is-idle, .fighter--hero.is-idle { animation: idle 1s steps(2, end) infinite; }
@keyframes idle { 50% { translate: 0 -2%; } }
.fx { position: absolute; right: 22%; bottom: 30%; width: 16%; image-rendering: pixelated; opacity: 0; }
.fx.is-on { animation: fx 420ms steps(4, end) both; }
@keyframes fx { 0% { opacity: 1; scale: .4; } 60% { opacity: 1; scale: 1.2; } 100% { opacity: 0; scale: 1.4; } }
.dmg { position: absolute; right: 22%; bottom: 62%; font: 400 clamp(14px, 2.4vw, 24px)/1 var(--arcade); color: var(--gold); text-shadow: 3px 3px 0 var(--ink); opacity: 0; }
.dmg.is-on { animation: dmg 800ms var(--ease) both; }
@keyframes dmg { 0% { opacity: 0; translate: 0 10px; } 20% { opacity: 1; translate: 0 0; } 80% { opacity: 1; translate: 0 -10px; } 100% { opacity: 0; translate: 0 -14px; } }
.ko {
  position: absolute; inset: 0; display: grid; place-items: center; margin: 0;
  font: 400 clamp(48px, 12vw, 120px)/1 var(--arcade); color: var(--gold);
  text-shadow: 6px 6px 0 var(--red), 12px 12px 0 var(--ink);
  opacity: 0; pointer-events: none;
}
.ko.is-on { animation: ko 1.4s var(--ease) both; }
@keyframes ko { 0% { opacity: 0; scale: 2.2; } 18% { opacity: 1; scale: .94; } 26% { scale: 1; } 80% { opacity: 1; } 100% { opacity: 0; scale: 1; } }

.hud {
  position: relative; z-index: 2; width: min(960px, 100%);
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: end;
  margin-top: 12px;
  order: -1; margin-bottom: 12px;
}
.hp { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: baseline; }
.hp__name { font: 700 clamp(15px, 1.8vw, 20px)/1.2 var(--pixel); letter-spacing: .06em; color: var(--paper); }
.hp__lv { font-size: 15px; color: var(--grey); justify-self: end; }
.hp--foe .hp__lv { justify-self: start; }
.hp--foe { grid-template-columns: 1fr auto; }
.hp--foe .hp__name { justify-self: end; grid-column: 2; grid-row: 1; }
.hp--foe .hp__lv { grid-column: 1; grid-row: 1; }
.hp__bar { grid-column: 1 / -1; height: 18px; background: var(--ink); box-shadow: 0 0 0 3px var(--paper); position: relative; overflow: hidden; }
.hp__bar i { position: absolute; inset: 3px; right: auto; width: calc((100% - 6px) * var(--hp) / 100); background: var(--green); transition: width 700ms steps(14, end), background-color 200ms; }
.hp--foe .hp__bar i { left: auto; right: 3px; }
.hp__bar i[data-low] { background: var(--gold); }
.hp__bar i[data-crit] { background: var(--red); }
.round { font: 400 clamp(12px, 1.6vw, 16px)/1 var(--arcade); color: var(--ink); background: var(--gold); padding: 10px 12px; box-shadow: 0 0 0 3px var(--ink); align-self: center; }

.fight__ui {
  width: min(960px, 100%); margin-top: 18px;
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px;
}
.fight__text {
  margin: 0; min-height: 96px; padding: 16px 20px;
  background: var(--paper); color: var(--ink); font-size: clamp(17px, 1.9vw, 22px); line-height: 1.35;
  box-shadow: 0 0 0 4px var(--ink), inset 0 0 0 3px #c2c3c7, inset 0 0 0 6px var(--paper), inset 0 0 0 9px var(--red);
}
.fight__ui:has(.moves[hidden]) .fight__text { grid-column: 1 / -1; }
.moves[hidden], .box__choices[hidden] { display: none; }
.moves { list-style: none; margin: 0; padding: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--paper); box-shadow: 0 0 0 4px var(--ink), inset 0 0 0 3px #c2c3c7; }
.moves button {
  width: 100%; min-height: 48px; padding: 6px 10px 6px 26px; text-align: left; position: relative;
  background: none; border: 0; cursor: pointer; color: var(--ink);
  font: 400 clamp(8px, 1vw, 11px)/1.4 var(--arcade);
}
.moves button::before { content: "▶"; position: absolute; left: 8px; color: var(--red); visibility: hidden; }
.moves button:is(:hover, :focus-visible)::before { visibility: visible; }
.moves button:focus-visible { outline: none; background: #e4e6ee; }
.moves small { display: block; font: 400 14px/1.2 var(--pixel); color: #5d6b8a; margin-top: 4px; }

.levelup {
  position: absolute; inset: 0; z-index: 4;
  display: grid; align-content: center; justify-items: center; gap: 18px; padding: 24px;
  background: rgb(26 28 44 / .94);
  text-align: center;
  animation: pop 300ms var(--ease) both;
}
.levelup[hidden] { display: none; }
.levelup__title { margin: 0; font: 700 clamp(26px, 4vw, 46px)/1.2 var(--pixel); letter-spacing: .04em; color: var(--gold); text-shadow: 4px 4px 0 var(--red); }
.levelup__stats { list-style: none; margin: 0; padding: 18px 22px; width: min(520px, 100%); display: grid; gap: 12px;
  background: var(--paper); color: var(--ink); box-shadow: 0 0 0 4px var(--ink), inset 0 0 0 3px #c2c3c7; font-size: 19px; text-align: left; }
.levelup__stats li { display: grid; grid-template-columns: 1fr 44%; gap: 12px; align-items: center; }
.stat { height: 14px; background: var(--ink); position: relative; }
.stat i { position: absolute; inset: 3px; right: auto; width: 0; background: var(--green); transition: width 900ms steps(12, end); }
.levelup.is-on .stat i { width: calc(100% - 6px); }
.levelup.is-on li:nth-child(2) .stat i { transition-delay: 350ms; }
.levelup.is-on li:nth-child(3) .stat i { transition-delay: 700ms; }
.levelup__ask { margin: 0; font-size: clamp(20px, 2.4vw, 26px); }
.levelup__actions { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: center; }

/* confetti (pixel stars) on KO */
.star { position: absolute; width: 8px; height: 8px; background: var(--gold); box-shadow: 8px 0 0 var(--gold), -8px 0 0 var(--gold), 0 8px 0 var(--gold), 0 -8px 0 var(--gold); pointer-events: none; animation: star 1.4s steps(10, end) both; }
@keyframes star { from { opacity: 1; translate: 0 0; } to { opacity: 0; translate: var(--dx) var(--dy); } }

/* ------------------------------------------------------------------ small screens */
@media (max-width: 720px) {
  .bar { padding: 12px 14px; }
  .bar__end { width: 100%; justify-content: space-between; }
  .screen { padding: 4px 8px 24px; }
  .box { position: relative; left: auto; right: auto; bottom: auto; margin: 12px 0 0; min-height: 0; }
  .frame { margin-bottom: 0; }
  .label { font-size: 10px; padding: 3px 4px 2px; }
  .fight { align-content: start; padding: 12px 10px 24px; }
  .fight__ui { grid-template-columns: 1fr; }
  .moves button { font-size: 9px; }
  .hp__lv { display: none; }
  .hp, .hp--foe { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .frame, .place, .fight__wipe, .cta { animation: none; }
  .label--hero, .fighter.is-idle, .box__next { animation: none; }
  .fighter--hero, .fighter--foe { animation: none; }
  .fighter--hero.is-hit-move, .fighter--foe.is-hurt { animation: none; }
  .ko.is-on { animation: fade 1.4s linear both; }
  @keyframes fade { 0%, 100% { opacity: 0; } 20%, 80% { opacity: 1; } }
  .star { display: none; }
}
.is-paused .label--hero, .is-paused .cta, .is-paused .fighter.is-idle { animation-play-state: paused; }
