* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #ededed;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 240px;
}

#display-container {
  width: 100%;
  max-width: 360px;
  max-height: 55vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 0 auto;
}

#display {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  overflow: hidden;
}

#canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}

#loading-text {
  position: absolute;
  top: 50%;              /* 垂直居中 */
  left: 50%;             /* 水平居中 */
  transform: translate(-50%, -50%); /* 完美居中 */
  font-size: 16px;
  white-space: nowrap;
  z-index: 0;
}


#keypad {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 440px;
  display: flex;
  gap: 10px;
  padding: 10px 12px 15px;
  background: #f8f8f8;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  align-items: stretch;
  bottom: -5px;
}

#joypad,
#numpad {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 6px;
  align-items: stretch;
}

.key {
  aspect-ratio: 1/1;
  border: none;
  border-radius: 8px;
  background: #fff;
  font-size: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  display: flex;
  justify-content: center;
  align-items: center;
}

.key:active {
  background: #ccc;
}

.hidden {
  visibility: hidden;
}

#choice, #back, #ok {
  background: #f5f5f5;
}

#up, #down, #left, #right {
  background: #e8f4fd;
  font-weight: bold;
}