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

body {
  background: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: 'Courier New', Courier, monospace;
  user-select: none;
}

.phone-body {
  background: linear-gradient(160deg, #2c2c2c 0%, #1a1a1a 100%);
  border-radius: 32px 32px 48px 48px;
  padding: 24px 20px 36px;
  box-shadow:
    0 0 0 3px #111,
    0 12px 48px rgba(0,0,0,0.8),
    inset 0 1px 0 rgba(255,255,255,0.08);
  width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.screen-bezel {
  background: #111;
  border-radius: 8px;
  padding: 10px;
  width: 100%;
  box-shadow:
    inset 0 2px 8px rgba(0,0,0,0.9),
    0 0 0 1px #333;
}

.screen {
  background: #4a7c4e;
  background: linear-gradient(135deg, #5a8f5e 0%, #3d6b41 50%, #4a7c4e 100%);
  border-radius: 4px;
  padding: 8px;
  position: relative;
  box-shadow: inset 0 0 12px rgba(0,0,0,0.4);
}

.hud {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 6px;
  color: #1a3d1e;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 1px;
}

.hud-label {
  opacity: 0.7;
  font-size: 9px;
}

#score, #high-score {
  min-width: 28px;
  text-align: right;
  color: #0f2911;
  font-size: 13px;
}

#score {
  margin-right: auto;
}

#game-canvas {
  display: block;
  image-rendering: pixelated;
  width: 100%;
  height: auto;
}

.overlay {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: rgba(58, 100, 60, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  text-align: center;
  color: #0f2911;
}

.overlay-title {
  font-size: 32px;
  font-weight: bold;
  letter-spacing: 4px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
  margin-bottom: 4px;
}

.overlay-sub {
  font-size: 11px;
  letter-spacing: 3px;
  opacity: 0.7;
  margin-bottom: 20px;
}

.overlay-btn {
  font-size: 10px;
  letter-spacing: 2px;
  border: 2px solid #0f2911;
  padding: 6px 12px;
  border-radius: 2px;
  animation: blink 1s step-end infinite;
  cursor: pointer;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.controls {
  width: 100%;
  display: flex;
  justify-content: center;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 3px;
}

.dpad-btn {
  background: #2a2a2a;
  border: none;
  border-radius: 6px;
  color: #888;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, transform 0.1s;
  box-shadow: 0 3px 0 #111, inset 0 1px 0 rgba(255,255,255,0.06);
  -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active {
  background: #444;
  transform: translateY(2px);
  box-shadow: 0 1px 0 #111;
}

.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-center{ grid-column: 2; grid-row: 2; background: #222; cursor: default; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 3; }

@media (max-width: 400px) {
  .phone-body {
    width: 100vw;
    border-radius: 0;
    min-height: 100vh;
    justify-content: center;
  }
}
