* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%;
  background: #0b0c14;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}
#wrap {
  position: relative;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
#game {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
}

/* ---- 触屏虚拟按键：仅触屏设备显示 ---- */
#touch { display: none; }
@media (pointer: coarse) {
  #touch { display: block; }
}
.tbtn {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.75);
  background: rgba(120,130,180,.22);
  border: 1px solid rgba(255,255,255,.25);
  font: bold 20px/1 sans-serif;
  border-radius: 10px;
  z-index: 10;
}
.tbtn:active, .tbtn.held { background: rgba(160,175,235,.5); }
#dpad { position: absolute; left: 14px; bottom: 16px; width: 150px; height: 150px; z-index: 10; }
#dpad .dir { width: 50px; height: 50px; }
#dpad .up    { left: 50px;  top: 0; }
#dpad .down  { left: 50px;  top: 100px; }
#dpad .left  { left: 0;     top: 50px; }
#dpad .right { left: 100px; top: 50px; }
#abtns { position: absolute; right: 14px; bottom: 16px; width: 170px; height: 150px; z-index: 10; }
.round { border-radius: 50% !important; width: 58px; height: 58px; }
#abtns .a    { right: 0;    top: 40px; }
#abtns .b    { right: 68px; top: 78px; }
#abtns .menu { right: 68px; top: 0; width: 44px; height: 44px; font-size: 16px; }

/* ---- 竖屏提示 ---- */
#rotate { display: none; }
@media (pointer: coarse) and (orientation: portrait) {
  #rotate {
    display: flex; align-items: center; justify-content: center;
    position: fixed; inset: 0; z-index: 99;
    background: #0b0c14; color: #e8ecf7;
    font: 18px/1.8 sans-serif; text-align: center;
  }
}

/* ---- 存档导入等 DOM 覆盖层 ---- */
#overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5,6,12,.88);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: #e8ecf7; font: 14px sans-serif;
}
#overlay textarea {
  width: min(80vw, 560px); height: 30vh;
  background: #141828; color: #cdd5f0;
  border: 1px solid #3a4468; border-radius: 6px;
  font: 12px monospace; padding: 8px;
}
#overlay button, #overlay label.file {
  background: #2c3a66; color: #e8ecf7;
  border: 1px solid #5a6ca0; border-radius: 6px;
  padding: 8px 22px; font: 14px sans-serif; cursor: pointer;
}
#overlay button:hover { background: #3a4c85; }
