:root {
  color-scheme: light;
  --ink: #18212f;
  --panel: #f7efe1;
  --rim: #403a30;
  --button: #d8382f;
  --button-dark: #9f211b;
  --sky: #7ac7ff;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, #7ac7ff 0%, #bfefff 58%, #79c85c 58%, #51a34a 100%);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

.game-shell {
  width: min(100vw, 1060px);
  padding: 14px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 3px solid var(--rim);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.18);
  font-variant-numeric: tabular-nums;
}

.hud div {
  min-width: 0;
}

.hud-label {
  display: block;
  color: #574d3d;
  font-size: clamp(10px, 2vw, 12px);
  font-weight: 800;
  letter-spacing: 0;
}

.hud strong {
  display: block;
  overflow: hidden;
  color: #1e2634;
  font-size: clamp(18px, 4.2vw, 26px);
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 4px solid var(--rim);
  border-radius: 8px;
  overflow: hidden;
  background: var(--sky);
  box-shadow: 0 16px 30px rgba(31, 34, 38, 0.28);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 14px;
  padding: 24px;
  background: rgba(20, 33, 50, 0.34);
  color: #fff;
  text-align: center;
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  margin: 0;
  text-shadow: 0 4px 0 #7b211a;
  font-size: clamp(38px, 9vw, 76px);
  letter-spacing: 0;
}

.overlay p {
  max-width: 560px;
  margin: 0 auto;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  font-size: clamp(15px, 3vw, 19px);
  font-weight: 700;
}

.overlay button,
.touch-controls button {
  border: 3px solid var(--rim);
  border-radius: 8px;
  background: var(--button);
  color: #fff;
  box-shadow: 0 5px 0 var(--button-dark);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.overlay button {
  justify-self: center;
  min-width: min(260px, 80vw);
  padding: 12px 20px;
  font-size: 20px;
}

.overlay button:active,
.touch-controls button:active,
.touch-controls button.active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--button-dark);
}

.touch-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(56px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.touch-controls button {
  height: 58px;
  touch-action: none;
  font-size: 22px;
}

@media (min-width: 820px) {
  .touch-controls {
    display: none;
  }
}

@media (max-width: 520px) {
  .game-shell {
    padding: 8px;
  }

  .hud {
    padding: 8px;
  }
}
