:root {
  --bg-start: #e9f4de;
  --bg-end: #cde6bc;
  --card-bg: rgba(247, 251, 242, 0.9);
  --card-border: rgba(22, 57, 32, 0.18);
  --text-main: #1a2b17;
  --text-muted: #41623b;
  --primary: #2f7d32;
  --primary-hover: #236327;
  --canvas-bg: #173f22;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text-main);
  background: radial-gradient(circle at 15% 20%, #f7fff2 0%, transparent 35%),
    linear-gradient(140deg, var(--bg-start), var(--bg-end));
}

.app-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.game-card {
  width: min(92vw, 560px);
  padding: 1.2rem;
  border-radius: 1rem;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.brand {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.5rem;
  line-height: 1;
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
}

.brand-mark svg {
  width: 100%;
  height: 100%;
}

.brand-text {
  letter-spacing: 0.02em;
  font-weight: 800;
  color: #1c3b16;
}

.brand-text span {
  color: #3f6e2a;
}

.scoreboard {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.metric {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

#gameCanvas {
  width: 100%;
  height: auto;
  background: var(--canvas-bg);
  border-radius: 0.8rem;
  border: 1px solid rgba(47, 125, 50, 0.26);
  display: block;
}

.game-stage {
  position: relative;
  touch-action: none;
}

.start-overlay {
  position: absolute;
  inset: 0;
  border-radius: 0.8rem;
  background: linear-gradient(160deg, rgba(10, 26, 14, 0.68), rgba(8, 18, 10, 0.72));
  display: grid;
  place-items: center;
  transition: opacity 240ms ease;
}

.start-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.start-card {
  padding: 1rem 1.2rem;
  border-radius: 0.8rem;
  background: rgba(234, 248, 228, 0.92);
  border: 1px solid rgba(31, 94, 38, 0.35);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.start-title {
  margin: 0 0 0.55rem;
  color: #1d3d1a;
  font-weight: 700;
  letter-spacing: 0.02em;
}

#playBtn {
  border: none;
  border-radius: 999px;
  padding: 0.5rem 1.2rem;
  color: #f8fafc;
  background: linear-gradient(145deg, #409a38, #2f7d32);
  font-weight: 700;
  cursor: pointer;
}

#playBtn:hover {
  filter: brightness(1.06);
}

#playBtn:active {
  transform: translateY(1px);
}

.controls {
  margin-top: 0.9rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.difficulty {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 600;
}

#difficultySelect {
  border: 1px solid rgba(22, 57, 32, 0.25);
  border-radius: 0.45rem;
  padding: 0.22rem 0.45rem;
  background: #f4faee;
  color: #244021;
  font-weight: 600;
}

#restartBtn {
  border: none;
  border-radius: 0.55rem;
  padding: 0.55rem 0.95rem;
  color: #f8fafc;
  background: var(--primary);
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

#restartBtn:hover {
  background: var(--primary-hover);
}

#restartBtn:active {
  transform: translateY(1px);
}

#statusText {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.mobile-pad {
  margin-top: 0.9rem;
  display: none;
  justify-content: center;
}

.beta-footer {
  display: flex;
  justify-content: center;
  padding: 0.35rem 1rem 0.85rem;
}

.beta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.36rem 0.74rem;
  border-radius: 999px;
  border: 1px solid rgba(29, 74, 30, 0.28);
  background: linear-gradient(140deg, rgba(236, 250, 225, 0.9), rgba(218, 239, 197, 0.85));
  box-shadow: 0 4px 12px rgba(16, 49, 19, 0.14);
}

.beta-mark {
  width: 1.1rem;
  height: 1.1rem;
  display: inline-flex;
}

.beta-mark svg {
  width: 100%;
  height: 100%;
}

.beta-text {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: rgba(24, 63, 24, 0.86);
}

.pad-grid {
  width: 136px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 0.45rem;
}

.pad-btn {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(16, 53, 18, 0.42);
  border-radius: 0.7rem;
  background: linear-gradient(145deg, #4ba24a, #2f7d32);
  color: #f3fde9;
  font-weight: 900;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(12, 38, 16, 0.25);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.pad-btn:active {
  transform: translateY(1px);
  filter: brightness(0.95);
}

.pad-up {
  grid-column: 2;
  grid-row: 1;
}

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

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

.pad-down {
  grid-column: 2;
  grid-row: 3;
}

@media (max-width: 520px) {
  .game-card {
    padding: 0.85rem;
  }

  .brand {
    font-size: 1.2rem;
  }

  .brand-mark {
    width: 1.7rem;
    height: 1.7rem;
  }

  .scoreboard {
    font-size: 0.92rem;
  }

  #statusText {
    font-size: 0.86rem;
  }

  .mobile-pad {
    display: flex;
  }

  .beta-footer {
    padding-bottom: 0.65rem;
  }

  .beta-pill {
    gap: 0.4rem;
    padding: 0.32rem 0.66rem;
  }

  .beta-text {
    font-size: 0.64rem;
    letter-spacing: 0.09em;
  }
}
