:root {
  --soil: #3d2a18;
  --soil-light: #5c3f24;
  --grass: #4a7c3f;
  --sky-top: #7eb8d4;
  --sky-bot: #c8e4f0;
  --night-top: #1a2433;
  --night-bot: #2d3f55;
  --ink: #1c140e;
  --cream: #f3ebe0;
  --accent: #e85d04;
  --hud: #1c140e;
}

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

html, body {
  min-height: 100%;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--soil);
}

.sky {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 70% 10%, rgba(255, 220, 140, 0.35), transparent 55%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bot) 48%, #8fbc6e 48%, var(--grass) 52%, var(--soil-light) 70%, var(--soil) 100%);
  z-index: 0;
  transition: background 0.6s ease;
}

body.is-night .sky {
  background:
    radial-gradient(ellipse 40% 30% at 80% 12%, rgba(240, 230, 180, 0.2), transparent 50%),
    linear-gradient(180deg, var(--night-top) 0%, var(--night-bot) 48%, #2a4a28 48%, #1e3520 52%, #2a1c10 70%, #1a120c 100%);
}

body.is-night {
  color: var(--cream);
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem) 1rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  min-height: 100dvh;
  justify-content: center;
}

.brand {
  text-align: center;
}

.logo {
  font-family: Bungee, cursive;
  font-size: clamp(3.5rem, 12vw, 5.5rem);
  line-height: 0.9;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-shadow: 3px 3px 0 var(--ink);
  animation: bob 2.4s ease-in-out infinite;
}

body.is-night .logo {
  text-shadow: 3px 3px 0 #0a0806;
}

.tagline {
  margin-top: 0.4rem;
  font-size: 1rem;
  font-weight: 600;
  opacity: 0.85;
}

.hud {
  display: flex;
  gap: 1.5rem;
  font-family: Bungee, cursive;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.hud-label {
  font-family: "DM Sans", sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.55;
}

.canvas-wrap {
  position: relative;
  width: min(100%, 800px);
  border: 3px solid var(--ink);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 6px 6px 0 rgba(28, 20, 14, 0.25);
  background: #dceef5;
  animation: frame-in 0.5s ease-out;
}

body.is-night .canvas-wrap {
  background: #243447;
  border-color: #0a0806;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.4);
}

#game {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
  cursor: pointer;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(220, 238, 245, 0.72);
  backdrop-filter: blur(2px);
  padding: 1rem;
  text-align: center;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

body.is-night .overlay {
  background: rgba(36, 52, 71, 0.78);
}

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

.overlay-title {
  font-family: Bungee, cursive;
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  color: var(--accent);
}

.overlay-hint {
  font-weight: 700;
  font-size: 1rem;
}

.overlay-keys {
  list-style: none;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  opacity: 0.8;
  line-height: 1.6;
}

kbd {
  display: inline-block;
  padding: 0.1em 0.4em;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.8em;
  font-weight: 700;
}

.touch-pad {
  display: none;
  width: min(100%, 800px);
  gap: 0.75rem;
  padding: 0.25rem 0 env(safe-area-inset-bottom, 0);
}

.touch-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 72px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  font-family: Bungee, cursive;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--cream);
  box-shadow: 4px 4px 0 rgba(28, 20, 14, 0.2);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.touch-btn:active,
.touch-btn.is-pressed {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 rgba(28, 20, 14, 0.2);
}

.touch-btn-jump {
  background: #ffd166;
}

.touch-btn-peck {
  background: #e9c46a;
}

.touch-icon {
  font-size: 1.4rem;
  line-height: 1;
}

body.is-night .touch-btn {
  border-color: #0a0806;
  color: #1c140e;
}

@media (max-width: 640px), (pointer: coarse) {
  .overlay-keys { display: none; }
  .touch-pad { display: flex; }
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes frame-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
