:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #080c0f;
  --surface: #11191c;
  --surface-2: #182326;
  --line: #294037;
  --text: #f2fff8;
  --muted: #9ab0a5;
  --primary: #38e08f;
  --accent: #ffd85a;
  --danger: #ff647c;
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 50% -20%, rgba(56, 224, 143, .15), transparent 42%),
    var(--bg);
  color: var(--text);
}

button, canvas { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.game-wrap {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.game-hud {
  width: min(100%, 720px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
}

.game-stat, .game-action {
  min-height: 38px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(17, 25, 28, .94);
  color: var(--text);
  font-weight: 750;
}

.game-stat span { color: var(--primary); }
.game-action { cursor: pointer; }
.game-action:active { transform: translateY(1px); background: var(--surface-2); }

.game-canvas {
  display: block;
  width: min(100%, var(--game-width, 720px));
  height: auto;
  max-height: calc(100dvh - 174px);
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #0e1518;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .38);
  touch-action: none;
  user-select: none;
}

.touch-controls {
  width: min(100%, 520px);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  touch-action: none;
  user-select: none;
}

.touch-button {
  min-width: 70px;
  min-height: 50px;
  padding: 10px 16px;
  border: 1px solid color-mix(in srgb, var(--primary) 55%, var(--line));
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(56, 224, 143, .2), rgba(56, 224, 143, .08));
  box-shadow: inset 0 1px rgba(255, 255, 255, .08);
  color: var(--text);
  font-weight: 850;
  font-size: 1rem;
  cursor: pointer;
}

.touch-button.primary {
  min-width: 110px;
  background: var(--primary);
  color: #062315;
}

.touch-button.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #271f00;
}

.touch-button:active, .touch-button.is-pressed {
  transform: scale(.96);
  filter: brightness(1.08);
}

.game-help {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.35;
  text-align: center;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(2, 48px);
  gap: 6px;
}
.dpad .touch-button { min-width: 52px; min-height: 48px; padding: 0; font-size: 1.25rem; }
.dpad-up { grid-column: 2; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }

@media (hover: hover) and (pointer: fine) and (min-height: 690px) {
  .game-help .touch-copy { display: none; }
}

@media (max-width: 600px), (max-height: 620px) {
  .game-wrap { justify-content: flex-start; }
  .game-hud { gap: 5px; }
  .game-stat, .game-action { min-height: 34px; padding: 5px 10px; font-size: .78rem; }
  .game-canvas { max-height: calc(100dvh - 170px); border-radius: 9px; }
  .touch-button { min-height: 46px; }
  .game-help { font-size: .7rem; }
}

