@font-face {
  font-family: Arcade;
  src: url("./assets/press-start-2p.ttf") format("truetype");
  font-display: swap;
}
:root {
  color-scheme: dark;
  --bg: #101719;
  --panel: #1a2527;
  --border: #384749;
  --lime: #d8fa68;
  --ink: #f4f4e7;
  --muted: #b0bfbb;
  --pixel: Arcade, monospace;
  --sans: "Trebuchet MS", system-ui, sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  --realm-ink: #d8eea7;
  --realm-edge: #597a64;
  --realm-dark: #293f35;
  margin: 0;
  background: var(--bg);
  background-image: linear-gradient(135deg, #31484438, transparent 42%), conic-gradient(at 2px 2px, transparent 75%, #4d66613b 0);
  background-size: 100% 100%, 12px 12px;
  color: var(--ink);
  font: 1rem/1.45 var(--sans);
  min-height: 100svh;
}
body[data-level="arcade"] { --realm-ink: #ffcf9e; --realm-edge: #946773; --realm-dark: #4b3241; }
body[data-level="waterpark"] { --realm-ink: #9aeee5; --realm-edge: #467e87; --realm-dark: #22484e; }
body[data-level="store"] { --realm-ink: #f7d79a; --realm-edge: #99825a; --realm-dark: #4a402e; }
body[data-level="nether"] { --realm-ink: #ffc093; --realm-edge: #a05b4e; --realm-dark: #4f302e; }
body[data-level="castle"] { --realm-ink: #ffd29c; --realm-edge: #81688f; --realm-dark: #42334e; }
body[data-level="end"] { --realm-ink: #e6c9ff; --realm-edge: #9074ad; --realm-dark: #42344e; }
button {
  font: inherit;
  cursor: pointer;
  color: inherit;
}
button:focus-visible,
canvas:focus-visible {
  outline: 3px solid white;
  outline-offset: 4px;
}
button:disabled {
  cursor: default;
}
[hidden] {
  display: none !important;
}
.sr-only,
.hero input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.topbar {
  background: #141d1e;
  border-bottom: 1px solid #324043;
}
.bar-inner,
main {
  width: min(100% - 48px, 1088px);
  margin: auto;
}
.bar-inner,
nav,
.tool,
.wordmark,
.actions,
.arena-header,
.hud,
.hud span,
.key-hints {
  display: flex;
  align-items: center;
}
.bar-inner {
  min-height: 65px;
  justify-content: space-between;
}
.wordmark {
  font: clamp(10px, 1.2vw, 14px)/1.45 var(--pixel);
  letter-spacing: -0.065em;
  gap: 0.58em;
}
.wordmark img {
  margin-right: 3px;
  image-rendering: pixelated;
}
.wordmark span {
  color: var(--lime);
}
nav {
  gap: 9px;
}
.tool,
.minor,
#dpad button {
  background: #212d2e;
  border: 1px solid #435351;
  border-radius: 3px;
  box-shadow: inset 0 1px #ffffff0e;
}
.tool {
  gap: 9px;
  justify-content: center;
  min-height: 35px;
  padding: 4px 12px;
  font-size: 0.9rem;
  font-weight: 700;
}
.tool:hover,
.minor:hover,
#dpad button:hover {
  background: #304040;
}
.sound {
  width: 37px;
  padding: 4px;
}
.sound svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}
.audible,
.sound[aria-pressed="true"] .silent {
  display: none;
}
.sound[aria-pressed="true"] .audible {
  display: block;
}
.help-icon {
  border: 1.5px solid #c4d0c8;
  border-radius: 50%;
  width: 15px;
  height: 15px;
  line-height: 13px;
  font: 700 11px/14px var(--sans);
}
main {
  padding: 24px 0 38px;
}
.banner {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: 222px;
  overflow: hidden;
  background: #254843;
  border: 2px solid #546957;
  box-shadow: 0 4px 0 #090e10;
}
.banner canvas,
.banner:after {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}
.banner:before {
  content: "";
  position: absolute;
  inset: 5px;
  pointer-events: none;
  --trim: linear-gradient(var(--realm-ink), var(--realm-ink));
  background:
    var(--trim) left top / 24px 2px, var(--trim) left top / 2px 12px,
    var(--trim) right top / 24px 2px, var(--trim) right top / 2px 12px,
    var(--trim) left bottom / 24px 2px, var(--trim) left bottom / 2px 12px,
    var(--trim) right bottom / 24px 2px, var(--trim) right bottom / 2px 12px;
  background-repeat: no-repeat;
  opacity: 0.7;
}
.banner canvas {
  object-fit: cover;
  object-position: center 55%;
  image-rendering: pixelated;
}
.banner:after {
  content: "";
  background: linear-gradient(
    90deg,
    #0a1b1bee 0%,
    #0e2525a8 30%,
    transparent 64%
  );
}
.banner-copy {
  padding: 28px 36px;
}
.banner h1 {
  font: 400 clamp(30px, 4.5vw, 52px)/1.24 var(--pixel);
  letter-spacing: -0.04em;
  margin: 0;
  color: #fff4cc;
  text-shadow: 0 0.095em #23312b;
}
.banner h1 #title-second {
  display: block;
  color: var(--lime);
}
.banner h1 #title-second:empty { display: none; }
.banner p {
  margin: 12px 0 0;
  color: #e2ece0;
  font-size: 1rem;
  text-shadow: 1px 1px #162d2c;
}
.levels {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: none;
}
.levels strong {
  color: var(--muted);
  font-size: 0.9rem;
}
.level-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  flex: 1;
}
.level-option {
  position: relative;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  min-height: 44px;
  line-height: 1.25;
  text-align: center;
  border: 1px solid #455353;
  background: #202b2e;
  color: #c6d0c9;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}
.level-option:hover { border-color: #8da38c; }
.level-option:has(input:focus-visible) {
  outline: 2px solid white;
  outline-offset: 2px;
}
.level-option:has(input:checked) {
  color: var(--realm-ink);
  border-color: var(--realm-edge);
  background: var(--realm-dark);
  box-shadow: inset 0 -3px var(--realm-edge);
}
.level-number {
  font: 0.63rem var(--pixel);
  color: #a8b6a8;
}
.level-option:has(input:checked) .level-number { color: inherit; }
#lobby[data-level="arcade"] .banner { border-color: #6a526c; }
#lobby[data-level="arcade"] #title-second { color: #ffbe8b; }
#lobby[data-level="waterpark"] .banner { border-color: #66a9ad; }
#lobby[data-level="waterpark"] h1 { color: #bdfff4; }
.banner p { max-width: 34ch; }
#lobby[data-level="nether"] .banner { border-color: #99524d; }
#lobby[data-level="nether"] #title-second { color: #ffad69; }
#lobby[data-level="castle"] .banner { border-color: #786591; }
#lobby[data-level="castle"] #title-second { color: #ffc088; }
#lobby[data-level="end"] .banner { border-color: #8b75a5; }
#lobby[data-level="end"] h1 { color: #e7d3ff; }
#lobby[data-level="store"] .banner { border-color: #ac986b; }
#lobby[data-level="store"] #title-second { color: #ffd183; }
#lobby[data-level="store"] #monster-list,
#lobby[data-level="nether"] #monster-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  row-gap: 10px;
}
#lobby[data-level="nether"] #monster-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.setup {
  display: grid;
  grid-template-columns: minmax(0, 2.4fr) minmax(260px, 1fr);
  gap: 26px;
  margin-top: 26px;
  align-items: start;
}
h2 {
  font: 400 1.08rem/1.6 var(--pixel);
  letter-spacing: -0.045em;
  margin: 0 0 15px;
}
h3 {
  font: 700 1.05rem/1.3 var(--sans);
  margin: 0;
}
p {
  margin: 0;
}
.heroes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.hero {
  --hero-ink: #72cffa;
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  background: #202c2e;
  border: 2px solid #445253;
  cursor: pointer;
  box-shadow: 0 3px 0 #080f10;
}
.hero.maxim { --hero-ink: #ffb765; }
.hero.mom { --hero-ink: #c9aaff; }
.hero.dad { --hero-ink: #ffa895; }
.hero:hover {
  border-color: #83938a;
}
.hero:has(input:checked) {
  border-color: var(--lime);
}
.hero:has(input:focus-visible) {
  outline: 3px solid white;
  outline-offset: 3px;
}
.portrait-frame {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #283e46;
  border-bottom: 1px solid #4a5b56;
}
.portrait-frame:before {
  content: "";
  pointer-events: none;
  position: absolute;
  z-index: 1;
  inset: 0;
  box-shadow: inset 0 2px #fff6, inset 2px 0 #fff3, inset -2px 0 #13212459, inset 0 -3px #182b3280;
}
.portrait-frame canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: 50% 20%;
  image-rendering: pixelated;
}
.selector {
  position: absolute;
  right: 11px;
  top: 11px;
  width: 22px;
  height: 22px;
  background: #142020bd;
  border: 2px solid #a7b7a39c;
}
.hero input:checked + .portrait-frame .selector {
  background: var(--lime);
  border-color: #e4ff9f;
}
.hero input:checked + .portrait-frame .selector:after {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 10px;
  height: 5px;
  border-left: 3px solid #203323;
  border-bottom: 3px solid #203323;
  transform: rotate(-45deg);
}
.hero-copy {
  padding: 13px 10px 15px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  border-top: 2px solid var(--hero-ink);
  background: linear-gradient(115deg, #2c3a3b, #1c282b 75%);
}
.hero-copy strong {
  font: 400 0.99rem/1.4 var(--pixel);
  letter-spacing: -0.04em;
}
.hero-copy > span {
  font-size: 0.91rem;
  color: #becdc7;
  display: flex;
  align-items: center;
  gap: 7px;
}
.bolt,
.sword,
.ghost,
.shout,
.heart,
.play-icon {
  display: inline-block;
  flex: none;
}
.bolt {
  width: 14px;
  height: 16px;
  background: #73d4ff;
  clip-path: polygon(47% 0, 94% 0, 64% 38%, 92% 38%, 23% 100%, 39% 57%, 8% 57%);
}
.sword {
  width: 15px;
  height: 15px;
  background: #ffb765;
  clip-path: polygon(
    75% 0,
    100% 0,
    100% 25%,
    49% 76%,
    63% 90%,
    52% 100%,
    32% 80%,
    11% 100%,
    0 89%,
    20% 68%,
    0 47%,
    12% 35%,
    26% 49%
  );
}
.ghost,
.shout {
  width: 15px;
  height: 15px;
}
.ghost {
  background: #c9aaff;
  clip-path: polygon(22% 13%, 34% 13%, 34% 0, 68% 0, 68% 13%, 81% 13%, 81% 25%, 93% 25%, 93% 94%, 73% 80%, 53% 95%, 33% 80%, 9% 94%, 9% 26%, 22% 26%);
}
.shout {
  background: #ffa895;
  clip-path: polygon(0 13%, 100% 13%, 100% 71%, 48% 71%, 20% 99%, 20% 71%, 0 71%);
}
.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--lime);
  color: #192318;
  border: 2px solid #e5ff9a;
  border-bottom-color: #9cb348;
  border-radius: 2px;
  box-shadow:
    0 4px 0 #657d31,
    0 6px 0 #091010;
  font: 400 0.88rem/1.5 var(--pixel);
  letter-spacing: -0.055em;
  min-height: 49px;
  padding: 10px 16px;
}
.primary:hover:enabled {
  background: #e6ff89;
}
.primary:active:enabled {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #657d31;
}
.primary:disabled {
  background: #41524b;
  border-color: #526057;
  box-shadow: 0 3px #17231a;
  color: #d1dbcd;
}
#play {
  width: 100%;
  margin-top: 15px;
}
.play-icon {
  width: 13px;
  height: 15px;
  background: currentColor;
  clip-path: polygon(
    0 0,
    30% 0,
    30% 15%,
    60% 15%,
    60% 30%,
    85% 30%,
    85% 42%,
    100% 42%,
    100% 58%,
    85% 58%,
    85% 70%,
    60% 70%,
    60% 85%,
    30% 85%,
    30% 100%,
    0 100%
  );
}
.guide-body {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 3px 0 #0b1112;
  padding: 0 19px;
}
.mission,
.life-note {
  display: flex;
  align-items: center;
  gap: 13px;
}
.mission {
  padding: 20px 0 17px;
}
.gem-box {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  flex: none;
  background: #253e32;
  border: 1px solid #466347;
}
.mission p {
  font-size: 0.91rem;
  line-height: 1.45;
  color: var(--muted);
  margin-top: 4px;
}
.monsters {
  padding: 16px 0;
  border-block: 1px dashed #475452;
}
.monsters ul {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 0;
  margin: 12px 0 0;
  list-style: none;
}
.monsters li {
  flex: 1;
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 6px;
  color: #d2dad4;
  font-size: 0.88rem;
  text-align: center;
}
.monsters canvas {
  background: linear-gradient(155deg, var(--realm-dark) 50%, #233033 50%);
  border: 1px solid var(--realm-edge);
  box-shadow: inset 0 2px #ffffff19, 0 2px #10191a;
  width: min(100%, 48px);
  aspect-ratio: 1;
  height: auto;
  image-rendering: pixelated;
}
.life-note {
  color: var(--muted);
  font-size: 0.91rem;
  padding: 13px 0;
  gap: 9px;
}
.heart {
  width: 16px;
  height: 14px;
  background: #fa8279;
  clip-path: polygon(
    0 18%,
    15% 18%,
    15% 0,
    38% 0,
    38% 15%,
    60% 15%,
    60% 0,
    83% 0,
    83% 15%,
    100% 15%,
    100% 48%,
    85% 48%,
    85% 64%,
    70% 64%,
    70% 78%,
    57% 78%,
    57% 95%,
    43% 95%,
    43% 80%,
    28% 80%,
    28% 65%,
    14% 65%,
    14% 49%,
    0 49%
  );
}
#arena {
  max-width: min(900px, calc((100svh - 232px) * 23 / 15));
  min-width: min(100%, 460px);
  margin: auto;
}
.arena-header,
.hud,
.actions {
  gap: 14px;
  justify-content: space-between;
}
.arena-header h2 {
  font-size: 0.84rem;
  margin: 0;
  text-align: center;
}
.minor {
  padding: 7px 12px;
  font-size: 0.94rem;
}
.hud {
  position: relative;
  margin: 14px 0 8px;
  padding: 7px 14px 10px;
  background: linear-gradient(105deg, var(--realm-dark), var(--panel) 50%);
  border: 1px solid var(--realm-edge);
  font-size: 0.93rem;
}
.hud img,
#hud-portrait {
  image-rendering: pixelated;
}
#hud-portrait {
  width: 29px;
  height: 29px;
  object-fit: cover;
  border: 1px solid var(--realm-edge);
}
#gem-progress {
  position: absolute;
  appearance: none;
  width: 100%;
  height: 3px;
  inset: auto 0 0;
  border: 0;
  background: #10211f;
  color: #8de9a7;
}
#gem-progress::-webkit-progress-bar { background: #10211f; }
#gem-progress::-webkit-progress-value { background: #8de9a7; }
#gem-progress::-moz-progress-bar { background: #8de9a7; }
.hud span {
  gap: 6px;
}
.hud b {
  font-variant-numeric: tabular-nums;
}
#hero-name {
  color: var(--realm-ink);
}
.board-wrap {
  position: relative;
  background: #0b1415;
  border: 2px solid var(--realm-edge);
  box-shadow: 0 4px 0 #080f10;
}
#board {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
  touch-action: none;
  outline-offset: 1px;
}
#message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #0a1416bb;
}
.message-card,
dialog {
  padding: 24px;
  background: #202c2e;
  border: 2px solid #819177;
  box-shadow: 0 6px #080e10;
}
.message-card {
  text-align: center;
  max-width: 92%;
}
.message-card p {
  margin-bottom: 16px;
}
.message-card button {
  margin: auto;
}
.actions {
  margin-top: 13px;
  flex-wrap: wrap;
}
.key-hints {
  font-size: 0.85rem;
  color: var(--muted);
  gap: 6px;
}
kbd {
  border: 1px solid #485753;
  background: #273331;
  padding: 2px 4px;
  color: #d8e2d8;
  border-radius: 2px;
}
#dpad {
  display: none;
  grid-template-columns: repeat(3, 44px);
  gap: 3px;
}
#dpad button {
  min-height: 42px;
  touch-action: manipulation;
  font-size: 1.1rem;
  color: #d4dfca;
}
#dpad [data-dir="up"] {
  grid-column: 2;
}
#dpad [data-dir="left"] {
  grid-column: 1;
}
dialog {
  width: min(460px, calc(100% - 32px));
  color: var(--ink);
}
dialog::backdrop {
  background: #080e10d9;
}
dialog p {
  color: #d0dbd3;
  line-height: 1.55;
  margin: 5px 0 15px;
}
.help-monsters {
  border-block: 1px solid var(--border);
  margin-bottom: 15px;
}
.help-monsters summary {
  color: var(--lime);
  cursor: pointer;
  padding: 9px 0;
  font-weight: 700;
}
.help-abilities {
  margin: 5px 0 15px;
  padding-left: 1.2em;
  color: #d0dbd3;
}
.help-abilities li + li { margin-top: 4px; }
dialog .primary {
  margin-top: 18px;
  width: 100%;
}
@media (pointer: coarse), (max-width: 720px) {
  #dpad {
    display: grid;
  }
  .key-hints {
    display: none;
  }
  #arena {
    max-width: 700px;
    min-width: 0;
  }
}
@media (min-width: 641px) and (max-width: 960px) {
  .setup { display: block; }
  .guide { margin-top: 24px; }
  .guide-body {
    display: grid;
    grid-template-columns: 1fr minmax(235px, 1.2fr) 0.65fr;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .monsters { border: 0; }
  .monsters ul { gap: 12px; }
  .monsters canvas { width: 40px; }
}
@media (min-width: 1120px) {
  .level-options { grid-template-columns: 1.12fr 1.12fr 1fr 1.28fr 1.05fr 1.28fr 0.71fr; }
  .level-option { padding-inline: 5px; gap: 5px; }
}
@media (max-width: 770px) {
  .bar-inner,
  main {
    width: calc(100% - 30px);
  }
  .setup {
    gap: 16px;
    grid-template-columns: minmax(0, 1.5fr) minmax(215px, 1fr);
  }
  .guide-body {
    padding: 0 12px;
  }
  .mission {
    gap: 8px;
  }
  .gem-box {
    width: 38px;
    height: 40px;
  }
  .hero-copy {
    padding: 12px 9px;
  }
  .hero-copy strong {
    font-size: 0.85rem;
  }
}
@media (max-width: 640px) {
  .bar-inner {
    min-height: 54px;
  }
  .wordmark {
    font-size: 0.58rem;
    gap: 5px;
  }
  .wordmark img {
    width: 25px;
    height: 25px;
    margin-right: 0;
  }
  .tool {
    min-height: 33px;
    font-size: 0.8rem;
    padding: 4px 8px;
    gap: 6px;
  }
  nav {
    gap: 6px;
  }
  main {
    padding: 15px 0 28px;
  }
  .banner {
    min-height: 176px;
  }
  .banner-copy {
    padding: 20px 14px;
  }
  .banner h1 {
    font-size: clamp(23px, 6.3vw, 36px);
  }
  .banner p {
    font-size: 0.87rem;
    max-width: 220px;
  }
  .banner canvas {
    object-position: 63% center;
  }
  #lobby:is([data-level="temple"], [data-level="waterpark"], [data-level="store"]) .banner canvas {
    object-position: 74% center;
  }
  #lobby[data-level="arcade"] .banner canvas { object-position: 78% center; }
  .banner:after {
    background: linear-gradient(90deg, #0d2022df, #0d202299 38%, transparent 95%);
  }
  #lobby[data-level="waterpark"] .banner:after {
    background: linear-gradient(90deg, #062a34ef, #0a3242ba 50%, transparent);
  }
  .setup {
    display: block;
    margin-top: 22px;
  }
  h2 {
    font-size: 0.92rem;
    margin-bottom: 12px;
  }
  .levels { display: block; padding: 8px; }
  .level-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .level-option:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .levels strong { position: absolute; clip-path: inset(50%); }
  #lobby[data-level="store"] #monster-list {
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  }
  .level-option {
    gap: 5px;
    padding: 7px 3px;
    font-size: 0.85rem;
    line-height: 1.2;
    text-align: center;
    min-height: 44px;
  }
  .level-number { font-size: 0.55rem; }
  .heroes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }
  .portrait-frame {
    aspect-ratio: 8 / 5;
  }
  .hero-copy {
    padding: 10px;
  }
  .hero-copy > span {
    font-size: 0.83rem;
  }
  .selector {
    width: 19px;
    height: 19px;
    top: 7px;
    right: 7px;
  }
  .hero input:checked + .portrait-frame .selector:after {
    left: 2px;
    top: 2px;
  }
  .guide {
    margin-top: 28px;
  }
  .guide-body {
    padding: 0 16px;
  }
  .mission {
    padding: 13px 0;
  }
  .monsters {
    padding: 12px 0;
  }
  .monsters ul {
    justify-content: space-between;
  }
  .monsters canvas {
    width: 35px;
    height: 35px;
  }
  .arena-header {
    gap: 5px;
    flex-wrap: wrap;
  }
  .arena-header h2 {
    font-size: 0.58rem;
  }
  .minor {
    font-size: 0.82rem;
    padding: 6px 8px;
  }
  .hud {
    padding: 6px 7px 9px;
    font-size: 0.78rem;
    gap: 5px;
  }
  .hud span {
    gap: 4px;
  }
  #hud-portrait {
    width: 22px;
    height: 22px;
  }
  .actions {
    gap: 6px;
  }
  #ability {
    flex: 1;
    font: 700 0.96rem/1.2 var(--sans);
    letter-spacing: 0;
    min-height: 48px;
  }
  .message-card {
    padding: 15px;
  }
  .message-card p {
    margin-bottom: 10px;
    font-size: 0.9rem;
  }
}
