html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; background: #14151b; color: #e8e8ee;
  font-family: -apple-system, Helvetica, Arial, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  -webkit-text-size-adjust: 100%;
}
body { position: fixed; left: 0; top: 0; }
#app { width: 100%; height: 100%; display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; }

#topbar {
  -webkit-flex: none; flex: none;
  padding: 6px 8px; padding-top: constant(safe-area-inset-top); padding-top: env(safe-area-inset-top);
  background: #20222c; border-bottom: 1px solid #000;
  white-space: nowrap; overflow: hidden;
}
.btn {
  position: relative; display: inline-block; overflow: hidden;
  margin: 2px 6px 2px 0; padding: 9px 14px;
  font-size: 15px; line-height: 18px; color: #fff;
  background: #3a3e52; border: 0; border-radius: 8px;
  -webkit-appearance: none; appearance: none; cursor: pointer;
}
.btn:active { background: #5a6088; }
#romLabel { background: #3d6bd6; }
#romInput { position: absolute; left: 0; top: 0; width: 100%; height: 100%; opacity: 0; font-size: 100px; }
#title, #fps { margin-left: 8px; font-size: 13px; color: #9aa0b8; }

#stage { -webkit-flex: 1 1 auto; flex: 1 1 auto; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; -webkit-align-content: flex-start; align-content: flex-start; }
#screenwrap { position: relative; margin: 0 auto; background: #000; line-height: 0; }
#screen { display: block; width: 240px; height: 160px; background: #000; }
#screen.pixel { image-rendering: -webkit-optimize-contrast; image-rendering: pixelated; }
#msg {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0; padding: 20px; box-sizing: border-box;
  display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center;
  text-align: center; line-height: 1.4; font-size: 18px; color: #cfd3e6; background: rgba(0,0,0,0.85);
}
#msg.hidden { display: none; }

.side { -webkit-flex: 1 1 0; flex: 1 1 0; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; min-width: 0; }
.pad { position: relative; width: 200px; height: 252px; }

/* retrato: pantalla arriba, controles abajo en dos mitades */
#app.port #screenwrap { -webkit-flex: 0 0 auto; flex: 0 0 auto; width: 100%; }
#app.port .side { -webkit-flex: 1 1 50%; flex: 1 1 50%; height: 270px; }
#app.port #leftSide { -webkit-order: 1; order: 1; }
#app.port #rightSide { -webkit-order: 2; order: 2; }
/* paisaje: izquierda | pantalla | derecha */
#app.land #stage { -webkit-flex-wrap: nowrap; flex-wrap: nowrap; -webkit-align-items: center; align-items: center; }
#app.land #leftSide { -webkit-order: 0; order: 0; }
#app.land #screenwrap { -webkit-order: 1; order: 1; -webkit-flex: none; flex: none; margin: 0; }
#app.land #rightSide { -webkit-order: 2; order: 2; }

.shoulder, .pill, .round, .dpad {
  position: absolute; box-sizing: border-box; text-align: center;
  background: #2c2f3d; border: 2px solid #44485e; color: #c9cde0; font-weight: bold;
}
.shoulder.on, .pill.on, .round.on, .arr.on { background: #6f78b8; color: #fff; }
.shoulder { top: 0; width: 110px; height: 46px; line-height: 42px; font-size: 20px; border-radius: 14px; }
#kL { left: 0; }
#kR { right: 0; }
.pill { top: 222px; width: 92px; height: 30px; line-height: 26px; font-size: 12px; border-radius: 15px; }
#kSelect { left: 36px; }
#kStart { right: 36px; }
.round { width: 78px; height: 78px; line-height: 74px; font-size: 26px; border-radius: 50%; }
.btnA { left: 114px; top: 70px; }
.btnB { left: 12px; top: 120px; }

.dpad { left: 20px; top: 58px; width: 160px; height: 160px; border-radius: 50%; }
.arr { position: absolute; width: 52px; height: 52px; line-height: 52px; font-size: 22px; border-radius: 12px; text-align: center; }
.arr.up { left: 54px; top: 8px; }
.arr.down { left: 54px; bottom: 8px; }
.arr.left { left: 8px; top: 54px; }
.arr.right { right: 8px; top: 54px; }
