@font-face {
  font-family: "GMarketSans";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2001@1.1/GmarketSansLight.woff") format("woff");
  font-weight: 300;
  font-display: swap;
}

@font-face {
  font-family: "GMarketSans";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2001@1.1/GmarketSansMedium.woff") format("woff");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "GMarketSans";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2001@1.1/GmarketSansBold.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "NexonLv1Gothic";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_20-04@2.1/NEXON Lv1 Gothic OTF Light.woff") format("woff");
  font-weight: 300;
  font-display: swap;
}

@font-face {
  font-family: "NexonLv1Gothic";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_20-04@2.1/NEXON Lv1 Gothic OTF.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "NexonLv1Gothic";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_20-04@2.1/NEXON Lv1 Gothic OTF Bold.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #050711;
  --panel: rgba(8, 12, 24, 0.84);
  --panel-strong: rgba(11, 15, 27, 0.94);
  --ink: #f6fbff;
  --muted: #aeb8c7;
  --line: rgba(183, 210, 232, 0.22);
  --cyan: #5ae7ff;
  --gold: #f8d47a;
  --red: #ff6478;
  --violet: #b38cff;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(120deg, rgba(94, 246, 214, 0.08), transparent 30%),
    linear-gradient(240deg, rgba(179, 140, 255, 0.12), transparent 34%),
    radial-gradient(circle at 50% -10%, rgba(248, 212, 122, 0.12), transparent 30%),
    linear-gradient(180deg, #101521 0%, var(--bg) 72%);
  color: var(--ink);
  font-family:
    "GMarketSans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.preload-image {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  color: var(--ink);
}

.shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 18px;
}

.game-panel {
  width: min(1180px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)),
    var(--panel-strong);
  box-shadow:
    0 28px 96px rgba(0, 0, 0, 0.58),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

body:not(.is-playing) .topbar,
body:not(.is-playing) .fight-hud {
  display: none;
}

.topbar,
.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
}

.topbar {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(90, 231, 255, 0.1), transparent 42%),
    rgba(4, 7, 16, 0.86);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1;
  text-shadow: 0 0 22px rgba(90, 231, 255, 0.18);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#restartButton,
#pauseButton {
  min-width: 96px;
  min-height: 40px;
  border: 1px solid rgba(248, 212, 122, 0.42);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(248, 212, 122, 0.18), rgba(248, 212, 122, 0.06)),
    rgba(12, 16, 26, 0.9);
  cursor: pointer;
}

#restartButton:hover,
#restartButton:focus-visible,
#pauseButton:hover,
#pauseButton:focus-visible {
  border-color: rgba(90, 231, 255, 0.72);
  background: rgba(90, 231, 255, 0.14);
  outline: 2px solid rgba(90, 231, 255, 0.35);
  outline-offset: 2px;
}

.fight-hud {
  display: none;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.team {
  width: min(38%, 390px);
  display: grid;
  gap: 6px;
}

.team span {
  display: block;
  max-width: 100%;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team small {
  display: none;
  min-height: 0;
  color: var(--muted);
  font-size: 12px;
}

.team-right {
  text-align: right;
}

.round-clock {
  min-width: 112px;
  display: grid;
  justify-items: center;
  gap: 2px;
}

.round-clock span {
  color: var(--gold);
  font-size: 34px;
  font-weight: 950;
  line-height: 1;
}

.round-clock small {
  color: var(--muted);
  font-size: 12px;
}

.meter {
  height: 12px;
  border: 1px solid rgba(245, 251, 255, 0.2);
  background: #111827;
}

.meter i {
  display: block;
  width: 100%;
  height: 100%;
}

.meter.hp i {
  background: linear-gradient(90deg, var(--red), var(--gold));
}

.meter.psy {
  height: 8px;
}

.meter.psy i {
  background: linear-gradient(90deg, var(--cyan), var(--violet));
}

.start-form {
  position: absolute;
  left: 50%;
  top: auto;
  bottom: clamp(14px, 4%, 26px);
  z-index: 12;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 12px;
  width: min(500px, calc(100% - 34px));
  padding: 18px;
  border: 1px solid rgba(248, 212, 122, 0.42);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(248, 212, 122, 0.1), rgba(90, 231, 255, 0.05)),
    rgba(3, 6, 12, 0.84);
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateX(-50%);
}

.start-form[hidden] {
  display: none;
}

.start-form strong,
.start-form label,
.start-form small {
  grid-column: 1 / -1;
}

.start-form strong {
  color: var(--gold);
  font-size: 20px;
  font-weight: 900;
  line-height: 1.1;
}

.start-form label,
.start-form small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.start-form input {
  min-height: 38px;
  width: 100%;
  border: 1px solid rgba(245, 251, 255, 0.22);
  border-radius: 6px;
  background: rgba(245, 251, 255, 0.1);
  color: var(--ink);
  padding: 0 10px;
}

.start-form input::placeholder {
  color: rgba(246, 251, 255, 0.46);
}

.start-form button,
.score-form button {
  min-height: 38px;
  border: 1px solid rgba(90, 231, 255, 0.5);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(90, 231, 255, 0.18), rgba(90, 231, 255, 0.06)),
    rgba(12, 16, 26, 0.9);
  color: var(--ink);
  cursor: pointer;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  background: #07101d;
  touch-action: pan-y;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #07101d;
  image-rendering: pixelated;
  touch-action: pan-y;
}

.mobile-controls {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

body.is-playing.is-mobile-preview .mobile-controls {
  display: block;
}

.joystick-pad {
  position: absolute;
  left: clamp(16px, 5vw, 46px);
  bottom: clamp(20px, 5vw, 38px);
  width: 126px;
  height: 126px;
  border: 1px solid rgba(246, 251, 255, 0.34);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(246, 251, 255, 0.14) 0 28%, rgba(90, 231, 255, 0.1) 29% 50%, rgba(6, 10, 20, 0.42) 51%),
    rgba(6, 10, 20, 0.28);
  box-shadow:
    0 0 24px rgba(90, 231, 255, 0.16),
    inset 0 0 22px rgba(246, 251, 255, 0.08);
  pointer-events: auto;
  touch-action: none;
}

.joystick-pad::before,
.joystick-pad::after {
  content: "";
  position: absolute;
  background: rgba(246, 251, 255, 0.22);
}

.joystick-pad::before {
  left: 18px;
  right: 18px;
  top: 50%;
  height: 1px;
}

.joystick-pad::after {
  top: 18px;
  bottom: 18px;
  left: 50%;
  width: 1px;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.82), rgba(90, 231, 255, 0.24) 36%, rgba(6, 10, 20, 0.72) 72%);
  box-shadow: 0 0 24px rgba(90, 231, 255, 0.28);
  transform: translate(-50%, -50%);
}

.mobile-actions {
  position: absolute;
  right: clamp(10px, 3.4vw, 32px);
  bottom: clamp(12px, 4.4vw, 34px);
  width: 272px;
  height: 188px;
  pointer-events: none;
}

.mobile-action {
  position: absolute;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 1px solid rgba(248, 212, 122, 0.5);
  border-radius: 50%;
  background:
    linear-gradient(180deg, rgba(248, 212, 122, 0.2), rgba(90, 231, 255, 0.06)),
    rgba(6, 10, 20, 0.56);
  color: var(--ink);
  font-size: 0;
  font-weight: 900;
  box-shadow:
    0 0 18px rgba(248, 212, 122, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  --icon-size: 30px;
  --icon-x: 50%;
  --icon-y: 50%;
}

.mobile-action::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--icon-size);
  height: var(--icon-size);
  background: #fff;
  mask: var(--button-icon) var(--icon-x) var(--icon-y) / contain no-repeat;
  -webkit-mask: var(--button-icon) var(--icon-x) var(--icon-y) / contain no-repeat;
  filter: drop-shadow(0 0 5px rgba(90, 231, 255, 0.22));
  transform: translate(-50%, -50%);
}

.mobile-action:active,
.mobile-action.is-held {
  border-color: rgba(90, 231, 255, 0.82);
  background:
    linear-gradient(180deg, rgba(90, 231, 255, 0.34), rgba(179, 140, 255, 0.14)),
    rgba(6, 10, 20, 0.72);
  transform: scale(0.96);
}

.mobile-action.jump {
  left: 77px;
  top: 21.6px;
  --button-icon: url("./assets/ui/touch-jump.png");
  --icon-size: 32px;
  --icon-y: 52%;
}

.mobile-action.attack {
  left: 100px;
  top: 93px;
  width: 94px;
  height: 94px;
  --button-icon: url("./assets/ui/touch-attack.png");
  --icon-size: 48px;
}

.mobile-action.attack::before {
  width: var(--icon-size);
  height: var(--icon-size);
}

.mobile-action.charge {
  left: 24.2px;
  top: 81.7px;
  --button-icon: url("./assets/ui/touch-charge.png");
  --icon-size: 34px;
  --icon-x: 48%;
}

.mobile-action.skill {
  left: 209.8px;
  top: 81.7px;
  --button-icon: url("./assets/ui/touch-kick.png");
  --icon-size: 34px;
}

.mobile-action.dodge {
  left: 157px;
  top: 21.6px;
  --button-icon: url("./assets/ui/touch-dodge.png");
  --icon-size: 33px;
  --icon-x: 52%;
}

.score-form {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 16px;
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 20;
  width: min(760px, calc(100vw - 32px));
  box-sizing: border-box;
  max-height: min(78vh, 620px);
  padding: 22px;
  border: 1px solid rgba(248, 212, 122, 0.36);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(248, 212, 122, 0.12), rgba(90, 231, 255, 0.05)),
    rgba(7, 10, 18, 0.98);
  box-shadow:
    0 28px 88px rgba(0, 0, 0, 0.62),
    0 0 0 9999px rgba(4, 7, 16, 0.58),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translate(-50%, -50%);
}

.score-form[hidden] {
  display: none;
}

.score-form strong {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  font-size: 15px;
}

.score-form small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.score-form button {
  justify-self: end;
  min-width: 104px;
}

.score-form button:hover,
.score-form button:focus-visible {
  border-color: rgba(248, 212, 122, 0.72);
  background: rgba(248, 212, 122, 0.14);
  outline: 2px solid rgba(248, 212, 122, 0.32);
  outline-offset: 2px;
}

.rankings-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  overflow: auto;
  min-width: 0;
  min-height: 0;
  padding-right: 4px;
}

.ranking-panel {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  padding: 14px;
  border: 1px solid rgba(183, 210, 232, 0.18);
  border-radius: 6px;
  background: rgba(246, 251, 255, 0.045);
}

.ranking-panel-wide {
  grid-column: 1 / -1;
}

.ranking-panel h2 {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 15px;
  line-height: 1.2;
}

.rankings-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
  min-width: 0;
}

.rankings-list li {
  color: var(--ink);
  font-size: 13px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.rankings-list span {
  display: block;
  min-width: 0;
  color: var(--cyan);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.rankings-list small {
  display: block;
  margin-top: 2px;
  font-weight: 500;
}

.controls {
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  background: rgba(4, 7, 16, 0.82);
}

.controls span {
  padding: 6px 8px;
  border: 1px solid rgba(245, 251, 255, 0.12);
  border-radius: 4px;
  background: rgba(245, 251, 255, 0.05);
}

@media (max-width: 720px) {
  .shell {
    padding: 8px;
  }

  .topbar,
  .controls {
    padding: 10px;
  }

  .topbar {
    align-items: flex-start;
    gap: 10px;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  #restartButton,
  #pauseButton {
    min-width: 78px;
    min-height: 36px;
  }

  .start-form,
  .score-form {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .score-form {
    gap: 12px;
    max-height: min(84vh, 640px);
    padding: 16px;
  }

  .start-form {
    bottom: 14px;
    gap: 10px;
    padding: 14px;
  }

  .start-form input {
    width: 100%;
  }

  .fight-hud {
    gap: 8px;
  }

  .team {
    width: 36%;
  }

  .round-clock {
    min-width: 76px;
  }

  .round-clock span {
    font-size: 26px;
  }
}

body.is-playing.is-touch-device .mobile-controls {
  display: block;
}

@media (max-width: 900px) {
  body.is-playing.is-touch-device .controls {
    display: none;
  }
}

@media (max-width: 560px) {
  .joystick-pad {
    width: 112px;
    height: 112px;
  }

  .joystick-knob {
    width: 50px;
    height: 50px;
  }

  .mobile-actions {
    width: 246px;
    height: 170px;
  }

  .mobile-action {
    width: 54px;
    height: 54px;
    --icon-size: 28px;
  }

  .mobile-action.jump {
    left: 70px;
    top: 19.8px;
    --icon-size: 30px;
  }

  .mobile-action.attack {
    left: 91px;
    top: 84px;
    width: 84px;
    height: 84px;
    --icon-size: 43px;
  }

  .mobile-action.charge {
    left: 22.7px;
    top: 74px;
    --icon-size: 31px;
  }

  .mobile-action.skill {
    left: 189.3px;
    top: 74px;
    --icon-size: 31px;
  }

  .mobile-action.dodge {
    left: 142px;
    top: 19.8px;
    --icon-size: 31px;
  }
}

@media (max-width: 560px) {
  .rankings-board {
    grid-template-columns: 1fr;
  }

  .ranking-panel-wide {
    grid-column: auto;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .shell {
    min-height: 100svh;
    place-items: start center;
    padding: 8px;
  }

  body:not(.is-playing) .game-panel {
    overflow: visible;
  }

  body:not(.is-playing) .canvas-wrap {
    overflow: visible;
  }

  .start-form {
    bottom: 8px;
    gap: 8px;
    width: min(440px, calc(100% - 24px));
    padding: 10px;
  }

  .start-form strong {
    font-size: 17px;
  }

  .start-form label,
  .start-form small {
    font-size: 11px;
  }

  .start-form input,
  .start-form button {
    min-height: 34px;
  }
}
