/* Play screen: HUD on top, then the board (canvas fitted by view.js) with
   the on-screen D-pad under it in portrait, beside it in landscape. The
   D-pad only shows on touch screens. */
.ef-play {
  gap: 0.5em;
}

.ef-hud {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.3em 1em;
  font-weight: 700;
  white-space: nowrap;
}

.ef-hud strong {
  color: #ffd76a;
}

.ef-timer.ef-urgent strong {
  color: #ff4040;
}

.ef-lives {
  color: #ff3b4f;
  letter-spacing: 0.1em;
}

.ef-god {
  color: #ff4444;
}

/* Pause, centred in the shared header, sized like its round buttons. */
.ef-tool {
  width: 40px;
  height: 40px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.ef-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.6em;
}

.ef-board {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  touch-action: none;
  overscroll-behavior: none;
}

.ef-board:focus,
html.tv .ef-board:focus {
  outline: none;
}

.ef-canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  box-sizing: border-box;
  border: 3px solid #2f4a35;
  background: #000000;
  transform: translate(-50%, -50%);
}

html.tv .ef-board:focus .ef-canvas {
  border-color: #ffd400;
}

.ef-dpad {
  flex: 0 0 auto;
  display: grid;
  grid-template-areas:
    "up up up"
    "left down right";
  grid-template-columns: repeat(3, max(52px, 8dvh));
  grid-auto-rows: max(52px, 8dvh);
  justify-content: center;
  gap: 6px;
  touch-action: none;
}

.ef-pad {
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ef-pad:active {
  background: rgba(255, 255, 255, 0.5);
}

/* Jump forward, the most used move: as wide as the three arrows below. */
.ef-pad-up {
  grid-area: up;
  border-radius: 999px;
}

.ef-pad-left {
  grid-area: left;
}

.ef-pad-down {
  grid-area: down;
}

.ef-pad-right {
  grid-area: right;
}

/* Portrait phones and tablets: the board leaves the side margins and runs
   edge to edge (2px from each side), so the canvas fills the width when
   the height allows it (it keeps its 720×880 shape). The HUD shrinks to
   one line and the D-pad buttons shrink to leave it the height (they grow
   back with the screen on tablets). Wide portrait screens: see below. */
@media (orientation: portrait) {
  .ef-shell:has(.ef-play:not([hidden])) {
    padding-top: 4px;
  }

  .ef-play,
  .ef-stage {
    gap: 6px;
  }

  .ef-hud {
    gap: 0.2em 0.7em;
    font-size: 0.85em;
  }

  .ef-board {
    margin-right: calc(2px - max(24px, env(safe-area-inset-right, 0px)));
    margin-left: calc(2px - max(24px, env(safe-area-inset-left, 0px)));
  }

  /* Same two rows as elsewhere, slightly smaller buttons. */
  .ef-dpad {
    grid-template-columns: repeat(3, max(48px, 6dvh));
    grid-auto-rows: max(48px, 6dvh);
    gap: 4px;
  }
}

/* Portrait screens from 960px wide keep the board inside the margins. */
@media (orientation: portrait) and (min-width: 960px) {
  .ef-board {
    margin-inline: 0;
  }
}

/* Landscape: the D-pad moves beside the board. */
@media (orientation: landscape) {
  .ef-stage {
    flex-direction: row;
    align-items: center;
  }

  .ef-board {
    align-self: stretch;
  }
}

/* Arrow position chosen in the options, for one-thumb play: under the
   board, against the left or right margin in portrait; before or after
   the board in landscape ("center" keeps them after it). */
.ef-dpad[data-position="left"] {
  justify-content: start;
}

.ef-dpad[data-position="right"] {
  justify-content: end;
}

@media (orientation: landscape) {
  .ef-dpad[data-position="left"] {
    order: -1;
  }
}

/* Mouse, keyboard and TV remote: no on-screen arrows (nor their option). */
@media (hover: hover) and (pointer: fine) {
  .ef-dpad,
  .ef-touch-only {
    display: none;
  }
}

html.tv .ef-dpad,
html.tv .ef-touch-only {
  display: none;
}
