:root {
  --bg-top: #1d2333;
  --bg-bottom: #090b12;
  --panel: rgba(10, 13, 22, 0.92);
  --panel-border: #65748f;
  --text-main: #eef3ff;
  --text-soft: rgba(238, 243, 255, 0.74);
  --accent: #e64e42;
  --accent-dark: #84261d;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Chakra Petch", sans-serif;
  background:
    radial-gradient(circle at 18% 20%, rgba(230, 78, 66, 0.18), transparent 25%),
    radial-gradient(circle at 78% 18%, rgba(82, 119, 255, 0.12), transparent 22%),
    linear-gradient(180deg, #242c3f 0%, var(--bg-top) 32%, #10141f 68%, var(--bg-bottom) 100%);
  color: var(--text-main);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 28rem;
  height: 28rem;
  top: -7rem;
  right: -4rem;
  background: radial-gradient(circle, rgba(255, 118, 84, 0.22) 0%, rgba(255, 118, 84, 0) 70%);
}

body::after {
  width: 26rem;
  height: 26rem;
  bottom: -12rem;
  left: -8rem;
  background: radial-gradient(circle, rgba(76, 102, 160, 0.24) 0%, rgba(76, 102, 160, 0) 72%);
}

.page-shell {
  position: relative;
  z-index: 1;
  width: 100vw;
  min-height: 100vh;
}

.game-panel {
  background: var(--panel);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.game-panel {
  position: relative;
  width: 100vw;
  height: 100vh;
  padding: 0;
  overflow: hidden;
}

.debug-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.debug-controls.hidden {
  display: none;
}

.debug-select-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.debug-select {
  min-width: 108px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(12, 17, 26, 0.88);
  color: var(--text-main);
  font: inherit;
}

.start-screen,
.character-select {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.start-screen {
  z-index: 4;
  background: url("./backgrounds/background-start.jpg") center / cover no-repeat;
}

.start-screen.hidden {
  display: none;
}

.start-screen-card,
.character-select-card {
  width: min(100%, 620px);
  padding: 30px;
  text-align: center;
}

.start-screen-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  width: min(100% - 32px, 520px);
  min-height: min(100vh - 64px, 680px);
  padding: 30px 20px 8px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.character-select-card {
  border-radius: 24px;
  border: 2px solid rgba(143, 163, 204, 0.3);
  background: rgba(12, 17, 26, 0.82);
  box-shadow: 0 28px 52px rgba(0, 0, 0, 0.34);
}

.character-select-kicker,
.character-select-title,
.character-select-brand,
.controls-modal-kicker,
.controls-modal-title,
.start-screen-hint {
  font-family: "Press Start 2P", monospace;
}

.press-start-button {
  margin-top: 0;
  min-width: min(100%, 360px);
  border: 0;
  border-radius: 999px;
  padding: 18px 26px;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.9rem, 2vw, 1.15rem);
  line-height: 1.5;
  color: #fff8f1;
  background: linear-gradient(180deg, #ff9d4d 0%, #e64e42 100%);
  box-shadow: 0 0 0 2px rgba(255, 180, 108, 0.22), inset 0 -3px 0 rgba(0, 0, 0, 0.2);
  cursor: pointer;
  animation: press-start-pulse 1.2s ease-in-out infinite alternate;
}

.press-start-button:hover {
  filter: brightness(1.06);
}

.start-screen-hint {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.8;
  color: rgba(255, 248, 241, 0.9);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.52);
}

.character-select {
  z-index: 4;
  z-index: 5;
  background:
    linear-gradient(180deg, rgba(8, 12, 20, 0.62), rgba(8, 12, 20, 0.84)),
    radial-gradient(circle at top, rgba(255, 119, 96, 0.18), transparent 34%),
    url("./backgrounds/background-start.jpg") center / cover no-repeat;
  backdrop-filter: blur(10px);
}

.character-select.hidden {
  display: none;
}

.character-select-kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: #ff8d6a;
}

.character-select-title {
  margin: 18px 0 0;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  line-height: 1.5;
}

.character-select-brand {
  margin: 18px 0 0;
  font-size: clamp(1.4rem, 2.6vw, 2rem);
  line-height: 1.4;
}

.character-select-copy {
  margin: 18px auto 0;
  max-width: 38ch;
  color: var(--text-soft);
  line-height: 1.6;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.character-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 24px 20px;
  border-radius: 22px;
  border: 2px solid rgba(143, 163, 204, 0.3);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.character-option:hover,
.character-option.is-selected {
  border-color: rgba(255, 141, 106, 0.88);
  background: rgba(255, 141, 106, 0.09);
  transform: translateY(-2px);
}

.character-option-art {
  width: 220px;
  height: 280px;
  object-fit: contain;
}

.character-option-name {
  font-size: 1.4rem;
  font-weight: 700;
}

.character-option-note {
  font-size: 1.02rem;
  color: var(--text-soft);
}

.start-game-button {
  margin-top: 24px;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  font: inherit;
  font-weight: 700;
  color: #fff6f4;
  background: linear-gradient(180deg, #ff7760 0%, var(--accent) 100%);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.start-game-button:hover {
  filter: brightness(1.05);
}

@keyframes press-start-pulse {
  from {
    transform: translateY(0);
    box-shadow: 0 0 0 2px rgba(255, 180, 108, 0.22), inset 0 -3px 0 rgba(0, 0, 0, 0.2);
  }

  to {
    transform: translateY(-2px);
    box-shadow: 0 0 0 2px rgba(255, 180, 108, 0.32), 0 12px 26px rgba(230, 78, 66, 0.24), inset 0 -3px 0 rgba(0, 0, 0, 0.2);
  }
}

.controls-modal {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(6, 10, 16, 0.76);
  backdrop-filter: blur(10px);
}

.controls-modal.hidden {
  display: none;
}

.level-complete-modal {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 182, 97, 0.22), transparent 28%),
    linear-gradient(180deg, rgba(7, 11, 18, 0.58), rgba(7, 11, 18, 0.88));
  backdrop-filter: blur(12px);
}

.level-complete-modal.hidden {
  display: none;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(7, 10, 16, 0.58), rgba(7, 10, 16, 0.9)),
    radial-gradient(circle at 50% 16%, rgba(103, 160, 255, 0.16), transparent 28%);
  backdrop-filter: blur(10px);
}

.loading-overlay.hidden {
  display: none;
}

.loading-card {
  width: min(100% - 24px, 560px);
  padding: 30px 28px;
  text-align: center;
  border-radius: 26px;
  border: 2px solid rgba(103, 160, 255, 0.28);
  background: rgba(13, 18, 29, 0.94);
  box-shadow: 0 26px 56px rgba(0, 0, 0, 0.38);
}

.loading-kicker,
.loading-title {
  font-family: "Press Start 2P", monospace;
}

.loading-kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: #8fb8ff;
}

.loading-title {
  margin: 18px 0 0;
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  line-height: 1.6;
  color: #eef4ff;
}

.loading-copy {
  margin: 18px auto 0;
  max-width: 34ch;
  color: rgba(238, 243, 255, 0.76);
  line-height: 1.6;
}

.loading-track {
  position: relative;
  height: 18px;
  margin-top: 22px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid rgba(143, 163, 204, 0.22);
  background: rgba(255, 255, 255, 0.08);
}

.loading-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #67a0ff 0%, #a8f2ff 100%);
  transition: width 120ms ease;
}

.loading-percent {
  display: inline-block;
  margin-top: 14px;
  font-weight: 700;
  color: #cfe2ff;
}

.level-complete-card {
  width: min(100% - 24px, 680px);
  padding: 34px 32px;
  text-align: center;
  border-radius: 28px;
  border: 2px solid rgba(255, 207, 110, 0.34);
  background:
    linear-gradient(180deg, rgba(20, 26, 38, 0.96), rgba(10, 14, 22, 0.96)),
    rgba(12, 17, 26, 0.9);
  box-shadow:
    0 30px 70px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.level-complete-kicker,
.level-complete-title {
  font-family: "Press Start 2P", monospace;
}

.level-complete-kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: #ffcf6e;
}

.level-complete-title {
  margin: 20px 0 0;
  font-size: clamp(1.1rem, 2.4vw, 1.8rem);
  line-height: 1.6;
  color: #fff4cf;
  text-shadow: 0 0 22px rgba(255, 207, 110, 0.18);
}

.level-complete-copy {
  margin: 22px auto 0;
  max-width: 34ch;
  color: rgba(238, 243, 255, 0.82);
  line-height: 1.7;
  font-size: 1.02rem;
}

.level-complete-actions {
  display: flex;
  justify-content: center;
  margin-top: 26px;
}

.controls-modal-card {
  position: relative;
  width: min(100%, 720px);
  padding: 28px;
  border-radius: 24px;
  border: 2px solid rgba(143, 163, 204, 0.3);
  background: rgba(13, 18, 29, 0.92);
  box-shadow: 0 26px 56px rgba(0, 0, 0, 0.36);
}

.controls-close-button {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.controls-modal-kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: #ff8d6a;
}

.controls-modal-title {
  margin: 18px 0 0;
  font-size: clamp(1rem, 2vw, 1.35rem);
  line-height: 1.6;
}

.controls-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.controls-modal-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(143, 163, 204, 0.18);
}

.controls-modal-key {
  display: inline-flex;
  align-self: flex-start;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 141, 106, 0.14);
  color: #ffd9cf;
  font-weight: 700;
}

.controls-modal-text {
  color: var(--text-soft);
  line-height: 1.45;
}

.game-frame {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(180deg, #2d3950 0%, #191f2f 54%, #11151e 100%);
}

.game-frame canvas {
  display: block;
  width: 100%;
  height: auto;
}

.top-hud {
  position: absolute;
  top: 20px;
  left: 24px;
  right: 24px;
  z-index: 3;
  pointer-events: none;
}

.hud-bar {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 20px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(8, 12, 18, 0.72);
  border: 1px solid rgba(143, 163, 204, 0.18);
  backdrop-filter: blur(8px);
}

.hud-health-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.hud-health-card {
  display: grid;
  gap: 6px;
  width: min(32vw, 320px);
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(8, 12, 18, 0.76);
  border: 1px solid rgba(143, 163, 204, 0.18);
  backdrop-filter: blur(8px);
  transition: opacity 160ms ease;
}

.hud-health-card-enemy {
  justify-self: end;
  text-align: right;
}

.hud-health-cards {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  min-width: min(32vw, 320px);
}

.hud-health-card.is-fading {
  opacity: 0;
  transition: opacity 2s linear;
}

.hud-health-card.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.hud-health-name,
.hud-health-value {
  font-size: 0.84rem;
  font-weight: 700;
}

.hud-health-name {
  font-size: 1.02rem;
  color: #f5f7ff;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud-health-value {
  color: var(--text-soft);
}

.hud-score-value {
  font-size: 0.82rem;
  font-weight: 700;
  color: #ffcf6e;
  letter-spacing: 0.04em;
}

.hud-lives {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
}

.hud-life-icon {
  width: 56px;
  height: 56px;
  object-fit: cover;
}

.hud-life-icon.is-lost {
  opacity: 0.26;
  filter: grayscale(1) brightness(0.72);
}

.hud-health-track {
  position: relative;
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(143, 163, 204, 0.18);
}

.hud-health-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: inherit;
  transition: width 140ms ease;
}

.hud-health-fill-player {
  background: linear-gradient(90deg, #56d286 0%, #8ef4b2 100%);
}

.hud-health-fill-enemy {
  background: linear-gradient(90deg, #ff6d5d 0%, #ffb171 100%);
}

#statusText {
  flex: 1;
  color: var(--text-soft);
  line-height: 1.5;
  font-weight: 600;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-volume-control {
  display: grid;
  gap: 6px;
  min-width: 132px;
}

.hud-volume-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-soft);
}

.hud-volume-slider {
  width: 100%;
  accent-color: #ff8d6a;
  cursor: pointer;
}

.music-toggle-button,
.restart-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  color: #fff6f4;
  background: linear-gradient(180deg, #ff7760 0%, var(--accent) 100%);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.music-toggle-button {
  background: linear-gradient(180deg, #67a0ff 0%, #355fd6 100%);
}

.music-toggle-button.is-muted {
  background: linear-gradient(180deg, #5a6274 0%, #363c4c 100%);
}

.music-toggle-button:hover,
.restart-button:hover {
  filter: brightness(1.05);
}

.music-toggle-button:active,
.restart-button:active {
  transform: translateY(1px);
}

@media (max-width: 640px) {
  .start-screen-card,
  .character-select-card,
  .controls-modal-card,
  .level-complete-card,
  .loading-card {
    width: min(100% - 20px, 720px);
    padding: 22px;
  }

  .controls-modal-grid {
    grid-template-columns: 1fr;
  }

  .press-start-button {
    min-width: 0;
    width: 100%;
  }

  .hud-bar {
    flex-direction: column;
    align-items: stretch;
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .top-hud {
    left: 12px;
    right: 12px;
    top: 12px;
  }

  .hud-health-row {
    flex-direction: column;
    align-items: stretch;
  }

  .hud-health-card {
    width: 100%;
  }

  .hud-health-card-enemy {
    text-align: left;
  }

  .hud-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hud-volume-control {
    min-width: 0;
  }

  .music-toggle-button,
  .restart-button {
    width: 100%;
  }
}