:root {
  color-scheme: dark;
  --ink: #f8fafc;
  --muted: #9aa5b1;
  --panel: rgba(14, 20, 31, 0.78);
  --stroke: rgba(255, 255, 255, 0.18);
  --red: #ff3158;
  --blue: #1fd4ff;
  --yellow: #f8d250;
  --green: #36e58b;
  --black: #07090f;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 14%, rgba(31, 212, 255, 0.16), transparent 30%),
    linear-gradient(135deg, #101219 0%, #27111b 48%, #0b1215 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  font: inherit;
}

button:disabled {
  cursor: default;
  opacity: 0.5;
}

.game-shell {
  width: min(1180px, 100vw);
  height: min(760px, 100dvh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: clamp(12px, 2.3vw, 24px);
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logo-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  image-rendering: pixelated;
  background:
    linear-gradient(#fff 0 0) 13px 4px / 8px 4px no-repeat,
    linear-gradient(#fff 0 0) 9px 8px / 16px 4px no-repeat,
    linear-gradient(var(--black) 0 0) 5px 12px / 24px 12px no-repeat,
    linear-gradient(var(--red) 0 0) 9px 16px / 16px 12px no-repeat,
    linear-gradient(var(--blue) 0 0) 6px 6px / 4px 4px no-repeat,
    linear-gradient(var(--blue) 0 0) 24px 6px / 4px 4px no-repeat;
  filter: drop-shadow(0 0 0 #fff) drop-shadow(0 4px 0 rgba(0, 0, 0, 0.22));
}

.meters {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.icon-button {
  width: 54px;
  min-height: 54px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), transparent 45%),
    #171d28;
  color: #ffffff;
  box-shadow:
    0 5px 0 #07090f,
    0 12px 26px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  font-size: 24px;
  font-weight: 950;
  line-height: 1;
}

.icon-button.is-paused {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 45%),
    var(--green);
  color: #06100b;
}

.icon-button:active {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 #07090f,
    0 8px 18px rgba(0, 0, 0, 0.3);
}

.meter {
  min-width: 86px;
  padding: 8px 10px;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 44%),
    var(--panel);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.meter span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.meter strong {
  display: block;
  margin-top: 3px;
  font-size: 22px;
  line-height: 1;
}

.web-meter {
  width: 132px;
  position: relative;
  overflow: hidden;
}

.web-meter b {
  display: block;
  height: 8px;
  margin-top: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: linear-gradient(90deg, var(--blue), #ffffff);
  box-shadow: inset -132px 0 0 rgba(255, 255, 255, 0.1);
  transform-origin: left center;
  transform: scaleX(1);
}

.stage-wrap {
  position: relative;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  overflow: hidden;
  background: #07090f;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.35),
    inset 0 0 0 2px rgba(255, 255, 255, 0.05);
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  touch-action: none;
}

#heroLayer {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
}

.scanlines {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0.16;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.16) 0,
    rgba(255, 255, 255, 0.16) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: overlay;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(180deg, rgba(5, 7, 13, 0.25), rgba(5, 7, 13, 0.62));
  transition:
    opacity 160ms ease,
    visibility 160ms ease;
}

.overlay.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.title-card {
  width: min(360px, 100%);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(8, 11, 19, 0.88);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.title-card h1 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(46px, 9vw, 88px);
  line-height: 0.9;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow:
    4px 0 0 var(--red),
    -4px 0 0 var(--blue),
    0 6px 0 rgba(0, 0, 0, 0.36);
}

.title-card p {
  margin: 10px 0 18px;
  color: var(--yellow);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.primary-button,
.touch-controls button {
  position: relative;
  overflow: hidden;
  min-height: 48px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent 42%),
    var(--red);
  color: white;
  box-shadow:
    0 5px 0 #8c142a,
    0 12px 26px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  font-weight: 950;
  text-transform: uppercase;
}

.primary-button::before,
.touch-controls button::before {
  content: "";
  position: absolute;
  inset: 7px auto auto 10px;
  width: 34px;
  height: 4px;
  background: rgba(255, 255, 255, 0.5);
}

.primary-button {
  min-width: 150px;
  padding: 0 18px;
}

.primary-button:active,
.touch-controls button:active {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 #8c142a,
    0 8px 18px rgba(0, 0, 0, 0.3);
}

.touch-controls {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.touch-controls button {
  font-size: 28px;
  line-height: 1;
}

.touch-controls button:last-child {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), transparent 42%),
    var(--blue);
  box-shadow:
    0 5px 0 #0b6f86,
    0 12px 26px rgba(0, 0, 0, 0.3);
}

@media (max-width: 760px), (pointer: coarse) {
  body {
    overflow: auto;
  }

  .game-shell {
    height: 100dvh;
    gap: 10px;
  }

  .hud {
    align-items: stretch;
  }

  .brand {
    max-width: 42vw;
    font-size: 13px;
  }

  .meters {
    flex: 1;
  }

  .meter {
    min-width: 0;
    flex: 1;
    padding: 7px;
  }

  .icon-button {
    width: 48px;
    min-height: 48px;
    flex: 0 0 48px;
  }

  .meter strong {
    font-size: 18px;
  }

  .web-meter {
    display: none;
  }

  .touch-controls {
    display: grid;
  }
}

@media (max-width: 460px) {
  .brand span:last-child {
    display: none;
  }

  .hud {
    gap: 8px;
  }

  .logo-mark {
    width: 30px;
    height: 30px;
  }
}
