/* iPhone-safe: no pinch, no sheet-dismissing overscroll. Buttons are the fallback. */
:root {
  --ink: #1a1a1a;
  --paper: #f4f1ea;
  --panel: rgba(244, 241, 234, 0.92);
  --line: #2a2a2a;
  --accent: #2a5f8f;
  --on: #2e7a55;
  --btn: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #c5ccd4;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#view.dragging { cursor: grabbing; }

header {
  position: fixed;
  top: var(--safe-t);
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 12px 8px;
  pointer-events: none;
}
header > * { pointer-events: auto; }
header h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.2;
}
#hint {
  position: fixed;
  top: calc(var(--safe-t) + 52px);
  left: 12px;
  z-index: 5;
  font-size: 12px;
  color: #333;
  background: var(--panel);
  border: 1px solid #bbb;
  border-radius: 8px;
  padding: 6px 10px;
  pointer-events: none;
}

button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: 600 14px/1 "Helvetica Neue", Helvetica, Arial, sans-serif;
  min-height: var(--btn);
  min-width: var(--btn);
  padding: 0 14px;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
}
button:active, button.held { background: #e4e0d6; }
button.on {
  background: var(--on);
  color: #fff;
  border-color: #145237;
}
button.active {
  background: var(--accent);
  color: #fff;
  border-color: #14344c;
}

#presets {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(96px + var(--safe-b));
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
#walk {
  position: fixed;
  right: 10px;
  bottom: calc(12px + var(--safe-b));
  z-index: 5;
  display: grid;
  grid-template-columns: 48px 48px 48px;
  grid-template-rows: 48px 48px 48px;
  gap: 6px;
}
#walk .pad { background: transparent; border: none; min-width: 0; padding: 0; pointer-events: none; }
#walk button { padding: 0; font-size: 18px; }
#btn-fwd { grid-column: 2; grid-row: 1; }
#btn-left { grid-column: 1; grid-row: 2; }
#btn-back { grid-column: 2; grid-row: 2; }
#btn-right { grid-column: 3; grid-row: 2; }

footer {
  position: fixed;
  left: 10px;
  bottom: calc(12px + var(--safe-b));
  right: 180px;
  z-index: 4;
  font-size: 11px;
  line-height: 1.35;
  color: #333;
  background: var(--panel);
  border: 1px solid #bbb;
  border-radius: 8px;
  padding: 6px 10px;
  max-width: 280px;
  pointer-events: none;
}

@media (min-width: 700px) {
  #presets { bottom: calc(16px + var(--safe-b)); justify-content: flex-start; left: 12px; right: 200px; }
  footer { left: auto; right: 12px; bottom: calc(160px + var(--safe-b)); max-width: 220px; }
}
