﻿:root {
  color-scheme: dark;
  --ink: #f6f0d7;
  --muted: #a9b0ac;
  --panel: #141817;
  --panel-strong: #090b0b;
  --edge: #38433f;
  --button: #242d2a;
  --button-hover: #32413b;
  --accent: #d9c15b;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 0, rgba(219, 193, 91, 0.12), transparent 36rem),
    linear-gradient(180deg, #121615 0%, #050606 100%);
  color: var(--ink);
  font-family: "Trebuchet MS", Verdana, Arial, sans-serif;
  overflow: hidden;
}

button,
select {
  color: var(--ink);
  background: var(--button);
  border: 1px solid var(--edge);
  border-radius: 6px;
  font: inherit;
  min-height: 36px;
}

button {
  padding: 0 14px;
  cursor: pointer;
}

button:hover,
select:hover {
  background: var(--button-hover);
}

button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.game-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  width: 100vw;
  height: 100vh;
  padding: 10px;
}

.stage-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  background: #050606;
  border: 1px solid #27302d;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

#game {
  width: min(calc(100vw - 22px), calc((100vh - 68px) * 1.272727));
  height: min(calc(100vh - 68px), calc((100vw - 22px) / 1.272727));
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #050606;
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 20px;
  color: var(--ink);
  background: rgba(3, 4, 4, 0.72);
  font-size: clamp(20px, 5vmin, 42px);
  text-align: center;
  text-shadow: 0 2px 0 #000;
}

.overlay.is-visible {
  display: grid;
}

.start-button {
  position: absolute;
  left: 50%;
  bottom: clamp(34px, 9vh, 84px);
  transform: translateX(-50%);
  min-width: 120px;
  min-height: 44px;
  background: #4d3e13;
  border-color: #b49535;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.start-button.is-hidden {
  display: none;
}

.control-bar {
  display: grid;
  grid-template-columns: auto auto auto minmax(160px, 280px);
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.control-bar select {
  width: 100%;
  padding: 0 10px;
}

@media (max-width: 620px) {
  body {
    overflow: auto;
  }

  .game-shell {
    min-height: 100vh;
    height: auto;
  }

  .control-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .control-bar select {
    grid-column: 1 / -1;
  }
}

.debug-control {
  display: none;
}

body.bq-debug-overlay .control-bar.debug-control {
  display: grid;
}

body.bq-debug-overlay .start-button.debug-control {
  display: block;
}

body.bq-debug-overlay .start-button.debug-control.is-hidden {
  display: none;
}

body:not(.bq-debug-overlay) .game-shell {
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
}

body:not(.bq-debug-overlay) #game {
  width: min(calc(100vw - 22px), calc((100vh - 22px) * 1.272727));
  height: min(calc(100vh - 22px), calc((100vw - 22px) / 1.272727));
}

.touch-controls {
  display: none;
}
body.bq-touch-device,
body.bq-touch-device * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html.bq-touch-device,
body.bq-touch-device {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

body.bq-touch-device .touch-controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 max(18px, env(safe-area-inset-left)) 0 max(18px, env(safe-area-inset-right));
  pointer-events: none;
}

.game-shell,
.stage-wrap,
#game,
.touch-controls,
.touch-controls * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body.bq-touch-device .touch-button {
  pointer-events: auto;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(7, 10, 12, 0.32);
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  font-family: Arial, sans-serif;
  line-height: 1;
  text-shadow: 0 1px 2px #000;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.32);
  touch-action: none;
}

body.bq-touch-device .touch-button.is-pressed,
body.bq-touch-device .touch-dpad.is-pressed {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.72);
}

body.bq-touch-device .touch-dpad {
  position: relative;
  width: 158px;
  height: 158px;
  border-radius: 50%;
  background: rgba(7, 10, 12, 0.24);
  border: 2px solid rgba(255, 255, 255, 0.32);
  pointer-events: auto;
  touch-action: none;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.32);
}

body.bq-touch-device .touch-dpad::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 50px;
  height: 50px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
  pointer-events: none;
  z-index: 1;
}
body.bq-touch-device .touch-dpad-zone {
  position: absolute;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
  touch-action: none;
  z-index: 2;
}

body.bq-touch-device .touch-zone-up-left,
body.bq-touch-device .touch-zone-up,
body.bq-touch-device .touch-zone-up-right,
body.bq-touch-device .touch-zone-left,
body.bq-touch-device .touch-zone-center,
body.bq-touch-device .touch-zone-right,
body.bq-touch-device .touch-zone-down-left,
body.bq-touch-device .touch-zone-down,
body.bq-touch-device .touch-zone-down-right {
  width: 33.333%;
  height: 33.333%;
}

body.bq-touch-device .touch-zone-up-left { left: 0; top: 0; }
body.bq-touch-device .touch-zone-up { left: 33.333%; top: 0; }
body.bq-touch-device .touch-zone-up-right { right: 0; top: 0; }
body.bq-touch-device .touch-zone-left { left: 0; top: 33.333%; }
body.bq-touch-device .touch-zone-center { left: 33.333%; top: 33.333%; }
body.bq-touch-device .touch-zone-right { right: 0; top: 33.333%; }
body.bq-touch-device .touch-zone-down-left { left: 0; bottom: 0; }
body.bq-touch-device .touch-zone-down { left: 33.333%; bottom: 0; }
body.bq-touch-device .touch-zone-down-right { right: 0; bottom: 0; }


body.bq-touch-device .touch-actions {
  display: grid;
  justify-items: center;
  align-items: center;
  margin: 0 4px 37px 0;
  pointer-events: none;
}

body.bq-touch-device .touch-jump {
  width: 84px !important;
  height: 84px !important;
  min-width: 84px !important;
  min-height: 84px !important;
  max-width: 84px !important;
  max-height: 84px !important;
  inline-size: 84px !important;
  block-size: 84px !important;
  aspect-ratio: 1 / 1;
  flex: 0 0 84px;
  border-radius: 50% !important;
  font-size: 32px;
}