:root {
  color-scheme: dark;
  --ink: #0c1729;
  --paper: #fffaf0;
  --green: #65e84d;
  --green-dark: #237d32;
  --blue: #59c7ff;
  --gold: #ffd23f;
  --red: #ff5c58;
  --panel: rgba(8, 19, 36, 0.92);
  --stroke: 3px solid rgba(255, 255, 255, 0.85);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -20%, #31537b 0, transparent 48%),
    #08111f;
  color: white;
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", Arial, sans-serif;
  font-weight: 800;
}

button,
kbd {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
canvas:focus-visible {
  outline: 5px solid var(--gold);
  outline-offset: 3px;
}

.back-to-arcade {
  display: inline-flex;
  flex: 0 0 auto;
  min-height: 36px;
  align-items: center;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 10px;
  background: rgba(8, 17, 31, 0.9);
  color: white;
  padding: 6px 10px;
  font-size: clamp(0.68rem, 1.5vw, 0.84rem);
  text-decoration: none;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
}

.back-to-arcade:hover {
  background: var(--green-dark);
}

.back-to-arcade:focus-visible {
  outline: 5px solid var(--gold);
  outline-offset: 3px;
}

.game-shell {
  width: min(100%, 1500px);
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  gap: 12px;
}

.mini-brand {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 9px;
  color: #dfffd8;
  font-size: clamp(0.8rem, 2vw, 1.05rem);
  letter-spacing: 0.055em;
}

@media (max-width: 620px) {
  .back-to-arcade span,
  .mini-brand span {
    display: none;
  }
}

.mini-brand__mark {
  width: 31px;
  height: 31px;
  object-fit: contain;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.34));
}

.topbar__buttons {
  display: flex;
  gap: 8px;
}

.icon-button {
  min-height: 36px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 11px;
  cursor: pointer;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.icon-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 4px solid rgba(255, 255, 255, 0.86);
  border-radius: 22px;
  background: #11233b;
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.45),
    inset 0 0 0 4px rgba(12, 23, 41, 0.75);
  user-select: none;
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.title-screen,
.message-screen,
.hud {
  position: absolute;
  inset: 0;
}

.cutscene-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 16px 7%;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(3, 10, 19, 0.85) 0 5.5%, transparent 13% 82%, rgba(3, 10, 19, 0.88) 96% 100%);
}

.cutscene-caption {
  max-width: min(760px, 80%);
  border: 3px solid white;
  border-radius: 15px;
  background: rgba(7, 19, 35, 0.92);
  padding: 11px 20px;
  color: white;
  font-size: clamp(0.82rem, 2vw, 1.22rem);
  letter-spacing: 0.055em;
  text-align: center;
  text-shadow: 0 2px 0 black;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.36);
}

.cutscene-skip {
  position: absolute;
  top: 8%;
  right: 3%;
  min-height: 38px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 11px;
  background: rgba(7, 19, 35, 0.78);
  padding: 7px 12px;
  color: white;
  font-size: clamp(0.62rem, 1.4vw, 0.82rem);
  letter-spacing: 0.06em;
  cursor: pointer;
  pointer-events: auto;
}

.cutscene-skip:hover {
  background: rgba(89, 199, 255, 0.82);
}

.stage.is-cutscene .touch-controls {
  display: none;
}

.stage.is-cutscene + .how-to-play {
  opacity: 0.45;
}

.title-screen {
  display: grid;
  place-items: center;
  background-image: url("assets/title-art.png");
  background-position: center;
  background-size: cover;
  isolation: isolate;
}

.title-screen__shade {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(2, 11, 20, 0.18), rgba(2, 11, 20, 0.72) 50%, rgba(2, 11, 20, 0.15)),
    linear-gradient(0deg, rgba(3, 10, 19, 0.48), transparent 50%);
}

.title-card,
.message-card {
  width: min(570px, 82%);
  border: 4px solid white;
  border-radius: 28px;
  background: rgba(9, 22, 40, 0.9);
  box-shadow:
    0 16px 0 rgba(4, 11, 22, 0.42),
    0 22px 55px rgba(0, 0, 0, 0.38);
  text-align: center;
}

.title-card {
  padding: clamp(18px, 4vw, 34px);
}

.production-credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.5vw, 14px);
  margin: 0 auto 13px;
}

.production-mark {
  width: clamp(52px, 7vw, 76px);
  height: clamp(52px, 7vw, 76px);
  flex: 0 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 5px 0 rgba(0, 0, 0, 0.28));
}

.production-credit .eyebrow {
  margin: 0;
  text-align: left;
}

.production-credit .eyebrow span {
  display: block;
  margin-top: 3px;
  color: white;
  font-size: 1.12em;
  letter-spacing: 0.075em;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--gold);
  font-size: clamp(0.66rem, 1.6vw, 0.95rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: break-word;
}

h1 {
  margin: 0;
  color: var(--green);
  font-size: clamp(2.2rem, 7vw, 5.4rem);
  line-height: 0.84;
  letter-spacing: -0.055em;
  text-shadow:
    0 5px 0 #176d33,
    0 8px 0 #0d3620;
  -webkit-text-stroke: 2px #eaffdb;
}

h1 span {
  display: block;
  margin-bottom: 8px;
  color: white;
  font-size: 0.43em;
  letter-spacing: 0.17em;
  text-shadow: 0 4px 0 #21466e;
  -webkit-text-stroke: 1px #fff;
}

.title-card__lead {
  margin: 20px auto 18px;
  max-width: 30em;
  font-size: clamp(0.85rem, 2vw, 1.15rem);
  line-height: 1.4;
}

.title-card__actions,
.message-card__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.big-button {
  min-width: 170px;
  min-height: 50px;
  border: 3px solid white;
  border-radius: 16px;
  padding: 11px 20px;
  color: #08111f;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
  letter-spacing: 0.035em;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.big-button:hover {
  filter: brightness(1.09);
  transform: translateY(-2px);
}

.big-button:active {
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  transform: translateY(4px);
}

.big-button--green {
  background: var(--green);
}

.big-button--blue {
  background: var(--blue);
}

.tiny-note {
  margin: 17px 0 0;
  color: #c7d7ea;
  font-size: clamp(0.65rem, 1.5vw, 0.85rem);
}

.hud {
  z-index: 4;
  pointer-events: none;
  padding: 18px;
}

.hud__top-left,
.hud__top-right,
.hud__top-center {
  position: absolute;
  top: 16px;
}

.hud__top-left {
  left: 18px;
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 7px;
}

.hud__top-right {
  right: 18px;
}

.hud__top-center {
  left: 50%;
  min-width: 260px;
  transform: translateX(-50%);
  text-align: center;
}

.hud-chip,
.objective,
.hearts {
  border: 2px solid rgba(255, 255, 255, 0.82);
  background: rgba(5, 18, 32, 0.83);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  text-shadow: 0 2px 0 #000;
}

.hud-chip {
  display: inline-block;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: clamp(0.6rem, 1.3vw, 0.84rem);
  letter-spacing: 0.06em;
}

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

.hearts {
  display: inline-block;
  border-radius: 13px 13px 0 0;
  padding: 6px 12px 3px;
  color: var(--red);
  font-size: clamp(0.9rem, 2.2vw, 1.35rem);
  letter-spacing: 0.04em;
}

.objective {
  border-radius: 0 0 13px 13px;
  padding: 5px 10px 7px;
  color: white;
  font-size: clamp(0.62rem, 1.3vw, 0.83rem);
  letter-spacing: 0.065em;
}

.boss-hud {
  position: absolute;
  top: 86px;
  left: 50%;
  width: min(480px, 48%);
  transform: translateX(-50%);
}

.boss-hud__name {
  margin-bottom: 5px;
  color: white;
  font-size: clamp(0.62rem, 1.4vw, 0.9rem);
  letter-spacing: 0.12em;
  text-align: center;
  text-shadow: 0 2px 0 black;
}

.boss-hud__track {
  height: clamp(13px, 2vw, 21px);
  overflow: hidden;
  border: 3px solid white;
  border-radius: 999px;
  background: #231b33;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.33);
}

.boss-hud__fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff4e52, #ffbd3d);
  transition: width 180ms ease;
}

.message-screen {
  z-index: 8;
  display: grid;
  place-items: center;
  background: rgba(4, 11, 22, 0.68);
  backdrop-filter: blur(5px);
}

.message-card {
  max-height: 90%;
  overflow-y: auto;
  padding: clamp(18px, 4vw, 32px);
}

.message-card h2 {
  margin: 0;
  color: var(--green);
  font-size: clamp(1.7rem, 5vw, 3.5rem);
  line-height: 0.97;
  text-shadow: 0 4px 0 #16502c;
  -webkit-text-stroke: 1px white;
}

.message-card__text {
  margin: 17px auto;
  max-width: 36em;
  color: #eef7ff;
  font-size: clamp(0.8rem, 1.8vw, 1.05rem);
  line-height: 1.55;
}

.tip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 22px;
}

.tip {
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  padding: 7px 11px;
  font-size: clamp(0.65rem, 1.3vw, 0.82rem);
}

.text-button {
  border: 0;
  background: transparent;
  padding: 9px 12px;
  color: #cae2ff;
  cursor: pointer;
  text-decoration: underline;
}

.toast {
  position: absolute;
  z-index: 10;
  left: 50%;
  bottom: 17%;
  max-width: 82%;
  border: 3px solid white;
  border-radius: 14px;
  background: rgba(5, 18, 32, 0.92);
  padding: 10px 16px;
  opacity: 0;
  font-size: clamp(0.72rem, 1.6vw, 1rem);
  letter-spacing: 0.035em;
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, 12px) scale(0.96);
  transition: opacity 140ms ease, transform 140ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.touch-controls {
  position: absolute;
  z-index: 6;
  right: 14px;
  bottom: 14px;
  left: 14px;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}

.touch-controls__move {
  display: flex;
  gap: 10px;
}

.touch-button {
  display: grid;
  width: 66px;
  height: 66px;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  background: rgba(7, 22, 39, 0.7);
  color: white;
  font-size: 1.6rem;
  pointer-events: auto;
  touch-action: none;
}

.touch-button.is-pressed {
  background: rgba(93, 220, 78, 0.85);
  transform: scale(0.94);
}

.touch-button--jump {
  width: 78px;
  height: 78px;
  background: rgba(49, 148, 207, 0.78);
  line-height: 0.8;
}

.touch-button--jump span {
  display: block;
  margin-top: -14px;
  font-size: 0.6rem;
}

.how-to-play {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 28px;
  padding: 13px 8px 0;
  color: #bed0e7;
  font-size: clamp(0.68rem, 1.4vw, 0.9rem);
  letter-spacing: 0.045em;
}

.rotate-hint {
  display: none;
}

.how-to-play div {
  display: flex;
  align-items: center;
  gap: 6px;
}

kbd,
.stomp-icon {
  display: inline-grid;
  min-width: 27px;
  height: 27px;
  place-items: center;
  border: 2px solid #a9bed5;
  border-radius: 7px;
  background: #172a42;
  color: white;
  box-shadow: 0 3px 0 #040b13;
}

[hidden] {
  display: none !important;
}

@media (hover: none), (pointer: coarse), (max-width: 900px) {
  .touch-controls {
    display: flex;
  }

  #titleScreen:not([hidden]) ~ .touch-controls,
  #messageScreen:not([hidden]) ~ .touch-controls {
    display: none;
  }

  .how-to-play {
    display: none;
  }

  .hud {
    padding: 8px;
  }

  .hud__top-left {
    top: 8px;
    left: 8px;
  }

  .hud__top-right {
    top: 8px;
    right: 8px;
  }

  .hud__top-center {
    top: 8px;
    min-width: 180px;
  }

  .boss-hud {
    top: 66px;
  }
}

@media (max-width: 620px) {
  .game-shell {
    padding-right: 4px;
    padding-left: 4px;
  }

  .stage {
    border-width: 2px;
    border-radius: 12px;
  }

  .topbar {
    min-height: 48px;
    padding: 0 4px;
  }

  .back-to-arcade,
  .icon-button {
    min-width: 44px;
    min-height: 44px;
  }

  .icon-button span,
  .hud__top-right {
    display: none;
  }

  .mini-brand__mark {
    width: 25px;
    height: 25px;
  }

  .production-credit {
    gap: 6px;
    margin-bottom: 5px;
  }

  .production-mark {
    width: 34px;
    height: 34px;
  }

  .production-credit .eyebrow {
    font-size: 0.48rem;
  }

  .title-card,
  .message-card {
    width: 90%;
    border-width: 3px;
    border-radius: 20px;
  }

  .title-card {
    width: 94%;
    padding: 9px 12px;
  }

  .title-card__lead,
  .tiny-note {
    display: none;
  }

  .title-card__actions {
    flex-wrap: nowrap;
    gap: 7px;
    margin-top: 7px;
  }

  .title-card h1 {
    font-size: 1.85rem;
    line-height: 0.82;
    -webkit-text-stroke-width: 1px;
  }

  .title-card h1 span {
    margin-bottom: 4px;
  }

  .title-card .big-button {
    min-width: 0;
    min-height: 44px;
    border-width: 2px;
    border-radius: 10px;
    padding: 5px 8px;
    font-size: 0.55rem;
    white-space: nowrap;
  }

  .big-button {
    min-width: 140px;
    min-height: 42px;
    padding: 8px 13px;
    font-size: 0.75rem;
  }

  .hud__top-center {
    left: auto;
    right: 8px;
    min-width: 140px;
    transform: none;
  }

  .hearts {
    font-size: 0.76rem;
  }

  .objective {
    font-size: 0.52rem;
  }

  .boss-hud {
    top: 56px;
    width: 52%;
  }

  .touch-button {
    width: 52px;
    height: 52px;
    border-width: 2px;
    font-size: 1.2rem;
  }

  .touch-button--jump {
    width: 62px;
    height: 62px;
  }
}

@media (max-width: 700px) and (orientation: portrait) {
  .production-credit {
    display: none;
  }

  .title-card__actions {
    align-items: stretch;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
  }

  .title-card .big-button {
    width: 100%;
    font-size: 0.7rem;
  }

  .rotate-hint {
    display: grid;
    max-width: 18rem;
    place-items: center;
    gap: 8px;
    margin: 12svh auto 0;
    padding: 0 18px;
    color: #d7e8f4;
    font-size: 1rem;
    text-align: center;
  }

  .rotate-hint span {
    color: var(--gold);
    font-size: 2.8rem;
    line-height: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
