:root {
  color-scheme: dark;
  --bg: #11080d;
  --panel: rgba(24, 12, 17, 0.74);
  --panel-strong: rgba(18, 8, 12, 0.9);
  --line: rgba(242, 198, 111, 0.36);
  --gold: #f4cb73;
  --ember: #d96336;
  --blood: #b52c2d;
  --bone: #f1ddae;
  --muted: #b99f8d;
  --shadow: rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 10%, rgba(207, 96, 45, 0.35), transparent 32%),
    radial-gradient(circle at 82% 24%, rgba(116, 55, 94, 0.24), transparent 35%),
    linear-gradient(145deg, #10070c, #28131c 48%, #090507);
  color: var(--bone);
  font-family: "Georgia", "Times New Roman", serif;
}

button {
  font: inherit;
}

.game {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.stage {
  position: relative;
  width: min(100vw - 20px, 1500px);
  height: min(100svh - 20px, 844px);
  min-height: 520px;
  overflow: hidden;
  border: 1px solid rgba(244, 203, 115, 0.35);
  background: #10070c;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.55);
  isolation: isolate;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: overlay;
  opacity: 0.24;
  z-index: 20;
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 42%, rgba(0, 0, 0, 0.62));
  z-index: 21;
}

.canvas-mount,
.game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.game-canvas {
  display: block;
}

.loading {
  position: absolute;
  inset: 0;
  z-index: 22;
  display: grid;
  place-items: center;
  background: #12080d;
  color: var(--gold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.loading.hidden {
  display: none;
}

.loading--error {
  color: #ffd4c7;
}

.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 23;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
}

.hud__cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  max-width: 46%;
}

.hud__cluster--right {
  justify-content: flex-end;
}

.hud__item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 28px var(--shadow);
  backdrop-filter: blur(7px);
}

.hud__label {
  color: var(--muted);
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hud strong {
  color: var(--bone);
  font-size: 0.95rem;
  white-space: nowrap;
}

.health {
  display: inline-flex;
  gap: 4px;
}

.heart {
  width: 12px;
  height: 18px;
  display: inline-block;
  transform: skew(-10deg);
  border: 1px solid rgba(255, 228, 178, 0.46);
  background: rgba(91, 35, 38, 0.4);
}

.heart--filled {
  background: linear-gradient(180deg, #ffb469, var(--blood));
  box-shadow: 0 0 12px rgba(217, 76, 55, 0.65);
}

.boss {
  position: absolute;
  top: 64px;
  left: 50%;
  z-index: 24;
  width: min(520px, calc(100% - 40px));
  transform: translateX(-50%);
  pointer-events: none;
}

.boss__label {
  display: flex;
  justify-content: space-between;
  color: var(--bone);
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  text-shadow: 0 2px 8px #000;
}

.boss__label strong {
  color: var(--ember);
}

.boss__track {
  height: 9px;
  margin-top: 5px;
  border: 1px solid rgba(244, 203, 115, 0.45);
  background: rgba(11, 4, 7, 0.8);
}

.boss__fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ab2429, #ed9348, #f4cb73);
  transition: width 120ms linear;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 23;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 7px 12px;
  border: 1px solid rgba(244, 203, 115, 0.28);
  background: rgba(14, 7, 11, 0.62);
  color: rgba(241, 221, 174, 0.86);
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  pointer-events: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 470px);
  align-items: stretch;
  background:
    linear-gradient(90deg, rgba(9, 4, 7, 0.12), rgba(9, 4, 7, 0.86)),
    rgba(11, 5, 8, 0.34);
}

.overlay.hidden {
  display: none;
}

.overlay__art {
  position: relative;
  min-height: 100%;
  background:
    linear-gradient(90deg, rgba(11, 5, 8, 0.06), rgba(11, 5, 8, 0.8)),
    image-set(url("./assets/generated/title-painting.png") type("image/png")),
    radial-gradient(circle at 42% 24%, rgba(215, 112, 51, 0.5), transparent 30%),
    linear-gradient(145deg, #23111b, #713327 52%, #12070b);
  background-size: cover;
  background-position: center;
}

.overlay__art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 42% 40%, transparent 34%, rgba(0, 0, 0, 0.45));
}

.overlay__panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(24px, 5vw, 58px);
  border-left: 1px solid rgba(244, 203, 115, 0.32);
  background: linear-gradient(180deg, rgba(24, 11, 17, 0.92), rgba(9, 4, 7, 0.94));
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.38);
}

.overlay__kicker {
  margin: 0 0 12px;
  color: var(--ember);
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.overlay h1 {
  margin: 0 0 16px;
  color: var(--gold);
  font-size: clamp(2.35rem, 6vw, 4.8rem);
  line-height: 0.9;
  text-shadow: 0 6px 22px rgba(0, 0, 0, 0.8);
}

.overlay p[data-ui="overlay-text"] {
  margin: 0;
  max-width: 34rem;
  color: rgba(241, 221, 174, 0.86);
  font-size: clamp(1rem, 1.5vw, 1.22rem);
  line-height: 1.55;
  white-space: pre-line;
}

.overlay__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0;
}

.overlay__controls span {
  padding: 5px 8px;
  border: 1px solid rgba(244, 203, 115, 0.28);
  color: var(--muted);
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.overlay__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button {
  min-width: 130px;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  color: var(--bone);
  background: rgba(42, 20, 26, 0.9);
  cursor: pointer;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.button:hover,
.button:focus-visible {
  outline: none;
  border-color: rgba(244, 203, 115, 0.88);
  box-shadow: 0 0 0 3px rgba(244, 203, 115, 0.22);
}

.button--primary {
  color: #1a0b0b;
  background: linear-gradient(180deg, #ffd98b, #ce6a37);
  font-weight: 700;
}

.button--ghost {
  background: rgba(11, 5, 8, 0.62);
}

.touch {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 54px;
  z-index: 26;
  display: none;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.touch__button {
  pointer-events: auto;
  min-width: 54px;
  height: 46px;
  padding: 0 11px;
  border: 1px solid rgba(244, 203, 115, 0.36);
  border-radius: 0;
  background: rgba(12, 6, 10, 0.64);
  color: var(--bone);
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  touch-action: none;
}

.touch__button:active {
  background: rgba(206, 106, 55, 0.72);
}

.qa-panel {
  position: fixed;
  right: 8px;
  bottom: 8px;
  z-index: 1000;
  display: flex;
  gap: 4px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.7);
  font-family: system-ui, sans-serif;
}

.qa-panel button {
  min-height: 26px;
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: #201820;
  color: #f5e4c0;
  font-size: 11px;
}

@media (hover: none), (pointer: coarse) {
  .touch {
    display: flex;
  }

  .hint {
    bottom: 108px;
  }
}

@media (max-width: 760px) {
  .stage {
    width: 100vw;
    height: 100svh;
    min-height: 0;
    border: 0;
  }

  .game {
    padding: 0;
  }

  .hud {
    top: 10px;
    left: 10px;
    right: 10px;
  }

  .hud__cluster {
    max-width: 58%;
    gap: 6px;
  }

  .hud__cluster--right {
    max-width: 42%;
  }

  .hud__item {
    min-height: 30px;
    padding: 5px 8px;
  }

  .hud__label {
    font-size: 0.58rem;
  }

  .hud strong {
    font-size: 0.78rem;
  }

  .health {
    gap: 2px;
  }

  .heart {
    width: 9px;
    height: 15px;
  }

  .overlay {
    grid-template-columns: 1fr;
    align-items: end;
    background:
      linear-gradient(180deg, rgba(9, 4, 7, 0.08), rgba(9, 4, 7, 0.88)),
      image-set(url("./assets/generated/title-painting.png") type("image/png")),
      linear-gradient(145deg, #23111b, #713327 52%, #12070b);
    background-size: cover;
    background-position: center;
  }

  .overlay__art {
    display: none;
  }

  .overlay__panel {
    width: 100%;
    min-width: 0;
    max-height: 72svh;
    overflow: hidden;
    padding: 22px 18px 28px;
    border-left: 0;
    border-top: 1px solid rgba(244, 203, 115, 0.32);
  }

  .overlay__kicker {
    font-size: 0.62rem;
    letter-spacing: 0.13em;
    line-height: 1.35;
  }

  .overlay h1 {
    font-size: clamp(2.15rem, 11vw, 3rem);
    line-height: 0.94;
    overflow-wrap: anywhere;
  }

  .overlay p[data-ui="overlay-text"] {
    max-width: 100%;
    font-size: 0.95rem;
    line-height: 1.45;
  }

  .overlay__controls {
    margin: 20px 0;
  }

  .overlay__controls span {
    font-size: 0.62rem;
  }

  .boss {
    top: 58px;
    width: calc(100% - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
