:root {
  --bg: #0b1033;
  --bg2: #121a4d;
  --panel: #18225e;
  --panel2: #202c73;
  --line: #9db5ff;
  --ink: #eef2ff;
  --ink2: #b9c4ee;
  --ink3: #8592c6;
  --gold: #ffd23f;
  --red: #ff5d6c;
  --green: #4ade80;
  --blue: #5b8cff;
  --shadow: #050824;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

body {
  background:
    radial-gradient(1px 1px at 12% 18%, #fff8, transparent),
    radial-gradient(1px 1px at 72% 12%, #fff6, transparent),
    radial-gradient(2px 2px at 40% 70%, #fff5, transparent),
    radial-gradient(1px 1px at 85% 60%, #fff7, transparent),
    radial-gradient(1px 1px at 25% 88%, #fff5, transparent),
    radial-gradient(1.5px 1.5px at 58% 35%, #fff6, transparent),
    linear-gradient(180deg, #0b1033 0%, #101a52 60%, #0b1033 100%);
  background-attachment: fixed;
}

.pixel {
  font-family: "Press Start 2P", ui-monospace, monospace;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
}

.box {
  background: var(--panel);
  border: 3px solid var(--line);
  box-shadow: 0 0 0 3px var(--shadow), 6px 6px 0 3px var(--shadow);
  padding: 14px;
  margin: 14px 0;
}

.box.gold {
  border-color: var(--gold);
}

h1,
h2,
h3 {
  margin: 0 0 8px;
}

h1 {
  font-size: 18px;
}

h2 {
  font-size: 14px;
}

h3 {
  font-size: 12px;
  color: var(--gold);
}

.muted {
  color: var(--ink2);
}

.tiny {
  font-size: 12px;
  color: var(--ink3);
}

.btn {
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 11px;
  background: var(--gold);
  color: #1a1440;
  border: 3px solid #1a1440;
  box-shadow: 4px 4px 0 var(--shadow);
  padding: 12px 14px;
  cursor: pointer;
  text-transform: uppercase;
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--shadow);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.ghost {
  background: var(--panel2);
  color: var(--ink);
  border-color: var(--line);
}

.btn.red {
  background: var(--red);
  color: #fff;
}

.btn.full {
  width: 100%;
}

input,
textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bg2);
  border: 3px solid var(--line);
  padding: 10px;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--gold);
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.card {
  background: var(--bg2);
  border: 3px solid #3a4a9a;
  padding: 12px;
  cursor: pointer;
  user-select: none;
}

.card.on {
  border-color: var(--gold);
  background: #2a2a5e;
}

.card.ok {
  border-color: var(--green);
}

.card.bad {
  border-color: var(--red);
}

.card.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.chip {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border: 2px solid var(--line);
  background: var(--panel2);
  margin: 4px 4px 0 0;
}

.chip.gold {
  border-color: var(--gold);
  color: var(--gold);
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

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

.stack > * + * {
  margin-top: 8px;
}

.timer {
  height: 10px;
  background: var(--bg2);
  border: 2px solid var(--line);
  margin-top: 8px;
}

.timer > div {
  height: 100%;
  background: var(--gold);
  transition: width 1s linear;
}

.timer.low > div {
  background: var(--red);
}

.hp {
  height: 26px;
  background: #2a0d1b;
  border: 3px solid #fff;
  box-shadow: 4px 4px 0 var(--shadow);
  position: relative;
}

.hp > div {
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--red) 0 14px, #ff8592 14px 16px);
  transition: width 0.6s ease;
}

.hp > span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  text-shadow: 2px 2px 0 #000;
}

.sticky {
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
  padding: 14px 0 10px;
}

.toast {
  position: fixed;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  z-index: 50;
  max-width: 92vw;
}

.pulse {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 3px var(--shadow), 0 0 18px 4px var(--gold);
  }
}

.boss {
  font-size: 72px;
  text-align: center;
  line-height: 1;
  animation: bob 2s ease-in-out infinite;
}

@keyframes bob {
  50% {
    transform: translateY(-6px);
  }
}

.hit {
  animation: hit 0.5s;
}

@keyframes hit {
  25% {
    transform: translateX(-8px);
    filter: brightness(2);
  }
  75% {
    transform: translateX(8px);
  }
}

.bar {
  height: 18px;
  background: var(--blue);
  min-width: 2px;
}

.bar.best {
  background: var(--green);
}

.score-big {
  font-family: "Press Start 2P", monospace;
  font-size: 34px;
  color: var(--gold);
  text-align: center;
  margin: 10px 0;
}

a {
  color: var(--gold);
}

@media (max-width: 420px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
  .boss {
    font-size: 56px;
  }
}

#top {
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar {
  background: var(--panel);
  border-bottom: 3px solid var(--line);
  box-shadow: 0 3px 0 var(--shadow);
}

.topbar .wrap {
  padding: 10px 16px;
}

#raid {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow-y: auto;
  background: #080b26;
}

[hidden] {
  display: none !important;
}

.card.static {
  cursor: default;
}

.pick {
  font: 600 13px/1.25 "Inter", system-ui, sans-serif;
  color: var(--ink);
  background: var(--panel2);
  border: 2px solid var(--line);
  padding: 8px 10px;
  cursor: pointer;
  flex: 1 1 auto;
}

.pick.on {
  background: var(--gold);
  color: #1a1440;
  border-color: #1a1440;
}

.mark {
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1.3;
}

.rules,
.posts {
  margin: 0;
  padding-left: 20px;
}

.posts {
  margin-top: 6px;
  font-size: 14px;
  color: var(--ink2);
}

.lb {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.lb li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px dashed #3a4a9a;
}

.lb li.me {
  color: var(--gold);
}

.lb .rank {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  width: 34px;
  color: var(--ink3);
}

.lb .pts {
  margin-left: auto;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
}

summary {
  cursor: pointer;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

.track {
  height: 8px;
  background: var(--bg2);
  border: 2px solid var(--line);
  margin-top: 10px;
}

.track > div {
  height: 100%;
  background: var(--blue);
}

/* ---------- pixel art ---------- */
img.px,
canvas.map {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

canvas.map {
  width: 100%;
  height: auto;
}

.mapwrap {
  position: relative;
  border: 3px solid var(--line);
  box-shadow: 0 0 0 3px var(--shadow), 6px 6px 0 3px var(--shadow);
  margin: 14px 0;
  overflow: hidden;
  line-height: 0;
}

.mapwrap .spot {
  position: absolute;
  transform: translate(-50%, -100%);
}

.mapwrap .hero,
.mapwrap .hero img {
  width: 100%;
  height: auto;
}

.mapwrap .tap {
  position: absolute;
  transform: translate(-50%, -100%);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.maplabel {
  position: absolute;
  transform: translateX(-50%);
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  line-height: 1;
  color: #fff;
  white-space: nowrap;
  text-shadow: 1px 0 #000, -1px 0 #000, 0 1px #000, 0 -1px #000;
  pointer-events: none;
  z-index: 3;
}

.maplabel.now {
  color: var(--gold);
}

.here {
  position: absolute;
  transform: translate(-50%, -100%);
  font-family: "Press Start 2P", monospace;
  color: var(--gold);
  text-shadow: 2px 2px 0 #000;
  animation: bounce 0.8s steps(2) infinite;
  pointer-events: none;
  z-index: 4;
}

@keyframes bounce {
  50% {
    margin-top: -4px;
  }
}

.hero {
  display: inline-block;
  position: relative;
  line-height: 0;
}

.hero img + img {
  display: none;
}

.hero.walking img:first-child {
  animation: frame-a 0.3s steps(1) infinite;
}

.hero.walking img + img {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  animation: frame-b 0.3s steps(1) infinite;
}

@keyframes frame-a {
  50% {
    visibility: hidden;
  }
}

@keyframes frame-b {
  0% {
    visibility: hidden;
  }
  50% {
    visibility: visible;
  }
}

.hero.idle {
  animation: idle 1.4s steps(2) infinite;
}

@keyframes idle {
  50% {
    transform: translateY(-2px);
  }
}

.mapwrap .spot.idle {
  animation: idle-spot 1.4s steps(2) infinite;
}

@keyframes idle-spot {
  50% {
    transform: translate(-50%, calc(-100% - 2px));
  }
}

.class-pick {
  display: flex;
  gap: 12px;
  align-items: center;
}

.scene {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

/* ---------- the end ---------- */
.the-end {
  font-family: "Press Start 2P", monospace;
  font-size: 30px;
  color: var(--gold);
  text-align: center;
  text-shadow: 4px 4px 0 var(--shadow);
  margin: 12px 0;
}

.stage-end {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 6px;
  padding: 26px 0 8px;
  overflow: hidden;
}

.fw {
  position: absolute;
  width: 6px;
  height: 6px;
  opacity: 0;
  animation: burst 1.8s ease-out infinite;
}

@keyframes burst {
  0% {
    transform: translate(0, 0);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy));
    opacity: 0;
  }
}

.kit li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
}

.kit {
  list-style: none;
  margin: 0;
  padding: 0;
}
