:root {
  --grass: #7CB342;
  --grass-dark: #558B2F;
  --road: #37474F;
  --road-dark: #1C2833;
  --river: #29B6F6;
  --river-dark: #0277BD;
  --rabbit: #FAFAFA;
  --rabbit-pink: #F8BBD0;
  --text: #FFFFFF;
  --text-shadow: rgba(0, 0, 0, 0.55);
  --button: rgba(255, 255, 255, 0.18);
  --button-active: rgba(255, 255, 255, 0.34);
  --button-border: rgba(255, 255, 255, 0.45);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #14202b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  width: 100vw;
  height: 100vh;
  position: relative;
  touch-action: none;
}

#game canvas {
  display: block;
  margin: 0 auto;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#dpad {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  height: 220px;
  display: none;
  pointer-events: none;
  z-index: 10;
}

#dpad.visible { display: block; }

.dpad-btn {
  position: absolute;
  width: 70px;
  height: 70px;
  border-radius: 16px;
  border: 2px solid var(--button-border);
  background: var(--button);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 28px;
  font-weight: bold;
  text-shadow: 0 2px 4px var(--text-shadow);
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s, background 0.08s;
}

.dpad-btn:active,
.dpad-btn.pressed {
  background: var(--button-active);
  transform: scale(0.92);
}

.dpad-btn:focus-visible {
  outline: 3px solid #FFEB3B;
  outline-offset: 2px;
}

.dpad-up    { top: 0;   left: 75px; }
.dpad-left  { top: 75px; left: 0; }
.dpad-down  { top: 150px; left: 75px; }
.dpad-right { top: 75px; left: 150px; }

#toast {
  position: fixed;
  top: calc(20px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.85);
  color: var(--text);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .dpad-btn, #toast { transition: none; }
}
