/* Touch controls and phone layout, shared by the game page and the Daily page.
   hollowmoon.js adds body.touch and fills #touch on touch screens (or ?touch). */

#touch[hidden], #rotate-hint[hidden], #touch .more[hidden] { display: none; }

body.touch {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
body.touch header { flex: none; }
body.touch footer { display: none; }
body.touch main {
  flex: 1 1 auto;
  min-height: 0;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: flex-start;
}
body.touch #stage {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

#touch {
  flex: none;
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  justify-content: space-between;
}
#touch button {
  font: inherit;
  font-size: 13px;
  color: var(--fg);
  background: #11151b;
  border: 1px solid #2a313b;
  border-radius: 6px;
  min-height: 40px;
  padding: 0 4px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
#touch button:active, #touch button.on { background: #1d2a33; border-color: var(--accent); color: var(--accent); }
#touch .side { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
#touch .cmds, #touch .more { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
#touch .dpad { flex: none; display: grid; grid-template-columns: repeat(3, 46px); grid-auto-rows: 46px; gap: 4px; }
#touch .dpad button { font-size: 20px; min-height: 0; }
#kbd-input { position: fixed; left: -200px; bottom: 0; width: 10px; height: 10px; opacity: 0; }

#rotate-hint { color: var(--dim); font-size: 12px; text-align: center; margin: 0; }

/* Phones on their side: commands left, map centre, d-pad right. */
@media (orientation: landscape) and (max-height: 520px) {
  body.touch header { display: none; }
  body.touch main { flex-direction: row; align-items: stretch; padding: 0; }
  body.touch #stage { order: 2; align-items: center; flex: 1 1 0; }
  body.touch #touch { display: contents; }
  body.touch #touch .side { order: 1; flex: 0 0 148px; justify-content: center; overflow-y: auto; }
  body.touch #touch .cmds, body.touch #touch .more { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  body.touch #touch button { min-height: 32px; font-size: 12px; }
  body.touch #touch .dpad { order: 3; align-self: center; grid-template-columns: repeat(3, 42px); grid-auto-rows: 42px; }
  body.touch #status, body.touch #touch-note { display: none; }
}
