:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b1116;
  color: #fff9ea;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(18, 62, 67, 0.42), transparent 38%),
    linear-gradient(315deg, rgba(139, 44, 69, 0.38), transparent 42%),
    #0b1116;
}

button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  color: #15171b;
  background: #ffe082;
  box-shadow: 0 5px 0 #9b7130;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease, opacity 120ms ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(1px);
  box-shadow: 0 4px 0 #9b7130;
}

button:active:not(:disabled) {
  transform: translateY(5px);
  box-shadow: 0 0 0 #9b7130;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.game-shell {
  width: min(1180px, 100vw);
  padding: clamp(10px, 1.6vw, 18px);
}

.stage {
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  min-height: min(760px, calc(100vh - 20px));
  background: #132025;
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.48);
}

canvas {
  display: block;
  width: 100%;
  height: min(74vh, 680px);
  min-height: 520px;
  background: #10202c;
  cursor: pointer;
}

.hud {
  position: absolute;
  z-index: 4;
  top: 12px;
  left: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  pointer-events: none;
}

.hud > div,
.upgrade-panel,
.mission,
.banner {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(9, 13, 18, 0.74);
  backdrop-filter: blur(9px);
}

.hud > div {
  min-width: 0;
  border-radius: 8px;
  padding: 9px 11px;
}

.label {
  display: block;
  color: #b9cbd5;
  font-size: 0.68rem;
  font-weight: 760;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(0.92rem, 1.7vw, 1.2rem);
}

.mission {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 16px;
  width: min(650px, calc(100% - 28px));
  transform: translateX(-50%);
  border-radius: 8px;
  padding: 11px 14px;
  color: #fff9ea;
  font-weight: 780;
  text-align: center;
  pointer-events: none;
}

.upgrade-panel {
  position: absolute;
  z-index: 6;
  top: 90px;
  right: 12px;
  width: 224px;
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.panel-title {
  color: #fff9ea;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.upgrade-panel button {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
  background: #8ed7c6;
  box-shadow: 0 5px 0 #2d6d66;
  text-align: left;
}

.banner {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 16px;
  padding: 28px;
  text-align: center;
  background:
    linear-gradient(rgba(8, 12, 18, 0.36), rgba(8, 12, 18, 0.84)),
    radial-gradient(circle at 50% 27%, rgba(125, 243, 224, 0.22), transparent 21rem);
}

.banner.hidden {
  display: none;
}

.banner h1 {
  margin: 0;
  font-size: clamp(3rem, 10vw, 7.2rem);
  line-height: 0.9;
  letter-spacing: 0;
  text-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
}

.banner p {
  margin: 0 auto;
  max-width: 660px;
  color: #e9f2ef;
  font-size: clamp(1rem, 2vw, 1.24rem);
  font-weight: 680;
  line-height: 1.42;
}

#startButton {
  justify-self: center;
  min-width: 170px;
}

.touch-controls {
  position: absolute;
  z-index: 7;
  left: 14px;
  bottom: 66px;
  display: none;
  grid-template-columns: repeat(3, 46px);
  grid-template-rows: repeat(2, 46px);
  gap: 8px;
}

.touch-controls button {
  min-height: 46px;
  padding: 0;
  background: rgba(255, 224, 130, 0.92);
}

.touch-controls [data-move="up"] {
  grid-column: 2;
}

.touch-controls [data-move="left"] {
  grid-column: 1;
  grid-row: 2;
}

.touch-controls [data-move="down"] {
  grid-column: 2;
  grid-row: 2;
}

.touch-controls [data-move="right"] {
  grid-column: 3;
  grid-row: 2;
}

.touch-controls [data-action="work"] {
  position: fixed;
  right: 18px;
  bottom: 72px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  color: #fff9ea;
  background: #e85d75;
  box-shadow: 0 6px 0 #8a2945;
}

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

  .game-shell {
    padding: 0;
  }

  .stage {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  canvas {
    height: 100vh;
    min-height: 640px;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 6px;
  }

  .hud > div {
    padding: 7px 8px;
  }

  .upgrade-panel {
    top: 182px;
    right: 8px;
    width: min(208px, 48vw);
  }

  .upgrade-panel button {
    font-size: 0.82rem;
  }

  .mission {
    bottom: 12px;
    font-size: 0.88rem;
  }

  .touch-controls {
    display: grid;
  }
}
