* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%;
  height: 100%;
  background-color: #0b0d12;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 16px 16px;
  color: #f0ead8;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #07080b;
  padding-bottom: env(safe-area-inset-bottom);
}
#game {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0b0c10;
}
.touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 16px calc(18px + env(safe-area-inset-bottom));
}
.touch[hidden] { display: none; }
.dpad {
  display: grid;
  grid-template-columns: 48px 48px 48px;
  grid-template-rows: 48px 48px 48px;
  grid-template-areas:
    ". u ."
    "l c r"
    ". d .";
  pointer-events: none;
  opacity: 0.92;
}
.dir, .actions button {
  pointer-events: auto;
  border: 2px solid rgba(240, 234, 216, 0.35);
  background: rgba(14, 16, 22, 0.72);
  color: #f0ead8;
  font: 700 16px/1 ui-monospace, Menlo, Consolas, monospace;
  border-radius: 10px;
  width: 48px;
  height: 48px;
  -webkit-tap-highlight-color: transparent;
}
.dir:active, .actions button:active { background: rgba(232, 200, 120, 0.35); }
.dir-pad { pointer-events: none; }
.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  padding-bottom: 12px;
}
.actions button {
  width: 64px;
  height: 64px;
  border-radius: 32px;
  letter-spacing: 0.06em;
  font-size: 13px;
}
.actions button.primary {
  width: 72px;
  height: 72px;
  border-radius: 36px;
  background: rgba(232, 200, 120, 0.22);
  border-color: rgba(232, 200, 120, 0.7);
  color: #e8c878;
  font-size: 16px;
}
@media (min-width: 900px) and (hover: hover) {
  .touch:not(.force) { display: none; }
}
