* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0c140c;
  --grass: #2f8a2c;
  --ink: #f4f7f2;
  --muted: rgba(244, 247, 242, 0.72);
  --accent: #ff4da6;
  --gold: #facc15;
  --panel: rgba(12, 20, 12, 0.88);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  overscroll-behavior: contain;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  position: relative;
  touch-action: manipulation;
}

.screen {
  display: none;
  height: 100%;
  width: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 20px;
  position: absolute;
  inset: 0;
}

.screen.active { display: flex; }

#screen-menu,
#screen-over {
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(47, 138, 44, 0.35), transparent 60%),
    linear-gradient(180deg, #132013 0%, #0c140c 55%, #081008 100%);
}

.kicker {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
  font-weight: 700;
}

h1 {
  font-size: clamp(2rem, 8vw, 2.8rem);
  letter-spacing: 0.02em;
  margin-bottom: 12px;
  text-transform: uppercase;
}

h2 {
  font-size: 1.6rem;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.subtitle {
  max-width: 28rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 14px;
  font-size: 0.98rem;
}

.howto {
  max-width: 26rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 22px;
  opacity: 0.9;
}

button {
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 3px solid #fff;
  background: var(--accent);
  color: #fff;
  padding: 14px 28px;
  cursor: pointer;
  image-rendering: pixelated;
  box-shadow: 4px 4px 0 #000;
  touch-action: manipulation;
}

button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #000;
}

.btn-ghost {
  margin-top: 12px;
  background: transparent;
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: none;
}

.best {
  margin-top: 18px;
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 700;
}

.final-time {
  font-size: 2.4rem;
  font-weight: 700;
  margin: 8px 0 4px;
  color: #fff;
}

.menu-credit {
  margin-top: 28px;
  font-size: 0.85rem;
  color: var(--muted);
}

.menu-credit a {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.menu-credit a:hover,
.menu-credit a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.inspire {
  margin-top: 10px;
  font-size: 0.7rem;
  color: rgba(244, 247, 242, 0.45);
  max-width: 22rem;
  line-height: 1.35;
}

#screen-game {
  padding: 0;
  background: #0a0f0a;
}

#pitch {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: default;
  image-rendering: pixelated;
}

/* On-screen D-pad — sits clear of the invader so thumbs don't cover him */
#dpad {
  position: absolute;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: 168px;
  height: 168px;
  display: grid;
  grid-template-columns: 56px 56px 56px;
  grid-template-rows: 56px 56px 56px;
  gap: 0;
  z-index: 5;
  touch-action: none;
  user-select: none;
}

.dpad__btn {
  width: 56px;
  height: 56px;
  padding: 0;
  margin: 0;
  border: 3px solid rgba(255, 255, 255, 0.55);
  border-radius: 10px;
  background: rgba(12, 20, 12, 0.72);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.55);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  letter-spacing: 0;
  text-transform: none;
}

.dpad__btn:active,
.dpad__btn.is-pressed {
  background: rgba(255, 77, 166, 0.85);
  border-color: #fff;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.55);
}

.dpad__up { grid-column: 2; grid-row: 1; }
.dpad__left { grid-column: 1; grid-row: 2; }
.dpad__right { grid-column: 3; grid-row: 2; }
.dpad__down { grid-column: 2; grid-row: 3; }

.touch-hint {
  position: absolute;
  bottom: calc(188px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid rgba(250, 204, 21, 0.35);
  color: var(--gold);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  pointer-events: none;
  animation: hint-fade 2.8s ease forwards;
  z-index: 4;
}

@keyframes hint-fade {
  0%, 55% { opacity: 1; }
  100% { opacity: 0; }
}

#btn-kick {
  position: absolute;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(28px, env(safe-area-inset-bottom, 0px));
  z-index: 5;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  padding: 0;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  background: rgba(12, 20, 12, 0.72);
  border: 3px solid rgba(255, 255, 255, 0.45);
  color: rgba(255, 255, 255, 0.55);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.55);
  touch-action: none;
}

#btn-kick.is-ready {
  background: rgba(250, 204, 21, 0.92);
  border-color: #fff;
  color: #111;
}

#btn-kick.is-pressed {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.55);
  background: var(--accent);
  color: #fff;
  border-color: #fff;
}

@media (min-width: 720px) {
  #dpad {
    left: 28px;
    transform: none;
  }
  #btn-kick {
    right: 36px;
    bottom: 36px;
  }
}
