:root {
  --bg: #1a1a2e;
  --panel: #16213e;
  --accent: #e94560;
  --sand: #f5d76e;
  --text: #eaeaea;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at top, #2a2a4a 0%, var(--bg) 70%);
  color: var(--text);
  font-family: "Courier New", Courier, monospace;
}

#wrap {
  width: 100vw;
  height: 100dvh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: max(0.4rem, env(safe-area-inset-top)) max(0.5rem, env(safe-area-inset-right))
    max(0.4rem, env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
}

#hud {
  flex: 0 0 auto;
  text-align: center;
}

#hud h1 {
  font-size: clamp(1rem, 3.5vw, 1.5rem);
  letter-spacing: 0.04em;
  color: var(--sand);
  text-shadow: 2px 2px 0 #000;
  margin-bottom: 0.2rem;
}

#stats {
  font-size: clamp(0.7rem, 2.5vw, 0.9rem);
  color: #b8c1ec;
  margin-bottom: 0.35rem;
}

#stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 320 / 200;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #87ceeb;
  border: 3px solid #0f0f1a;
  box-shadow: 0 0 0 2px var(--accent);
  display: block;
  touch-action: none;
}

#controls {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.25rem 0;
  user-select: none;
  -webkit-user-select: none;
}

.ctrl-group {
  display: flex;
  gap: 0.5rem;
}

.btn {
  min-width: 3.2rem;
  min-height: 3.2rem;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--text);
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 10px;
  touch-action: manipulation;
}

.btn:active, .btn.active {
  background: var(--accent);
}

.btn-bark {
  min-width: 4.4rem;
  font-size: 0.9rem;
  color: #1a1a2e;
  background: var(--sand);
  border-color: #b8860b;
}

.btn-bark:active, .btn-bark.active {
  background: #fff3b0;
}

#help {
  flex: 0 0 auto;
  margin-top: 0.35rem;
  font-size: clamp(0.65rem, 2vw, 0.75rem);
  color: #8a93b8;
  text-align: center;
}

@media (min-width: 900px) {
  #controls { display: none; }
}
