* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: radial-gradient(circle at top, #232b35 0%, #101318 55%, #07090c 100%);
  font-family: Arial, Helvetica, sans-serif;
  color: #fff;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

.game-shell {
  width: 100vw;
  max-width: 430px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: rgba(7, 9, 12, 0.82);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 12px;
  flex-wrap: wrap;
}

.view-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.view-toggle {
  width: 38px;
  height: 38px;
  margin: 0;
  padding: 0;
  border-radius: 12px;
  font-size: 22px;
  line-height: 1;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f6c445;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: #d6d6d6;
}

.game {
  --sky-top: #7fd8ff;
  --sky-mid: #9be7ff;
  --sky-low: #f7d27a;
  --ground-top: #6f8b45;
  --ground-low: #2f4420;
  --sun-opacity: 1;
  --moon-opacity: 0;
  --stars-opacity: 0;
  --dusk-opacity: 0;
  --night-tint: 0;
  --time-darkness: 0;
  --skyline-speed: 18s;
  --cloud-speed: 24s;
  --mountain-speed: 30s;
  --tree-back-speed: 8s;
  --tree-front-speed: 4s;
  --landscape-speed: 18s;
  --floor-speed: 2.2s;
  position: relative;
  width: 100%;
  flex: 1;
  height: auto;
  min-height: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: #171247;
  box-shadow: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 500ms linear;
}

.game::before {
  content: "";
  position: absolute;
  left: 54px;
  top: 50px;
  width: 46px;
  height: 46px;
  background:
    linear-gradient(#fff3a6 0 0) 8px 0 / 30px 8px no-repeat,
    linear-gradient(#fff3a6 0 0) 0 8px / 46px 30px no-repeat,
    linear-gradient(#fff3a6 0 0) 8px 38px / 30px 8px no-repeat;
  image-rendering: pixelated;
  opacity: var(--sun-opacity);
  filter: drop-shadow(0 0 16px rgba(255, 226, 118, 0.75));
  pointer-events: none;
  z-index: 1;
}

.game::after {
  content: "";
  position: absolute;
  right: 56px;
  top: 46px;
  width: 42px;
  height: 42px;
  background:
    linear-gradient(#e6f3ff 0 0) 8px 0 / 26px 8px no-repeat,
    linear-gradient(#e6f3ff 0 0) 0 8px / 34px 26px no-repeat,
    linear-gradient(#e6f3ff 0 0) 8px 34px / 26px 8px no-repeat,
    linear-gradient(var(--sky-top) 0 0) 22px 8px / 20px 24px no-repeat;
  image-rendering: pixelated;
  opacity: var(--moon-opacity);
  filter: drop-shadow(0 0 14px rgba(214, 239, 255, 0.55));
  pointer-events: none;
  z-index: 1;
}

.landscape,
.skyline,
.clouds,
.mountains,
.trees-back,
.road,
.trees-front,
.floor-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.landscape {
  background-image: url("../assets/backgrounds/pixel-sun-landscape-hq.png");
  background-repeat: repeat-x;
  background-size: auto 100%;
  background-position: 0 0;
  animation: scrollLandscape var(--landscape-speed) linear infinite;
  image-rendering: pixelated;
  z-index: 1;
  opacity: 1;
  transition: opacity 2400ms linear;
}

.landscape::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      rgba(7, 10, 38, calc(var(--time-darkness) * 0.35)),
      rgba(3, 5, 19, calc(var(--time-darkness) * 0.68))
  );
  mix-blend-mode: multiply;
}

.landscape-next {
  opacity: 0;
  z-index: 2;
}

.landscape-next.is-visible {
  opacity: 1;
}

.skyline {
  background-image:
    linear-gradient(rgba(255, 255, 210, var(--stars-opacity)) 0 0),
    linear-gradient(rgba(255, 255, 210, calc(var(--stars-opacity) * 0.7)) 0 0),
    linear-gradient(90deg, rgba(255, 255, 255, 0.14) 0 2px, transparent 2px 34px);
  background-position: 18px 24px, 58px 48px, 0 0;
  background-size: 3px 3px, 2px 2px, 96px 100%;
  background-repeat: repeat;
  animation: scrollBg var(--skyline-speed) linear infinite;
  opacity: 0;
  z-index: 2;
}

.clouds {
  top: 24px;
  height: 130px;
  background-image:
    linear-gradient(#ffffff 0 0),
    linear-gradient(#ffffff 0 0),
    linear-gradient(#ffffff 0 0),
    linear-gradient(#edf8ff 0 0),
    linear-gradient(#ffffff 0 0),
    linear-gradient(#ffffff 0 0),
    linear-gradient(#edf8ff 0 0);
  background-size:
    34px 12px,
    58px 18px,
    30px 12px,
    82px 10px,
    28px 10px,
    50px 16px,
    72px 10px;
  background-position:
    28px 32px,
    58px 20px,
    110px 34px,
    34px 48px,
    245px 70px,
    272px 58px,
    230px 84px;
  background-repeat: repeat-x;
  animation: scrollBg var(--cloud-speed) linear infinite;
  image-rendering: pixelated;
  opacity: 0;
  z-index: 2;
}

.mountains {
  top: 115px;
  height: 180px;
  background:
    linear-gradient(135deg, transparent 0 43%, rgba(80, 121, 104, 0.42) 43% 54%, transparent 54%),
    linear-gradient(45deg, transparent 0 42%, rgba(185, 216, 164, 0.24) 42% 52%, transparent 52%),
    linear-gradient(90deg, rgba(63, 113, 67, 0.16) 0 42px, transparent 42px 80px);
  background-size: 360px 170px, 520px 170px, 160px 170px;
  animation: scrollBg var(--mountain-speed) linear infinite;
  opacity: 0;
  z-index: 2;
}

.trees-back,
.trees-front {
  image-rendering: pixelated;
  background-repeat: repeat-x;
}

.trees-back {
  top: 210px;
  height: 150px;
  background-image:
    linear-gradient(#2f6f45 0 0),
    linear-gradient(#3f8a51 0 0),
    linear-gradient(#2a5131 0 0),
    linear-gradient(#5a3922 0 0),
    linear-gradient(#2f6f45 0 0),
    linear-gradient(#3f8a51 0 0),
    linear-gradient(#2a5131 0 0),
    linear-gradient(#5a3922 0 0);
  background-size:
    34px 18px,
    52px 26px,
    38px 18px,
    10px 42px,
    28px 16px,
    44px 22px,
    30px 15px,
    8px 34px;
  background-position:
    38px 32px,
    24px 44px,
    42px 66px,
    48px 82px,
    198px 46px,
    184px 58px,
    204px 78px,
    212px 92px;
  animation: scrollBg var(--tree-back-speed) linear infinite;
  opacity: 0;
  z-index: 3;
}

.road {
  top: 335px;
  background:
    linear-gradient(100deg, transparent 0 18%, rgba(255, 232, 151, 0.38) 18% 21%, transparent 21% 100%),
    linear-gradient(80deg, transparent 0 78%, rgba(255, 232, 151, 0.32) 78% 81%, transparent 81% 100%),
    linear-gradient(180deg, #7d5c37 0%, #4c3320 58%, #24170f 100%);
  clip-path: polygon(18% 0, 82% 0, 100% 100%, 0 100%);
  opacity: 0;
  z-index: 3;
}

.trees-front {
  top: 272px;
  height: 190px;
  background-image:
    linear-gradient(#1e5d35 0 0),
    linear-gradient(#2f7b41 0 0),
    linear-gradient(#174328 0 0),
    linear-gradient(#4c2d1d 0 0),
    linear-gradient(#1f6237 0 0),
    linear-gradient(#39884b 0 0),
    linear-gradient(#174328 0 0),
    linear-gradient(#4c2d1d 0 0);
  background-size:
    44px 22px,
    68px 34px,
    48px 22px,
    14px 68px,
    34px 18px,
    58px 28px,
    40px 20px,
    12px 58px;
  background-position:
    96px 28px,
    78px 48px,
    104px 82px,
    116px 108px,
    305px 48px,
    288px 66px,
    310px 98px,
    320px 120px;
  animation: scrollBg var(--tree-front-speed) linear infinite;
  opacity: 0;
  z-index: 4;
}

.floor-lines {
  top: 350px;
  background-image:
    linear-gradient(rgba(255, 218, 114, 0.2), rgba(255, 218, 114, 0)),
    repeating-linear-gradient(90deg, rgba(246, 196, 69, 0.28) 0 70px, transparent 70px 160px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 2px, transparent 2px 18px);
  animation: scrollBg var(--floor-speed) linear infinite;
  opacity: 0;
  z-index: 5;
}

.time-tint {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 112, 45, var(--dusk-opacity)), rgba(4, 10, 27, var(--night-tint)));
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 3;
}

@keyframes scrollBg {
  from { background-position-x: 0; }
  to { background-position-x: -1000px; }
}

@keyframes scrollLandscape {
  from { background-position-x: 0; }
  to { background-position-x: -2172px; }
}

.lane-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  z-index: 4;
}

.lane-line {
  opacity: 0;
}

.lane-line.lane-top { top: 54%; }
.lane-line.lane-mid { top: 69%; }
.lane-line.lane-bottom { top: 76%; }

.calibration-mode .lane-line {
  height: 3px;
  opacity: 1;
  z-index: 21;
  box-shadow: 0 0 10px currentColor;
}

.calibration-mode .lane-line::after {
  position: absolute;
  left: 10px;
  top: -22px;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(5, 8, 12, 0.78);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.calibration-mode .lane-line.lane-top {
  background: rgba(88, 197, 255, 0.9);
  color: #58c5ff;
}

.calibration-mode .lane-line.lane-top::after {
  content: "ALTO";
}

.calibration-mode .lane-line.lane-mid {
  background: rgba(255, 215, 76, 0.95);
  color: #ffd74c;
}

.calibration-mode .lane-line.lane-mid::after {
  content: "MEDIO";
}

.calibration-mode .lane-line.lane-bottom {
  background: rgba(110, 255, 134, 0.95);
  color: #6eff86;
}

.calibration-mode .lane-line.lane-bottom::after {
  content: "BAJO";
}

.calibration-panel {
  position: absolute;
  right: calc(10px + env(safe-area-inset-right));
  top: calc(66px + env(safe-area-inset-top));
  z-index: 42;
  width: min(284px, calc(100% - 20px));
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: rgba(6, 8, 12, 0.86);
  color: #fff;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38);
  pointer-events: auto;
}

.calibration-panel h2 {
  margin-bottom: 4px;
  font-size: 15px;
  line-height: 1.2;
}

.calibration-panel p {
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
}

.calibration-row {
  display: grid;
  grid-template-columns: 1fr 38px 56px 38px;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.calibration-row span {
  font-size: 12px;
  font-weight: 700;
}

.calibration-row strong {
  color: #ffd74c;
  font-size: 12px;
  text-align: center;
}

.calibration-row button,
.calibration-actions button {
  width: auto;
  margin: 0;
  padding: 7px 8px;
  border-radius: 9px;
  font-size: 14px;
  line-height: 1;
}

.calibration-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.calibration-actions button {
  font-size: 12px;
}

.karateka {
  position: absolute;
  left: 28%;
  width: 68px;
  height: 96px;
  transform: translateX(-50%);
  z-index: 8;
  transition: top 0.12s ease-out;
}

.karateka-sprite {
  position: absolute;
  inset: -18px -22px -10px -18px;
  width: calc(100% + 40px);
  height: calc(100% + 28px);
  object-fit: contain;
  image-rendering: pixelated;
  opacity: 0;
  pointer-events: none;
}

.karateka.has-sprite .karateka-sprite {
  opacity: 1;
}

.karateka.has-sprite.punch .karateka-sprite,
.karateka.has-sprite.jumpkick .karateka-sprite {
  transform: scale(1.22);
  transform-origin: center center;
}

.karateka.has-sprite.sweep {
  width: 126px;
  height: 88px;
}

.karateka.has-sprite.sweep .karateka-sprite {
  inset: -18px -20px -18px -16px;
  width: calc(100% + 36px);
  height: calc(100% + 36px);
  transform: scale(1.18);
  transform-origin: center center;
  animation: karatekaSweepMotion var(--action-duration, 240ms) steps(2, end) infinite;
}

.karateka.hurt {
  animation: hurtBlink 420ms steps(2, end);
}

.karateka.has-sprite .head,
.karateka.has-sprite .body,
.karateka.has-sprite .arm,
.karateka.has-sprite .leg {
  display: none;
}

.karateka .head {
  width: 30px;
  height: 30px;
  background: #f1c29a;
  border-radius: 50%;
  margin: 0 auto 3px;
  border: 3px solid #151515;
}

.karateka .body {
  width: 48px;
  height: 48px;
  background: #f8f8f8;
  border: 3px solid #151515;
  border-radius: 8px;
  margin: 0 auto;
  position: relative;
}

.karateka .belt {
  position: absolute;
  left: -4px;
  right: -4px;
  top: 22px;
  height: 8px;
  background: #111;
  border-radius: 8px;
}

.karateka .arm,
.karateka .leg {
  position: absolute;
  background: #f8f8f8;
  border: 3px solid #151515;
  border-radius: 12px;
  transform-origin: center top;
}

.karateka .arm.left {
  width: 18px;
  height: 46px;
  left: 4px;
  top: 40px;
  transform: rotate(28deg);
}

.karateka .arm.right {
  width: 18px;
  height: 46px;
  right: 4px;
  top: 40px;
  transform: rotate(-28deg);
}

.karateka .leg.left {
  width: 20px;
  height: 46px;
  left: 20px;
  top: 78px;
  transform: rotate(10deg);
}

.karateka .leg.right {
  width: 20px;
  height: 46px;
  right: 20px;
  top: 78px;
  transform: rotate(-10deg);
}

.karateka.punch .arm.right {
  width: 64px;
  height: 18px;
  right: -42px;
  top: 49px;
  transform: rotate(0deg);
  background: #fff;
}

.karateka.kick .leg.right,
.karateka.sweep .leg.right {
  width: 66px;
  height: 20px;
  right: -44px;
  top: 86px;
  transform: rotate(-8deg);
  background: #fff;
}

.karateka.jumpkick .leg.right {
  width: 66px;
  height: 20px;
  right: -44px;
  top: 36px;
  transform: rotate(-18deg);
  background: #fff;
}

.enemy {
  position: absolute;
  right: -80px;
  width: 72px;
  height: 72px;
  transform-origin: center center;
  z-index: 7;
}

.enemy-sprite {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
}

.enemy.bird {
  width: 69px;
  height: 69px;
}

.enemy.paperPlane,
.enemy.balloonBomb {
  width: 78px;
  height: 78px;
}

.enemy.ninja {
  width: 69px;
  height: 69px;
}

.enemy.sumo,
.enemy.robot {
  width: 81px;
  height: 81px;
}

.enemy.snake {
  width: 96px;
  height: 69px;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.35)) drop-shadow(0 0 6px rgba(184, 255, 95, 0.34));
}

.enemy.rollingBomb,
.enemy.cactusSlider {
  width: 81px;
  height: 63px;
}

.enemy.jungleCockatoo {
  width: 118px;
  height: 86px;
}

.enemy.jungleTropicalBat {
  width: 118px;
  height: 82px;
}

.enemy.jungleTribalArrow {
  width: 120px;
  height: 44px;
}

.enemy.jungleKarateMonkey {
  width: 96px;
  height: 96px;
}

.enemy.jungleMaskWarrior {
  width: 106px;
  height: 108px;
}

.enemy.jungleAngryTotem {
  width: 98px;
  height: 104px;
}

.enemy.jungleBigSnake {
  width: 122px;
  height: 58px;
}

.enemy.junglePoisonFrog {
  width: 104px;
  height: 58px;
}

.enemy.jungleSnapPlant {
  width: 120px;
  height: 62px;
}

.enemy.snowScarfPenguin,
.enemy.snowPolarOwl,
.enemy.desertRedVulture,
.enemy.desertMagicCarpet,
.enemy.desertGoldScarab,
.enemy.nuclearToxicDrone,
.enemy.nuclearMutantFly,
.enemy.nuclearRadBat,
.enemy.moonTinyUfo,
.enemy.moonWingedAlien,
.enemy.moonFaceMeteor {
  width: 118px;
  height: 86px;
}

.enemy.snowWingedSnowball {
  width: 90px;
  height: 86px;
}

.enemy.snowTinyYeti,
.enemy.snowBoxingSnowman,
.enemy.snowAngrySkier,
.enemy.desertKarateMummy,
.enemy.desertBandit,
.enemy.desertPharaohStatue,
.enemy.nuclearHazmatZombie,
.enemy.nuclearGreenMutant,
.enemy.nuclearBarrelWalker,
.enemy.moonRivalAstronaut,
.enemy.moonAlienKarateka,
.enemy.moonMoonRobot {
  width: 104px;
  height: 104px;
}

.enemy.nuclearGreenMutant,
.enemy.nuclearBarrelWalker,
.enemy.moonMoonRobot {
  width: 116px;
  height: 110px;
}

.enemy.snowSledSlider,
.enemy.snowRollingSnowball,
.enemy.desertLittleScorpion,
.enemy.desertSandSnake,
.enemy.desertAngryTumbleweed,
.enemy.nuclearToxicSlime,
.enemy.nuclearMutantRoach,
.enemy.nuclearRadMine,
.enemy.moonRollingMoonRock,
.enemy.moonAngryRover,
.enemy.moonSpaceWorm {
  width: 124px;
  height: 64px;
}

.enemy.snowLivingIcicle {
  width: 102px;
  height: 72px;
}

.enemy.moonAngryRover {
  width: 132px;
  height: 66px;
}

.enemy .head {
  width: 17px;
  height: 17px;
  background: #d9a270;
  border-radius: 50%;
  border: 2px solid #101010;
  margin: 0 auto 2px;
}

.enemy .body {
  width: 26px;
  height: 30px;
  border-radius: 6px;
  margin: 0 auto;
  background: #d94848;
  border: 2px solid #101010;
}

.enemy .legs {
  width: 23px;
  height: 11px;
  margin: -2px auto 0;
  border-left: 6px solid #101010;
  border-right: 6px solid #101010;
}

.enemy.top .body { background: #7cc4ff; }
.enemy.mid .body { background: #f6c445; }
.enemy.bottom .body { background: #d94848; }

.boss {
  position: absolute;
  left: 100%;
  width: 148px;
  height: 148px;
  transform: translateY(-50%);
  transform-origin: center center;
  z-index: 9;
  filter: drop-shadow(0 12px 0 rgba(0, 0, 0, 0.28)) drop-shadow(0 0 18px rgba(246, 196, 69, 0.2));
}

.boss-sprite {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.boss-label,
.boss-cue {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(7, 9, 12, 0.82);
  border: 1px solid rgba(246, 196, 69, 0.55);
  color: #f6c445;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.boss-label {
  top: -28px;
}

.boss-cue {
  bottom: -26px;
  color: #ffffff;
}

.boss-health {
  position: absolute;
  left: 16px;
  right: 16px;
  top: -8px;
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.45);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
}

.boss-health-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff3b3b, #f6c445);
  transition: width 120ms ease-out;
}

.boss.entering {
  animation: bossEnter 320ms steps(2, end) infinite;
}

.boss.vulnerable {
  filter: drop-shadow(0 12px 0 rgba(0, 0, 0, 0.28)) drop-shadow(0 0 18px rgba(246, 196, 69, 0.5));
}

.boss.vulnerable .boss-sprite {
  animation: bossFightMotion 300ms steps(2, end) infinite;
}

.boss.hit {
  filter: brightness(1.9) drop-shadow(0 0 22px rgba(255, 255, 255, 0.7));
}

.boss.defeated {
  animation: bossDefeat 720ms ease-out forwards;
}

.boss-alert {
  position: absolute;
  left: 50%;
  top: 18%;
  z-index: 16;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(7, 9, 12, 0.86);
  border: 2px solid rgba(246, 196, 69, 0.8);
  color: #f6c445;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  pointer-events: none;
  animation: bossAlert 1400ms ease-out forwards;
}

@keyframes bossEnter {
  from { transform: translateY(-50%) translateX(0) rotate(-1deg); }
  to { transform: translateY(-50%) translateX(-12px) rotate(2deg); }
}

@keyframes bossFightMotion {
  from { transform: translateY(-3px) scale(1.02) rotate(-1deg); }
  to { transform: translateY(4px) scale(0.98) rotate(1deg); }
}

@keyframes bossDefeat {
  0% { opacity: 1; transform: translateY(-50%) scale(1); }
  45% { opacity: 1; transform: translateY(-50%) scale(1.35) rotate(-5deg); }
  100% { opacity: 0; transform: translateY(-50%) scale(0.25) rotate(12deg); }
}

@keyframes bossAlert {
  0% { opacity: 0; transform: translate(-50%, -12px) scale(0.95); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  82% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -14px) scale(0.98); }
}

.hit-text {
  position: absolute;
  z-index: 9;
  color: #f6c445;
  font-weight: 900;
  font-size: 22px;
  pointer-events: none;
  animation: pop 550ms ease-out forwards;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.impact {
  position: absolute;
  z-index: 11;
  min-width: 54px;
  min-height: 42px;
  color: #111;
  font-size: 20px;
  font-weight: 900;
  text-align: center;
  pointer-events: none;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.55);
  animation: impactPop 500ms ease-out forwards;
}

.impact::before {
  content: "";
  position: absolute;
  inset: 6px 2px 2px;
  z-index: -1;
  background:
    linear-gradient(#fff4a3 0 0) 14px 0 / 30px 8px no-repeat,
    linear-gradient(#ffdd45 0 0) 6px 8px / 46px 20px no-repeat,
    linear-gradient(#ff8d30 0 0) 0 16px / 58px 12px no-repeat,
    linear-gradient(#fff4a3 0 0) 18px 28px / 22px 8px no-repeat;
  image-rendering: pixelated;
}

.impact span {
  position: absolute;
  left: 26px;
  top: 18px;
  width: 7px;
  height: 7px;
  background: #fff4a3;
  image-rendering: pixelated;
  animation: sparkFly 420ms ease-out forwards;
}

.impact-top span { background: #9fd5ff; }
.impact-mid span { background: #f6c445; }
.impact-bottom span { background: #ff8d30; }

.damage-flash::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 14;
  background: rgba(255, 40, 40, 0.22);
  pointer-events: none;
  animation: damageFlash 420ms ease-out forwards;
}

.special-flash::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 14;
  background: rgba(246, 196, 69, 0.3);
  pointer-events: none;
  animation: specialFlash 560ms ease-out forwards;
}

.special-wave {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 14;
  width: 90px;
  height: 90px;
  border: 6px solid rgba(100, 210, 255, 0.88);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.3);
  box-shadow: 0 0 26px rgba(100, 210, 255, 0.75), inset 0 0 22px rgba(255, 255, 255, 0.55);
  animation: specialWave 680ms ease-out forwards;
}

.shielded .karateka::after {
  content: "";
  position: absolute;
  inset: -16px -20px;
  border: 3px solid rgba(100, 210, 255, 0.9);
  border-radius: 50%;
  filter: drop-shadow(0 0 10px rgba(100, 210, 255, 0.8));
  pointer-events: none;
  animation: shieldPulse 700ms ease-in-out infinite;
}

.bonus {
  position: absolute;
  z-index: 8;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 3px solid rgba(7, 9, 12, 0.78);
  border-radius: 10px;
  color: #111;
  font-size: 22px;
  font-weight: 900;
  image-rendering: pixelated;
  animation: bonusBob 700ms steps(2, end) infinite;
}

.bonus-score { background: #f6c445; }
.bonus-coin { background: #ffe36d; }
.bonus-shield { background: #64d2ff; }
.bonus-life { background: #ff5f7a; color: #fff; }
.bonus-slow { background: #9fd5ff; }
.bonus-double { background: #b8ff7a; }

.coin {
  position: absolute;
  z-index: 7;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 2px solid rgba(80, 52, 0, 0.78);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff7b4 0 18%, #ffd84c 19% 64%, #c58a12 65% 100%);
  color: #6b4300;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25), 0 0 12px rgba(246, 196, 69, 0.5);
  pointer-events: none;
  animation: coinSpin 640ms steps(4, end) infinite;
}

.mission-chip {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 12;
  max-width: min(72%, 360px);
  padding: 8px 12px;
  border: 2px solid rgba(246, 196, 69, 0.65);
  border-radius: 12px;
  background: rgba(7, 9, 12, 0.66);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  pointer-events: none;
  text-transform: uppercase;
}

.slowmo .mission-chip {
  box-shadow: 0 0 18px rgba(159, 213, 255, 0.55);
}

.double-score .mission-chip {
  border-color: rgba(184, 255, 122, 0.8);
}

.boss-target {
  position: absolute;
  right: 18%;
  z-index: 10;
  transform: translateY(-50%);
  min-width: 94px;
  padding: 10px 14px;
  border: 3px solid #fff;
  border-radius: 16px;
  background: rgba(7, 9, 12, 0.72);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  pointer-events: none;
  animation: bossTargetPulse 440ms steps(2, end) infinite;
}

.boss-target-top { box-shadow: 0 0 24px rgba(159, 213, 255, 0.95); }
.boss-target-mid { box-shadow: 0 0 24px rgba(246, 196, 69, 0.95); }
.boss-target-bottom { box-shadow: 0 0 24px rgba(255, 141, 48, 0.95); }

.stage-clear {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 18;
  transform: translate(-50%, -50%);
  min-width: min(86%, 390px);
  padding: 16px 20px;
  border: 3px solid rgba(246, 196, 69, 0.95);
  border-radius: 18px;
  background: rgba(7, 9, 12, 0.86);
  color: #f6c445;
  text-align: center;
  text-transform: uppercase;
  pointer-events: none;
  animation: stageClear 1700ms ease-out forwards;
}

.stage-clear strong,
.stage-clear span {
  display: block;
  line-height: 1.1;
}

.stage-clear strong {
  font-size: 26px;
  letter-spacing: 0.05em;
}

.stage-clear span {
  margin-top: 7px;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
}

.stage-intro {
  position: absolute;
  left: 50%;
  top: 24%;
  z-index: 17;
  min-width: min(82%, 330px);
  padding: 14px 18px;
  border: 3px solid rgba(255, 255, 255, 0.88);
  border-radius: 16px;
  background: rgba(7, 9, 12, 0.76);
  color: #fff;
  text-align: center;
  text-transform: uppercase;
  pointer-events: none;
  animation: stageClear 1700ms ease-out forwards;
}

.stage-intro span,
.stage-intro strong {
  display: block;
  line-height: 1.1;
}

.stage-intro span {
  color: #9fd5ff;
  font-size: 12px;
  font-weight: 900;
}

.stage-intro strong {
  margin-top: 6px;
  color: #f6c445;
  font-size: 26px;
}

@keyframes pop {
  from { opacity: 1; transform: translateY(0) scale(0.8); }
  to { opacity: 0; transform: translateY(-42px) scale(1.25); }
}

@keyframes impactPop {
  from { opacity: 0; transform: scale(0.6) rotate(-8deg); }
  20% { opacity: 1; transform: scale(1.15) rotate(4deg); }
  to { opacity: 0; transform: translateY(-22px) scale(0.9) rotate(-3deg); }
}

@keyframes sparkFly {
  from { opacity: 1; transform: translate(0, 0) scale(1); }
  to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}

@keyframes hurtBlink {
  0%, 100% { opacity: 1; }
  25%, 75% { opacity: 0.35; }
}

@keyframes karatekaSweepMotion {
  from { transform: translateX(-7px) scale(1.18) rotate(-2deg); }
  to { transform: translateX(12px) scale(1.24) rotate(3deg); }
}

@keyframes specialWave {
  0% { opacity: 0.95; transform: translate(-50%, -50%) scale(0.3); }
  70% { opacity: 0.65; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(8); }
}

@keyframes damageFlash {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes specialFlash {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(1.08); }
}

@keyframes shieldPulse {
  from { opacity: 0.55; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1.04); }
}

@keyframes bonusBob {
  from { transform: translateY(-50%) translateY(-4px); }
  to { transform: translateY(-50%) translateY(4px); }
}

@keyframes coinSpin {
  0% { transform: translateY(-50%) scaleX(1); }
  50% { transform: translateY(-50%) scaleX(0.42); }
  100% { transform: translateY(-50%) scaleX(1); }
}

@keyframes bossTargetPulse {
  from { opacity: 0.72; transform: translateY(-50%) scale(0.94); }
  to { opacity: 1; transform: translateY(-50%) scale(1.04); }
}

@keyframes stageClear {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.86); }
  16% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  78% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -64%) scale(0.95); }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(7, 9, 12, 0.58);
  backdrop-filter: blur(5px);
}

.panel {
  width: min(380px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: rgba(21, 27, 35, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.5);
}

.panel h1,
.panel h2 {
  margin-bottom: 12px;
  color: #f6c445;
  line-height: 1.1;
}

.panel p {
  color: #d8d8d8;
  line-height: 1.45;
  margin-bottom: 12px;
}

.ranking-message {
  min-height: 20px;
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 16px 0;
}

.key {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  font-size: 13px;
}

.key-arrow {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: 0 auto 7px;
  border-radius: 50%;
  background: #f6c445;
  color: #111;
  font-size: 24px;
  font-weight: 900;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 13px 20px;
  background: #f6c445;
  color: #111;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
}

button:hover {
  filter: brightness(1.05);
}

input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  margin: 7px 0;
  outline: none;
}

input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.scoreboards {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.board {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 12px;
  min-height: 110px;
}

.board h3 {
  color: #f6c445;
  font-size: 14px;
  margin-bottom: 8px;
}

.board ol {
  padding-left: 18px;
  font-size: 12px;
  color: #ddd;
  line-height: 1.7;
}

.board a {
  color: #9fd5ff;
  text-decoration: none;
}

.hidden {
  display: none;
}

.special-button {
  position: absolute;
  right: calc(14px + env(safe-area-inset-right));
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 18;
  width: 58px;
  height: 58px;
  margin: 0;
  padding: 0;
  border: 3px solid rgba(7, 9, 12, 0.74);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(100, 210, 255, 0.55);
  color: #071018;
  font-size: 26px;
  line-height: 1;
  opacity: 0.55;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.special-button.charged {
  opacity: 1;
  background: #64d2ff;
  filter: drop-shadow(0 0 14px rgba(100, 210, 255, 0.9));
  animation: specialButtonPulse 620ms steps(2, end) infinite;
}

.mobile-buttons {
  display: none;
}

.mobile-buttons button {
  margin: 0;
  width: 92px;
  min-height: 34px;
  padding: 10px 8px;
  border-radius: 14px;
  font-size: 12px;
  opacity: 0.72;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
}

@media (max-width: 720px) {
  body { align-items: flex-start; }
  .game-shell { width: 100vw; max-width: 430px; }
  .top-bar { padding: calc(8px + env(safe-area-inset-top)) 12px 8px; }
  .brand { font-size: 13px; }
  .stats { width: 100%; justify-content: space-between; }
  .game {
    height: auto;
    min-height: 0;
    max-height: none;
  }
  .scoreboards { grid-template-columns: 1fr; }
  .panel h1 { font-size: 26px; }
  .panel p { font-size: 14px; }
  .key { font-size: 12px; }
}

body.landscape-mode .game-shell {
  max-width: none;
}

.game-shell:fullscreen,
.game-shell:-webkit-full-screen {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
}

body.landscape-mode .top-bar {
  padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
}

body.landscape-mode .brand {
  font-size: 12px;
}

body.landscape-mode .stats {
  width: auto;
  flex: 1 1 auto;
  justify-content: center;
}

body.landscape-mode .game {
  min-height: 0;
}

body.landscape-mode .karateka {
  left: 35%;
}

body.landscape-mode .enemy {
  transform: translateY(-50%);
}

body.landscape-mode .mobile-buttons {
  position: absolute;
  inset: calc(44px + env(safe-area-inset-top)) 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 19;
  display: block;
  pointer-events: none;
}

body.landscape-mode .mobile-buttons button {
  position: absolute;
  pointer-events: auto;
}

body.landscape-mode .mobile-buttons button[data-action="top"] {
  left: calc(12px + env(safe-area-inset-left));
  top: 12%;
}

body.landscape-mode .mobile-buttons button[data-action="bottom"] {
  left: calc(12px + env(safe-area-inset-left));
  bottom: 12%;
}

body.landscape-mode .mobile-buttons button[data-action="mid"] {
  right: calc(12px + env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
}

body.landscape-mode .game {
  flex: 1 1 auto;
}

body.landscape-mode .calibration-panel {
  top: calc(50px + env(safe-area-inset-top));
  width: 264px;
}

body.landscape-mode .overlay {
  z-index: 40;
  align-items: center;
  justify-content: center;
  padding: calc(8px + env(safe-area-inset-top)) 128px calc(8px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

body.landscape-mode .panel {
  width: min(520px, 100%);
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  padding: 12px;
  border-radius: 16px;
}

body.landscape-mode .panel h1,
body.landscape-mode .panel h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

body.landscape-mode .panel p {
  margin-bottom: 7px;
  font-size: 12px;
  line-height: 1.3;
}

body.landscape-mode .controls {
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 8px 0;
}

body.landscape-mode .key {
  padding: 7px;
  font-size: 11px;
}

body.landscape-mode .panel button {
  padding: 9px 14px;
  margin-top: 5px;
}

body.landscape-mode .scoreboards {
  margin-top: 8px;
  gap: 6px;
}

body.landscape-mode .board {
  min-height: 72px;
  padding: 8px;
}

body.landscape-mode .board h3 {
  font-size: 12px;
}

body.landscape-mode .board ol {
  font-size: 11px;
  line-height: 1.35;
}

@media (orientation: portrait) {
  body.landscape-mode .game-shell {
    position: fixed;
    left: 50%;
    top: 50%;
    width: 100dvh;
    height: 100vw;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center;
  }
}

@media (orientation: landscape) {
  .game-shell {
    max-width: none;
  }

  .top-bar {
    padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
  }

  .stats {
    width: auto;
    flex: 1 1 auto;
    justify-content: center;
  }

  .karateka {
    left: 35%;
  }

  .enemy {
    transform: translateY(-50%);
  }

  .mobile-buttons {
    position: absolute;
    inset: calc(44px + env(safe-area-inset-top)) 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 19;
    display: block;
    pointer-events: none;
  }

  .mobile-buttons button {
    position: absolute;
    pointer-events: auto;
  }

  .mobile-buttons button[data-action="top"] {
    left: calc(12px + env(safe-area-inset-left));
    top: 12%;
  }

  .mobile-buttons button[data-action="bottom"] {
    left: calc(12px + env(safe-area-inset-left));
    bottom: 12%;
  }

  .mobile-buttons button[data-action="mid"] {
    right: calc(12px + env(safe-area-inset-right));
    top: 50%;
    transform: translateY(-50%);
  }

  .calibration-panel {
    top: calc(50px + env(safe-area-inset-top));
    width: 264px;
  }

  .overlay {
    z-index: 40;
    align-items: center;
    justify-content: center;
    padding: calc(8px + env(safe-area-inset-top)) 128px calc(8px + env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  .panel {
    width: min(520px, 100%);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    padding: 12px;
    border-radius: 16px;
  }

  .panel h1,
  .panel h2 {
    margin-bottom: 6px;
    font-size: 22px;
  }

  .panel p {
    margin-bottom: 7px;
    font-size: 12px;
    line-height: 1.3;
  }

  .controls {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin: 8px 0;
  }

  .key {
    padding: 7px;
    font-size: 11px;
  }

  .panel button {
    padding: 9px 14px;
    margin-top: 5px;
  }

  .scoreboards {
    margin-top: 8px;
    gap: 6px;
  }

  .board {
    min-height: 72px;
    padding: 8px;
  }

  .board h3 {
    font-size: 12px;
  }

  .board ol {
    font-size: 11px;
    line-height: 1.35;
  }
}

@media (max-width: 390px) {
  .game {
    height: auto;
    min-height: 0;
  }
}

@keyframes specialButtonPulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}
