:root {
  color-scheme: dark;
  --paper: #f2dfaf;
  --ink: #20150e;
  --gold: #f3c45a;
  --red: #d94b3d;
  --blue: #5fa8d3;
  --green: #6fb06f;
  --pink: #ff7bbd;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background:
    radial-gradient(circle at 24% 18%, rgba(243, 196, 90, 0.18), transparent 28%),
    linear-gradient(135deg, #17100d 0%, #2a1813 42%, #101820 100%);
  color: var(--paper);
  font-family: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  touch-action: none;
  user-select: none;
}

.home-link {
  position: fixed;
  z-index: 6;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  height: 38px;
  padding: 0 14px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  background: var(--gold);
  box-shadow: 4px 4px 0 #000;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
  text-transform: uppercase;
}

.game-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

#game {
  display: block;
  width: min(100vw - 36px, calc((100vh - 36px) * 16 / 9));
  aspect-ratio: 16 / 9;
  height: auto;
  max-height: calc(100vh - 36px);
  border: 5px solid #090604;
  border-radius: 8px;
  background: #090604;
  box-shadow: 0 18px 80px rgba(0, 0, 0, 0.64), inset 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.hud-panel {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 5;
  width: min(260px, calc(100vw - 116px));
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: rgba(25, 17, 13, 0.82);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
}

.hud-row,
.bossline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  text-transform: uppercase;
}

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

.meter {
  height: 12px;
  margin: 6px 0 10px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: #251712;
}

.meter span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--red), #ffdf73);
  transition: width 0.18s ease;
}

.meter.ex span {
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--pink));
}

.bossline {
  align-items: flex-start;
  flex-direction: column;
  margin-top: 2px;
}

.bossline span {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 23px;
  line-height: 1;
  letter-spacing: 0;
}

.bossline small {
  color: #d7c299;
  font-size: 11px;
}

.touch-pad {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: none;
  grid-template-columns: repeat(6, minmax(48px, 1fr));
  gap: 8px;
  width: min(92vw, 520px);
  transform: translateX(-50%);
}

.touch-pad button {
  min-height: 44px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  background: rgba(242, 223, 175, 0.93);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.65);
  color: var(--ink);
  font: 800 11px/1 "Space Grotesk", sans-serif;
  text-transform: uppercase;
}

.touch-pad button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.65);
}

@media (pointer: coarse), (max-width: 760px) {
  .touch-pad {
    display: grid;
  }

  .hud-panel {
    width: min(220px, calc(100vw - 106px));
    padding: 9px;
  }

  .bossline span {
    font-size: 19px;
  }

  #game {
    width: min(100vw - 16px, calc((100vh - 96px) * 16 / 9));
    max-height: calc(100vh - 96px);
  }

  .game-shell {
    align-items: start;
    padding: 74px 8px 88px;
  }
}
