/* /play: same shell as resume; game chrome uses site tokens */

body.play-page {
  display: block;
  place-items: unset;
  min-height: 100%;
  overscroll-behavior: none;
}

body.play-page main {
  display: block;
  align-items: stretch;
  padding: 0;
}

.play-main {
  padding: 16px 0 0;
}

.play-sheet {
  text-align: center;
  padding: 16px;
}

.play-stage {
  display: flex;
  justify-content: center;
  margin: 0 auto;
  padding: 10px;
  background: #05080c;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.play-stage canvas,
body.play-page canvas {
  display: block;
  width: min(100%, 576px);
  height: auto;
  max-width: 100%;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 4px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}

/* Touch controls — themed like site chips, not NES gold */
body.play-page > .touch {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

html.touch-ui body.play-page > .touch {
  display: flex;
}

@media (hover: hover) and (pointer: fine) and (min-width: 901px) {
  body.play-page > .touch { display: none !important; }
}

html.touch-ui,
html.touch-ui body.play-page {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

html.touch-ui body.play-page {
  display: flex;
  flex-direction: column;
  min-height: 0;
  touch-action: manipulation;
}

html.touch-ui body.play-page header {
  flex: 0 0 auto;
  padding: 10px 0 8px;
}

html.touch-ui body.play-page .brand h1 {
  font-size: 1.2rem;
}

html.touch-ui body.play-page nav {
  padding-top: 2px;
  margin-top: 0;
  font-size: 0.82rem;
}

html.touch-ui body.play-page nav a {
  margin: 0 10px 0 0;
}

html.touch-ui body.play-page .play-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 6px 0 0;
  overflow: hidden;
}

html.touch-ui body.play-page .play-sheet {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 12px;
  padding: 8px;
  box-shadow: none;
}

html.touch-ui body.play-page .play-stage {
  max-width: 100%;
  max-height: 100%;
  padding: 4px;
}

html.touch-ui body.play-page .play-stage canvas,
html.touch-ui body.play-page canvas {
  width: auto !important;
  height: auto !important;
  max-width: 100%;
  max-height: min(100%, calc(100dvh - 12rem - 13.5rem));
}

html.touch-ui body.play-page footer {
  flex: 0 0 auto;
  padding: 8px 0 6px;
}

html.touch-ui body.play-page > .touch {
  position: static;
  flex: 0 0 auto;
  width: 100%;
  margin: 0;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  background: rgba(18, 24, 31, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

html.touch-ui body.play-page main {
  padding-bottom: 0 !important;
}

body.play-page .pad {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: 68px 68px 68px;
  grid-template-rows: 68px 68px 68px;
  gap: 6px;
}

body.play-page .pad button,
body.play-page .mute,
body.play-page .pause,
body.play-page .fire {
  margin: 0;
  padding: 0;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 14px var(--mono);
  letter-spacing: 0.04em;
  border-radius: 8px;
  touch-action: none;
  -webkit-touch-callout: none;
}

body.play-page .pad button[data-dir="up"] { grid-area: 1 / 2; }
body.play-page .pad button[data-dir="left"] { grid-area: 2 / 1; }
body.play-page .pad button[data-dir="down"] { grid-area: 3 / 2; }
body.play-page .pad button[data-dir="right"] { grid-area: 2 / 3; }

body.play-page .arrow {
  display: block;
  width: 0;
  height: 0;
  margin: 0 auto;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 14px solid var(--accent);
}

body.play-page .arrow.down { transform: rotate(180deg); }
body.play-page .arrow.left { transform: rotate(-90deg); }
body.play-page .arrow.right { transform: rotate(90deg); }

body.play-page .pad button.is-down,
body.play-page .mute.is-down,
body.play-page .pause.is-down,
body.play-page .fire.is-down,
body.play-page .fire:active {
  background: rgba(61, 214, 195, 0.18);
  border-color: var(--accent);
  color: var(--ink);
}

body.play-page .pad button.is-down .arrow {
  border-bottom-color: var(--ink);
}

body.play-page .menu-keys {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
  align-self: center;
}

body.play-page .mute,
body.play-page .pause {
  width: 76px;
  height: 36px;
  flex: 0 0 auto;
  font-size: 12px;
}

body.play-page .fire {
  width: 104px;
  height: 104px;
  flex: 0 0 auto;
}

@media (max-width: 480px) {
  body.play-page .pad {
    grid-template-columns: 58px 58px 58px;
    grid-template-rows: 58px 58px 58px;
  }

  body.play-page .mute,
  body.play-page .pause {
    width: 64px;
    height: 32px;
    font-size: 11px;
  }

  body.play-page .fire {
    width: 88px;
    height: 88px;
    font-size: 13px;
  }
}

@media (max-height: 740px) {
  html.touch-ui body.play-page .pad {
    grid-template-columns: 56px 56px 56px;
    grid-template-rows: 56px 56px 56px;
    gap: 4px;
  }

  html.touch-ui body.play-page .fire {
    width: 84px;
    height: 84px;
    font-size: 13px;
  }

  html.touch-ui body.play-page .mute,
  body.play-page .pause {
    width: 64px;
    height: 32px;
    font-size: 11px;
  }

  html.touch-ui body.play-page header {
    padding: 6px 0 4px;
  }
}

@media (max-height: 640px) {
  html.touch-ui body.play-page header {
    display: none;
  }
}
