#game {
  display: none;
}

html.js #fallback {
  display: none;
}

html.js #game {
  display: block;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px 12px;
  pointer-events: none;
}

.hud .hud-count {
  background: rgba(18, 16, 14, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 0.9rem;
  backdrop-filter: blur(4px);
}

.hud .hud-contact {
  background: var(--accent);
  color: #160c08;
  border: none;
  border-radius: 999px;
  padding: 6px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.hud .hud-contact[hidden] {
  display: none;
}

.hud .hud-prompt {
  position: absolute;
  bottom: max(128px, calc(env(safe-area-inset-bottom) + 128px));
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.95rem;
  color: var(--ink);
  text-shadow: 0 1px 4px #000;
  padding: 0 16px;
}

.dpad {
  position: absolute;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  display: grid;
  grid-template-areas:
    ". up ."
    "left mid right"
    ". down .";
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(3, 64px);
  gap: 8px;
  opacity: 0.9;
}

.dpad-btn {
  border: 1px solid var(--line);
  background: rgba(28, 25, 22, 0.7);
  color: var(--ink);
  border-radius: 14px;
  font-size: 1.3rem;
  display: grid;
  place-content: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active {
  background: var(--accent);
  color: #160c08;
}

.dpad-up {
  grid-area: up;
}
.dpad-left {
  grid-area: left;
}
.dpad-right {
  grid-area: right;
}
.dpad-down {
  grid-area: down;
}

.modal {
  position: absolute;
  inset: 0;
  z-index: 10;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: relative;
  margin: auto;
  max-width: min(92vw, 560px);
  max-height: 84dvh;
  overflow: auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(18px, 4vw, 28px);
  top: 50%;
  transform: translateY(-50%);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--street);
  font-size: 1rem;
}

.modal-content {
  display: grid;
  gap: 12px;
}

.modal-content h2 {
  font-size: clamp(1.4rem, 5vw, 1.8rem);
}

.modal-content .projects-grid {
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .dpad {
    right: 24px;
    left: auto;
    margin: 0;
  }
}
