*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #05070c;
  color: #8d9ab2;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 700px at 50% 30%, #131a2a 0%, #05070c 70%);
}

/* Exact pixel size is set by main.js resize(); this is only the fallback
   shape before the first layout pass. */
#stage {
  position: relative;
  width: min(100vw, calc((100vh - 34px) * 16 / 9));
  aspect-ratio: 16 / 9;
}

#screen {
  display: block;
  width: 100%;
  height: 100%;
  background: #05070c;
  border-radius: 4px;
  box-shadow:
    0 0 0 1px #1d2536,
    0 24px 70px rgba(0, 0, 0, 0.75),
    0 0 90px rgba(255, 122, 26, 0.06);
}

#help {
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: 0.3px;
  color: #55617a;
  text-align: center;
  line-height: 1.6;
}
#help b { color: #8f9db6; }

/* ------------------------------------------------------------ touch pad */

#pad { display: none; }

body.touch #help { display: none; }

body.touch #screen { border-radius: 0; box-shadow: none; }

/* The controls track the viewport, not the letterboxed game box, so thumbs
   still reach the corners on a very wide phone. */
body.touch #pad {
  display: block;
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.cluster {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  pointer-events: none;
}
.cluster.left  { left: max(14px, env(safe-area-inset-left)); width: 168px; height: 168px; }
.cluster.right { right: max(14px, env(safe-area-inset-right)); width: 188px; height: 168px; }

.tb {
  position: absolute;
  pointer-events: auto;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: rgba(12, 16, 26, 0.42);
  color: #dfe6f2;
  font: 700 15px/1 ui-monospace, Menlo, monospace;
  border-radius: 14px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 60ms, background 60ms;
  touch-action: none;
}
.tb.active { background: rgba(255, 122, 26, 0.75); color: #14161d; transform: scale(0.94); }

.dir { width: 58px; height: 58px; font-size: 17px; }
.dir.up    { left: 55px; top: 0; }
.dir.left  { left: 0;  top: 55px; }
.dir.right { left: 110px; top: 55px; }
.dir.down  { left: 55px; top: 110px; }

.act { width: 74px; height: 74px; border-radius: 50%; font-size: 17px; }
.act.punch   { right: 92px; top: 30px;  border-color: rgba(255,210,122,0.5); }
.act.kick    { right: 8px;  top: 6px;   border-color: rgba(255,210,122,0.5); }
.act.block   { right: 100px; top: 112px; width: 62px; height: 62px; font-size: 12px; }
.act.special { right: 14px; top: 92px;  border-color: rgba(255,122,26,0.75); background: rgba(255,122,26,0.20); }

/* Bottom centre: the only stretch of screen neither thumb nor the HUD wants. */
.sys {
  pointer-events: auto;
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 52px; height: 32px;
  font-size: 13px;
  border-radius: 8px;
  opacity: 0.75;
}

/* --------------------------------------------------------- orientation */

#rotate { display: none; }

@media (hover: none) and (pointer: coarse) and (orientation: portrait) {
  #rotate {
    display: flex;
    position: absolute;
    inset: 0;
    z-index: 20;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: #05070c;
    color: #9fb0c8;
    font-size: 14px;
    letter-spacing: 1px;
  }
  .rot-icon { font-size: 54px; animation: tilt 1.6s ease-in-out infinite; }
  @keyframes tilt {
    0%, 100% { transform: rotate(0deg); }
    50%      { transform: rotate(90deg); }
  }
}
