:root {
  color-scheme: light;
  --bg: #f4f7f1;
  --panel: #ffffff;
  --ink: #182019;
  --muted: #5d675d;
  --line: #cbd6c4;
  --accent: #146c5c;
  --accent-strong: #0d4f45;
  --warm: #f6b73c;
  --danger: #bb3e3e;
  --focus: #2349d8;
}

* {
  box-sizing: border-box;
}

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

body {
  background: linear-gradient(180deg, #eef5e9 0%, var(--bg) 48%, #eaf0f6 100%);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.game-panel {
  width: min(100%, 900px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(24, 32, 25, 0.12);
  padding: 20px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2.15rem;
  line-height: 1.1;
}

h2 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.primary-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  padding: 0 18px;
}

.primary-button:hover,
.primary-button:active {
  background: var(--accent-strong);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.hud {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.hud-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcf8;
}

.hud-item span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.hud-item strong {
  display: block;
  margin-top: 4px;
  font-size: 1.6rem;
}

.arena {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 260px;
  overflow: hidden;
  border: 2px solid #395145;
  border-radius: 8px;
  background: #dce8d5;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.end-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 25, 19, 0.68);
}

.end-screen[hidden] {
  display: none;
}

.end-box {
  width: min(100%, 320px);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 22px;
  text-align: center;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
}

.end-box p {
  color: var(--muted);
}

.help {
  margin-top: 16px;
  color: var(--muted);
}

.help p {
  margin-bottom: 0;
  line-height: 1.5;
}

.mobile-controls {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(2, 54px);
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  touch-action: none;
}

.control-button {
  width: 64px;
  height: 54px;
  border: 1px solid #a6b5a0;
  border-radius: 8px;
  background: #f7faf4;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 700;
  user-select: none;
  touch-action: none;
}

.control-button:active,
.control-button.is-active {
  background: var(--warm);
  border-color: #a46d12;
}

.control-up {
  grid-column: 2;
}

.control-left {
  grid-column: 1;
  grid-row: 2;
}

.control-down {
  grid-column: 2;
  grid-row: 2;
}

.control-right {
  grid-column: 3;
  grid-row: 2;
}

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

@media (max-width: 520px) {
  .app-shell {
    align-items: flex-start;
    padding: 12px;
  }

  .game-panel {
    padding: 14px;
  }

  .game-header {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button {
    width: 100%;
  }

  .hud {
    gap: 8px;
  }

  .hud-item {
    padding: 10px;
  }

  .hud-item strong {
    font-size: 1.35rem;
  }

  .arena {
    min-height: 220px;
  }

  h1 {
    font-size: 1.6rem;
  }
}
